X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_GroupDlg.cxx;h=83fd3c41207c1efeb3ac09b607198e7668ba973a;hp=a83f360b5c664175e151c595341b5dc8699de69e;hb=1ca52d6d9244fecf0d7fdbb15047f96c1a0ccec7;hpb=72598d17882a440afe96df9731407ce1bf241c70 diff --git a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx index a83f360b5..83fd3c412 100644 --- a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx @@ -1,23 +1,23 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 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 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 -// -// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +// 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 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 +// +// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org // // // @@ -28,7 +28,6 @@ #include "SMESHGUI_GroupDlg.h" #include "SMESHGUI_FilterDlg.h" -#include "SMESHGUI_Filter.h" #include "SMESHGUI.h" #include "SMESHGUI_Utils.h" @@ -38,18 +37,25 @@ #include "SMESHGUI_FilterUtils.h" #include "SMESHGUI_GEOMGenUtils.h" -#include "SALOMEGUI_QtCatchCorbaException.hxx" +#include "SMESH_TypeFilter.hxx" +#include "SMESH_Actor.h" +#include "GEOMBase.h" + +#include "SUIT_Desktop.h" +#include "SUIT_ResourceMgr.h" + +#include "SalomeApp_Tools.h" +#include "SALOMEDSClient_Study.hxx" +#include "SALOME_ListIO.hxx" #include "SALOME_ListIteratorOfListIO.hxx" -#include "VTKViewer_ViewFrame.h" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_MessageBox.h" -#include "QAD_RightFrame.h" -#include "utilities.h" -#include "SMESH_Actor.h" +#include "SVTK_ViewWindow.h" +#include "SVTK_Selector.h" -#include "GEOMBase.h" +#include "utilities.h" + +// OCCT Includes +#include // QT Includes #include @@ -74,15 +80,20 @@ using namespace std; //================================================================================= -// class : SMESHGUI_GroupDlg() -// purpose : +// function : SMESHGUI_GroupDlg() +// purpose : //================================================================================= -SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( QWidget* parent, const char* name, SALOME_Selection* theSel, - SMESH::SMESH_Mesh_ptr theMesh, bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) +SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name, + SMESH::SMESH_Mesh_ptr theMesh, bool modal, WFlags fl) + : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | + WStyle_Title | WStyle_SysMenu | WDestructiveClose), + mySMESHGUI( theModule ), + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + myIsBusy( false ), + myActor( 0 ) { - if ( !name ) setName( "SMESHGUI_GroupDlg" ); - initDialog(theSel, true); + if (!name) setName("SMESHGUI_GroupDlg"); + initDialog(true); if (!theMesh->_is_nil()) init(theMesh); else { @@ -91,24 +102,40 @@ SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( QWidget* parent, const char* name, SALOME_ myGeomGroupBtn->setEnabled(false); myGeomGroupLine->setEnabled(false); } - + + mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector(); + /* Move widget on the botton right corner of main widget */ int x, y ; mySMESHGUI->DefineDlgPosition(this, x, y); this->move(x, y); } -SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( QWidget* parent, const char* name, SALOME_Selection* theSel, - SMESH::SMESH_Group_ptr theGroup, bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) +//================================================================================= +// function : SMESHGUI_GroupDlg() +// purpose : +//================================================================================= +SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name, + SMESH::SMESH_Group_ptr theGroup, bool modal, WFlags fl) + : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | + WStyle_Title | WStyle_SysMenu | WDestructiveClose), + mySMESHGUI( theModule ), + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + myIsBusy( false ) { - if ( !name ) setName( "SMESHGUI_GroupDlg" ); - initDialog(theSel, false); + if (!name) setName("SMESHGUI_GroupDlg"); + + mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector(); + + initDialog(false); if (!theGroup->_is_nil()) init(theGroup); else { mySelectSubMesh->setEnabled(false); mySelectGroup->setEnabled(false); + + myCurrentLineEdit = myMeshGroupLine; + setSelectionMode(5); } /* Move widget on the botton right corner of main widget */ @@ -117,23 +144,27 @@ SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( QWidget* parent, const char* name, SALOME_ this->move(x, y); } -void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) +//================================================================================= +// function : SMESHGUI_GroupDlg() +// purpose : +//================================================================================= +void SMESHGUI_GroupDlg::initDialog(bool create) { myFilterDlg = 0; myCreate = create; myCurrentLineEdit = 0; - - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); + + QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); if (create) - setCaption( tr( "SMESH_CREATE_GROUP_TITLE" ) ); + setCaption(tr("SMESH_CREATE_GROUP_TITLE")); else - setCaption( tr( "SMESH_EDIT_GROUP_TITLE" ) ); - - setSizeGripEnabled( TRUE ); + setCaption(tr("SMESH_EDIT_GROUP_TITLE")); + + setSizeGripEnabled(TRUE); QGridLayout* aMainLayout = new QGridLayout(this, 7, 3, 11, 6); - + /***************************************************************/ QLabel* meshGroupLab = new QLabel(this, "mesh/group label"); if (create) @@ -144,7 +175,7 @@ void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) myMeshGroupBtn->setPixmap(image0); myMeshGroupLine = new QLineEdit(this, "mesh/group line"); myMeshGroupLine->setReadOnly(true); - + /***************************************************************/ myTypeGroup = new QButtonGroup(1, Qt::Vertical, this, "Group types"); myTypeGroup->setTitle(tr("SMESH_ELEMENTS_TYPE")); @@ -161,7 +192,7 @@ void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) } myTypeGroup->setEnabled(create); myTypeId = -1; - + /***************************************************************/ QLabel* aName = new QLabel(this, "name label"); aName->setText(tr("SMESH_NAME")); @@ -181,7 +212,7 @@ void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) myWGStack = new QWidgetStack( this, "widget stack"); QWidget* wg1 = new QFrame( myWGStack, "first widget" ); QWidget* wg2 = new QFrame( myWGStack, "second widget" ); - + /***************************************************************/ QGroupBox* aContentBox = new QGroupBox(1, Qt::Horizontal, wg1, "content box"); aContentBox->setTitle(tr("SMESH_CONTENT")); @@ -220,7 +251,7 @@ void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) /***************************************************************/ QGroupBox* aSelectBox = new QGroupBox(3, Qt::Horizontal, wg1, "select box"); aSelectBox->setTitle(tr("SMESH_SELECT_FROM")); - + mySelectSubMesh = new QCheckBox(aSelectBox, "submesh checkbox"); mySelectSubMesh->setText(tr("SMESH_SUBMESH")); mySelectSubMesh->setMinimumSize(50, 0); @@ -230,7 +261,7 @@ void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) mySubMeshLine = new QLineEdit(aSelectBox, "submesh line"); mySubMeshLine->setReadOnly(true); onSelectSubMesh(false); - + mySelectGroup = new QCheckBox(aSelectBox, "group checkbox"); mySelectGroup->setText(tr("SMESH_GROUP")); mySelectGroup->setMinimumSize(50, 0); @@ -240,7 +271,7 @@ void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) myGroupLine = new QLineEdit(aSelectBox, "group line"); myGroupLine->setReadOnly(true); onSelectGroup(false); - + /***************************************************************/ QGridLayout* wg1Layout = new QGridLayout( wg1, 3, 1, 0, 6 ); wg1Layout->addWidget(aContentBox, 0, 0); @@ -256,7 +287,7 @@ void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) myGeomGroupLine = new QLineEdit(wg2, "geometry group line"); myGeomGroupLine->setReadOnly(true); //VSR ??? onSelectGeomGroup(false); - + /***************************************************************/ QGridLayout* wg2Layout = new QGridLayout( wg2, 2, 3, 0, 6 ); wg2Layout->addWidget(geomObject, 0, 0); @@ -331,8 +362,6 @@ void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(onClose())); /* Init selection */ - mySelection = theSel; - mySMESHGUI = SMESHGUI::GetSMESHGUI(); mySMESHGUI->SetActiveDialogBox(this); mySMESHGUI->SetState(800); @@ -343,14 +372,14 @@ void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(onDeactivate())); connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(onClose())); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(onObjectSelectionChanged())); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onObjectSelectionChanged())); myGrpTypeGroup->setButton(myGrpTypeGroup->id(rb1)); // VSR !!! onGrpTypeChanged(myGrpTypeGroup->id(rb1)); // VSR!!! if (myMesh->_is_nil() ) myTypeGroup->setButton(0); - + updateButtons(); } @@ -368,23 +397,29 @@ SMESHGUI_GroupDlg::~SMESHGUI_GroupDlg() } } - //================================================================================= // function : Init() // purpose : //================================================================================= -void SMESHGUI_GroupDlg::init(SMESH::SMESH_Mesh_ptr theMesh) +void SMESHGUI_GroupDlg::init (SMESH::SMESH_Mesh_ptr theMesh) { + mySelectionMgr->installFilter(myMeshFilter); + /* init data from current selection */ myMesh = SMESH::SMESH_Mesh::_duplicate(theMesh); myGroup = SMESH::SMESH_Group::_nil(); - + myActor = SMESH::FindActorByObject(myMesh); SMESH::SetPickable(myActor); - - QString aName = mySelection->firstIObject()->getName(); - myMeshGroupLine->setText(aName) ; - myMeshGroupLine->home( false ); + + SALOME_ListIO aList; + mySelectionMgr->selectedObjects( aList ); + if( !aList.IsEmpty() ) + { + QString aName = aList.First()->getName(); + myMeshGroupLine->setText(aName) ; + myMeshGroupLine->home( false ); + } myCurrentLineEdit = 0; @@ -396,24 +431,24 @@ void SMESHGUI_GroupDlg::init(SMESH::SMESH_Mesh_ptr theMesh) // function : Init() // purpose : //================================================================================= -void SMESHGUI_GroupDlg::init(SMESH::SMESH_Group_ptr theGroup) +void SMESHGUI_GroupDlg::init (SMESH::SMESH_Group_ptr theGroup) { myMesh = theGroup->GetMesh(); myGroup = SMESH::SMESH_Group::_duplicate(theGroup); - + myActor = SMESH::FindActorByObject(myMesh); if ( !myActor ) myActor = SMESH::FindActorByObject(myGroup); SMESH::SetPickable(myActor); - + int aType = 0; switch(theGroup->GetType()) { case SMESH::NODE: aType= 0; break; case SMESH::EDGE: aType = 1; break; case SMESH::FACE: aType = 2; break; case SMESH::VOLUME: aType = 3; break; - } - + } + myName->setText(myGroup->GetName()); myName->home(false); myMeshGroupLine->setText(myGroup->GetName()); @@ -423,7 +458,7 @@ void SMESHGUI_GroupDlg::init(SMESH::SMESH_Group_ptr theGroup) myElements->clear(); setSelectionMode(aType); myTypeId = aType; - + myIdList.clear(); if (!theGroup->IsEmpty()) { SMESH::long_array_var anElements = myGroup->GetListOfID(); @@ -436,15 +471,14 @@ void SMESHGUI_GroupDlg::init(SMESH::SMESH_Group_ptr theGroup) } } - //================================================================================= // function : updateButtons() -// purpose : +// purpose : //================================================================================= void SMESHGUI_GroupDlg::updateButtons() { - bool enable; - + bool enable; + if (myGrpTypeId == 0) enable = !myName->text().stripWhiteSpace().isEmpty() && myElements->count() > 0; else if (myGrpTypeId == 1) @@ -458,9 +492,9 @@ void SMESHGUI_GroupDlg::updateButtons() //================================================================================= // function : onNameChanged() -// purpose : +// purpose : //================================================================================= -void SMESHGUI_GroupDlg::onNameChanged(const QString& text) +void SMESHGUI_GroupDlg::onNameChanged (const QString& text) { updateButtons(); } @@ -469,7 +503,7 @@ void SMESHGUI_GroupDlg::onNameChanged(const QString& text) // function : onTypeChanged() // purpose : Group elements type radio button management //================================================================================= -void SMESHGUI_GroupDlg::onTypeChanged(int id) +void SMESHGUI_GroupDlg::onTypeChanged (int id) { if (myTypeId != id) { myElements->clear(); @@ -483,7 +517,7 @@ void SMESHGUI_GroupDlg::onTypeChanged(int id) // function : onGrpTypeChanged() // purpose : Group type radio button management //================================================================================= -void SMESHGUI_GroupDlg::onGrpTypeChanged(int id) +void SMESHGUI_GroupDlg::onGrpTypeChanged (int id) { if (myGrpTypeId != id) { myWGStack->raiseWidget( id ); @@ -496,47 +530,51 @@ void SMESHGUI_GroupDlg::onGrpTypeChanged(int id) // function : setSelectionMode() // purpose : Radio button management //================================================================================= -void SMESHGUI_GroupDlg::setSelectionMode(int theMode) +void SMESHGUI_GroupDlg::setSelectionMode (int theMode) { // PAL7314 if (myMesh->_is_nil()) return; - + if (mySelectionMode != theMode) { - mySelection->ClearIObjects(); - mySelection->ClearFilters(); + mySelectionMgr->clearSelected(); + mySelectionMgr->clearFilters(); SMESH::SetPointRepresentation(false); if (theMode < 4) { - switch(theMode){ + switch (theMode) { case 0: - if ( myActor ) + if (myActor) myActor->SetPointRepresentation(true); else SMESH::SetPointRepresentation(true); - QAD_Application::getDesktop()->SetSelectionMode(NodeSelection, true); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(NodeSelection); break; case 1: - QAD_Application::getDesktop()->SetSelectionMode(EdgeSelection, true); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(EdgeSelection); break; case 2: - QAD_Application::getDesktop()->SetSelectionMode(FaceSelection, true); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(FaceSelection); break; default: - QAD_Application::getDesktop()->SetSelectionMode(VolumeSelection, true); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(VolumeSelection); } - } - else { - QAD_Application::getDesktop()->SetSelectionMode(ActorSelection, true); + } else { + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(ActorSelection); if (theMode == 4) - mySelection->AddFilter(mySubMeshFilter); + mySelectionMgr->installFilter(mySubMeshFilter); else if (theMode == 5) - mySelection->AddFilter(myGroupFilter); + mySelectionMgr->installFilter(myGroupFilter); else if (theMode == 6) - mySelection->AddFilter(myMeshFilter); + mySelectionMgr->installFilter(myMeshFilter); } mySelectionMode = theMode; } -} +} //================================================================================= // function : onApply() @@ -544,11 +582,13 @@ void SMESHGUI_GroupDlg::setSelectionMode(int theMode) //================================================================================= bool SMESHGUI_GroupDlg::onApply() { - if (mySMESHGUI->ActiveStudyLocked()) + if (mySMESHGUI->isActiveStudyLocked()) return false; - - if ( myGrpTypeId == 0 && !myName->text().stripWhiteSpace().isEmpty() && myElements->count() > 0) { - mySelection->ClearIObjects(); + + if (myGrpTypeId == 0 && + !myName->text().stripWhiteSpace().isEmpty() && + myElements->count() > 0) { + mySelectionMgr->clearSelected(); if (myGroup->_is_nil()) { SMESH::ElementType aType = SMESH::ALL; switch(myTypeId) { @@ -567,19 +607,19 @@ bool SMESHGUI_GroupDlg::onApply() myGroup = SMESH::AddGroup(myMesh, aType, myName->text()); myGroup->Add(anIdList.inout()); - + /* init for next operation */ myName->setText(""); myElements->clear(); myGroup = SMESH::SMESH_Group::_nil(); - } - else { + + } else { myGroup->SetName(myName->text()); QValueList aAddList; QValueList::iterator anIt; QListBoxItem* anItem; - + for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next()) { int anId = anItem->text().toInt(); if ((anIt = myIdList.find(anId)) == myIdList.end()) @@ -609,33 +649,36 @@ bool SMESHGUI_GroupDlg::onApply() myIdList.append(anItem->text().toInt()); } - mySMESHGUI->GetActiveStudy()->updateObjBrowser(true); + mySMESHGUI->updateObjBrowser(true); SMESH::UpdateView(); // asv: fix of BUG PAL5515 - mySelection->ClearIObjects(); + mySelectionMgr->clearSelected(); return true; - } - else if (myGrpTypeId == 1 && !myName->text().stripWhiteSpace().isEmpty() && !CORBA::is_nil( myGeomGroup )) - { - SMESH::ElementType aType = SMESH::ALL; - switch(myTypeId) { - case 0: aType = SMESH::NODE; break; - case 1: aType = SMESH::EDGE; break; - case 2: aType = SMESH::FACE; break; - case 3: aType = SMESH::VOLUME; break; - } - - SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument(); - GEOM::GEOM_IGroupOperations_var aGroupOp = SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId()); - - SMESH::SMESH_GroupOnGeom_var aGroupOnGeom = myMesh->CreateGroupFromGEOM(aType, myName->text(),myGeomGroup); - - mySMESHGUI->GetActiveStudy()->updateObjBrowser(true); - mySelection->ClearIObjects(); - /* init for next operation */ - myName->setText(""); - return true; + } else if (myGrpTypeId == 1 && + !myName->text().stripWhiteSpace().isEmpty() && + !CORBA::is_nil(myGeomGroup)) + { + SMESH::ElementType aType = SMESH::ALL; + switch (myTypeId) { + case 0: aType = SMESH::NODE; break; + case 1: aType = SMESH::EDGE; break; + case 2: aType = SMESH::FACE; break; + case 3: aType = SMESH::VOLUME; break; } - + + _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); + GEOM::GEOM_IGroupOperations_var aGroupOp = + SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId()); + + SMESH::SMESH_GroupOnGeom_var aGroupOnGeom = + myMesh->CreateGroupFromGEOM(aType, myName->text(),myGeomGroup); + + mySMESHGUI->updateObjBrowser(true); + mySelectionMgr->clearSelected(); + /* init for next operation */ + myName->setText(""); + return true; + } + return false; } @@ -649,7 +692,6 @@ void SMESHGUI_GroupDlg::onOK() onClose(); } -static bool busy = false; //================================================================================= // function : onListSelectionChanged() // purpose : Called when selection in element list is changed @@ -657,11 +699,11 @@ static bool busy = false; void SMESHGUI_GroupDlg::onListSelectionChanged() { // MESSAGE("SMESHGUI_GroupDlg::onListSelectionChanged(); myActor = " << myActor); - if (busy || !myActor) return; - busy = true; + if( myIsBusy || !myActor) return; + myIsBusy = true; if (myCurrentLineEdit == 0) { - mySelection->ClearIObjects(); + mySelectionMgr->clearSelected(); TColStd_MapOfInteger aIndexes; QListBoxItem* anItem; for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next()) { @@ -670,10 +712,14 @@ void SMESHGUI_GroupDlg::onListSelectionChanged() aIndexes.Add(anId); } } - mySelection->AddOrRemoveIndex(myActor->getIO(), aIndexes, false, false); - mySelection->AddIObject(myActor->getIO()); + mySelector->AddOrRemoveIndex(myActor->getIO(), aIndexes, false); + SALOME_ListIO aList; + aList.Append(myActor->getIO()); + mySelectionMgr->setSelectedObjects(aList,false); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->highlight( myActor->getIO(), true, true ); } - busy = false; + myIsBusy = false; } //================================================================================= @@ -682,178 +728,181 @@ void SMESHGUI_GroupDlg::onListSelectionChanged() //================================================================================= void SMESHGUI_GroupDlg::onObjectSelectionChanged() { - if (busy || !isEnabled()) return; - busy = true; + if ( myIsBusy || !isEnabled()) return; + myIsBusy = true; - int aNbSel = mySelection->IObjectCount(); + SALOME_ListIO aList; + mySelectionMgr->selectedObjects( aList ); + + int aNbSel = aList.Extent(); myElements->clearSelection(); - + if (myCurrentLineEdit) { - myCurrentLineEdit->setText("") ; + myCurrentLineEdit->setText(""); QString aString = ""; - - if (myCurrentLineEdit == myMeshGroupLine) - { - mySelectSubMesh->setEnabled(false); - mySelectGroup->setEnabled(false); - myGroupLine->setText(""); - mySubMeshLine->setText(""); - - myGeomGroupBtn->setEnabled(false); - myGeomGroupLine->setEnabled(false); - myGeomGroupLine->setText(""); - if (!myCreate) - myName->setText(""); - - myElements->clear(); - - if(aNbSel != 1) - { - myGroup = SMESH::SMESH_Group::_nil(); - myMesh = SMESH::SMESH_Mesh::_nil(); - busy = false; - return; - } - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - - if (myCreate) - { - myMesh = SMESH::IObjectToInterface(IO); - if(myMesh->_is_nil()) - return; - myGroup = SMESH::SMESH_Group::_nil(); - - myActor = SMESH::FindActorByObject(myMesh); - SMESH::SetPickable(myActor); - - aString = mySelection->firstIObject()->getName(); - myMeshGroupLine->setText(aString) ; - myMeshGroupLine->home( false ); - - mySelectSubMesh->setEnabled(true); - mySelectGroup->setEnabled(true); - myGeomGroupBtn->setEnabled(true); - myGeomGroupLine->setEnabled(true); - updateButtons(); - } - else - { - SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface(IO); - if(aGroup->_is_nil()) - return; - busy = false; - myCurrentLineEdit = 0; - init(aGroup); - busy = true; - mySelectSubMesh->setEnabled(true); - mySelectGroup->setEnabled(true); - myGeomGroupBtn->setEnabled(true); - myGeomGroupLine->setEnabled(true); - } - myCurrentLineEdit = 0; - busy = false; - if (!myCreate) - return; - if (myTypeId == -1) - onTypeChanged(0); - else - { - myElements->clear(); - setSelectionMode(myTypeId); - } - - return; + if (myCurrentLineEdit == myMeshGroupLine) { + mySelectSubMesh->setEnabled(false); + mySelectGroup->setEnabled(false); + myGroupLine->setText(""); + mySubMeshLine->setText(""); + + myGeomGroupBtn->setEnabled(false); + myGeomGroupLine->setEnabled(false); + myGeomGroupLine->setText(""); + if (!myCreate) + myName->setText(""); + + myElements->clear(); + + if (aNbSel != 1 ) { + myGroup = SMESH::SMESH_Group::_nil(); + myMesh = SMESH::SMESH_Mesh::_nil(); + myIsBusy = false; + return; } - else if (myCurrentLineEdit == myGeomGroupLine) - { - - if(aNbSel != 1) - { - myGeomGroup = GEOM::GEOM_Object::_nil(); - busy = false; - return; - } - - Standard_Boolean testResult = Standard_False; - myGeomGroup = GEOMBase::ConvertIOinGEOMObject(mySelection->firstIObject(), testResult ); - - // Check if the object is a geometry group - if(!testResult || CORBA::is_nil( myGeomGroup )) - { - myGeomGroup = GEOM::GEOM_Object::_nil(); - busy = false; - return; - } - // Check if group constructed on the same shape as a mesh or on its child - SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument(); - GEOM::GEOM_IGroupOperations_var anOp = SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId()); - // The main shape of the group - GEOM::GEOM_Object_var aGroupMainShape; - if( myGeomGroup->GetType() == 37 ) - aGroupMainShape = anOp->GetMainShape( myGeomGroup ); - else - aGroupMainShape = GEOM::GEOM_Object::_duplicate(myGeomGroup); - SALOMEDS::SObject_var aGroupMainShapeSO = aStudy->FindObjectIOR( aStudy->ConvertObjectToIOR(aGroupMainShape) ); - // The mesh SObject - SALOMEDS::SObject_var aMeshSO = aStudy->FindObjectIOR( aStudy->ConvertObjectToIOR(myMesh) ); - if ( aMeshSO->_is_nil() ) { - myGeomGroup = GEOM::GEOM_Object::_nil(); - busy = false; + Handle(SALOME_InteractiveObject) IO = aList.First(); + + if (myCreate) { + myMesh = SMESH::IObjectToInterface(IO); + if (myMesh->_is_nil()) + { + myIsBusy = false; return; - } - SALOMEDS::SObject_var anObj, aRef; - bool isRefOrSubShape = false; - if ( aMeshSO->FindSubObject( 1, anObj ) && anObj->ReferencedObject( aRef )) { - if ( strcmp( aRef->GetID(), aGroupMainShapeSO->GetID() ) == 0 ) - isRefOrSubShape = true; - else - { - SALOMEDS::SObject_var aFather = aGroupMainShapeSO->GetFather(); - SALOMEDS::SComponent_var aComponent = aGroupMainShapeSO->GetFatherComponent(); - while ( !isRefOrSubShape && strcmp( aFather->GetID(), aComponent->GetID() ) != 0 ) - { - if (strcmp( aRef->GetID(), aFather->GetID() ) == 0) - isRefOrSubShape = true; - else - aFather = aFather->GetFather(); - } - } } - if ( !isRefOrSubShape ) - { - myGeomGroup = GEOM::GEOM_Object::_nil(); - busy = false; - return; - } + myGroup = SMESH::SMESH_Group::_nil(); + + myActor = SMESH::FindActorByObject(myMesh); + SMESH::SetPickable(myActor); + + aString = aList.First()->getName(); + myMeshGroupLine->setText(aString) ; + myMeshGroupLine->home( false ); + + mySelectSubMesh->setEnabled(true); + mySelectGroup->setEnabled(true); + myGeomGroupBtn->setEnabled(true); + myGeomGroupLine->setEnabled(true); + updateButtons(); + } else { + SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface(IO); + if (aGroup->_is_nil()) + { + myIsBusy = false; + return; + } + myIsBusy = false; + myCurrentLineEdit = 0; + init(aGroup); + myIsBusy = true; + mySelectSubMesh->setEnabled(true); + mySelectGroup->setEnabled(true); + myGeomGroupBtn->setEnabled(true); + myGeomGroupLine->setEnabled(true); } - - if (aNbSel >= 1) { - if (aNbSel > 1) { - if (myCurrentLineEdit == mySubMeshLine) + myCurrentLineEdit = 0; + myIsBusy = false; + if (!myCreate) + return; + + if (myTypeId == -1) + onTypeChanged(0); + else { + myElements->clear(); + setSelectionMode(myTypeId); + } + + myIsBusy = false; + return; + + } else if (myCurrentLineEdit == myGeomGroupLine) { + if (aNbSel != 1) { + myGeomGroup = GEOM::GEOM_Object::_nil(); + myIsBusy = false; + return; + } + + Standard_Boolean testResult = Standard_False; + myGeomGroup = GEOMBase::ConvertIOinGEOMObject(aList.First(), testResult); + + // Check if the object is a geometry group + if (!testResult || CORBA::is_nil(myGeomGroup)) { + myGeomGroup = GEOM::GEOM_Object::_nil(); + myIsBusy = false; + return; + } + // Check if group constructed on the same shape as a mesh or on its child + _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); + GEOM::GEOM_IGroupOperations_var anOp = + SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId()); + + // The main shape of the group + GEOM::GEOM_Object_var aGroupMainShape; + if (myGeomGroup->GetType() == 37) + aGroupMainShape = anOp->GetMainShape(myGeomGroup); + else + aGroupMainShape = GEOM::GEOM_Object::_duplicate(myGeomGroup); + _PTR(SObject) aGroupMainShapeSO = + //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(aGroupMainShape)); + aStudy->FindObjectID(aGroupMainShape->GetStudyEntry()); + + // The mesh SObject + _PTR(SObject) aMeshSO = SMESH::FindSObject(myMesh); + if (!aMeshSO) { + myGeomGroup = GEOM::GEOM_Object::_nil(); + myIsBusy = false; + return; + } + _PTR(SObject) anObj, aRef; + bool isRefOrSubShape = false; + if (aMeshSO->FindSubObject(1, anObj) && anObj->ReferencedObject(aRef)) { + //if (strcmp(aRef->GetID(), aGroupMainShapeSO->GetID()) == 0) { + if (aRef->GetID() == aGroupMainShapeSO->GetID()) { + isRefOrSubShape = true; + } else { + _PTR(SObject) aFather = aGroupMainShapeSO->GetFather(); + _PTR(SComponent) aComponent = aGroupMainShapeSO->GetFatherComponent(); + //while (!isRefOrSubShape && strcmp(aFather->GetID(), aComponent->GetID()) != 0) { + while (!isRefOrSubShape && aFather->GetID() != aComponent->GetID()) { + //if (strcmp(aRef->GetID(), aFather->GetID()) == 0) + if (aRef->GetID() == aFather->GetID()) + isRefOrSubShape = true; + else + aFather = aFather->GetFather(); + } + } + } + if (!isRefOrSubShape) { + myGeomGroup = GEOM::GEOM_Object::_nil(); + myIsBusy = false; + return; + } + } + + if(aNbSel >= 1) { + if(aNbSel > 1) { + if(myCurrentLineEdit == mySubMeshLine) aString = tr("SMESH_SUBMESH_SELECTED").arg(aNbSel); - else if (myCurrentLineEdit == myGroupLine || myCurrentLineEdit == myGeomGroupLine) + else if(myCurrentLineEdit == myGroupLine || myCurrentLineEdit == myGeomGroupLine) aString = tr("SMESH_GROUP_SELECTED").arg(aNbSel); - } - else { - aString = mySelection->firstIObject()->getName(); + } else { + aString = aList.First()->getName(); } } - - myCurrentLineEdit->setText(aString) ; - myCurrentLineEdit->home( false ); - + + myCurrentLineEdit->setText(aString); + myCurrentLineEdit->home(false); + updateButtons(); - } - else { - if (aNbSel == 1) { + + } else { + if (aNbSel == 1 && myActor ) { QString aListStr = ""; int aNbItems = 0; if (myTypeId == 0) { - aNbItems = SMESH::GetNameOfSelectedNodes(mySelection, aListStr); - } - else { - aNbItems = SMESH::GetNameOfSelectedElements(mySelection, aListStr); + aNbItems = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr); + } else { + aNbItems = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aListStr); } if (aNbItems > 0) { QStringList anElements = QStringList::split(" ", aListStr); @@ -865,17 +914,16 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() } } } - - if ( !myActor ) { - if ( !myGroup->_is_nil() ) + + if (!myActor) { + if (!myGroup->_is_nil()) myActor = SMESH::FindActorByObject(myGroup); else myActor = SMESH::FindActorByObject(myMesh); } - - busy = false; -} + myIsBusy = false; +} //================================================================================= // function : onSelectSubMesh() @@ -886,7 +934,7 @@ void SMESHGUI_GroupDlg::onSelectSubMesh(bool on) if (on) { if (mySelectGroup->isChecked()) { mySelectGroup->setChecked(false); - } + } //VSR: else if (mySelectGeomGroup->isChecked()) { //VSR: mySelectGeomGroup->setChecked(false); //VSR: } @@ -987,7 +1035,7 @@ void SMESHGUI_GroupDlg::setCurrentSelection() //================================================================================= // function : setFilters() -// purpose : SLOT. Called when "Filter" button pressed. +// purpose : SLOT. Called when "Filter" button pressed. //================================================================================= void SMESHGUI_GroupDlg::setFilters() { @@ -1003,13 +1051,13 @@ void SMESHGUI_GroupDlg::setFilters() if ( myFilterDlg == 0 ) { - myFilterDlg = new SMESHGUI_FilterDlg( (QWidget*)parent(), aType ); + myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, aType ); connect( myFilterDlg, SIGNAL( Accepted() ), SLOT( onFilterAccepted() ) ); } else myFilterDlg->Init( aType ); - myFilterDlg->SetSelection( mySelection ); + myFilterDlg->SetSelection(); myFilterDlg->SetMesh( myMesh ); myFilterDlg->SetSourceWg( myElements ); @@ -1037,10 +1085,14 @@ void SMESHGUI_GroupDlg::onFilterAccepted() //================================================================================= void SMESHGUI_GroupDlg::onAdd() { - int aNbSel = mySelection->IObjectCount(); + SALOME_ListIO aList; + mySelectionMgr->selectedObjects( aList ); + + int aNbSel = aList.Extent(); + if (aNbSel == 0 || !myActor || myMesh->_is_nil()) return; - busy = true; + myIsBusy = true; SMESH::ElementType aType = SMESH::ALL; switch(myTypeId) { @@ -1051,14 +1103,14 @@ void SMESHGUI_GroupDlg::onAdd() } if (myCurrentLineEdit == 0) { - //if (aNbSel != 1) { busy = false; return; } + //if (aNbSel != 1) { myIsBusy = false; return; } QString aListStr = ""; int aNbItems = 0; if (myTypeId == 0) { - aNbItems = SMESH::GetNameOfSelectedNodes(mySelection, myActor->getIO(), aListStr); + aNbItems = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr); } else { - aNbItems = SMESH::GetNameOfSelectedElements(mySelection, myActor->getIO(), aListStr); + aNbItems = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aListStr); } if (aNbItems > 0) { QStringList anElements = QStringList::split(" ", aListStr); @@ -1072,16 +1124,21 @@ void SMESHGUI_GroupDlg::onAdd() myElements->setSelected(anItem, true); } } - } - else if (myCurrentLineEdit == mySubMeshLine) { - SALOME_ListIteratorOfListIO anIt(mySelection->StoredIObjects()); + } else if (myCurrentLineEdit == mySubMeshLine) { + //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects()); + + SALOME_ListIO aList; + mySelectionMgr->selectedObjects( aList ); + + SALOME_ListIteratorOfListIO anIt (aList); for (; anIt.More(); anIt.Next()) { - SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(anIt.Value()); + SMESH::SMESH_subMesh_var aSubMesh = + SMESH::IObjectToInterface(anIt.Value()); if (!aSubMesh->_is_nil()) { // check if mesh is the same if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) { try { - SMESH::long_array_var anElements = aSubMesh->GetElementsByType ( aType ); + SMESH::long_array_var anElements = aSubMesh->GetElementsByType(aType); int k = anElements->length(); QListBoxItem* anItem = 0; for (int i = 0; i < k; i++) { @@ -1095,19 +1152,24 @@ void SMESHGUI_GroupDlg::onAdd() } } catch (const SALOME::SALOME_Exception& ex) { - QtCatchCorbaException(ex); + SalomeApp_Tools::QtCatchCorbaException(ex); } } } } mySelectSubMesh->setChecked(false); - busy = false; + myIsBusy = false; onListSelectionChanged(); - } - else if (myCurrentLineEdit == myGroupLine) { - SALOME_ListIteratorOfListIO anIt(mySelection->StoredIObjects()); + + } else if (myCurrentLineEdit == myGroupLine) { + //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects()); + SALOME_ListIO aList; + mySelectionMgr->selectedObjects( aList ); + + SALOME_ListIteratorOfListIO anIt (aList); for (; anIt.More(); anIt.Next()) { - SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface(anIt.Value()); + SMESH::SMESH_Group_var aGroup = + SMESH::IObjectToInterface(anIt.Value()); if (!aGroup->_is_nil()) { // check if mesh is the same if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) { @@ -1127,36 +1189,38 @@ void SMESHGUI_GroupDlg::onAdd() } } mySelectGroup->setChecked(false); - busy = false; + myIsBusy = false; onListSelectionChanged(); - } - else if (myCurrentLineEdit == myGeomGroupLine && !CORBA::is_nil(myGeomGroup)) { - - SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument(); - GEOM::GEOM_IGroupOperations_var aGroupOp = SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId()); - + + } else if (myCurrentLineEdit == myGeomGroupLine && !CORBA::is_nil(myGeomGroup)) { + _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); + GEOM::GEOM_IGroupOperations_var aGroupOp = + SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId()); + SMESH::ElementType aGroupType = SMESH::ALL; switch(aGroupOp->GetType(myGeomGroup)) { case 7: aGroupType = SMESH::NODE; break; case 6: aGroupType = SMESH::EDGE; break; case 4: aGroupType = SMESH::FACE; break; case 2: aGroupType = SMESH::VOLUME; break; - default: return; + default: myIsBusy = false; return; } - + if (aGroupType == aType) { - SALOMEDS::SObject_var aGroupSO = aStudy->FindObjectIOR( aStudy->ConvertObjectToIOR(myGeomGroup) ); + _PTR(SObject) aGroupSO = + //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(myGeomGroup)); + aStudy->FindObjectID(myGeomGroup->GetStudyEntry()); // Construct filter SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager(); SMESH::Filter_var aFilter = aFilterMgr->CreateFilter(); SMESH::BelongToGeom_var aBelongToGeom = aFilterMgr->CreateBelongToGeom();; aBelongToGeom->SetGeom(myGeomGroup); - aBelongToGeom->SetShapeName(aGroupSO->GetName()); + aBelongToGeom->SetShapeName(aGroupSO->GetName().c_str()); aBelongToGeom->SetElementType(aType); - aFilter->SetPredicate( aBelongToGeom ); - - SMESH::long_array_var anElements = aFilter->GetElementsId( myMesh ); - + aFilter->SetPredicate(aBelongToGeom); + + SMESH::long_array_var anElements = aFilter->GetElementsId(myMesh); + int k = anElements->length(); QListBoxItem* anItem = 0; for (int i = 0; i < k; i++) { @@ -1169,13 +1233,13 @@ void SMESHGUI_GroupDlg::onAdd() myElements->setSelected(anItem, true); } } - + //VSR: mySelectGeomGroup->setChecked(false); - busy = false; + myIsBusy = false; onListSelectionChanged(); } - busy = false; - // mySelection->ClearIObjects(); + myIsBusy = false; + // mySelectionMgr->clearSelected(); updateButtons(); } @@ -1185,18 +1249,21 @@ void SMESHGUI_GroupDlg::onAdd() //================================================================================= void SMESHGUI_GroupDlg::onRemove() { - busy = true; + myIsBusy = true; if (myCurrentLineEdit == 0) { for (int i = myElements->count(); i > 0; i--) { if (myElements->isSelected(i-1)) { myElements->removeItem(i-1); } } - } - else { - int aNbSel = mySelection->IObjectCount(); - if (aNbSel == 0) { busy = false; return; } - + } else { + SALOME_ListIO aList; + mySelectionMgr->selectedObjects( aList ); + + int aNbSel = aList.Extent(); + + if (aNbSel == 0) { myIsBusy = false; return; } + SMESH::ElementType aType = SMESH::ALL; switch(myTypeId) { case 0: aType = SMESH::NODE; break; @@ -1206,7 +1273,11 @@ void SMESHGUI_GroupDlg::onRemove() } if (myCurrentLineEdit == mySubMeshLine) { - SALOME_ListIteratorOfListIO anIt(mySelection->StoredIObjects()); + //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects()); + SALOME_ListIO aList; + mySelectionMgr->selectedObjects( aList ); + + SALOME_ListIteratorOfListIO anIt (aList); for (; anIt.More(); anIt.Next()) { SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(anIt.Value()); if (!aSubMesh->_is_nil()) { @@ -1223,7 +1294,7 @@ void SMESHGUI_GroupDlg::onRemove() } } catch (const SALOME::SALOME_Exception& ex) { - QtCatchCorbaException(ex); + SalomeApp_Tools::QtCatchCorbaException(ex); } } else { @@ -1237,7 +1308,7 @@ void SMESHGUI_GroupDlg::onRemove() } } catch (const SALOME::SALOME_Exception& ex) { - QtCatchCorbaException(ex); + SalomeApp_Tools::QtCatchCorbaException(ex); } } } @@ -1246,7 +1317,11 @@ void SMESHGUI_GroupDlg::onRemove() } else if (myCurrentLineEdit == myGroupLine) { Standard_Boolean aRes; - SALOME_ListIteratorOfListIO anIt(mySelection->StoredIObjects()); + //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects()); + SALOME_ListIO aList; + mySelectionMgr->selectedObjects( aList ); + + SALOME_ListIteratorOfListIO anIt (aList); for (; anIt.More(); anIt.Next()) { SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface(anIt.Value()); if (aRes && !aGroup->_is_nil()) { @@ -1264,7 +1339,7 @@ void SMESHGUI_GroupDlg::onRemove() } } } - busy = false; + myIsBusy = false; updateButtons(); } @@ -1279,7 +1354,7 @@ void SMESHGUI_GroupDlg::onSort() // myElements->update(); int i, k = myElements->count(); if (k > 0) { - busy = true; + myIsBusy = true; QStringList aSelected; std::vector anArray(k); // QMemArray anArray(k); @@ -1287,7 +1362,7 @@ void SMESHGUI_GroupDlg::onSort() // fill the array for (anItem = myElements->firstItem(), i = 0; anItem != 0; anItem = anItem->next(), i++) { anArray[i] = anItem->text().toInt(); - if (anItem->isSelected()) + if (anItem->isSelected()) aSelected.append(anItem->text()); } // sort & update list @@ -1301,7 +1376,7 @@ void SMESHGUI_GroupDlg::onSort() anItem = myElements->findItem(*it, Qt::ExactMatch); if (anItem) myElements->setSelected(anItem, true); } - busy = false; + myIsBusy = false; } } @@ -1309,70 +1384,65 @@ void SMESHGUI_GroupDlg::onSort() // function : closeEvent() // purpose : //================================================================================= -void SMESHGUI_GroupDlg::closeEvent( QCloseEvent* e ) +void SMESHGUI_GroupDlg::closeEvent (QCloseEvent*) { onClose(); } -//======================================================================= -// name : SMESHGUI_GroupDlg::onClose -// Purpose : SLOT called when "Close" button pressed. Close dialog -//======================================================================= +//================================================================================= +// function : SMESHGUI_GroupDlg::onClose +// purpose : SLOT called when "Close" button pressed. Close dialog +//================================================================================= void SMESHGUI_GroupDlg::onClose() { - QAD_StudyFrame* aStudyFrame = mySMESHGUI->GetActiveStudy()->getActiveStudyFrame(); - if (aStudyFrame->getTypeView() == VIEW_VTK) { + if (SMESH::GetCurrentVtkView()) { + SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters SMESH::SetPointRepresentation(false); SMESH::SetPickable(); - - // remove filters from viewer - if(VTKViewer_InteractorStyleSALOME* aStyle = SMESH::GetInteractorStyle()){ - SMESH::RemoveFilter(SMESHGUI_EdgeFilter,aStyle); - SMESH::RemoveFilter(SMESHGUI_FaceFilter,aStyle); - } } - - mySelection->ClearIObjects(); - QAD_Application::getDesktop()->SetSelectionMode(ActorSelection); - mySelection->ClearFilters(); + + mySelectionMgr->clearSelected(); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(ActorSelection); + mySelectionMgr->clearFilters(); mySMESHGUI->ResetState(); reject(); } -//======================================================================= -// name : SMESHGUI_GroupDlg::onDeactivate -// Purpose : SLOT called when dialog must be deativated -//======================================================================= +//================================================================================= +// function : SMESHGUI_GroupDlg::onDeactivate +// purpose : SLOT called when dialog must be deativated +//================================================================================= void SMESHGUI_GroupDlg::onDeactivate() { mySMESHGUI->ResetState(); - setEnabled( false ); + setEnabled(false); } -//======================================================================= -// name : SMESHGUI_GroupDlg::enterEvent -// Purpose : Event filter -//======================================================================= -void SMESHGUI_GroupDlg::enterEvent( QEvent* ) +//================================================================================= +// function : SMESHGUI_GroupDlg::enterEvent +// purpose : Event filter +//================================================================================= +void SMESHGUI_GroupDlg::enterEvent (QEvent*) { - if ( !isEnabled() ) { - SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); - setEnabled( true ); + if (!isEnabled()) { + mySMESHGUI->EmitSignalDeactivateDialog(); + setEnabled(true); mySelectionMode = -1; - setSelectionMode( myTypeId ); - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + setSelectionMode(myTypeId); + //mySMESHGUI->SetActiveDialogBox((QDialog*)this); + mySMESHGUI->SetActiveDialogBox(this); mySMESHGUI->SetState(800); } } -//======================================================================= -//function : hideEvent -//purpose : caused by ESC key -//======================================================================= - -void SMESHGUI_GroupDlg::hideEvent ( QHideEvent * e ) +//================================================================================= +// function : hideEvent +// purpose : caused by ESC key +//================================================================================= +void SMESHGUI_GroupDlg::hideEvent (QHideEvent*) { - if ( !isMinimized() ) + if (!isMinimized()) onClose(); }