From bbede5dec737e321b257972460fcddebc642d4f6 Mon Sep 17 00:00:00 2001 From: vsv Date: Tue, 1 Sep 2009 08:06:18 +0000 Subject: [PATCH] Porting on VTK 5.2 and higher --- src/CONVERTOR/VISU_MergeFilterUtilities.cxx | 36 ++++++++++++++++++- src/OBJECT/VISU_Actor.cxx | 4 +++ src/OBJECT/VISU_Actor.h | 4 +++ src/OBJECT/VISU_MeshAct.cxx | 29 +++++++++++++++ src/OBJECT/VISU_ScalarMapAct.cxx | 22 ++++++++++++ .../VISU_DeformedShapeAndScalarMapPL.cxx | 4 +-- src/PIPELINE/VISU_XYPlotActor.cxx | 30 +++++++++++++--- 7 files changed, 121 insertions(+), 8 deletions(-) diff --git a/src/CONVERTOR/VISU_MergeFilterUtilities.cxx b/src/CONVERTOR/VISU_MergeFilterUtilities.cxx index 63a9b040..3f5cc0d5 100644 --- a/src/CONVERTOR/VISU_MergeFilterUtilities.cxx +++ b/src/CONVERTOR/VISU_MergeFilterUtilities.cxx @@ -372,7 +372,29 @@ namespace //--------------------------------------------------------------- typedef vtkDataArray* (vtkDataSetAttributes::* TGetAttribute)(); +#if (VTK_MINOR_VERSION == 0) typedef int (vtkDataSetAttributes::* TSetAttribute)(vtkDataArray*); +#else + typedef int (vtkDataSetAttributes::* TSetAttribute)(vtkAbstractArray*); + typedef int (vtkDataSetAttributes::* TSetDataAttribute)(vtkDataArray*); +#endif + + +#if (VTK_MINOR_VERSION > 0) + inline + void + CopyArray(vtkDataArray* theDataArray, + vtkDataSetAttributes* theOutput, + TSetDataAttribute theSetAttribute, + vtkIdType theFixedNbTuples) + { + if(theDataArray){ + vtkIdType aNbTuples = theDataArray->GetNumberOfTuples(); + if(theFixedNbTuples == aNbTuples) + (theOutput->*theSetAttribute)(theDataArray); + } + } +#endif inline void @@ -395,7 +417,11 @@ namespace CopyAttribute(vtkDataSetAttributes* theInput, TGetAttribute theGetAttribute, vtkDataSetAttributes* theOutput, +#if (VTK_MINOR_VERSION == 0) TSetAttribute theSetAttribute, +#else + TSetDataAttribute theSetAttribute, +#endif vtkIdType theFixedNbTuples) { CopyArray((theInput->*theGetAttribute)(), @@ -410,7 +436,11 @@ namespace CopyDataSetAttribute(vtkDataSet *theInput, TGetAttribute theGetAttribute, vtkDataSet *theOutput, +#if (VTK_MINOR_VERSION == 0) TSetAttribute theSetAttribute, +#else + TSetDataAttribute theSetAttribute, +#endif vtkIdType theNbPoints, vtkIdType theNbCells) { @@ -437,7 +467,11 @@ namespace { CopyArray(theInput->GetArray(theFieldName), theOutput, - &vtkDataSetAttributes::AddArray, +#if (VTK_MINOR_VERSION == 0) + &vtkDataSetAttributes::AddArray, +#else + &vtkFieldData::AddArray, +#endif theFixedNbTuples); } diff --git a/src/OBJECT/VISU_Actor.cxx b/src/OBJECT/VISU_Actor.cxx index 1c29b5d7..1f528d6f 100644 --- a/src/OBJECT/VISU_Actor.cxx +++ b/src/OBJECT/VISU_Actor.cxx @@ -109,7 +109,11 @@ VISU_Actor myIsShrinkable(false), myShrinkFilter(VTKViewer_ShrinkFilter::New()), myAnnotationMapper(vtkTextMapper::New()), +#if ( (VTK_MINOR_VERSION == 0)) myAnnotationActor(vtkTextActor::New()), +#else + myAnnotationActor(vtkActor2D::New()), +#endif myTextActor(VTKViewer_FramedTextActor::New()), myIsFeatureEdgesAllowed(false), myIsFeatureEdgesEnabled(false), diff --git a/src/OBJECT/VISU_Actor.h b/src/OBJECT/VISU_Actor.h index 76cc277e..4b04a92e 100644 --- a/src/OBJECT/VISU_Actor.h +++ b/src/OBJECT/VISU_Actor.h @@ -382,7 +382,11 @@ class VISU_OBJECT_EXPORT VISU_Actor : public VISU_ActorBase bool myIsShrunk; vtkSmartPointer myAnnotationMapper; +#if (VTK_MINOR_VERSION == 0) vtkSmartPointer myAnnotationActor; +#else + vtkSmartPointer myAnnotationActor; +#endif vtkSmartPointer myTextActor; diff --git a/src/OBJECT/VISU_MeshAct.cxx b/src/OBJECT/VISU_MeshAct.cxx index 410d91bf..8f204c95 100644 --- a/src/OBJECT/VISU_MeshAct.cxx +++ b/src/OBJECT/VISU_MeshAct.cxx @@ -374,6 +374,7 @@ VISU_MeshAct GetMatrix(mySurfaceActor->GetUserMatrix()); using namespace SVTK::Representation; +#if (VTK_MINOR_VERSION == 0) switch(GetRepresentation()){ case Points : myNodeActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren); @@ -400,6 +401,34 @@ VISU_MeshAct mySurfaceActor->RenderTranslucentGeometry(ren); break; } +#else + switch(GetRepresentation()){ + case Points : + myNodeActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren); + myNodeActor->RenderTranslucentPolygonalGeometry(ren); + break; + case Wireframe : + case Insideframe : + myEdgeActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren); + myEdgeActor->RenderTranslucentPolygonalGeometry(ren); + break; + case Surface : + mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren); + mySurfaceActor->RenderTranslucentPolygonalGeometry(ren); + break; + case Surfaceframe : + mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren); + mySurfaceActor->RenderTranslucentPolygonalGeometry(ren); + + myEdgeActor->SetAllocatedRenderTime(this->AllocatedRenderTime/2.0,ren); + myEdgeActor->RenderTranslucentPolygonalGeometry(ren); + break; + case FeatureEdges : + mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren); + mySurfaceActor->RenderTranslucentPolygonalGeometry(ren); + break; + } +#endif return 1; } diff --git a/src/OBJECT/VISU_ScalarMapAct.cxx b/src/OBJECT/VISU_ScalarMapAct.cxx index 51e3ed80..30e389d2 100644 --- a/src/OBJECT/VISU_ScalarMapAct.cxx +++ b/src/OBJECT/VISU_ScalarMapAct.cxx @@ -616,6 +616,7 @@ VISU_ScalarMapAct GetMatrix(mySurfaceActor->GetUserMatrix()); using namespace SVTK::Representation; +#if (VTK_MINOR_VERSION == 0) switch ( GetRepresentation() ) { case Surfaceframe: @@ -635,6 +636,27 @@ VISU_ScalarMapAct mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren); mySurfaceActor->RenderTranslucentGeometry(ren); } +#else + switch ( GetRepresentation() ) { + case Surfaceframe: + + mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren); + mySurfaceActor->RenderTranslucentPolygonalGeometry(ren); + + myEdgeActor->SetAllocatedRenderTime(this->AllocatedRenderTime/2.0,ren); + myEdgeActor->RenderTranslucentPolygonalGeometry(ren); + break; + + case Points: + myPointsActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren); + myPointsActor->RenderTranslucentPolygonalGeometry(ren); + break; + + default: + mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren); + mySurfaceActor->RenderTranslucentPolygonalGeometry(ren); + } +#endif return 1; } diff --git a/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx b/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx index 2da76c09..326eca89 100644 --- a/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx +++ b/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx @@ -143,7 +143,7 @@ VISU_DeformedShapeAndScalarMapPL myCellDataToPointData, GetMergedInput()); - myScalars = GetMergedInput(); + myScalars = vtkUnstructuredGrid::SafeDownCast(GetMergedInput()); UpdateScalars(); @@ -258,7 +258,7 @@ VISU_DeformedShapeAndScalarMapPL if(GetScalars() == theScalars) return; - myScalars = theScalars; + myScalars = vtkUnstructuredGrid::SafeDownCast(theScalars); UpdateScalars(); } diff --git a/src/PIPELINE/VISU_XYPlotActor.cxx b/src/PIPELINE/VISU_XYPlotActor.cxx index a151b2fe..cf3df155 100644 --- a/src/PIPELINE/VISU_XYPlotActor.cxx +++ b/src/PIPELINE/VISU_XYPlotActor.cxx @@ -747,12 +747,16 @@ int VISU_XYPlotActor::RenderOpaqueGeometry(vtkViewport *viewport) this->TitleTextProperty); } + +#if (VTK_MINOR_VERSION == 0) + //VSV: Function is not supported in VTK 5.2 and high vtkAxisActor2D::SetFontSize(viewport, this->TitleMapper, size, 1.0, stringSize); - +#endif + this->TitleActor->GetPositionCoordinate()->SetValue( pos[0] + 0.5 * (pos2[0] - pos[0]) - stringSize[0] / 2.0, pos2[1] - stringSize[1] / 2.0); @@ -1715,14 +1719,22 @@ void VISU_XYPlotActor::PlaceAxes(vtkViewport *viewport, int *size, // Estimate the padding around the X and Y axes tprop->ShallowCopy(axisX->GetTitleTextProperty()); textMapper->SetInput(axisX->GetTitle()); + +#if (VTK_MINOR_VERSION == 0) + //VSV: Function is not supported in VTK 5.2 and high vtkAxisActor2D::SetFontSize( viewport, textMapper, size, fontFactorX, titleSizeX); - +#endif + tprop->ShallowCopy(axisY->GetTitleTextProperty()); textMapper->SetInput(axisY->GetTitle()); + +#if (VTK_MINOR_VERSION == 0) + //VSV: Function is not supported in VTK 5.2 and high vtkAxisActor2D::SetFontSize( viewport, textMapper, size, fontFactorY, titleSizeY); - +#endif + // At this point the thing to do would be to actually ask the Y axis // actor to return the largest label. // In the meantime, let's try with the min and max @@ -1730,17 +1742,25 @@ void VISU_XYPlotActor::PlaceAxes(vtkViewport *viewport, int *size, sprintf(str2, axisY->GetLabelFormat(), axisY->GetAdjustedRange()[1]); tprop->ShallowCopy(axisY->GetLabelTextProperty()); textMapper->SetInput(strlen(str1) > strlen(str2) ? str1 : str2); + +#if (VTK_MINOR_VERSION == 0) + //VSV: Function is not supported in VTK 5.2 and high vtkAxisActor2D::SetFontSize( viewport, textMapper, size, labelFactorY * fontFactorY, labelSizeY); - +#endif + // We do only care of the height of the label in the X axis, so let's // use the min for example sprintf(str1, axisX->GetLabelFormat(), axisX->GetAdjustedRange()[0]); tprop->ShallowCopy(axisX->GetLabelTextProperty()); textMapper->SetInput(str1); + +#if (VTK_MINOR_VERSION == 0) + //VSV: Function is not supported in VTK 5.2 and high vtkAxisActor2D::SetFontSize( viewport, textMapper, size, labelFactorX * fontFactorX, labelSizeX); - +#endif + tickOffsetX = axisX->GetTickOffset(); tickOffsetY = axisY->GetTickOffset(); tickLengthX = axisX->GetTickLength(); -- 2.39.2