Salome HOME
INT PAL 0052775: Any dialogue with the selector raises an exception for second viewer
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_NodesDlg.cxx
index 69bdb257e5ef71194835e7b50b4b2f256b29f86e..e163699d4fc9921378360e394f3f1a8ad23c6dc0 100644 (file)
@@ -382,8 +382,9 @@ void SMESHGUI_NodesDlg::Init()
   connect( mySMESHGUI,     SIGNAL( SignalDeactivateActiveDialog() ), SLOT( DeactivateActiveDialog() ) );
   /* to close dialog if study frame change */
   connect( mySMESHGUI,     SIGNAL( SignalStudyFrameChanged() ),      SLOT( reject() ) );
-  connect(mySMESHGUI,      SIGNAL(SignalCloseAllDialogs()),          SLOT(reject()));
-
+  connect( mySMESHGUI,     SIGNAL( SignalCloseAllDialogs() ),        SLOT( reject() ) );
+  connect( mySMESHGUI,     SIGNAL( SignalActivatedViewManager() ),   SLOT( onOpenView() ) );
+  connect( mySMESHGUI,     SIGNAL( SignalCloseView() ),              SLOT( onCloseView() ) );
   // set selection mode
   SMESH::SetPointRepresentation( true );
   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ) )
@@ -402,7 +403,6 @@ void SMESHGUI_NodesDlg::ValueChangedInSpinBox( double newValue )
     double vx = SpinBox_X->GetValue();
     double vy = SpinBox_Y->GetValue();
     double vz = SpinBox_Z->GetValue();
-
     mySimulation->SetPosition( vx, vy, vz );
   }
 }
@@ -547,7 +547,6 @@ void SMESHGUI_NodesDlg::reject()
   disconnect( mySelectionMgr, 0, this, 0 );
   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ) )
     aViewWindow->SetSelectionMode( ActorSelection );
-
   mySimulation->SetVisibility( false );
   SMESH::SetPointRepresentation( false );
   mySMESHGUI->ResetState();
@@ -555,6 +554,36 @@ void SMESHGUI_NodesDlg::reject()
   QDialog::reject();
 }
 
+//=================================================================================
+// function : onOpenView()
+// purpose  :
+//=================================================================================
+void SMESHGUI_NodesDlg::onOpenView()
+{
+  if ( mySelector && mySimulation ) {
+    mySimulation->SetVisibility(false);
+    SMESH::SetPointRepresentation(false);
+  }
+  else {
+    SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
+    mySelector = aViewWindow->GetSelector();
+    mySimulation = new SMESH::TNodeSimulation(aViewWindow);
+    ActivateThisDialog();
+  }
+}
+
+//=================================================================================
+// function : onCloseView()
+// purpose  :
+//=================================================================================
+void SMESHGUI_NodesDlg::onCloseView()
+{
+  DeactivateActiveDialog();
+  mySelector = 0;
+  delete mySimulation;
+  mySimulation = 0;
+}
+
 //=================================================================================
 // function : ClickOnHelp()
 // purpose  :
@@ -644,8 +673,14 @@ void SMESHGUI_NodesDlg::SelectionIntoArgument()
 //=================================================================================
 void SMESHGUI_NodesDlg::enterEvent( QEvent* )
 {
-  if ( !GroupConstructors->isEnabled() )
+  if ( !GroupConstructors->isEnabled() ) {
+    SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
+    if ( aViewWindow && !mySelector && !mySimulation) {
+      mySelector = aViewWindow->GetSelector();
+      mySimulation = new SMESH::TNodeSimulation(aViewWindow);
+    }
     ActivateThisDialog();
+  }
 }
 
 //=================================================================================
@@ -678,7 +713,6 @@ void SMESHGUI_NodesDlg::ActivateThisDialog()
   SMESH::SetPointRepresentation( true );
   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ) )
     aViewWindow->SetSelectionMode( NodeSelection );
-
   SelectionIntoArgument();
 }