X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_GroupDlg.cxx;h=b9396313bb87e81b284c3e58874978770855a78d;hp=5f7b9da9d6ab6ff4fd177efdab650a8b2a62625f;hb=5309d564cb25bce0159bf722cd6347c06f7bc13f;hpb=c38c10811a065cf5b13e8807ed71864d92ca7d80 diff --git a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx index 5f7b9da9d..b9396313b 100644 --- a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx @@ -89,8 +89,9 @@ 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() ) + mySelector(SMESH::GetViewWindow( theModule )->GetSelector()), + myIsBusy( false ), + myActor( 0 ) { if (!name) setName("SMESHGUI_GroupDlg"); initDialog(true); @@ -103,6 +104,7 @@ SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name, myGeomGroupLine->setEnabled(false); } + /* Move widget on the botton right corner of main widget */ int x, y ; mySMESHGUI->DefineDlgPosition(this, x, y); @@ -119,18 +121,22 @@ 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() ) + mySelector(SMESH::GetViewWindow( theModule )->GetSelector()), + myIsBusy( false ) { if (!name) setName("SMESHGUI_GroupDlg"); + 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 */ int x, y ; mySMESHGUI->DefineDlgPosition(this, x, y); @@ -147,7 +153,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 +402,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 +411,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; @@ -525,7 +536,7 @@ void SMESHGUI_GroupDlg::setSelectionMode (int theMode) return; if (mySelectionMode != theMode) { - mySelectionMgr->clearSelected(); + // [PAL10408] mySelectionMgr->clearSelected(); mySelectionMgr->clearFilters(); SMESH::SetPointRepresentation(false); if (theMode < 4) { @@ -535,25 +546,30 @@ 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 (theMode == 4) mySelectionMgr->installFilter(mySubMeshFilter); else if (theMode == 5) mySelectionMgr->installFilter(myGroupFilter); else if (theMode == 6) mySelectionMgr->installFilter(myMeshFilter); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(ActorSelection); } mySelectionMode = theMode; } @@ -675,7 +691,6 @@ void SMESHGUI_GroupDlg::onOK() onClose(); } -static bool busy = false; //================================================================================= // function : onListSelectionChanged() // purpose : Called when selection in element list is changed @@ -683,8 +698,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 +715,8 @@ void SMESHGUI_GroupDlg::onListSelectionChanged() SALOME_ListIO aList; aList.Append(myActor->getIO()); mySelectionMgr->setSelectedObjects(aList,false); - myViewWindow->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 @@ -829,13 +841,13 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() aGroupMainShape = GEOM::GEOM_Object::_duplicate(myGeomGroup); _PTR(SObject) aGroupMainShapeSO = //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(aGroupMainShape)); - aStudy->FindObjectIOR(aGroupMainShape->GetStudyEntry()); + aStudy->FindObjectID(aGroupMainShape->GetStudyEntry()); // The mesh SObject _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,23 +1082,40 @@ 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) { - case 0: aType = SMESH::NODE; break; - case 1: aType = SMESH::EDGE; break; - case 2: aType = SMESH::FACE; break; - case 3: aType = SMESH::VOLUME; break; + case 0: + aType = SMESH::NODE; + mySelector->SetSelectionMode(NodeSelection); + break; + case 1: + aType = SMESH::EDGE; + mySelector->SetSelectionMode(EdgeSelection); + break; + case 2: + aType = SMESH::FACE; + mySelector->SetSelectionMode(FaceSelection); + break; + case 3: + aType = SMESH::VOLUME; + mySelector->SetSelectionMode(VolumeSelection); + break; + default: + mySelector->SetSelectionMode(ActorSelection); } + 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 +1138,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 +1170,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 +1201,7 @@ void SMESHGUI_GroupDlg::onAdd() } } mySelectGroup->setChecked(false); - busy = false; + myIsBusy = false; onListSelectionChanged(); } else if (myCurrentLineEdit == myGeomGroupLine && !CORBA::is_nil(myGeomGroup)) { @@ -1181,13 +1215,13 @@ 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) { _PTR(SObject) aGroupSO = //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(myGeomGroup)); - aStudy->FindObjectIOR(myGeomGroup->GetStudyEntry()); + aStudy->FindObjectID(myGeomGroup->GetStudyEntry()); // Construct filter SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager(); SMESH::Filter_var aFilter = aFilterMgr->CreateFilter(); @@ -1213,10 +1247,10 @@ void SMESHGUI_GroupDlg::onAdd() } //VSR: mySelectGeomGroup->setChecked(false); - busy = false; + myIsBusy = false; onListSelectionChanged(); } - busy = false; + myIsBusy = false; // mySelectionMgr->clearSelected(); updateButtons(); } @@ -1227,7 +1261,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 +1269,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 +1286,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 +1330,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 +1351,7 @@ void SMESHGUI_GroupDlg::onRemove() } } } - busy = false; + myIsBusy = false; updateButtons(); } @@ -1326,7 +1366,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 +1388,7 @@ void SMESHGUI_GroupDlg::onSort() anItem = myElements->findItem(*it, Qt::ExactMatch); if (anItem) myElements->setSelected(anItem, true); } - busy = false; + myIsBusy = false; } } @@ -1374,7 +1414,8 @@ void SMESHGUI_GroupDlg::onClose() } mySelectionMgr->clearSelected(); - myViewWindow->SetSelectionMode(ActorSelection); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(ActorSelection); mySelectionMgr->clearFilters(); mySMESHGUI->ResetState();