X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_SingleEditDlg.cxx;h=18283b882bd4e0810a19b3c0266f7f09a2ef6167;hp=f93ce95565ca740eaef14420091c6bd91cf8bf83;hb=d9f4b53e489dd5857db264ede6acded7b076c9f1;hpb=bd4e115a78b52e3fbc016e5e30bb0e19b2a9e7d6 diff --git a/src/SMESHGUI/SMESHGUI_SingleEditDlg.cxx b/src/SMESHGUI/SMESHGUI_SingleEditDlg.cxx old mode 100755 new mode 100644 index f93ce9556..18283b882 --- a/src/SMESHGUI/SMESHGUI_SingleEditDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_SingleEditDlg.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2022 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 @@ -6,7 +6,7 @@ // 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. +// 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 @@ -22,6 +22,9 @@ // File : SMESHGUI_SingleEditDlg.cxx // Author : Sergey LITONIN, Open CASCADE S.A.S. + +#include + // SMESH includes // #include "SMESHGUI_SingleEditDlg.h" @@ -42,7 +45,6 @@ #include #include -#include #include #include @@ -93,8 +95,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); @@ -170,7 +172,7 @@ QWidget* SMESHGUI_SingleEditDlg::createButtonFrame (QWidget* theParent) // name : isValid() // Purpose : Verify validity of input data //======================================================================= -bool SMESHGUI_SingleEditDlg::isValid (const bool theMess) const +bool SMESHGUI_SingleEditDlg::isValid (const bool /*theMess*/) const { int id1, id2; return getNodeIds(myEdge->text(), id1, id2); @@ -215,14 +217,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); @@ -244,14 +248,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); @@ -259,7 +263,7 @@ void SMESHGUI_SingleEditDlg::onClose() disconnect(mySelectionMgr, 0, this, 0); disconnect(mySMESHGUI, 0, this, 0); mySMESHGUI->ResetState(); - reject(); + QDialog::reject(); } //================================================================================= @@ -305,7 +309,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(); @@ -329,7 +333,7 @@ static bool findTriangles (const SMDS_MeshNode * theNode1, //function : onTextChange() //purpose : //======================================================================= -void SMESHGUI_SingleEditDlg::onTextChange (const QString& theNewText) +void SMESHGUI_SingleEditDlg::onTextChange (const QString& /*theNewText*/) { if (myBusy) return; BusyLocker lock(myBusy); @@ -337,7 +341,7 @@ void SMESHGUI_SingleEditDlg::onTextChange (const QString& theNewText) myOkBtn->setEnabled(false); myApplyBtn->setEnabled(false); - // hilight entered edge + // highlight entered edge if(myActor){ if(SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh()){ Handle(SALOME_InteractiveObject) anIO = myActor->getIO(); @@ -345,9 +349,9 @@ void SMESHGUI_SingleEditDlg::onTextChange (const QString& theNewText) aList.Append(anIO); mySelectionMgr->setSelectedObjects(aList,false); - TColStd_IndexedMapOfInteger selectedIndices; - TColStd_MapOfInteger newIndices; - mySelector->GetIndex(anIO,selectedIndices); + SVTK_IndexedMapOfVtkIds selectedIndices; + SVTK_ListOfVtk newIndices; + mySelector->GetCompositeIndex(anIO,selectedIndices); int id1, id2; if ( !getNodeIds(myEdge->text(), id1, id2) ) @@ -365,25 +369,13 @@ 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); - + newIndices.push_back( aNode1->GetID() ); + newIndices.push_back( aNode2->GetID() ); + myOkBtn->setEnabled(true); myApplyBtn->setEnabled(true); } - mySelector->AddOrRemoveIndex(anIO,newIndices, false); + mySelector->AddOrRemoveCompositeIndex(anIO, newIndices, false); SMESH::GetViewWindow(mySMESHGUI)->highlight( anIO, true, true ); } } @@ -418,12 +410,22 @@ void SMESHGUI_SingleEditDlg::onSelectionDone() if(SMDS_Mesh* aMesh = aVisualObj->GetMesh()) { const SMDS_MeshElement* tria[2]; - if( SMESH::GetEdgeNodes( mySelector, aVisualObj, anId1, anId2 ) >= 1 && + + bool valid = false; + SVTK_IndexedMapOfVtkIds anIds; + mySelector->GetCompositeIndex(anIO,anIds); + if( anIds.Extent() == 1 && anIds(1).size() == 2 ) { + anId1 = anIds(1)[0]; + anId2 = anIds(1)[1]; + valid = true; + } + + if( valid && 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); } @@ -437,44 +439,52 @@ void SMESHGUI_SingleEditDlg::onSelectionDone() //======================================================================= // name : onDeactivate() -// Purpose : SLOT called when dialog must be deativated +// Purpose : SLOT called when dialog must be deactivated //======================================================================= 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); + } } //================================================================================= @@ -483,7 +493,7 @@ void SMESHGUI_SingleEditDlg::hideEvent (QHideEvent*) //================================================================================= bool SMESHGUI_SingleEditDlg::onApply() { - if (mySMESHGUI->isActiveStudyLocked()) + if (SMESHGUI::isStudyLocked()) return false; // verify validity of input data if (!isValid(true)) @@ -513,6 +523,7 @@ bool SMESHGUI_SingleEditDlg::onApply() // update actor if (aResult) { mySelector->ClearIndex(); + mySelector->ClearCompositeIndex(); mySelectionMgr->setSelectedObjects(aList, false); onSelectionDone(); SMESH::UpdateView(); @@ -549,7 +560,7 @@ SMESHGUI_TrianglesInversionDlg : SMESHGUI_SingleEditDlg(theModule) { setWindowTitle(tr("CAPTION")); - myHelpFileName = "diagonal_inversion_of_elements_page.html"; + myHelpFileName = "diagonal_inversion_of_elements.html"; } SMESHGUI_TrianglesInversionDlg::~SMESHGUI_TrianglesInversionDlg() @@ -573,7 +584,7 @@ SMESHGUI_UnionOfTwoTrianglesDlg : SMESHGUI_SingleEditDlg(theModule) { setWindowTitle(tr("CAPTION")); - myHelpFileName = "uniting_two_triangles_page.html"; + myHelpFileName = "uniting_two_triangles.html"; } SMESHGUI_UnionOfTwoTrianglesDlg::~SMESHGUI_UnionOfTwoTrianglesDlg()