IPAL53819: Mesh edition clears Numbering

Keep numbering when a mesh is cleared
This commit is contained in:
eap 2016-11-22 14:34:16 +03:00
parent a3b465189d
commit 164f564028
3 changed files with 29 additions and 30 deletions

View File

@ -1529,10 +1529,10 @@ void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation)
} }
} }
if(myNodeActor->GetPointsLabeled()){ if(myNodeActor->GetPointsLabeled()) {
myNodeActor->UpdateLabels();
myNodeActor->VisibilityOn(); myNodeActor->VisibilityOn();
} }
if(my0DActor) if(my0DActor)
my0DActor->UpdateLabels(); my0DActor->UpdateLabels();

View File

@ -145,13 +145,14 @@ void SMESH_CellLabelActor::SetFontProperties( SMESH::LabelFont family, int size,
void SMESH_CellLabelActor::SetCellsLabeled(bool theIsCellsLabeled) void SMESH_CellLabelActor::SetCellsLabeled(bool theIsCellsLabeled)
{ {
myIsCellsLabeled = theIsCellsLabeled;
myCellsLabels->SetVisibility(false);
myTransformFilter->Update(); myTransformFilter->Update();
vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::SafeDownCast(myTransformFilter->GetOutput()); vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::SafeDownCast(myTransformFilter->GetOutput());
if ( !aGrid )
return;
myIsCellsLabeled = theIsCellsLabeled && aGrid->GetNumberOfPoints(); if ( myIsCellsLabeled && aGrid )
if ( myIsCellsLabeled )
{ {
myCellsNumDataSet->ShallowCopy(aGrid); myCellsNumDataSet->ShallowCopy(aGrid);
vtkUnstructuredGrid *aDataSet = myCellsNumDataSet; vtkUnstructuredGrid *aDataSet = myCellsNumDataSet;
@ -172,8 +173,6 @@ void SMESH_CellLabelActor::SetCellsLabeled(bool theIsCellsLabeled)
aDataSet->GetCellData()->SetScalars(anArray); aDataSet->GetCellData()->SetScalars(anArray);
myCellCenters->SetInputData(aDataSet); myCellCenters->SetInputData(aDataSet);
myCellsLabels->SetVisibility(GetVisibility()); myCellsLabels->SetVisibility(GetVisibility());
}else{
myCellsLabels->SetVisibility(false);
} }
} }

View File

@ -44,7 +44,8 @@ vtkStandardNewMacro(SMESH_NodeLabelActor);
/*! /*!
Constructor. Constructor.
*/ */
SMESH_NodeLabelActor::SMESH_NodeLabelActor() { SMESH_NodeLabelActor::SMESH_NodeLabelActor()
{
//Definition of points numbering pipeline //Definition of points numbering pipeline
//--------------------------------------- //---------------------------------------
myPointsNumDataSet = vtkUnstructuredGrid::New(); myPointsNumDataSet = vtkUnstructuredGrid::New();
@ -90,7 +91,8 @@ SMESH_NodeLabelActor::SMESH_NodeLabelActor() {
/*! /*!
Destructor Destructor
*/ */
SMESH_NodeLabelActor::~SMESH_NodeLabelActor() { SMESH_NodeLabelActor::~SMESH_NodeLabelActor()
{
//Deleting of points numbering pipeline //Deleting of points numbering pipeline
//--------------------------------------- //---------------------------------------
myPointsNumDataSet->Delete(); myPointsNumDataSet->Delete();
@ -130,16 +132,16 @@ void SMESH_NodeLabelActor::SetFontProperties( SMESH::LabelFont family, int size,
myPtsTextProp->SetColor( r, g, b ); myPtsTextProp->SetColor( r, g, b );
} }
void SMESH_NodeLabelActor::SetPointsLabeled(bool theIsPointsLabeled) { void SMESH_NodeLabelActor::SetPointsLabeled(bool theIsPointsLabeled)
{
myIsPointsLabeled = theIsPointsLabeled;
myPointLabels->SetVisibility( false );
myTransformFilter->Update(); myTransformFilter->Update();
vtkDataSet* aGrid = vtkUnstructuredGrid::SafeDownCast(myTransformFilter->GetOutput()); vtkDataSet* aGrid = vtkUnstructuredGrid::SafeDownCast(myTransformFilter->GetOutput());
if(!aGrid) if ( myIsPointsLabeled && aGrid )
return;
myIsPointsLabeled = theIsPointsLabeled && aGrid->GetNumberOfPoints();
if ( myIsPointsLabeled )
{ {
myPointsNumDataSet->ShallowCopy(aGrid); myPointsNumDataSet->ShallowCopy(aGrid);
vtkUnstructuredGrid *aDataSet = myPointsNumDataSet; vtkUnstructuredGrid *aDataSet = myPointsNumDataSet;
@ -160,10 +162,6 @@ void SMESH_NodeLabelActor::SetPointsLabeled(bool theIsPointsLabeled) {
myPointLabels->SetVisibility( GetVisibility() ); myPointLabels->SetVisibility( GetVisibility() );
anArray->Delete(); anArray->Delete();
} }
else
{
myPointLabels->SetVisibility( false );
}
} }
@ -189,7 +187,8 @@ void SMESH_NodeLabelActor::RemoveFromRender(vtkRenderer* theRenderer)
SMESH_DeviceActor::RemoveFromRender(theRenderer); SMESH_DeviceActor::RemoveFromRender(theRenderer);
} }
void SMESH_NodeLabelActor::UpdateLabels() { void SMESH_NodeLabelActor::UpdateLabels()
{
if(myIsPointsLabeled) if(myIsPointsLabeled)
SetPointsLabeled(myIsPointsLabeled); SetPointsLabeled(myIsPointsLabeled);
} }
@ -198,7 +197,8 @@ void SMESH_NodeLabelActor::UpdateLabels() {
void SMESH_NodeLabelActor::ProcessEvents(vtkObject* vtkNotUsed(theObject), void SMESH_NodeLabelActor::ProcessEvents(vtkObject* vtkNotUsed(theObject),
unsigned long theEvent, unsigned long theEvent,
void* theClientData, void* theClientData,
void* vtkNotUsed(theCallData)) { void* vtkNotUsed(theCallData))
{
SMESH_NodeLabelActor* self = reinterpret_cast<SMESH_NodeLabelActor*>(theClientData); SMESH_NodeLabelActor* self = reinterpret_cast<SMESH_NodeLabelActor*>(theClientData);
if(self) if(self)
self->UpdateLabels(); self->UpdateLabels();