Salome HOME
Updated copyright comment
[modules/gui.git] / src / SVTK / SVTK_CubeAxesActor2D.cxx
index 7c2d6ae8ce75d11c47f93423ecd0d364485f073b..2929cef2106177a23921a87e1cfc0aa57fbadab5 100644 (file)
@@ -1,30 +1,28 @@
-//  SALOME OBJECT : kernel of SALOME component
+// Copyright (C) 2007-2024  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
+//
+// 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, or (at your option) any later version.
 //
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-// 
-//  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. 
-// 
-//  This library is distributed in the hope that it will be useful, 
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-//  Lesser General Public License for more details. 
-// 
-//  You should have received a copy of the GNU Lesser General Public 
-//  License along with this library; if not, write to the Free Software 
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
-// 
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
+//  SALOME OBJECT : kernel of SALOME component
 //  File   : SVTK_CubeAxesActor2D.cxx
 //  Author : Eugeny Nikolaev
-//  Module : SALOME
-//  $Header$
 
 #include "SVTK_CubeAxesActor2D.h"
 #include "VTKViewer_Transform.h"
@@ -45,8 +43,7 @@
 #include <vtkProperty.h>
 #include <vtkProperty2D.h>
 
-vtkCxxRevisionMacro(SVTK_CubeAxesActor2D, "$Revision$");
-vtkStandardNewMacro(SVTK_CubeAxesActor2D);
+vtkStandardNewMacro(SVTK_CubeAxesActor2D)
 
 // Instantiate this object.
 SVTK_CubeAxesActor2D::SVTK_CubeAxesActor2D()
@@ -63,9 +60,9 @@ SVTK_CubeAxesActor2D::SVTK_CubeAxesActor2D()
   this->rgridMapperYZ = vtkPolyDataMapper::New();
   this->rgridMapperXZ = vtkPolyDataMapper::New();
 
-  this->rgridMapperXY->SetInput(this->planeXY->GetOutput());
-  this->rgridMapperYZ->SetInput(this->planeYZ->GetOutput());
-  this->rgridMapperXZ->SetInput(this->planeXZ->GetOutput());
+  this->rgridMapperXY->SetInputConnection(this->planeXY->GetOutputPort());
+  this->rgridMapperYZ->SetInputConnection(this->planeYZ->GetOutputPort());
+  this->rgridMapperXZ->SetInputConnection(this->planeXZ->GetOutputPort());
 
   this->wireActorXY->SetMapper(rgridMapperXY);
   this->wireActorYZ->SetMapper(rgridMapperYZ);
@@ -194,22 +191,18 @@ int SVTK_CubeAxesActor2D::RenderOverlay(vtkViewport *viewport)
   return renderedSomething;
 }
 
-static void ChangeValues(vtkFloatingPointType* aArray1,
-                        vtkFloatingPointType* aArray2,
-                        vtkFloatingPointType *aRange1,
-                        vtkFloatingPointType* aRange2,
-                        bool theY)
+static void ChangeValues(double* aArray1,
+                         double* aArray2,
+                         double *aRange1,
+                         double* aRange2,
+                         bool theY)
 {
-  vtkFloatingPointType tmp=-1000;
+  double tmp=-1000;
   if (!theY){
     for (int i=0; i<4; i++){
       tmp = aArray1[i]; aArray1[i] = aArray2[i]; aArray2[i] = tmp;
     }
-#ifndef WNT
     for(int i=0;i<2; i++){
-#else
-    for(i=0;i<2; i++){
-#endif
       tmp = aRange1[i]; aRange1[i] = aRange2[i]; aRange2[i] = tmp;
     }
   }
@@ -224,15 +217,15 @@ static void ChangeValues(vtkFloatingPointType* aArray1,
   }
 }
 
-static void ChangeArrays(vtkFloatingPointType* xCoords,
-                        vtkFloatingPointType* yCoords,
-                        vtkFloatingPointType* zCoords,
-                        vtkFloatingPointType* xRange,
-                        vtkFloatingPointType* yRange,
-                        vtkFloatingPointType* zRange,
-                        const int xAxes,
-                        const int yAxes, 
-                        const int zAxes)
+static void ChangeArrays(double* xCoords,
+                         double* yCoords,
+                         double* zCoords,
+                         double* xRange,
+                         double* yRange,
+                         double* zRange,
+                         const int xAxes,
+                         const int yAxes, 
+                         const int zAxes)
 {
   if ( xAxes == 0 && yAxes == 2 && zAxes == 1)
     ChangeValues(yCoords,zCoords,yRange,zRange,true);
@@ -255,8 +248,8 @@ static void ChangeArrays(vtkFloatingPointType* xCoords,
 // with the boundary of the viewport (minus borders).
 int SVTK_CubeAxesActor2D::RenderOpaqueGeometry(vtkViewport *viewport)
 {
-  vtkFloatingPointType bounds[6], slope = 0.0, minSlope, num, den;
-  vtkFloatingPointType pts[8][3], d2, d2Min, min;
+  double bounds[6], slope = 0.0, minSlope, num, den;
+  double pts[8][3], d2, d2Min, min;
   int i, idx = 0;
   int xIdx, yIdx = 0, zIdx = 0, zIdx2, renderedSomething=0;
   int xAxes = 0, yAxes, zAxes;
@@ -293,7 +286,7 @@ int SVTK_CubeAxesActor2D::RenderOpaqueGeometry(vtkViewport *viewport)
     if ( this->FlyMode == VTK_FLY_CLOSEST_TRIAD )
       {
       // Loop over points and find the closest point to the camera
-      min = VTK_LARGE_FLOAT;
+      min = VTK_FLOAT_MAX;
       for (i=0; i < 8; i++)
         {
         if ( pts[i][2] < min )
@@ -314,10 +307,10 @@ int SVTK_CubeAxesActor2D::RenderOpaqueGeometry(vtkViewport *viewport)
       }
     else
       {
-      vtkFloatingPointType e1[2], e2[2], e3[2];
+      double e1[2], e2[2], e3[2];
 
       // Find distance to origin
-      d2Min = VTK_LARGE_FLOAT;
+      d2Min = VTK_FLOAT_MAX;
       for (i=0; i < 8; i++)
         {
         d2 = pts[i][0]*pts[i][0] + pts[i][1]*pts[i][1];
@@ -330,7 +323,7 @@ int SVTK_CubeAxesActor2D::RenderOpaqueGeometry(vtkViewport *viewport)
 
       // find minimum slope point connected to closest point and on 
       // right side (in projected coordinates). This is the first edge.
-      minSlope = VTK_LARGE_FLOAT;
+      minSlope = VTK_FLOAT_MAX;
       for (xIdx=0, i=0; i<3; i++)
         {
         num = (pts[Conn[idx][i]][1] - pts[idx][1]);
@@ -407,7 +400,7 @@ int SVTK_CubeAxesActor2D::RenderOpaqueGeometry(vtkViewport *viewport)
     }
 
   // Setup the axes for plotting
-  vtkFloatingPointType xCoords[4], yCoords[4], zCoords[4], xRange[2], yRange[2], zRange[2];
+  double xCoords[4], yCoords[4], zCoords[4], xRange[2], yRange[2], zRange[2];
   this->AdjustAxes(pts, bounds, idx, xIdx, yIdx, zIdx, zIdx2, 
                    xAxes, yAxes, zAxes, 
                    xCoords, yCoords, zCoords, xRange, yRange, zRange);
@@ -422,8 +415,8 @@ int SVTK_CubeAxesActor2D::RenderOpaqueGeometry(vtkViewport *viewport)
   // if xAxes=0 yAxes=1 zAxes=2 - good situation
   if (!(xAxes == 0 && yAxes == 1 && zAxes == 2))
     ChangeArrays(xCoords,yCoords,zCoords,
-                xRange,yRange,zRange,
-                xAxes,yAxes,zAxes);
+                 xRange,yRange,zRange,
+                 xAxes,yAxes,zAxes);
 
   double aTScale[3];
   if(m_Transform.GetPointer() != NULL)
@@ -450,32 +443,20 @@ int SVTK_CubeAxesActor2D::RenderOpaqueGeometry(vtkViewport *viewport)
 
   // XCoords coordinates for X grid
   vtkFloatArray *XCoords = vtkFloatArray::New();
-#ifndef WNT
   for(int i=0;i<numOfLabelsX;i++){
-#else
-  for(i=0;i<numOfLabelsX;i++){
-#endif
-    vtkFloatingPointType val = bounds[0]+i*(bounds[1]-bounds[0])/(numOfLabelsX-1);
+    double val = bounds[0]+i*(bounds[1]-bounds[0])/(numOfLabelsX-1);
     XCoords->InsertNextValue(val);
   }
   // YCoords coordinates for Y grid
   vtkFloatArray *YCoords = vtkFloatArray::New();
-#ifndef WNT
   for(int i=0;i<numOfLabelsX;i++){
-#else
-  for(i=0;i<numOfLabelsX;i++){
-#endif
-    vtkFloatingPointType val = bounds[2]+i*(bounds[3]-bounds[2])/(numOfLabelsY-1);
+    double val = bounds[2]+i*(bounds[3]-bounds[2])/(numOfLabelsY-1);
     YCoords->InsertNextValue(val);
   }
   // ZCoords coordinates for Z grid
   vtkFloatArray *ZCoords = vtkFloatArray::New();
-#ifndef WNT
   for(int i=0;i<numOfLabelsZ;i++){
-#else
-  for(i=0;i<numOfLabelsZ;i++){
-#endif
-    vtkFloatingPointType val = bounds[4]+i*(bounds[5]-bounds[4])/(numOfLabelsZ-1);
+    double val = bounds[4]+i*(bounds[5]-bounds[4])/(numOfLabelsZ-1);
     ZCoords->InsertNextValue(val);
   }
 
@@ -485,14 +466,14 @@ int SVTK_CubeAxesActor2D::RenderOpaqueGeometry(vtkViewport *viewport)
   rgrid->SetYCoordinates(YCoords);
   rgrid->SetZCoordinates(ZCoords);
 
-  this->planeXY->SetInput(rgrid);
-  this->planeYZ->SetInput(rgrid);
-  this->planeXZ->SetInput(rgrid);
+  this->planeXY->SetInputData(rgrid);
+  this->planeYZ->SetInputData(rgrid);
+  this->planeXZ->SetInputData(rgrid);
 
   rgrid->Delete();
 
-  vtkFloatingPointType aCPosition[3];
-  vtkFloatingPointType aCDirection[3];
+  double aCPosition[3];
+  double aCDirection[3];
   this->Camera->GetPosition(aCPosition);
   this->Camera->GetDirectionOfProjection(aCDirection);
 
@@ -500,12 +481,12 @@ int SVTK_CubeAxesActor2D::RenderOpaqueGeometry(vtkViewport *viewport)
   bool replaceXY=false;
   bool replaceYZ=false;
   bool replaceXZ=false;
-  vtkFloatingPointType p[6][3]; // centers of planes
-  vtkFloatingPointType vecs[6][3]; // 6 vectors from camera position to centers
+  double p[6][3]; // centers of planes
+  double vecs[6][3]; // 6 vectors from camera position to centers
 
-  vtkFloatingPointType aMiddleX = (XCoords->GetValue(0) + XCoords->GetValue(numOfLabelsX-1))/2;
-  vtkFloatingPointType aMiddleY = (YCoords->GetValue(0) + YCoords->GetValue(numOfLabelsY-1))/2;
-  vtkFloatingPointType aMiddleZ = (ZCoords->GetValue(0) + ZCoords->GetValue(numOfLabelsZ-1))/2;
+  double aMiddleX = (XCoords->GetValue(0) + XCoords->GetValue(numOfLabelsX-1))/2;
+  double aMiddleY = (YCoords->GetValue(0) + YCoords->GetValue(numOfLabelsY-1))/2;
+  double aMiddleZ = (ZCoords->GetValue(0) + ZCoords->GetValue(numOfLabelsZ-1))/2;
 
   // plane XY
   p[0][0] = aMiddleX; // plane X=0.5 Y=0.5 Z=0
@@ -534,11 +515,7 @@ int SVTK_CubeAxesActor2D::RenderOpaqueGeometry(vtkViewport *viewport)
   p[5][1] = YCoords->GetValue(numOfLabelsY-1);
   p[5][2] = aMiddleZ;
 
-#ifndef WNT
   for(int i=0;i<3;i++) 
-#else
-  for(i=0;i<3;i++) 
-#endif
     for(int j=0;j<6;j++) vecs[j][i] = p[j][i] - aCPosition[i];
 
   if ( vtkMath::Dot(vecs[0],aCDirection) < vtkMath::Dot(vecs[1],aCDirection))
@@ -561,7 +538,7 @@ int SVTK_CubeAxesActor2D::RenderOpaqueGeometry(vtkViewport *viewport)
   YCoords->Delete();
   ZCoords->Delete();
 
-  vtkFloatingPointType color[3];
+  double color[3];
 
   this->GetProperty()->GetColor(color);
   this->wireActorXY->GetProperty()->SetColor(color);