Salome HOME
PAL9878 - selection lost after operation
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_RemoveElementsDlg.cxx
index 011402ab7c0680656a689acdbe920f72d73f6f29..8bd1824a2ea64fcc0b16a21aca2cd1fd10946d16 100644 (file)
@@ -82,12 +82,11 @@ SMESHGUI_RemoveElementsDlg
            WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
     mySelector(SMESH::GetViewWindow(theModule)->GetSelector()),
     mySelectionMgr(SMESH::GetSelectionMgr(theModule)),
-    myViewWindow(SMESH::GetViewWindow(theModule)),
     mySMESHGUI(theModule),
     myBusy(false)
 {
-    QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_REM_ELEMENT")));
-    QPixmap image1 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
+    QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_REM_ELEMENT")));
+    QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
 
     if (!name)
       setName("SMESHGUI_RemoveElementsDlg");
@@ -225,7 +224,8 @@ void SMESHGUI_RemoveElementsDlg::Init()
   this->move(x, y);
   this->show(); /* displays Dialog */
 
-  myViewWindow->SetSelectionMode(CellSelection);
+  if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+    aViewWindow->SetSelectionMode(CellSelection);
 
   SelectionIntoArgument();
 }
@@ -261,9 +261,7 @@ void SMESHGUI_RemoveElementsDlg::ClickOnApply()
     }
 
     if (aResult) {
-      SALOME_ListIO aList;
-      aList.Append(myActor->getIO());
-      mySelectionMgr->setSelectedObjects(aList, false);
+      myEditCurrentArgument->clear();
       SMESH::UpdateView();
     }
   }
@@ -287,8 +285,9 @@ void SMESHGUI_RemoveElementsDlg::ClickOnOk()
 //=================================================================================
 void SMESHGUI_RemoveElementsDlg::ClickOnCancel()
 {
-  mySelectionMgr->clearSelected();
-  myViewWindow->SetSelectionMode(ActorSelection);
+  //mySelectionMgr->clearSelected();
+  if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+    aViewWindow->SetSelectionMode(ActorSelection);
   disconnect(mySelectionMgr, 0, this, 0);
   mySMESHGUI->ResetState();
   reject();
@@ -314,36 +313,28 @@ void SMESHGUI_RemoveElementsDlg::onTextChange (const QString& theNewText)
   if(myActor){
     if(SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh()){
       Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
-      SALOME_ListIO aList;
-      aList.Append(anIO);
-      mySelectionMgr->setSelectedObjects(aList, false);
       
-      TColStd_IndexedMapOfInteger selectedIndices;
       TColStd_MapOfInteger newIndices;
-      mySelector->GetIndex(anIO,selectedIndices);
       
       QStringList aListId = QStringList::split(" ", theNewText, false);
       for (int i = 0; i < aListId.count(); i++) {
        if(const SMDS_MeshElement *anElem = aMesh->FindElement(aListId[i].toInt())) {
-         if (selectedIndices.Add(anElem->GetID())) {
-           newIndices.Add(anElem->GetID());
-         }
+         newIndices.Add(anElem->GetID());
          myNbOkElements++;
        }
       }
-    
-      if (newIndices.Extent() > 0){
-       mySelector->AddOrRemoveIndex(anIO,newIndices,true);
-       myViewWindow->highlight(anIO,true,true);
-      }
+      
+      mySelector->AddOrRemoveIndex(anIO,newIndices,false);
+      if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+       aViewWindow->highlight(anIO,true,true);
     }
   }
-
+  
   if (myNbOkElements) {
     buttonOk->setEnabled(true);
     buttonApply->setEnabled(true);
   }
-
+  
   myBusy = false;
 }
 
@@ -457,7 +448,8 @@ void SMESHGUI_RemoveElementsDlg::ActivateThisDialog()
 
   mySMESHGUI->SetActiveDialogBox((QDialog*)this); // ??
 
-  myViewWindow->SetSelectionMode(NodeSelection);
+  if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+    aViewWindow->SetSelectionMode(NodeSelection);
 
   SelectionIntoArgument(); // ??
 }