]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Porting on VTK 5.2 and higher
authorvsv <vsv@opencascade.com>
Tue, 1 Sep 2009 08:06:18 +0000 (08:06 +0000)
committervsv <vsv@opencascade.com>
Tue, 1 Sep 2009 08:06:18 +0000 (08:06 +0000)
src/CONVERTOR/VISU_MergeFilterUtilities.cxx
src/OBJECT/VISU_Actor.cxx
src/OBJECT/VISU_Actor.h
src/OBJECT/VISU_MeshAct.cxx
src/OBJECT/VISU_ScalarMapAct.cxx
src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx
src/PIPELINE/VISU_XYPlotActor.cxx

index 63a9b040b3ccea94608ff21ccde1692882a73721..3f5cc0d5d20ad4c07f1de1776252c06c76774bca 100644 (file)
@@ -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);
   }
 
index 1c29b5d7cadcfbf53387f284530d8fa82a000d25..1f528d6f240d3ea89ae5c4cc5acb39f481d8dee5 100644 (file)
@@ -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),
index 76cc277e55e4614bcb5d66cea1291297f96acc8a..4b04a92eb79cab990172792c63da2051cdfb0b10 100644 (file)
@@ -382,7 +382,11 @@ class VISU_OBJECT_EXPORT VISU_Actor : public VISU_ActorBase
   bool myIsShrunk;
 
   vtkSmartPointer<vtkTextMapper> myAnnotationMapper;
+#if (VTK_MINOR_VERSION == 0)
   vtkSmartPointer<vtkTextActor>  myAnnotationActor;
+#else
+  vtkSmartPointer<vtkActor2D>  myAnnotationActor;
+#endif
 
   vtkSmartPointer<VTKViewer_FramedTextActor> myTextActor;
 
index 410d91bf94c9c13f128b6155d0e28af4ef6f799e..8f204c956d333febe5585d5f2f359175ceb4597a 100644 (file)
@@ -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;
 }
 
index 51e3ed8064ed6ef2c7c6bb9a7604319fced2cc67..30e389d214244183b17e3c9a6b8da7712226fb77 100644 (file)
@@ -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;
 }
index 2da76c099d091acea9427c1654b6d5442f1892c8..326eca89878b0f86e689879fe4eacab718037ac2 100644 (file)
@@ -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();
 }
 
index a151b2fefff75703eaeb9daf3cbc2f1b4ec9c302..cf3df155e8f6b0579c4d63cba668917cae09118b 100644 (file)
@@ -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();