Salome HOME
Update of CheckDone
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MakeNodeAtPointDlg.cxx
index 970500e69d7f60d60c8abd5e20da97d695ab7b48..49ee4b4cba6d57a138fbc5ea21a03539d102fd15 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2024  CEA, EDF, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -48,6 +48,9 @@
 #include <SUIT_Desktop.h>
 #include <SVTK_ViewModel.h>
 #include <SVTK_ViewWindow.h>
+#include <SVTK_Renderer.h>
+#include <SVTK_RenderWindowInteractor.h>
+#include <SVTK_Event.h>
 #include <SalomeApp_Tools.h>
 #include <SalomeApp_TypeFilter.h>
 #include <SUIT_ResourceMgr.h>
 #include <QButtonGroup>
 
 // VTK includes
+#include <vtkObject.h>
 #include <vtkProperty.h>
+#include <vtkGenericRenderWindowInteractor.h>
+#include <vtkInteractorObserver.h>
 
 // IDL includes
 #include <SALOMEconfig.h>
 #define SPACING 6
 #define MARGIN  11
 
+namespace
+{
+  enum { MANUAL_MODE = 0, SEARCH_MODE, INTERACTIVE_MODE };
+}
+
+//#define SELECTION_PRECISION 4
+
+//=======================================================================
 /*!
  * \brief Dialog to publish a sub-shape of the mesh main shape
  *        by selecting mesh elements
  */
+//=======================================================================
+
 SMESHGUI_MakeNodeAtPointDlg::SMESHGUI_MakeNodeAtPointDlg()
   : SMESHGUI_Dialog( 0, false, true )
 {
@@ -107,6 +123,7 @@ SMESHGUI_MakeNodeAtPointDlg::SMESHGUI_MakeNodeAtPointDlg()
 // function : createMainFrame()
 // purpose  : Create frame containing dialog's input fields
 //=======================================================================
+
 QWidget* SMESHGUI_MakeNodeAtPointDlg::createMainFrame (QWidget* theParent)
 {
   QWidget* aFrame = new QWidget(theParent);
@@ -114,8 +131,9 @@ QWidget* SMESHGUI_MakeNodeAtPointDlg::createMainFrame (QWidget* theParent)
   SUIT_ResourceMgr* rm = SMESH::GetResourceMgr( SMESHGUI::GetSMESHGUI() );
   QPixmap iconMoveNode        (rm->loadPixmap("SMESH", tr("ICON_DLG_MOVE_NODE")));
   QPixmap iconMoveWithoutNode (rm->loadPixmap("SMESH", tr("ICON_DLG_MOVE_WITHOUT_NODE")));
+  QPixmap iconMoveInteractive (rm->loadPixmap("SMESH", tr("ICON_DLG_MOVE_NODE_INTERACTIVE")));
   QPixmap iconSelect          (rm->loadPixmap("SMESH", tr("ICON_SELECT")));
-
+  
   // constructor
   QGroupBox* aPixGrp = new QGroupBox(tr("MOVE_NODE"), this);
   aPixGrp->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
@@ -124,16 +142,20 @@ QWidget* SMESHGUI_MakeNodeAtPointDlg::createMainFrame (QWidget* theParent)
   aPixGrpLayout->setMargin(MARGIN);
   aPixGrpLayout->setSpacing(SPACING);
 
-  myRButNodeToMove = new QRadioButton(aPixGrp);
+  myRButNodeToMove      = new QRadioButton(aPixGrp);
   myRButMoveWithoutNode = new QRadioButton(aPixGrp);
+  myRButMoveInteractive = new QRadioButton(aPixGrp);
   myRButNodeToMove->setIcon(iconMoveNode);
   myRButMoveWithoutNode->setIcon(iconMoveWithoutNode);
+  myRButMoveInteractive->setIcon(iconMoveInteractive);
   myRButNodeToMove->setChecked(true);
 
   aPixGrpLayout->addWidget(myRButNodeToMove);
   aPixGrpLayout->addWidget(myRButMoveWithoutNode);
-  myButtonGroup->addButton(myRButNodeToMove, 0);
+  aPixGrpLayout->addWidget(myRButMoveInteractive);
+  myButtonGroup->addButton(myRButNodeToMove,      0);
   myButtonGroup->addButton(myRButMoveWithoutNode, 1);
+  myButtonGroup->addButton(myRButMoveInteractive, 2);
 
   // Node to move
 
@@ -297,11 +319,15 @@ void SMESHGUI_MakeNodeAtPointDlg::ButtonToggled (bool on)
   * \param int - number of the button
  */
 //================================================================================
+
 void SMESHGUI_MakeNodeAtPointDlg::ConstructorsClicked (int constructorId)
 {
   switch (constructorId) {
-  case 0:
+  case MANUAL_MODE:
+  case INTERACTIVE_MODE:
     {
+      myUpdateBtn->setVisible( constructorId == MANUAL_MODE );
+      myDestinationGrp->setTitle( tr( constructorId == MANUAL_MODE ? "DESTINATION" : "DESTINATION_BY_MOUSE"));
       myDestDXLabel->show();
       myDestDYLabel->show();
       myDestDZLabel->show();
@@ -312,9 +338,10 @@ void SMESHGUI_MakeNodeAtPointDlg::ConstructorsClicked (int constructorId)
       myCurrentY->SetValue(0);
       myCurrentZ->SetValue(0);
       if (!myNodeToMoveGrp->isVisible()) myNodeToMoveGrp->show();
+      myIdBtn->setChecked( true );
       break;
     }
-  case 1:
+  case SEARCH_MODE:
     {
       myId->setText("");
       myCurrentX->SetValue(0);
@@ -326,7 +353,8 @@ void SMESHGUI_MakeNodeAtPointDlg::ConstructorsClicked (int constructorId)
       myDestDX->hide();
       myDestDY->hide();
       myDestDZ->hide();
-      if (myNodeToMoveGrp->isVisible()) {myNodeToMoveGrp->hide();}
+      if (myNodeToMoveGrp->isVisible()) myNodeToMoveGrp->hide();
+      myDestBtn->setChecked( true );
       break;
     }
   }
@@ -343,26 +371,30 @@ void SMESHGUI_MakeNodeAtPointDlg::ConstructorsClicked (int constructorId)
 */
 //================================================================================
 
-SMESHGUI_MakeNodeAtPointOp::SMESHGUI_MakeNodeAtPointOp()
+SMESHGUI_MakeNodeAtPointOp::SMESHGUI_MakeNodeAtPointOp(int defaultConstructor) : 
+  SMESHGUI_InteractiveOp()
 {
+  myDefaultConstructor = defaultConstructor;
   mySimulation = 0;
+  mySMESHGUI = 0;
   myDlg = new SMESHGUI_MakeNodeAtPointDlg;
   myFilter = 0;
-  myHelpFileName = "mesh_through_point_page.html";
+  myHelpFileName = "mesh_through_point.html";
 
   myNoPreview = false;
   myUpdateDestination = false;
   myDestCoordChanged = true;
 
   // connect signals and slots
-  connect(myDlg->myDestinationX, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
-  connect(myDlg->myDestinationY, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
-  connect(myDlg->myDestinationZ, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
-  connect(myDlg->myDestDX, SIGNAL (valueChanged(double)), this, SLOT(onDestCoordChanged()));
-  connect(myDlg->myDestDY, SIGNAL (valueChanged(double)), this, SLOT(onDestCoordChanged()));
-  connect(myDlg->myDestDZ, SIGNAL (valueChanged(double)), this, SLOT(onDestCoordChanged()));
-  connect(myDlg->myId,SIGNAL (textChanged(const QString&)),SLOT(redisplayPreview()));
-  connect(myDlg->myPreviewChkBox,   SIGNAL (toggled(bool)),SLOT(redisplayPreview()));
+  connect(myDlg->myDestinationX,  SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
+  connect(myDlg->myDestinationY,  SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
+  connect(myDlg->myDestinationZ,  SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
+  connect(myDlg->myDestDX,        SIGNAL (valueChanged(double)), this, SLOT(onDestCoordChanged()));
+  connect(myDlg->myDestDY,        SIGNAL (valueChanged(double)), this, SLOT(onDestCoordChanged()));
+  connect(myDlg->myDestDZ,        SIGNAL (valueChanged(double)), this, SLOT(onDestCoordChanged()));
+  connect(myDlg->myId,            SIGNAL (textChanged(const QString&)),SLOT(redisplayPreview()));
+  connect(myDlg->myPreviewChkBox, SIGNAL (toggled(bool)),              SLOT(redisplayPreview()));
+  connect(myDlg->myButtonGroup,   SIGNAL (buttonClicked(int)),         SLOT(constructorChanged()));
 
   // IPAL22913: TC6.5.0: selected in "Move node" dialog box node is not highlighted
   // note: this slot seems to be lost together with removed obsolete SMESHGUI_MoveNodesDlg class
@@ -370,6 +402,12 @@ SMESHGUI_MakeNodeAtPointOp::SMESHGUI_MakeNodeAtPointOp()
   connect(myDlg->myUpdateBtn, SIGNAL (clicked()), this, SLOT(onUpdateDestination()));
 }
 
+//================================================================================
+/*!
+ * \brief SLOT. Update preview upon [Update destination] clicked
+ */
+//================================================================================
+
 void SMESHGUI_MakeNodeAtPointOp::onUpdateDestination()
 {
   myUpdateDestination = true;
@@ -377,6 +415,12 @@ void SMESHGUI_MakeNodeAtPointOp::onUpdateDestination()
   myUpdateDestination = false;
 }
 
+//================================================================================
+/*!
+ * \brief SLOT. Update preview upon Destination coordinates change
+ */
+//================================================================================
+
 void SMESHGUI_MakeNodeAtPointOp::onDestCoordChanged()
 {
   myDestCoordChanged = false;
@@ -384,10 +428,12 @@ void SMESHGUI_MakeNodeAtPointOp::onDestCoordChanged()
   myDestCoordChanged = true;
 }
 
+
 //=======================================================================
 // function : startOperation()
 // purpose  : Init dialog fields, connect signals and slots, show dialog
 //=======================================================================
+
 void SMESHGUI_MakeNodeAtPointOp::startOperation()
 {
   myNoPreview = false;
@@ -395,7 +441,11 @@ void SMESHGUI_MakeNodeAtPointOp::startOperation()
 
   // 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);
@@ -416,6 +466,7 @@ void SMESHGUI_MakeNodeAtPointOp::startOperation()
   // IPAL19360
   SMESHGUI_SelectionOp::startOperation(); // this method should be called only after filter creation
   //activateSelection(); // set filters   // called inside of previous statement
+  SMESHGUI_InteractiveOp::startOperation();
   myDlg->myId->setText("");
   myDlg->myDestinationX->SetValue(0);
   myDlg->myDestinationY->SetValue(0);
@@ -431,24 +482,22 @@ void SMESHGUI_MakeNodeAtPointOp::startOperation()
   myDlg->myDestDZ->setReadOnly(true);
   myDlg->myRButNodeToMove->setChecked(true);
 
-  myDlg->ConstructorsClicked(GetConstructorId());
+  if ( myDefaultConstructor == INTERACTIVE_MODE ) {
+    addObserver();
+    myDlg->myButtonGroup->button( INTERACTIVE_MODE )->setChecked(true);
+  }
+  myDlg->ConstructorsClicked( GetConstructorId() );
 
   myDlg->show();
 
   onSelectionDone(); // init myMeshActor
-
-  if ( myMeshActor ) {
-//     myMeshActor->SetRepresentation( VTK_WIREFRAME );
-    myMeshActor->SetPointRepresentation(true);
-    SMESH::RepaintCurrentView();
-    redisplayPreview();
-  }
 }
 
 //=================================================================================
 // function : GetConstructorId()
 // purpose  :
 //=================================================================================
+
 int SMESHGUI_MakeNodeAtPointOp::GetConstructorId()
 {
   return myDlg->myButtonGroup->checkedId();
@@ -463,14 +512,23 @@ int SMESHGUI_MakeNodeAtPointOp::GetConstructorId()
 void SMESHGUI_MakeNodeAtPointOp::stopOperation()
 {
   myNoPreview = true;
-  mySimulation->SetVisibility(false);
+  if ( mySimulation )
+  {
+    mySimulation->SetVisibility(false);
+    delete mySimulation;
+    mySimulation = 0;
+  }
   if ( myMeshActor ) {
-    myMeshActor->SetPointRepresentation(false);
-    SMESH::RepaintCurrentView();
     myMeshActor = 0;
   }
+  SMESH::SetPointRepresentation( false );
+  SMESH::RepaintCurrentView();
+
+  disconnect(mySMESHGUI, SIGNAL (SignalActivatedViewManager()), this, SLOT(onOpenView()));
+  disconnect(mySMESHGUI, SIGNAL (SignalCloseView()),            this, SLOT(onCloseView()));
   selectionMgr()->removeFilter( myFilter );
   SMESHGUI_SelectionOp::stopOperation();
+  removeObserver();
 }
 
 //================================================================================
@@ -481,7 +539,7 @@ void SMESHGUI_MakeNodeAtPointOp::stopOperation()
 
 bool SMESHGUI_MakeNodeAtPointOp::onApply()
 {
-  if( isStudyLocked() )
+  if( SMESHGUI::isStudyLocked() )
     return false;
 
   if ( !myMeshActor ) {
@@ -516,14 +574,14 @@ bool SMESHGUI_MakeNodeAtPointOp::onApply()
     if (aMeshEditor->_is_nil())
       return true;
 
-    aMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
+    aMesh->SetParameters( aParameters.join(":").toUtf8().constData() );
 
     bool ok;
     int anId = myDlg->myId->text().toInt( &ok );
     if( !ok || anId < 1 )
-      anId = aMeshEditor->FindNodeClosestTo(myDlg->myDestinationX->GetValue(),
-                                            myDlg->myDestinationY->GetValue(),
-                                            myDlg->myDestinationZ->GetValue());
+      anId = FromSmIdType<int>(aMeshEditor->FindNodeClosestTo(myDlg->myDestinationX->GetValue(),
+                                                            myDlg->myDestinationY->GetValue(),
+                                                            myDlg->myDestinationZ->GetValue()));
 
     int aResult = aMeshEditor->MoveNode(anId,
                                         myDlg->myDestinationX->GetValue(),
@@ -593,6 +651,8 @@ void SMESHGUI_MakeNodeAtPointOp::onSelectionDone()
 {
   if ( !myDlg->isVisible() || !myDlg->isEnabled() )
     return;
+
+  myNoPreview = true;
   try {
     SALOME_ListIO aList;
     selectionMgr()->selectedObjects(aList, SVTK_Viewer::Type());
@@ -601,6 +661,10 @@ void SMESHGUI_MakeNodeAtPointOp::onSelectionDone()
     Handle(SALOME_InteractiveObject) anIO = aList.First();
     SMESH_Actor* aMeshActor = SMESH::FindActorByEntry(anIO->getEntry());
 
+    if (( myDlg->myIdBtn->isChecked() && myDlg->myIdBtn->isEnabled() ) ||
+        ( !myDlg->myNodeToMoveGrp->isVisible() ))
+      myMeshActor = aMeshActor;
+
     if (!aMeshActor) { // coord by geom
       if ( myDlg->myDestBtn->isChecked() ) {
         GEOM::GEOM_Object_var geom = SMESH::IObjectToInterface<GEOM::GEOM_Object>(anIO);
@@ -609,63 +673,56 @@ void SMESHGUI_MakeNodeAtPointOp::onSelectionDone()
           if ( GEOMBase::GetShape(geom, aShape) &&
                aShape.ShapeType() == TopAbs_VERTEX ) {
             gp_Pnt P = BRep_Tool::Pnt(aShape);
-            myNoPreview = true;
             myDlg->myDestinationX->SetValue(P.X());
             myDlg->myDestinationY->SetValue(P.Y());
             myDlg->myDestinationZ->SetValue(P.Z());
-            myNoPreview = false;
-            redisplayPreview();
           }
         }
+        myNoPreview = false;
+        redisplayPreview();
         return;
       }
     }
 
-    if ( !myMeshActor )
-      myMeshActor = aMeshActor;
-
     QString aString;
     int nbElems = SMESH::GetNameOfSelectedElements(selector(),anIO, aString);
     if (nbElems == 1) {
       if (SMDS_Mesh* aMesh = aMeshActor->GetObject()->GetMesh()) {
         if (const SMDS_MeshNode* aNode = aMesh->FindNode(aString.toInt())) {
-          myNoPreview = true;
           if ( myDlg->myDestBtn->isChecked() ) { // set coord
             myDlg->myDestinationX->SetValue(aNode->X());
             myDlg->myDestinationY->SetValue(aNode->Y());
             myDlg->myDestinationZ->SetValue(aNode->Z());
-            myNoPreview = false;
-            redisplayPreview();
           }
           else if ( myDlg->myIdBtn->isChecked() &&
                     myDlg->myIdBtn->isEnabled() ) { // set node to move
             myDlg->myId->setText(aString);
-            myNoPreview = false;
+            myDlg->myCurrentX->SetValue( aNode->X() );
+            myDlg->myCurrentY->SetValue( aNode->Y() );
+            myDlg->myCurrentZ->SetValue( aNode->Z() );
             redisplayPreview();
           }
 
-          if (const SMDS_MeshNode* aCurrentNode = aMesh->FindNode(myDlg->myId->text().toInt())) {
-            double x = aCurrentNode->X();
-            double y = aCurrentNode->Y();
-            double z = aCurrentNode->Z();
-            double dx = myDlg->myDestinationX->GetValue() - x;
-            double dy = myDlg->myDestinationY->GetValue() - y;
-            double dz = myDlg->myDestinationZ->GetValue() - z;
-            myDlg->myCurrentX->SetValue(x);
-            myDlg->myCurrentY->SetValue(y);
-            myDlg->myCurrentZ->SetValue(z);
-            myDlg->myDestDX->SetValue(dx);
-            myDlg->myDestDY->SetValue(dy);
-            myDlg->myDestDZ->SetValue(dz);
-            myDlg->myDestDX->setReadOnly(false);
-            myDlg->myDestDY->setReadOnly(false);
-            myDlg->myDestDZ->setReadOnly(false);
-          }
+          double x = myDlg->myCurrentX->GetValue();
+          double y = myDlg->myCurrentY->GetValue();
+          double z = myDlg->myCurrentZ->GetValue();
+          double dx = myDlg->myDestinationX->GetValue() - x;
+          double dy = myDlg->myDestinationY->GetValue() - y;
+          double dz = myDlg->myDestinationZ->GetValue() - z;
+          myDlg->myDestDX->SetValue(dx);
+          myDlg->myDestDY->SetValue(dy);
+          myDlg->myDestDZ->SetValue(dz);
+          myDlg->myDestDX->setReadOnly(false);
+          myDlg->myDestDY->setReadOnly(false);
+          myDlg->myDestDZ->setReadOnly(false);
         }
       }
     }
   } catch (...) {
   }
+
+  myNoPreview = false;
+  redisplayPreview();
 }
 
 //================================================================================
@@ -680,12 +737,15 @@ void SMESHGUI_MakeNodeAtPointOp::redisplayPreview()
     return;
   myNoPreview = true;
 
+  if ( !myMeshActor && GetConstructorId() == SEARCH_MODE )
+    onSelectionDone();
+
   SMESH::MeshPreviewStruct_var aMeshPreviewStruct;
 
   bool moveShown = false;
   if ( myMeshActor)
   {
-    const bool isPreview = myDlg->myPreviewChkBox->isChecked();
+    const bool  isPreview = myDlg->myPreviewChkBox->isChecked();
     const bool isMoveNode = myDlg->myRButMoveWithoutNode->isChecked();
     QString msg;
     if ( isValid( msg ) )
@@ -714,22 +774,28 @@ void SMESHGUI_MakeNodeAtPointOp::redisplayPreview()
                 myDlg->myDestinationX->SetValue(x);
                 myDlg->myDestinationY->SetValue(y);
                 myDlg->myDestinationZ->SetValue(z);
-              }
-              if ( myDestCoordChanged ) {
-                dx = myDlg->myDestinationX->GetValue() - myDlg->myCurrentX->GetValue();
-                dy = myDlg->myDestinationY->GetValue() - myDlg->myCurrentY->GetValue();
-                dz = myDlg->myDestinationZ->GetValue() - myDlg->myCurrentZ->GetValue();
                 myDlg->myDestDX->SetValue(dx);
                 myDlg->myDestDY->SetValue(dy);
                 myDlg->myDestDZ->SetValue(dz);
               }
-              else {
-                dx = myDlg->myDestDX->GetValue() + myDlg->myCurrentX->GetValue();;
-                dy = myDlg->myDestDY->GetValue() + myDlg->myCurrentY->GetValue();;
-                dz = myDlg->myDestDZ->GetValue() + myDlg->myCurrentZ->GetValue();;
-                myDlg->myDestinationX->SetValue(dx);
-                myDlg->myDestinationY->SetValue(dy);
-                myDlg->myDestinationZ->SetValue(dz);
+              else
+              {
+                if ( myDestCoordChanged ) {
+                  dx = myDlg->myDestinationX->GetValue() - x;
+                  dy = myDlg->myDestinationY->GetValue() - y;
+                  dz = myDlg->myDestinationZ->GetValue() - z;
+                  myDlg->myDestDX->SetValue(dx);
+                  myDlg->myDestDY->SetValue(dy);
+                  myDlg->myDestDZ->SetValue(dz);
+                }
+                else {
+                  dx = myDlg->myDestDX->GetValue() + x;
+                  dy = myDlg->myDestDY->GetValue() + y;
+                  dz = myDlg->myDestDZ->GetValue() + z;
+                  myDlg->myDestinationX->SetValue(dx);
+                  myDlg->myDestinationY->SetValue(dy);
+                  myDlg->myDestinationZ->SetValue(dz);
+                }
               }
               myDlg->myCurrentX->SetValue(x);
               myDlg->myCurrentY->SetValue(y);
@@ -750,9 +816,9 @@ void SMESHGUI_MakeNodeAtPointOp::redisplayPreview()
               myDlg->myDestDZ->setReadOnly(true);
             }
             if ( isPreview && isMoveNode && anId == 0 )
-              anId = aPreviewer->FindNodeClosestTo(myDlg->myDestinationX->GetValue(),
-                                                   myDlg->myDestinationY->GetValue(),
-                                                   myDlg->myDestinationZ->GetValue());
+              anId = FromSmIdType<int>(aPreviewer->FindNodeClosestTo(myDlg->myDestinationX->GetValue(),
+                                                                   myDlg->myDestinationY->GetValue(),
+                                                                   myDlg->myDestinationZ->GetValue()));
             // find id and/or just compute preview
             aPreviewer->MoveNode(anId,
                                  myDlg->myDestinationX->GetValue(),
@@ -765,7 +831,8 @@ void SMESHGUI_MakeNodeAtPointOp::redisplayPreview()
             }
           }
         }
-      }catch (...) {
+      }
+      catch (...) {
       }
     }
   }
@@ -787,11 +854,12 @@ void SMESHGUI_MakeNodeAtPointOp::redisplayPreview()
     aMeshPreviewStruct->elementConnectivities.length(1);
     aMeshPreviewStruct->elementConnectivities[0] = 0;
   }
-
+  if (!mySimulation)
+    mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI ));
   // display data
-  if ( aMeshPreviewStruct.operator->() )
+  if ( & aMeshPreviewStruct.in() )
   {
-    mySimulation->SetData(aMeshPreviewStruct._retn());
+    mySimulation->SetData( aMeshPreviewStruct.in() );
   }
   else
   {
@@ -801,6 +869,52 @@ void SMESHGUI_MakeNodeAtPointOp::redisplayPreview()
   myNoPreview = false;
 }
 
+//=================================================================================
+/*!
+ * \brief SLOT called when the viewer opened
+ */
+//=================================================================================
+
+void SMESHGUI_MakeNodeAtPointOp::onOpenView()
+{
+  if ( mySimulation ) {
+    mySimulation->SetVisibility(false);
+    SMESH::SetPointRepresentation(false);
+  }
+  else {
+    mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI ));
+  }
+}
+
+//=================================================================================
+/*!
+ * \brief SLOT called when the creation mode is changed 
+ */
+ //=================================================================================
+
+void SMESHGUI_MakeNodeAtPointOp::constructorChanged() {
+  redisplayPreview();
+  if (GetConstructorId() == INTERACTIVE_MODE) {
+    addObserver();
+  }
+  else {
+    removeObserver();
+  }
+}
+
+
+//=================================================================================
+/*!
+ * \brief SLOT called when the viewer closed
+ */
+//=================================================================================
+
+void SMESHGUI_MakeNodeAtPointOp::onCloseView()
+{
+  delete mySimulation;
+  mySimulation = 0;
+}
+
 //================================================================================
 /*!
  * \brief SLOT called when the node id is manually changed
@@ -820,8 +934,8 @@ void SMESHGUI_MakeNodeAtPointOp::onTextChange( const QString& theText )
 
       if( const SMDS_MeshNode* aNode = aMesh->FindNode( theText.toInt() ) )
       {
-        TColStd_MapOfInteger aListInd;
-        aListInd.Add( aNode->GetID() );
+        SVTK_TVtkIDsMap aListInd;
+        aListInd.Add( FromSmIdType<int>(aNode->GetID()) );
         selector()->AddOrRemoveIndex( anIO, aListInd, false );
         if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( SMESHGUI::GetSMESHGUI() ) )
           aViewWindow->highlight( anIO, true, true );
@@ -839,7 +953,7 @@ void SMESHGUI_MakeNodeAtPointOp::onTextChange( const QString& theText )
 void SMESHGUI_MakeNodeAtPointOp::activateSelection()
 {
   selectionMgr()->clearFilters();
-  SMESH::SetPointRepresentation(false);
+  SMESH::SetPointRepresentation( true );
   selectionMgr()->installFilter( myFilter );
   setSelectionMode( NodeSelection );
 }
@@ -869,3 +983,54 @@ LightApp_Dialog* SMESHGUI_MakeNodeAtPointOp::dlg() const
   return myDlg;
 }
 
+
+//================================================================================
+/*
+* \brief Process InteractiveSelectionChanged event
+*/
+//================================================================================
+
+void SMESHGUI_MakeNodeAtPointOp::processStyleEvents(unsigned long theEvent, void* theCallData) {
+  if (theEvent == SVTK::InteractiveSelectionChanged) {
+    double* aCoord = (double*)theCallData;
+    myDlg->myDestinationX->SetValue(aCoord[0]);
+    myDlg->myDestinationY->SetValue(aCoord[1]);
+    myDlg->myDestinationZ->SetValue(aCoord[2]);
+    redisplayPreview();
+  }
+}
+
+//================================================================================
+/*
+* \brief Process LeftButtonPressEvent event
+*/
+//================================================================================
+void SMESHGUI_MakeNodeAtPointOp::processInteractorEvents(unsigned long theEvent, void* theCallData) {
+  (void*)theCallData;
+  if (theEvent == vtkCommand::LeftButtonPressEvent) {
+    bool control = myRWInteractor->GetDevice()->GetControlKey();
+    bool shift = myRWInteractor->GetDevice()->GetControlKey();
+    if (GetConstructorId() == INTERACTIVE_MODE && myDlg->myDestBtn->isChecked() && !shift && !control) {
+      if (SVTK_ViewWindow* svtkViewWindow = SMESH::GetViewWindow(SMESHGUI::GetSMESHGUI())) {
+        svtkViewWindow->activateInteractiveSelection();
+      }
+    }
+  }
+   /*
+   if ( myRWInteractor && myRWInteractor->GetDevice() && myInteractorStyle ) {
+      int xClick, yClick; // Last click position
+      myRWInteractor->GetDevice()->GetEventPosition(xClick, yClick);
+      double nodeCoords[3];
+      vtkInteractorObserver::ComputeWorldToDisplay(myRWInteractor->GetRenderer()->GetDevice(),
+                                                   myDlg->myDestinationX->GetValue(),
+                                                   myDlg->myDestinationY->GetValue(),
+                                                   myDlg->myDestinationZ->GetValue(),
+                                                   nodeCoords);
+      double rad = std::sqrt(std::pow(xClick - nodeCoords[0], 2) + std::pow(yClick - nodeCoords[1], 2));
+      if (rad < SELECTION_PRECISION) {
+        if (SVTK_ViewWindow* svtkViewWindow = SMESH::GetViewWindow(mySMESHGUI)) {
+          svtkViewWindow->activateInteractiveSelection();
+        }
+      }
+  }*/
+}