X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_SingleEditDlg.cxx;h=08424f6d49a6d91fe65eae2ac847c5092df9ecf9;hp=6a27b17a337f9e4003e8abe4f74cc0847d8520e5;hb=ccb5e3c25bf204e839c0094f50f543eacedba5e6;hpb=0635c9fc80f67d1e5dc0e94ec85f487286a92070 diff --git a/src/SMESHGUI/SMESHGUI_SingleEditDlg.cxx b/src/SMESHGUI/SMESHGUI_SingleEditDlg.cxx index 6a27b17a3..08424f6d4 100755 --- a/src/SMESHGUI/SMESHGUI_SingleEditDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_SingleEditDlg.cxx @@ -1,24 +1,25 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // File : SMESHGUI_SingleEditDlg.cxx // Author : Sergey LITONIN, Open CASCADE S.A.S. // SMESH includes @@ -92,8 +93,8 @@ private: SMESHGUI_SingleEditDlg ::SMESHGUI_SingleEditDlg(SMESHGUI* theModule) : QDialog(SMESH::GetDesktop(theModule)), - mySelector(SMESH::GetViewWindow(theModule)->GetSelector()), mySelectionMgr(SMESH::GetSelectionMgr(theModule)), + mySelector(SMESH::GetViewWindow(theModule)->GetSelector()), mySMESHGUI(theModule) { setModal(false); @@ -214,14 +215,16 @@ void SMESHGUI_SingleEditDlg::Init() // main buttons connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk())); - connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose())); + connect(myCloseBtn, SIGNAL(clicked()), SLOT(reject())); connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply())); connect(myHelpBtn, SIGNAL(clicked()), SLOT(onHelp())); // selection and SMESHGUI connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone())); connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate())); - connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose())); + connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(reject())); + connect(mySMESHGUI, SIGNAL(SignalActivatedViewManager()), SLOT(onOpenView())); + connect(mySMESHGUI, SIGNAL(SignalCloseView()), SLOT(onCloseView())); connect(myEdge, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&))); myOkBtn->setEnabled(false); @@ -243,14 +246,14 @@ void SMESHGUI_SingleEditDlg::Init() void SMESHGUI_SingleEditDlg::onOk() { if (onApply()) - onClose(); + reject(); } //======================================================================= -// name : onClose() +// name : reject() // Purpose : SLOT called when "Close" button pressed. Close dialog //======================================================================= -void SMESHGUI_SingleEditDlg::onClose() +void SMESHGUI_SingleEditDlg::reject() { if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) aViewWindow->SetSelectionMode(ActorSelection); @@ -258,7 +261,7 @@ void SMESHGUI_SingleEditDlg::onClose() disconnect(mySelectionMgr, 0, this, 0); disconnect(mySMESHGUI, 0, this, 0); mySMESHGUI->ResetState(); - reject(); + QDialog::reject(); } //================================================================================= @@ -278,10 +281,10 @@ void SMESHGUI_SingleEditDlg::onHelp() platform = "application"; #endif SUIT_MessageBox::warning(this, tr("WRN_WARNING"), - tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). - arg(app->resourceMgr()->stringValue("ExternalBrowser", - platform)). - arg(myHelpFileName)); + tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). + arg(app->resourceMgr()->stringValue("ExternalBrowser", + platform)). + arg(myHelpFileName)); } } @@ -304,7 +307,7 @@ static bool findTriangles (const SMDS_MeshNode * theNode1, SMDS_ElemIteratorPtr it = theNode1->GetInverseElementIterator(); while (it->more()) { const SMDS_MeshElement* elem = it->next(); - if (elem->GetType() == SMDSAbs_Face && elem->NbNodes() == 3) + if (elem->GetType() == SMDSAbs_Face && elem->NbCornerNodes() == 3) emap.insert(elem); } it = theNode2->GetInverseElementIterator(); @@ -312,12 +315,14 @@ static bool findTriangles (const SMDS_MeshNode * theNode1, const SMDS_MeshElement* elem = it->next(); if (elem->GetType() == SMDSAbs_Face && emap.find(elem) != emap.end()) + { if (theTria1) { theTria2 = elem; break; } else { theTria1 = elem; } + } } return (theTria1 && theTria2); } @@ -348,13 +353,13 @@ void SMESHGUI_SingleEditDlg::onTextChange (const QString& theNewText) int id1, id2; if ( !getNodeIds(myEdge->text(), id1, id2) ) - return; + return; const SMDS_MeshNode* aNode1 = aMesh->FindNode( id1 ); const SMDS_MeshNode* aNode2 = aMesh->FindNode( id2 ); if ( !aNode1 || !aNode2 || aNode1 == aNode2 ) - return; + return; // find a triangle and an edge index const SMDS_MeshElement* tria1; @@ -362,23 +367,23 @@ void SMESHGUI_SingleEditDlg::onTextChange (const QString& theNewText) if ( findTriangles(aNode1,aNode2,tria1,tria2) ) { - newIndices.Add(tria1->GetID()); - - const SMDS_MeshNode* a3Nodes[3]; - SMDS_ElemIteratorPtr it; - int edgeInd = 2, i; - for (i = 0, it = tria1->nodesIterator(); it->more(); i++) { - a3Nodes[ i ] = static_cast(it->next()); - if (i > 0 && ( a3Nodes[ i ] == aNode1 && a3Nodes[ i - 1] == aNode2 || - a3Nodes[ i ] == aNode2 && a3Nodes[ i - 1] == aNode1 ) ) { - edgeInd = i - 1; - break; - } - } - newIndices.Add(-edgeInd-1); - - myOkBtn->setEnabled(true); - myApplyBtn->setEnabled(true); + newIndices.Add(tria1->GetID()); + + const SMDS_MeshNode* a3Nodes[3]; + SMDS_ElemIteratorPtr it; + int edgeInd = 2, i; + for (i = 0, it = tria1->nodesIterator(); it->more(); i++) { + a3Nodes[ i ] = static_cast(it->next()); + if (i > 0 && ( (a3Nodes[ i ] == aNode1 && a3Nodes[ i - 1] == aNode2) || + (a3Nodes[ i ] == aNode2 && a3Nodes[ i - 1] == aNode1) ) ) { + edgeInd = i - 1; + break; + } + } + newIndices.Add(-edgeInd-1); + + myOkBtn->setEnabled(true); + myApplyBtn->setEnabled(true); } mySelector->AddOrRemoveIndex(anIO,newIndices, false); SMESH::GetViewWindow(mySMESHGUI)->highlight( anIO, true, true ); @@ -416,17 +421,17 @@ void SMESHGUI_SingleEditDlg::onSelectionDone() { const SMDS_MeshElement* tria[2]; if( SMESH::GetEdgeNodes( mySelector, aVisualObj, anId1, anId2 ) >= 1 && - findTriangles( aMesh->FindNode( anId1 ), aMesh->FindNode( anId2 ), tria[0],tria[1] ) ) + findTriangles( aMesh->FindNode( anId1 ), aMesh->FindNode( anId2 ), tria[0],tria[1] ) ) { - QString aText = QString("%1-%2").arg(anId1).arg(anId2); - myEdge->setText(aText); - - myOkBtn->setEnabled(true); - myApplyBtn->setEnabled(true); + QString aText = QString("%1-%2").arg(anId1).arg(anId2); + myEdge->setText(aText); + + myOkBtn->setEnabled(true); + myApplyBtn->setEnabled(true); } else { - myEdge->clear(); + myEdge->clear(); } } } @@ -441,37 +446,45 @@ void SMESHGUI_SingleEditDlg::onDeactivate() setEnabled(false); } -//======================================================================= -// name : enterEvent() -// Purpose : Event filter -//======================================================================= -void SMESHGUI_SingleEditDlg::enterEvent (QEvent*) +//================================================================================= +// function : onOpenView() +// purpose : +//================================================================================= +void SMESHGUI_SingleEditDlg::onOpenView() { - if (!isEnabled()) { + if ( !mySelector ) { + mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector(); mySMESHGUI->EmitSignalDeactivateDialog(); - if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) - aViewWindow->SetSelectionMode(EdgeOfCellSelection); setEnabled(true); } } //================================================================================= -// function : closeEvent() +// function : onCloseView() // purpose : //================================================================================= -void SMESHGUI_SingleEditDlg::closeEvent (QCloseEvent*) +void SMESHGUI_SingleEditDlg::onCloseView() { - onClose(); + onDeactivate(); + mySelector = 0; } //======================================================================= -//function : hideEvent() -//purpose : caused by ESC key +// name : enterEvent() +// Purpose : Event filter //======================================================================= -void SMESHGUI_SingleEditDlg::hideEvent (QHideEvent*) +void SMESHGUI_SingleEditDlg::enterEvent (QEvent*) { - if (!isMinimized()) - onClose(); + if (!isEnabled()) { + mySMESHGUI->EmitSignalDeactivateDialog(); + SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ); + if ( aViewWindow) { + aViewWindow->SetSelectionMode(EdgeOfCellSelection); + if (!mySelector) + mySelector = aViewWindow->GetSelector(); + } + setEnabled(true); + } } //================================================================================= @@ -494,8 +507,8 @@ bool SMESHGUI_SingleEditDlg::onApply() if (aMesh->_is_nil()) { SUIT_MessageBox::information(SMESH::GetDesktop(mySMESHGUI), - tr("SMESH_ERROR"), - tr("SMESHG_NO_MESH")); + tr("SMESH_ERROR"), + tr("SMESHG_NO_MESH")); return false; } @@ -513,6 +526,7 @@ bool SMESHGUI_SingleEditDlg::onApply() mySelectionMgr->setSelectedObjects(aList, false); onSelectionDone(); SMESH::UpdateView(); + SMESHGUI::Modified(); } return aResult;