X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FOBJECT%2FSMESH_NodeLabelActor.cxx;h=4ac4c90f20faabb31a0df0dd2216adf4653b4274;hp=604db28ee83298d5dac0ef6602ce8c66125600bb;hb=f016bdf914220827ec8f9a7048bc78fc3fb8c299;hpb=b0a908c0d20341651771d0249fb10882f54b2aad diff --git a/src/OBJECT/SMESH_NodeLabelActor.cxx b/src/OBJECT/SMESH_NodeLabelActor.cxx index 604db28ee..4ac4c90f2 100644 --- a/src/OBJECT/SMESH_NodeLabelActor.cxx +++ b/src/OBJECT/SMESH_NodeLabelActor.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -39,12 +39,13 @@ #include #include -vtkStandardNewMacro(SMESH_NodeLabelActor); +vtkStandardNewMacro(SMESH_NodeLabelActor) /*! Constructor. */ -SMESH_NodeLabelActor::SMESH_NodeLabelActor() { +SMESH_NodeLabelActor::SMESH_NodeLabelActor() +{ //Definition of points numbering pipeline //--------------------------------------- myPointsNumDataSet = vtkUnstructuredGrid::New(); @@ -57,12 +58,12 @@ SMESH_NodeLabelActor::SMESH_NodeLabelActor() { myPtsSelectVisiblePoints->SetInputConnection(myPtsMaskPoints->GetOutputPort()); myPtsSelectVisiblePoints->SelectInvisibleOff(); myPtsSelectVisiblePoints->SetTolerance(0.1); - + myPtsLabeledDataMapper = vtkLabeledDataMapper::New(); myPtsLabeledDataMapper->SetInputConnection(myPtsSelectVisiblePoints->GetOutputPort()); - myPtsLabeledDataMapper->SetLabelFormat("%d"); + //myPtsLabeledDataMapper->SetLabelFormat("%d"); myPtsLabeledDataMapper->SetLabelModeToLabelScalars(); - + myPtsTextProp = vtkTextProperty::New(); myPtsTextProp->SetFontFamilyToTimes(); myPtsTextProp->SetFontSize(10); @@ -90,19 +91,20 @@ SMESH_NodeLabelActor::SMESH_NodeLabelActor() { /*! Destructor */ -SMESH_NodeLabelActor::~SMESH_NodeLabelActor() { +SMESH_NodeLabelActor::~SMESH_NodeLabelActor() +{ //Deleting of points numbering pipeline //--------------------------------------- myPointsNumDataSet->Delete(); - + // commented: porting to vtk 5.0 // myPtsLabeledDataMapper->RemoveAllInputs(); myPtsLabeledDataMapper->Delete(); - + // commented: porting to vtk 5.0 // myPtsSelectVisiblePoints->UnRegisterAllOutputs(); myPtsSelectVisiblePoints->Delete(); - + // commented: porting to vtk 5.0 // myPtsMaskPoints->UnRegisterAllOutputs(); myPtsMaskPoints->Delete(); @@ -130,40 +132,36 @@ void SMESH_NodeLabelActor::SetFontProperties( SMESH::LabelFont family, int size, myPtsTextProp->SetColor( r, g, b ); } -void SMESH_NodeLabelActor::SetPointsLabeled(bool theIsPointsLabeled) { +void SMESH_NodeLabelActor::SetPointsLabeled(bool theIsPointsLabeled) +{ + myIsPointsLabeled = theIsPointsLabeled; + + myPointLabels->SetVisibility( false ); + myTransformFilter->Update(); vtkDataSet* aGrid = vtkUnstructuredGrid::SafeDownCast(myTransformFilter->GetOutput()); - if(!aGrid) - return; - - myIsPointsLabeled = theIsPointsLabeled && aGrid->GetNumberOfPoints(); - - if ( myIsPointsLabeled ) + if ( myIsPointsLabeled && aGrid ) { myPointsNumDataSet->ShallowCopy(aGrid); vtkUnstructuredGrid *aDataSet = myPointsNumDataSet; - - int aNbElem = aDataSet->GetNumberOfPoints(); - - vtkIntArray *anArray = vtkIntArray::New(); + + vtkIdType aNbElem = aDataSet->GetNumberOfPoints(); + + vtkIdTypeArray *anArray = vtkIdTypeArray::New(); anArray->SetNumberOfValues( aNbElem ); - + for ( vtkIdType anId = 0; anId < aNbElem; anId++ ) { - int aSMDSId = myVisualObj->GetNodeObjId( anId ); + vtkIdType aSMDSId = myVisualObj->GetNodeObjId( anId ); anArray->SetValue( anId, aSMDSId ); } - + aDataSet->GetPointData()->SetScalars( anArray ); myPtsMaskPoints->SetInputData( aDataSet ); myPointLabels->SetVisibility( GetVisibility() ); anArray->Delete(); } - else - { - myPointLabels->SetVisibility( false ); - } } @@ -189,17 +187,19 @@ void SMESH_NodeLabelActor::RemoveFromRender(vtkRenderer* theRenderer) SMESH_DeviceActor::RemoveFromRender(theRenderer); } -void SMESH_NodeLabelActor::UpdateLabels() { +void SMESH_NodeLabelActor::UpdateLabels() +{ if(myIsPointsLabeled) SetPointsLabeled(myIsPointsLabeled); } void SMESH_NodeLabelActor::ProcessEvents(vtkObject* vtkNotUsed(theObject), - unsigned long theEvent, + unsigned long /*theEvent*/, void* theClientData, - void* vtkNotUsed(theCallData)) { - SMESH_NodeLabelActor* self = reinterpret_cast(theClientData); + void* vtkNotUsed(theCallData)) +{ + SMESH_NodeLabelActor* self = reinterpret_cast(theClientData); if(self) self->UpdateLabels(); }