+#include <vtkCellArray.h>
+#include <vtkUnsignedCharArray.h>
+#include <vtkUnstructuredGrid.h>
+#include <vtkDataSetMapper.h>
+#include <vtkRenderer.h>
+#include <vtkProperty.h>
+#include <vtkPoints.h>
+
+// Qt includes
+#include <QComboBox>
+#include <QGroupBox>
+#include <QLabel>
+#include <QPushButton>
+#include <QRadioButton>
+#include <QHBoxLayout>
+#include <QVBoxLayout>
+#include <QKeyEvent>
+#include <QButtonGroup>
+
+// IDL includes
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_MeshEditor)
+
+#define SPACING 6
+#define MARGIN 11
+
+namespace SMESH
+{
+ long AddNode( SMESH::SMESH_Mesh_ptr theMesh, float x, float y, float z, const QStringList& theParameters )
+ {
+ long aNodeId = -1;
+ SUIT_OverrideCursor wc;
+ try {
+ _PTR(SObject) aSobj = SMESH::FindSObject( theMesh );
+ SMESH::SMESH_MeshEditor_var aMeshEditor = theMesh->GetMeshEditor();
+ theMesh->SetParameters( theParameters.join(":").toLatin1().constData() );
+ aNodeId = aMeshEditor->AddNode( x, y, z );
+ _PTR(Study) aStudy = GetActiveStudyDocument();
+ CORBA::Long anId = aStudy->StudyId();
+ if (TVisualObjPtr aVisualObj = SMESH::GetVisualObj( anId, aSobj->GetID().c_str() ) ) {
+ aVisualObj->Update( true );
+ }
+ }
+ catch ( SALOME::SALOME_Exception& exc ) {
+ INFOS( "Follow exception was cought:\n\t" << exc.details.text );
+ }
+ catch ( const std::exception& exc ) {
+ INFOS( "Follow exception was cought:\n\t" << exc.what() );
+ }
+ catch ( ... ) {
+ INFOS( "Unknown exception was cought !!!" );
+ }
+ return aNodeId;
+ }
+
+ class TNodeSimulation
+ {
+ SVTK_ViewWindow* myViewWindow;
+
+ SALOME_Actor* myPreviewActor;
+ vtkDataSetMapper* myMapper;
+ vtkPoints* myPoints;
+
+ public:
+ TNodeSimulation( SVTK_ViewWindow* theViewWindow ):
+ myViewWindow( theViewWindow )
+ {
+ vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New();
+
+ // Create points
+ myPoints = vtkPoints::New();
+ myPoints->SetNumberOfPoints( 1 );
+ myPoints->SetPoint( 0, 0.0, 0.0, 0.0 );
+
+ // Create cells
+ vtkIdList *anIdList = vtkIdList::New();
+ anIdList->SetNumberOfIds( 1 );
+
+ vtkCellArray *aCells = vtkCellArray::New();
+ aCells->Allocate( 2, 0 );
+
+ vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
+ aCellTypesArray->SetNumberOfComponents( 1 );
+ aCellTypesArray->Allocate( 1 );
+
+ anIdList->SetId( 0, 0 );
+ aCells->InsertNextCell( anIdList );
+ aCellTypesArray->InsertNextValue( VTK_VERTEX );
+
+ VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
+ aCellLocationsArray->SetNumberOfComponents( 1 );
+ aCellLocationsArray->SetNumberOfTuples( 1 );
+
+ aCells->InitTraversal();
+ vtkIdType npts = 0;
+ aCellLocationsArray->SetValue( 0, aCells->GetTraversalLocation( npts ) );
+
+ aGrid->SetCells( aCellTypesArray, aCellLocationsArray, aCells );
+
+ aGrid->SetPoints( myPoints );
+ aGrid->SetCells( aCellTypesArray, aCellLocationsArray, aCells );
+ aCellLocationsArray->Delete();
+ aCellTypesArray->Delete();
+ aCells->Delete();
+ anIdList->Delete();
+
+ // Create and display actor
+ myMapper = vtkDataSetMapper::New();
+ myMapper->SetInputData( aGrid );
+ aGrid->Delete();
+
+ myPreviewActor = SALOME_Actor::New();
+ myPreviewActor->SetInfinitive( true );
+ myPreviewActor->VisibilityOff();
+ myPreviewActor->PickableOff();
+ myPreviewActor->SetMapper( myMapper );
+
+ vtkProperty* aProp = vtkProperty::New();
+ aProp->SetRepresentationToPoints();
+
+ double anRGB[3];
+ GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
+ aProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
+
+ double aPointSize = GetFloat( "SMESH:node_size", 3 );
+ aProp->SetPointSize( aPointSize );
+
+ myPreviewActor->SetProperty( aProp );
+ aProp->Delete();
+
+ myViewWindow->AddActor( myPreviewActor );
+ }
+
+ void SetPosition( float x, float y, float z )
+ {
+ myPoints->SetPoint( 0, x, y, z );
+ myPoints->Modified();
+ SetVisibility( true );
+ }
+
+ void SetVisibility( bool theVisibility )
+ {
+ myPreviewActor->SetVisibility( theVisibility );
+ RepaintCurrentView();
+ }
+
+ ~TNodeSimulation()
+ {
+ myViewWindow->RemoveActor( myPreviewActor );
+ myPreviewActor->Delete();
+
+ myMapper->RemoveAllInputs();
+ myMapper->Delete();