X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_GroupDlg.cxx;h=262e33c5e412b4adc68b8cd5c16bfedaece7e801;hp=5f7b9da9d6ab6ff4fd177efdab650a8b2a62625f;hb=c9c6669fab21f2a0d544d79e60ceb119800b4cb5;hpb=c38c10811a065cf5b13e8807ed71864d92ca7d80 diff --git a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx index 5f7b9da9d..262e33c5e 100644 --- a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx @@ -89,8 +89,8 @@ SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name, WStyle_Title | WStyle_SysMenu | WDestructiveClose), mySMESHGUI( theModule ), mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), - myViewWindow( SMESH::GetViewWindow( theModule ) ), - mySelector( myViewWindow->GetSelector() ) + myIsBusy( false ), + myActor( 0 ) { if (!name) setName("SMESHGUI_GroupDlg"); initDialog(true); @@ -103,6 +103,8 @@ SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name, 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); @@ -119,10 +121,12 @@ SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name, WStyle_Title | WStyle_SysMenu | WDestructiveClose), mySMESHGUI( theModule ), mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), - myViewWindow( SMESH::GetViewWindow( theModule ) ), - mySelector( myViewWindow->GetSelector() ) + myIsBusy( false ) { if (!name) setName("SMESHGUI_GroupDlg"); + + mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector(); + initDialog(false); if (!theGroup->_is_nil()) init(theGroup); @@ -130,7 +134,7 @@ SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name, mySelectSubMesh->setEnabled(false); mySelectGroup->setEnabled(false); } - + /* Move widget on the botton right corner of main widget */ int x, y ; mySMESHGUI->DefineDlgPosition(this, x, y); @@ -147,7 +151,7 @@ void SMESHGUI_GroupDlg::initDialog(bool create) myCreate = create; myCurrentLineEdit = 0; - QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); if (create) setCaption(tr("SMESH_CREATE_GROUP_TITLE")); @@ -396,6 +400,8 @@ SMESHGUI_GroupDlg::~SMESHGUI_GroupDlg() //================================================================================= 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(); @@ -403,11 +409,14 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_Mesh_ptr theMesh) myActor = SMESH::FindActorByObject(myMesh); SMESH::SetPickable(myActor); - const SALOME_ListIO& aList = mySelector->StoredIObjects(); - - QString aName = aList.First()->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; @@ -535,19 +544,24 @@ void SMESHGUI_GroupDlg::setSelectionMode (int theMode) myActor->SetPointRepresentation(true); else SMESH::SetPointRepresentation(true); - myViewWindow->SetSelectionMode(NodeSelection); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(NodeSelection); break; case 1: - myViewWindow->SetSelectionMode(EdgeSelection); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(EdgeSelection); break; case 2: - myViewWindow->SetSelectionMode(FaceSelection); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(FaceSelection); break; default: - myViewWindow->SetSelectionMode(VolumeSelection); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(VolumeSelection); } } else { - myViewWindow->SetSelectionMode(ActorSelection); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(ActorSelection); if (theMode == 4) mySelectionMgr->installFilter(mySubMeshFilter); else if (theMode == 5) @@ -675,7 +689,6 @@ void SMESHGUI_GroupDlg::onOK() onClose(); } -static bool busy = false; //================================================================================= // function : onListSelectionChanged() // purpose : Called when selection in element list is changed @@ -683,8 +696,8 @@ 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) { mySelectionMgr->clearSelected(); @@ -700,9 +713,10 @@ void SMESHGUI_GroupDlg::onListSelectionChanged() SALOME_ListIO aList; aList.Append(myActor->getIO()); mySelectionMgr->setSelectedObjects(aList,false); - myViewWindow->highlight( myActor->getIO(), true, true ); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->highlight( myActor->getIO(), true, true ); } - busy = false; + myIsBusy = false; } //================================================================================= @@ -711,11 +725,12 @@ void SMESHGUI_GroupDlg::onListSelectionChanged() //================================================================================= void SMESHGUI_GroupDlg::onObjectSelectionChanged() { - if (busy || !isEnabled()) return; - busy = true; - - const SALOME_ListIO& aList = mySelector->StoredIObjects(); + if ( myIsBusy || !isEnabled()) return; + myIsBusy = true; + SALOME_ListIO aList; + mySelectionMgr->selectedObjects( aList ); + int aNbSel = aList.Extent(); myElements->clearSelection(); @@ -737,10 +752,10 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() myElements->clear(); - if (aNbSel != 1) { + if (aNbSel != 1 ) { myGroup = SMESH::SMESH_Group::_nil(); myMesh = SMESH::SMESH_Mesh::_nil(); - busy = false; + myIsBusy = false; return; } Handle(SALOME_InteractiveObject) IO = aList.First(); @@ -749,7 +764,7 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() myMesh = SMESH::IObjectToInterface(IO); if (myMesh->_is_nil()) { - busy = false; + myIsBusy = false; return; } myGroup = SMESH::SMESH_Group::_nil(); @@ -770,25 +785,22 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface(IO); if (aGroup->_is_nil()) { - busy = false; + myIsBusy = false; return; } - busy = false; + myIsBusy = false; myCurrentLineEdit = 0; init(aGroup); - busy = true; + myIsBusy = true; mySelectSubMesh->setEnabled(true); mySelectGroup->setEnabled(true); myGeomGroupBtn->setEnabled(true); myGeomGroupLine->setEnabled(true); } myCurrentLineEdit = 0; - busy = false; + myIsBusy = false; if (!myCreate) - { - busy = false; return; - } if (myTypeId == -1) onTypeChanged(0); @@ -797,13 +809,13 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() setSelectionMode(myTypeId); } - busy = false; + myIsBusy = false; return; } else if (myCurrentLineEdit == myGeomGroupLine) { if (aNbSel != 1) { myGeomGroup = GEOM::GEOM_Object::_nil(); - busy = false; + myIsBusy = false; return; } @@ -813,7 +825,7 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() // Check if the object is a geometry group if (!testResult || CORBA::is_nil(myGeomGroup)) { myGeomGroup = GEOM::GEOM_Object::_nil(); - busy = false; + myIsBusy = false; return; } // Check if group constructed on the same shape as a mesh or on its child @@ -835,7 +847,7 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() _PTR(SObject) aMeshSO = SMESH::FindSObject(myMesh); if (!aMeshSO) { myGeomGroup = GEOM::GEOM_Object::_nil(); - busy = false; + myIsBusy = false; return; } _PTR(SObject) anObj, aRef; @@ -859,16 +871,16 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() } if (!isRefOrSubShape) { myGeomGroup = GEOM::GEOM_Object::_nil(); - busy = false; + myIsBusy = false; return; } } - if (aNbSel >= 1) { - if (aNbSel > 1) { - if (myCurrentLineEdit == mySubMeshLine) + 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 = aList.First()->getName(); @@ -881,7 +893,7 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() updateButtons(); } else { - if (aNbSel == 1) { + if (aNbSel == 1 && myActor ) { QString aListStr = ""; int aNbItems = 0; if (myTypeId == 0) { @@ -907,7 +919,7 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() myActor = SMESH::FindActorByObject(myMesh); } - busy = false; + myIsBusy = false; } //================================================================================= @@ -1070,12 +1082,14 @@ void SMESHGUI_GroupDlg::onFilterAccepted() //================================================================================= void SMESHGUI_GroupDlg::onAdd() { - const SALOME_ListIO& aList = mySelector->StoredIObjects(); + 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) { @@ -1086,7 +1100,7 @@ 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) { @@ -1109,7 +1123,10 @@ void SMESHGUI_GroupDlg::onAdd() } } else if (myCurrentLineEdit == mySubMeshLine) { //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects()); - const SALOME_ListIO& aList = mySelector->StoredIObjects(); + + SALOME_ListIO aList; + mySelectionMgr->selectedObjects( aList ); + SALOME_ListIteratorOfListIO anIt (aList); for (; anIt.More(); anIt.Next()) { SMESH::SMESH_subMesh_var aSubMesh = @@ -1138,12 +1155,14 @@ void SMESHGUI_GroupDlg::onAdd() } } mySelectSubMesh->setChecked(false); - busy = false; + myIsBusy = false; onListSelectionChanged(); } else if (myCurrentLineEdit == myGroupLine) { //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects()); - const SALOME_ListIO& aList = mySelector->StoredIObjects(); + SALOME_ListIO aList; + mySelectionMgr->selectedObjects( aList ); + SALOME_ListIteratorOfListIO anIt (aList); for (; anIt.More(); anIt.Next()) { SMESH::SMESH_Group_var aGroup = @@ -1167,7 +1186,7 @@ void SMESHGUI_GroupDlg::onAdd() } } mySelectGroup->setChecked(false); - busy = false; + myIsBusy = false; onListSelectionChanged(); } else if (myCurrentLineEdit == myGeomGroupLine && !CORBA::is_nil(myGeomGroup)) { @@ -1181,7 +1200,7 @@ void SMESHGUI_GroupDlg::onAdd() case 6: aGroupType = SMESH::EDGE; break; case 4: aGroupType = SMESH::FACE; break; case 2: aGroupType = SMESH::VOLUME; break; - default: busy = false; return; + default: myIsBusy = false; return; } if (aGroupType == aType) { @@ -1213,10 +1232,10 @@ void SMESHGUI_GroupDlg::onAdd() } //VSR: mySelectGeomGroup->setChecked(false); - busy = false; + myIsBusy = false; onListSelectionChanged(); } - busy = false; + myIsBusy = false; // mySelectionMgr->clearSelected(); updateButtons(); } @@ -1227,7 +1246,7 @@ 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)) { @@ -1235,10 +1254,12 @@ void SMESHGUI_GroupDlg::onRemove() } } } else { - const SALOME_ListIO& aList = mySelector->StoredIObjects(); + SALOME_ListIO aList; + mySelectionMgr->selectedObjects( aList ); + int aNbSel = aList.Extent(); - if (aNbSel == 0) { busy = false; return; } + if (aNbSel == 0) { myIsBusy = false; return; } SMESH::ElementType aType = SMESH::ALL; switch(myTypeId) { @@ -1250,7 +1271,9 @@ void SMESHGUI_GroupDlg::onRemove() if (myCurrentLineEdit == mySubMeshLine) { //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects()); - const SALOME_ListIO& aList = mySelector->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()); @@ -1292,7 +1315,9 @@ void SMESHGUI_GroupDlg::onRemove() else if (myCurrentLineEdit == myGroupLine) { Standard_Boolean aRes; //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects()); - const SALOME_ListIO& aList = mySelector->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()); @@ -1311,7 +1336,7 @@ void SMESHGUI_GroupDlg::onRemove() } } } - busy = false; + myIsBusy = false; updateButtons(); } @@ -1326,7 +1351,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); @@ -1348,7 +1373,7 @@ void SMESHGUI_GroupDlg::onSort() anItem = myElements->findItem(*it, Qt::ExactMatch); if (anItem) myElements->setSelected(anItem, true); } - busy = false; + myIsBusy = false; } } @@ -1374,7 +1399,8 @@ void SMESHGUI_GroupDlg::onClose() } mySelectionMgr->clearSelected(); - myViewWindow->SetSelectionMode(ActorSelection); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(ActorSelection); mySelectionMgr->clearFilters(); mySMESHGUI->ResetState();