Salome HOME
Merge from OCC_development_generic_2006
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_RemoveElementsDlg.cxx
index baf1814d25bf1c28f332e06d684c2ea1d99713ea..ef6dfa0d2d7a312d7143597e4782023dafd82f93 100644 (file)
@@ -45,6 +45,7 @@
 #include "SVTK_ViewWindow.h"
 #include "SALOME_ListIO.hxx"
 
+#include "SalomeApp_Tools.h"
 #include "utilities.h"
 
 // OCCT Includes
@@ -82,7 +83,6 @@ 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)
 {
@@ -225,7 +225,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();
 }
@@ -257,11 +258,16 @@ void SMESHGUI_RemoveElementsDlg::ClickOnApply()
     try {
       SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
       aResult = aMeshEditor->RemoveElements(anArrayOfIdeces.inout());
-    } catch (...) {
+    } catch (const SALOME::SALOME_Exception& S_ex) {
+      SalomeApp_Tools::QtCatchCorbaException(S_ex);
+      myEditCurrentArgument->clear();
+    } catch (...){
+      myEditCurrentArgument->clear();
     }
 
     if (aResult) {
       myEditCurrentArgument->clear();
+      mySelector->ClearIndex();
       SMESH::UpdateView();
     }
   }
@@ -285,8 +291,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();
@@ -324,7 +331,8 @@ void SMESHGUI_RemoveElementsDlg::onTextChange (const QString& theNewText)
       }
       
       mySelector->AddOrRemoveIndex(anIO,newIndices,false);
-      myViewWindow->highlight(anIO,true,true);
+      if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+       aViewWindow->highlight(anIO,true,true);
     }
   }
   
@@ -446,7 +454,8 @@ void SMESHGUI_RemoveElementsDlg::ActivateThisDialog()
 
   mySMESHGUI->SetActiveDialogBox((QDialog*)this); // ??
 
-  myViewWindow->SetSelectionMode(NodeSelection);
+  if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+    aViewWindow->SetSelectionMode(NodeSelection);
 
   SelectionIntoArgument(); // ??
 }