Salome HOME
updated copyright message
[modules/gui.git] / src / VTKViewer / VTKViewer_Trihedron.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 9f279af..9fef8e6
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -6,7 +6,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -25,7 +25,6 @@
 #include "VTKViewer_Algorithm.h"
 
 // VTK Includes
-#include <vtkConfigure.h>
 #include <vtkMath.h>
 #include <vtkMapper.h>
 #include <vtkDataSet.h>
 // QT includes
 #include <QtGlobal>
 
-vtkStandardNewMacro(VTKViewer_UnScaledActor);
+vtkStandardNewMacro(VTKViewer_UnScaledActor)
 
 /*!Constructor*/
 VTKViewer_UnScaledActor::VTKViewer_UnScaledActor() 
 {
-  Bounds[0] = Bounds[2] = Bounds[4] = VTK_LARGE_FLOAT;
-  Bounds[1] = Bounds[3] = Bounds[5] = -VTK_LARGE_FLOAT;
+  Bounds[0] = Bounds[2] = Bounds[4] = VTK_FLOAT_MAX;
+  Bounds[1] = Bounds[3] = Bounds[5] = -VTK_FLOAT_MAX;
 }
 
 /*!
   \return bounding box
 */
-vtkFloatingPointType* 
+double* 
 VTKViewer_UnScaledActor
 ::GetBounds()
 {
@@ -80,24 +79,24 @@ void VTKViewer_UnScaledActor::SetSize(int theSize)
 void VTKViewer_UnScaledActor::Render(vtkRenderer *theRenderer)
 {
   if(theRenderer){
-    vtkFloatingPointType P[2][3] = {{-1.0, -1.0, 0.0},{+1.0, +1.0, 0.0}};
+    double P[2][3] = {{-1.0, -1.0, 0.0},{+1.0, +1.0, 0.0}};
     theRenderer->ViewToWorld(P[0][0],P[0][1],P[0][2]);
     theRenderer->ViewToWorld(P[1][0],P[1][1],P[1][2]);
-    vtkFloatingPointType aWorldDiag = sqrt((P[1][0]-P[0][0])*(P[1][0]-P[0][0])+
+    double aWorldDiag = sqrt((P[1][0]-P[0][0])*(P[1][0]-P[0][0])+
                                            (P[1][1]-P[0][1])*(P[1][1]-P[0][1])+
                                            (P[1][2]-P[0][2])*(P[1][2]-P[0][2]));
     int* aSize = theRenderer->GetRenderWindow()->GetSize();
-    vtkFloatingPointType aWinDiag = sqrt(vtkFloatingPointType(aSize[0]*aSize[0]+aSize[1]*aSize[1]));
+    double aWinDiag = sqrt(double(aSize[0]*aSize[0]+aSize[1]*aSize[1]));
     vtkDataSet* aDataSet = GetMapper()->GetInput();
-    aDataSet->Update();
-    vtkFloatingPointType aLength = aDataSet->GetLength();
-    vtkFloatingPointType aPrecision = 1.0E-3;
-    vtkFloatingPointType aZeroTol   = 1.0E-12;
-    vtkFloatingPointType anOldScale = GetScale()[0];
-    vtkFloatingPointType aScale = anOldScale;
-    vtkFloatingPointType aMaxSize = (vtkFloatingPointType)qMax(aSize[1],aSize[0]);
+    GetMapper()->Update();
+    double aLength = aDataSet->GetLength();
+    double aPrecision = 1.0E-3;
+    double aZeroTol   = 1.0E-12;
+    double anOldScale = GetScale()[0];
+    double aScale = anOldScale;
+    double aMaxSize = (double)qMax(aSize[1],aSize[0]);
     if (qAbs(aWinDiag) > aZeroTol && qAbs(aLength) > aZeroTol && qAbs(aMaxSize) > aZeroTol)
-      aScale = mySize*aWorldDiag/aWinDiag/aLength*sqrt(vtkFloatingPointType(qMin(aSize[1],aSize[0]))/aMaxSize);
+      aScale = mySize*aWorldDiag/aWinDiag/aLength*sqrt(double(qMin(aSize[1],aSize[0]))/aMaxSize);
     if(qAbs(aScale) > aZeroTol && qAbs(aScale - anOldScale)/aScale > aPrecision){
       SetScale(aScale);
     }
@@ -105,14 +104,14 @@ void VTKViewer_UnScaledActor::Render(vtkRenderer *theRenderer)
   vtkFollower::Render(theRenderer);
 }
 
-vtkStandardNewMacro(VTKViewer_LineActor);
+vtkStandardNewMacro(VTKViewer_LineActor)
 
 #ifdef IPAL21440
 vtkCxxSetObjectMacro(VTKViewer_LineActor,LabelActor,vtkTextActor);
 #else
-vtkCxxSetObjectMacro(VTKViewer_LineActor,LabelActor,VTKViewer_UnScaledActor);
+vtkCxxSetObjectMacro(VTKViewer_LineActor,LabelActor,VTKViewer_UnScaledActor)
 #endif
-vtkCxxSetObjectMacro(VTKViewer_LineActor,ArrowActor,vtkFollower);
+vtkCxxSetObjectMacro(VTKViewer_LineActor,ArrowActor,vtkFollower)
 
 /*!Adds Label and Arrow actors to \a theRenderer.*/
 void VTKViewer_LineActor::Render(vtkRenderer *theRenderer)
@@ -140,7 +139,7 @@ VTKViewer_Axis::VTKViewer_Axis()
   myLineSource->SetPoint1(0.0,0.0,0.0);
   
   myMapper[0] = vtkPolyDataMapper::New();
-  myMapper[0]->SetInput(myLineSource->GetOutput());
+  myMapper[0]->SetInputConnection(myLineSource->GetOutputPort());
   
   myLineActor = VTKViewer_LineActor::New();
   myLineActor->SetMapper(myMapper[0]);
@@ -153,7 +152,7 @@ VTKViewer_Axis::VTKViewer_Axis()
   myConeSource->SetCenter(-0.5,0.0,0.0);
   
   myMapper[1] = vtkPolyDataMapper::New();
-  myMapper[1]->SetInput(myConeSource->GetOutput());
+  myMapper[1]->SetInputConnection(myConeSource->GetOutputPort());
   
   myArrowActor = vtkFollower::New();
   myArrowActor->SetMapper(myMapper[1]);
@@ -169,7 +168,7 @@ VTKViewer_Axis::VTKViewer_Axis()
   
   myLabelActor = vtkTextActor::New();
   myLabelActor->SetMapper(myTextMapper);
-  myLabelActor->ScaledTextOff();
+  myLabelActor->SetTextScaleModeToNone();
   myLabelActor->PickableOff();
   
   vtkCoordinate* aCoord = vtkCoordinate::New();
@@ -179,7 +178,7 @@ VTKViewer_Axis::VTKViewer_Axis()
   myVectorText = vtkVectorText::New();
   
   myMapper[2] = vtkPolyDataMapper::New();
-  myMapper[2]->SetInput(myVectorText->GetOutput());
+  myMapper[2]->SetInputConnection(myVectorText->GetOutputPort());
   
   myLabelActor = VTKViewer_UnScaledActor::New();
   myLabelActor->SetMapper(myMapper[2]);
@@ -308,12 +307,12 @@ void VTKViewer_Axis::SetColor(double theRed, double theGreen, double theBlue)
 
 /*! Set size of VTKViewer_Axis
  */
-void VTKViewer_Axis::SetSize(vtkFloatingPointType theSize)
+void VTKViewer_Axis::SetSize(double theSize)
 {
-  vtkFloatingPointType aPosition[3] = {myDir[0]*theSize, myDir[1]*theSize, myDir[2]*theSize};
+  double aPosition[3] = {myDir[0]*theSize, myDir[1]*theSize, myDir[2]*theSize};
 
-  vtkFloatingPointType aCoef = 0.99;
-  vtkFloatingPointType aLinePosition[3] = {aPosition[0]*aCoef, aPosition[1]*aCoef, aPosition[2]*aCoef};
+  double aCoef = 0.99;
+  double aLinePosition[3] = {aPosition[0]*aCoef, aPosition[1]*aCoef, aPosition[2]*aCoef};
   myLineSource->SetPoint2(aLinePosition);
   
   myArrowActor->SetPosition(0.0,0.0,0.0);
@@ -354,11 +353,11 @@ protected:
   VTKViewer_XAxis();
   VTKViewer_XAxis(const VTKViewer_XAxis&);
 public:
-  vtkTypeMacro(VTKViewer_XAxis,VTKViewer_Axis);
+  vtkTypeMacro(VTKViewer_XAxis,VTKViewer_Axis)
   static VTKViewer_XAxis *New();
 };
 
-vtkStandardNewMacro(VTKViewer_XAxis);
+vtkStandardNewMacro(VTKViewer_XAxis)
 
 /*!Initialize X Axis*/
 VTKViewer_XAxis::VTKViewer_XAxis(){ 
@@ -380,11 +379,11 @@ protected:
   VTKViewer_YAxis();
   VTKViewer_YAxis(const VTKViewer_YAxis&);
 public:
-  vtkTypeMacro(VTKViewer_YAxis,VTKViewer_Axis);
+  vtkTypeMacro(VTKViewer_YAxis,VTKViewer_Axis)
   static VTKViewer_YAxis *New();
 };
 
-vtkStandardNewMacro(VTKViewer_YAxis);
+vtkStandardNewMacro(VTKViewer_YAxis)
 
 /*!Initialize Y Axis*/
 VTKViewer_YAxis::VTKViewer_YAxis()
@@ -408,11 +407,11 @@ protected:
   VTKViewer_ZAxis();
   VTKViewer_ZAxis(const VTKViewer_ZAxis&);
 public:
-  vtkTypeMacro(VTKViewer_ZAxis,VTKViewer_Axis);
+  vtkTypeMacro(VTKViewer_ZAxis,VTKViewer_Axis)
   static VTKViewer_ZAxis *New();
 };
 
-vtkStandardNewMacro(VTKViewer_ZAxis);
+vtkStandardNewMacro(VTKViewer_ZAxis)
 
 /*!Initialize Z Axis*/
 VTKViewer_ZAxis::VTKViewer_ZAxis()
@@ -427,7 +426,7 @@ VTKViewer_ZAxis::VTKViewer_ZAxis()
   SetColor(0.0,0.0,1.0);
 }
 
-vtkStandardNewMacro(VTKViewer_Trihedron);
+vtkStandardNewMacro(VTKViewer_Trihedron)
 
 /*!
   Constructor
@@ -438,7 +437,7 @@ VTKViewer_Trihedron::VTKViewer_Trihedron()
   myAxis[0] = VTKViewer_XAxis::New();
   myAxis[1] = VTKViewer_YAxis::New();
   myAxis[2] = VTKViewer_ZAxis::New();
-  static vtkFloatingPointType aSize = 100;
+  static double aSize = 100;
   SetSize(aSize);
 }
 
@@ -455,7 +454,7 @@ VTKViewer_Trihedron::~VTKViewer_Trihedron()
 
 /*! Set size of axes
  */
-void VTKViewer_Trihedron::SetSize(vtkFloatingPointType theSize)
+void VTKViewer_Trihedron::SetSize(double theSize)
 {
   mySize = theSize;
   for(int i = 0; i < 3; i++)