Salome HOME
INT PAL 0052775: Any dialogue with the selector raises an exception for second viewer
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_FindElemByPointDlg.cxx
index c5a4e447ab3aabe3dfd9c20329e818fd992f5525..fc4304500cff44a28641f5505dc693f87b504b31 100644 (file)
@@ -238,6 +238,7 @@ SMESHGUI_FindElemByPointOp::SMESHGUI_FindElemByPointOp()
   :SMESHGUI_SelectionOp()
 {
   mySimulation = 0;
   :SMESHGUI_SelectionOp()
 {
   mySimulation = 0;
+  mySMESHGUI = 0;
   myDlg = new SMESHGUI_FindElemByPointDlg;
   myHelpFileName = "find_element_by_point_page.html";
 
   myDlg = new SMESHGUI_FindElemByPointDlg;
   myHelpFileName = "find_element_by_point_page.html";
 
@@ -279,7 +280,10 @@ void SMESHGUI_FindElemByPointOp::startOperation()
 {
   // init simulation with a current View
   if ( mySimulation ) delete mySimulation;
 {
   // init simulation with a current View
   if ( mySimulation ) delete mySimulation;
-  mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( getSMESHGUI() ));
+  mySMESHGUI = getSMESHGUI();
+  mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI ) );
+  connect(mySMESHGUI, SIGNAL (SignalActivatedViewManager()), this, SLOT(onOpenView()));
+  connect(mySMESHGUI, SIGNAL (SignalCloseView()), this, SLOT(onCloseView()));
   vtkProperty* aProp = vtkProperty::New();
   aProp->SetRepresentationToWireframe();
   aProp->SetColor(250, 0, 250);
   vtkProperty* aProp = vtkProperty::New();
   aProp->SetRepresentationToWireframe();
   aProp->SetColor(250, 0, 250);
@@ -309,10 +313,37 @@ void SMESHGUI_FindElemByPointOp::stopOperation()
     delete mySimulation;
     mySimulation = 0;
   }
     delete mySimulation;
     mySimulation = 0;
   }
+  disconnect(mySMESHGUI, SIGNAL (SignalActivatedViewManager()), this, SLOT(onOpenView()));
+  disconnect(mySMESHGUI, SIGNAL (SignalCloseView()), this, SLOT(onCloseView()));
   selectionMgr()->removeFilter( myFilter );
   SMESHGUI_SelectionOp::stopOperation();
 }
 
   selectionMgr()->removeFilter( myFilter );
   SMESHGUI_SelectionOp::stopOperation();
 }
 
+//=================================================================================
+/*!
+ * \brief SLOT called when the viewer opened
+ */
+//=================================================================================
+void SMESHGUI_FindElemByPointOp::onOpenView()
+{
+  if ( mySimulation ) {
+    mySimulation->SetVisibility(false);
+  }
+  else {
+    mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI ));
+  }
+}
+
+//=================================================================================
+/*!
+ * \brief SLOT called when the viewer closed
+ */
+//=================================================================================
+void SMESHGUI_FindElemByPointOp::onCloseView()
+{
+  delete mySimulation;
+  mySimulation = 0;
+}
 //================================================================================
 /*!
  * \brief hilight found selected elements
 //================================================================================
 /*!
  * \brief hilight found selected elements
@@ -503,7 +534,8 @@ void SMESHGUI_FindElemByPointOp::redisplayPreview()
   myPreview->nodesXYZ[0].x = myDlg->myX->GetValue();
   myPreview->nodesXYZ[0].y = myDlg->myY->GetValue();
   myPreview->nodesXYZ[0].z = myDlg->myZ->GetValue();
   myPreview->nodesXYZ[0].x = myDlg->myX->GetValue();
   myPreview->nodesXYZ[0].y = myDlg->myY->GetValue();
   myPreview->nodesXYZ[0].z = myDlg->myZ->GetValue();
-
+  if (!mySimulation)
+    mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI ));
   mySimulation->SetData(&myPreview.in());
 }
 
   mySimulation->SetData(&myPreview.in());
 }