-namespace SMESH
-{
- class TIdPreview
- { // to display in the viewer IDs of the selected elements
- SVTK_ViewWindow* myViewWindow;
-
- vtkUnstructuredGrid* myIdGrid;
- SALOME_Actor* myIdActor;
-
- vtkUnstructuredGrid* myPointsNumDataSet;
- vtkMaskPoints* myPtsMaskPoints;
- vtkSelectVisiblePoints* myPtsSelectVisiblePoints;
- vtkLabeledDataMapper* myPtsLabeledDataMapper;
- vtkTextProperty* aPtsTextProp;
- bool myIsPointsLabeled;
- vtkActor2D* myPointLabels;
-
- std::vector<int> myIDs;
-
- public:
- TIdPreview(SVTK_ViewWindow* theViewWindow):
- myViewWindow(theViewWindow)
- {
- myIdGrid = vtkUnstructuredGrid::New();
-
- // Create and display actor
- vtkDataSetMapper* aMapper = vtkDataSetMapper::New();
- aMapper->SetInputData( myIdGrid );
-
- myIdActor = SALOME_Actor::New();
- myIdActor->SetInfinitive(true);
- myIdActor->VisibilityOff();
- myIdActor->PickableOff();
-
- myIdActor->SetMapper( aMapper );
- aMapper->Delete();
-
- myViewWindow->AddActor(myIdActor);
-
- //Definition of points numbering pipeline
- myPointsNumDataSet = vtkUnstructuredGrid::New();
-
- myPtsMaskPoints = vtkMaskPoints::New();
- myPtsMaskPoints->SetInputData(myPointsNumDataSet);
- myPtsMaskPoints->SetOnRatio(1);
-
- myPtsSelectVisiblePoints = vtkSelectVisiblePoints::New();
- myPtsSelectVisiblePoints->SetInputConnection(myPtsMaskPoints->GetOutputPort());
- myPtsSelectVisiblePoints->SelectInvisibleOff();
- myPtsSelectVisiblePoints->SetTolerance(0.1);
-
- myPtsLabeledDataMapper = vtkLabeledDataMapper::New();
- myPtsLabeledDataMapper->SetInputConnection(myPtsSelectVisiblePoints->GetOutputPort());
- myPtsLabeledDataMapper->SetLabelModeToLabelScalars();
-
- vtkTextProperty* aPtsTextProp = vtkTextProperty::New();
- aPtsTextProp->SetFontFamilyToTimes();
- static int aPointsFontSize = 12;
- aPtsTextProp->SetFontSize(aPointsFontSize);
- aPtsTextProp->SetBold(1);
- aPtsTextProp->SetItalic(0);
- aPtsTextProp->SetShadow(0);
- myPtsLabeledDataMapper->SetLabelTextProperty(aPtsTextProp);
- aPtsTextProp->Delete();
-
- myIsPointsLabeled = false;
-
- myPointLabels = vtkActor2D::New();
- myPointLabels->SetMapper(myPtsLabeledDataMapper);
- myPointLabels->GetProperty()->SetColor(1,1,1);
- myPointLabels->SetVisibility(myIsPointsLabeled);
-
- AddToRender(myViewWindow->getRenderer());
- }
-
- void SetPointsData ( SMDS_Mesh* theMesh,
- TColStd_MapOfInteger & theNodesIdMap )
- {
- vtkPoints* aPoints = vtkPoints::New();
- aPoints->SetNumberOfPoints(theNodesIdMap.Extent());
- myIDs.clear();
-
- TColStd_MapIteratorOfMapOfInteger idIter( theNodesIdMap );
- for( int i = 0; idIter.More(); idIter.Next(), i++ ) {
- const SMDS_MeshNode* aNode = theMesh->FindNode(idIter.Key());
- aPoints->SetPoint( i, aNode->X(), aNode->Y(), aNode->Z() );
- myIDs.push_back(idIter.Key());
- }
-
- myIdGrid->SetPoints(aPoints);
-
- aPoints->Delete();