Back to index

salome-gui  6.5.0
SVTK_CubeAxesActor2D.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  SALOME OBJECT : kernel of SALOME component
00024 //  File   : SVTK_CubeAxesActor2D.cxx
00025 //  Author : Eugeny Nikolaev
00026 
00027 #include "SVTK_CubeAxesActor2D.h"
00028 #include "VTKViewer_Transform.h"
00029 
00030 #include <vtkPolyDataMapper.h>
00031 #include <vtkRectilinearGridGeometryFilter.h>
00032 #include <vtkActor.h>
00033 #include <vtkCubeAxesActor2D.h>
00034 #include <vtkAxisActor2D.h>
00035 #include <vtkCamera.h>
00036 #include <vtkDataSet.h>
00037 #include <vtkMath.h>
00038 #include <vtkObjectFactory.h>
00039 #include <vtkTextProperty.h>
00040 #include <vtkViewport.h>
00041 #include <vtkFloatArray.h>
00042 #include <vtkRectilinearGrid.h>
00043 #include <vtkProperty.h>
00044 #include <vtkProperty2D.h>
00045 
00046 vtkCxxRevisionMacro(SVTK_CubeAxesActor2D, "$Revision: 1.6.2.1.8.3.2.1 $");
00047 vtkStandardNewMacro(SVTK_CubeAxesActor2D);
00048 
00049 // Instantiate this object.
00050 SVTK_CubeAxesActor2D::SVTK_CubeAxesActor2D()
00051 {
00052   this->wireActorXY = vtkActor::New();
00053   this->wireActorYZ = vtkActor::New();
00054   this->wireActorXZ = vtkActor::New();
00055 
00056   this->planeXY = vtkRectilinearGridGeometryFilter::New();
00057   this->planeYZ = vtkRectilinearGridGeometryFilter::New();
00058   this->planeXZ = vtkRectilinearGridGeometryFilter::New();
00059 
00060   this->rgridMapperXY = vtkPolyDataMapper::New();
00061   this->rgridMapperYZ = vtkPolyDataMapper::New();
00062   this->rgridMapperXZ = vtkPolyDataMapper::New();
00063 
00064   this->rgridMapperXY->SetInput(this->planeXY->GetOutput());
00065   this->rgridMapperYZ->SetInput(this->planeYZ->GetOutput());
00066   this->rgridMapperXZ->SetInput(this->planeXZ->GetOutput());
00067 
00068   this->wireActorXY->SetMapper(rgridMapperXY);
00069   this->wireActorYZ->SetMapper(rgridMapperYZ);
00070   this->wireActorXZ->SetMapper(rgridMapperXZ);
00071 
00072   this->wireActorXY->GetProperty()->SetRepresentationToWireframe();
00073   this->wireActorYZ->GetProperty()->SetRepresentationToWireframe();
00074   this->wireActorXZ->GetProperty()->SetRepresentationToWireframe();
00075 
00076   // setting ambient to 1 (if no - incorrect reaction on light)
00077   this->wireActorXY->GetProperty()->SetAmbient(1);
00078   this->wireActorYZ->GetProperty()->SetAmbient(1);
00079   this->wireActorXZ->GetProperty()->SetAmbient(1);
00080 
00081   this->XAxis->SetTitle(this->XLabel);
00082   this->YAxis->SetTitle(this->YLabel);
00083   this->ZAxis->SetTitle(this->ZLabel);
00084   
00085   this->XAxis->SetNumberOfLabels(this->NumberOfLabels);
00086   this->YAxis->SetNumberOfLabels(this->NumberOfLabels);
00087   this->ZAxis->SetNumberOfLabels(this->NumberOfLabels);
00088  
00089   this->XAxis->SetLabelFormat(this->LabelFormat);
00090   this->YAxis->SetLabelFormat(this->LabelFormat);
00091   this->ZAxis->SetLabelFormat(this->LabelFormat);
00092   
00093   this->XAxis->SetFontFactor(this->FontFactor);
00094   this->YAxis->SetFontFactor(this->FontFactor);
00095   this->ZAxis->SetFontFactor(this->FontFactor);
00096   
00097   this->XAxis->SetProperty(this->GetProperty());
00098   this->YAxis->SetProperty(this->GetProperty());
00099   this->ZAxis->SetProperty(this->GetProperty());
00100 
00101   vtkTextProperty* aTLProp = vtkTextProperty::New();
00102   aTLProp->SetBold(0);
00103   aTLProp->SetItalic(0);
00104   aTLProp->SetShadow(0);
00105   aTLProp->SetFontFamilyToArial();
00106   aTLProp->SetColor(1,0,0);
00107   if (this->XAxis->GetLabelTextProperty())
00108     this->XAxis->GetLabelTextProperty()->ShallowCopy(aTLProp);
00109   aTLProp->SetColor(0,1,0);
00110   if (this->YAxis->GetLabelTextProperty())
00111     this->YAxis->GetLabelTextProperty()->ShallowCopy(aTLProp);
00112   aTLProp->SetColor(0,0,1);
00113   if (this->ZAxis->GetLabelTextProperty())
00114     this->ZAxis->GetLabelTextProperty()->ShallowCopy(aTLProp);;
00115 
00116   aTLProp->SetColor(1,0,0);
00117   if (this->XAxis->GetLabelTextProperty())
00118     this->XAxis->GetTitleTextProperty()->ShallowCopy(aTLProp);
00119   aTLProp->SetColor(0,1,0);
00120   if (this->YAxis->GetLabelTextProperty())
00121     this->YAxis->GetTitleTextProperty()->ShallowCopy(aTLProp);
00122   aTLProp->SetColor(0,0,1);
00123   if (this->ZAxis->GetLabelTextProperty())
00124     this->ZAxis->GetTitleTextProperty()->ShallowCopy(aTLProp);
00125   
00126   aTLProp->Delete();
00127   
00128 }
00129 
00130 SVTK_CubeAxesActor2D::~SVTK_CubeAxesActor2D()
00131 {
00132   this->wireActorXY->Delete();
00133   this->wireActorYZ->Delete();
00134   this->wireActorXZ->Delete();
00135 
00136   this->planeXY->Delete();
00137   this->planeYZ->Delete();
00138   this->planeXZ->Delete();
00139 
00140   this->rgridMapperXY->Delete();
00141   this->rgridMapperYZ->Delete();
00142   this->rgridMapperXZ->Delete();
00143 }
00144 
00145 // Static variable describes connections in cube.
00146 static int Conn[8][3] = {{1,2,4}, {0,3,5}, {3,0,6}, {2,1,7},
00147                          {5,6,0}, {4,7,1}, {7,4,2}, {6,5,3}};
00148 
00149 // Project the bounding box and compute edges on the border of the bounding
00150 // cube. Determine which parts of the edges are visible via intersection 
00151 // with the boundary of the viewport (minus borders).
00152 int SVTK_CubeAxesActor2D::RenderOverlay(vtkViewport *viewport)
00153 {
00154   int renderedSomething=0;
00155 
00156   // Initialization
00157   if ( ! this->RenderSomething )
00158     {
00159     return 0;
00160     }
00161   
00162   //Render the axes
00163   if ( this->XAxisVisibility )
00164     {
00165     renderedSomething += this->XAxis->RenderOverlay(viewport);
00166     }
00167   if ( this->YAxisVisibility )
00168     {
00169     renderedSomething += this->YAxis->RenderOverlay(viewport);
00170     }
00171   if ( this->ZAxisVisibility )
00172     {
00173     renderedSomething += this->ZAxis->RenderOverlay(viewport);
00174     }
00175   
00176   bool RX=false,RY=false;
00177   if (this->XAxisVisibility){
00178     this->wireActorXY->RenderOverlay(viewport);
00179     this->wireActorXZ->RenderOverlay(viewport);
00180     RX = true;
00181   }
00182   if (this->YAxisVisibility){
00183     if(!RX) this->wireActorXY->RenderOverlay(viewport);
00184     this->wireActorYZ->RenderOverlay(viewport);
00185     RY = true;
00186   }
00187   if (this->ZAxisVisibility){
00188     if(!RX) this->wireActorXZ->RenderOverlay(viewport);
00189     if(!RY) this->wireActorYZ->RenderOverlay(viewport);
00190   }
00191 
00192   return renderedSomething;
00193 }
00194 
00195 static void ChangeValues(vtkFloatingPointType* aArray1,
00196                          vtkFloatingPointType* aArray2,
00197                          vtkFloatingPointType *aRange1,
00198                          vtkFloatingPointType* aRange2,
00199                          bool theY)
00200 {
00201   vtkFloatingPointType tmp=-1000;
00202   if (!theY){
00203     for (int i=0; i<4; i++){
00204       tmp = aArray1[i]; aArray1[i] = aArray2[i]; aArray2[i] = tmp;
00205     }
00206     for(int i=0;i<2; i++){
00207       tmp = aRange1[i]; aRange1[i] = aRange2[i]; aRange2[i] = tmp;
00208     }
00209   }
00210   else{
00211     tmp = aArray1[2]; aArray1[2] = aArray2[0]; aArray2[0] = tmp;
00212     tmp = aArray1[3]; aArray1[3] = aArray2[1]; aArray2[1] = tmp;
00213     tmp = aArray1[0]; aArray1[0] = aArray2[2]; aArray2[2] = tmp;
00214     tmp = aArray1[1]; aArray1[1] = aArray2[3]; aArray2[3] = tmp;
00215 
00216     tmp = aRange1[0]; aRange1[0] = aRange2[1]; aRange2[1] = tmp;
00217     tmp = aRange1[1]; aRange1[1] = aRange2[0]; aRange2[0] = tmp;
00218   }
00219 }
00220 
00221 static void ChangeArrays(vtkFloatingPointType* xCoords,
00222                          vtkFloatingPointType* yCoords,
00223                          vtkFloatingPointType* zCoords,
00224                          vtkFloatingPointType* xRange,
00225                          vtkFloatingPointType* yRange,
00226                          vtkFloatingPointType* zRange,
00227                          const int xAxes,
00228                          const int yAxes, 
00229                          const int zAxes)
00230 {
00231   if ( xAxes == 0 && yAxes == 2 && zAxes == 1)
00232     ChangeValues(yCoords,zCoords,yRange,zRange,true);
00233   else if (xAxes == 1 && yAxes == 0 && zAxes == 2)
00234     ChangeValues(xCoords,yCoords,xRange,yRange,true);
00235   else if (xAxes == 1 && yAxes == 2 && zAxes == 0){
00236     ChangeValues(xCoords,zCoords,xRange,zRange,false);
00237     // xAxes == 0 && yAxes == 2 && zAxes == 1
00238     ChangeValues(yCoords,zCoords,yRange,zRange,true);
00239   } else if (xAxes == 2 && yAxes == 0 && zAxes == 1){
00240     ChangeValues(xCoords,yCoords,xRange,yRange,true);
00241     // xAxes == 0 && yAxes == 2 && zAxes == 1
00242     ChangeValues(zCoords,yCoords,zRange,yRange,true);
00243   } else if (xAxes == 2 && yAxes == 1 && zAxes == 0)
00244     ChangeValues(zCoords,xCoords,zRange,xRange,false);
00245 }
00246 
00247 // Project the bounding box and compute edges on the border of the bounding
00248 // cube. Determine which parts of the edges are visible via intersection 
00249 // with the boundary of the viewport (minus borders).
00250 int SVTK_CubeAxesActor2D::RenderOpaqueGeometry(vtkViewport *viewport)
00251 {
00252   vtkFloatingPointType bounds[6], slope = 0.0, minSlope, num, den;
00253   vtkFloatingPointType pts[8][3], d2, d2Min, min;
00254   int i, idx = 0;
00255   int xIdx, yIdx = 0, zIdx = 0, zIdx2, renderedSomething=0;
00256   int xAxes = 0, yAxes, zAxes;
00257 
00258   // Initialization
00259   if ( !this->Camera )
00260     {
00261     vtkErrorMacro(<<"No camera!");
00262     this->RenderSomething = 0;
00263     return 0;
00264     }
00265   
00266   this->RenderSomething = 1;
00267 
00268   // determine the bounds to use
00269   this->GetBounds(bounds);
00270 
00271   // Build the axes (almost always needed so we don't check mtime)
00272   // Transform all points into display coordinates
00273   this->TransformBounds(viewport, bounds, pts);
00274 
00275   // Find the portion of the bounding box that fits within the viewport,
00276   if ( this->ClipBounds(viewport, pts, bounds) == 0 )
00277     {
00278     this->RenderSomething = 0;
00279     return 0;
00280     }
00281 
00282   // Take into account the inertia. Process only so often.
00283   if ( this->RenderCount++ == 0 || !(this->RenderCount % this->Inertia) )
00284     {
00285     // Okay, we have a bounding box, maybe clipped and scaled, that is visible.
00286     // We setup the axes depending on the fly mode.
00287     if ( this->FlyMode == VTK_FLY_CLOSEST_TRIAD )
00288       {
00289       // Loop over points and find the closest point to the camera
00290       min = VTK_LARGE_FLOAT;
00291       for (i=0; i < 8; i++)
00292         {
00293         if ( pts[i][2] < min )
00294           {
00295           idx = i;
00296           min = pts[i][2];
00297           }
00298         }
00299 
00300       // Setup the three axes to be drawn
00301       xAxes = 0;
00302       xIdx = Conn[idx][0];
00303       yAxes = 1;
00304       yIdx = Conn[idx][1];
00305       zAxes = 2;
00306       zIdx = idx;
00307       zIdx2 = Conn[idx][2];
00308       }
00309     else
00310       {
00311       vtkFloatingPointType e1[2], e2[2], e3[2];
00312 
00313       // Find distance to origin
00314       d2Min = VTK_LARGE_FLOAT;
00315       for (i=0; i < 8; i++)
00316         {
00317         d2 = pts[i][0]*pts[i][0] + pts[i][1]*pts[i][1];
00318         if ( d2 < d2Min )
00319           {
00320           d2Min = d2;
00321           idx = i;
00322           }
00323         }
00324 
00325       // find minimum slope point connected to closest point and on 
00326       // right side (in projected coordinates). This is the first edge.
00327       minSlope = VTK_LARGE_FLOAT;
00328       for (xIdx=0, i=0; i<3; i++)
00329         {
00330         num = (pts[Conn[idx][i]][1] - pts[idx][1]);
00331         den = (pts[Conn[idx][i]][0] - pts[idx][0]);
00332         if ( den != 0.0 )
00333           {
00334           slope = num / den;
00335           }
00336         if ( slope < minSlope && den > 0 )
00337           {
00338           xIdx = Conn[idx][i];
00339           yIdx = Conn[idx][(i+1)%3];
00340           zIdx = Conn[idx][(i+2)%3];
00341           xAxes = i;
00342           minSlope = slope;
00343           }
00344         }
00345 
00346       // find edge (connected to closest point) on opposite side
00347       for ( i=0; i<2; i++)
00348         {
00349         e1[i] = (pts[xIdx][i] - pts[idx][i]);
00350         e2[i] = (pts[yIdx][i] - pts[idx][i]);
00351         e3[i] = (pts[zIdx][i] - pts[idx][i]);
00352         }
00353       vtkMath::Normalize2D(e1);
00354       vtkMath::Normalize2D(e2);
00355       vtkMath::Normalize2D(e3);
00356 
00357       if ( vtkMath::Dot2D(e1,e2) < vtkMath::Dot2D(e1,e3) )
00358         {
00359         yAxes = (xAxes + 1) % 3;
00360         }
00361       else
00362         {
00363         yIdx = zIdx;
00364         yAxes = (xAxes + 2) % 3;
00365         }
00366 
00367       // Find the final point by determining which global x-y-z axes have not 
00368       // been represented, and then determine the point closest to the viewer.
00369       zAxes = (xAxes != 0 && yAxes != 0 ? 0 :
00370               (xAxes != 1 && yAxes != 1 ? 1 : 2));
00371       if ( pts[Conn[xIdx][zAxes]][2] < pts[Conn[yIdx][zAxes]][2] )
00372         {
00373         zIdx = xIdx;
00374         zIdx2 = Conn[xIdx][zAxes];
00375         }
00376       else
00377         {
00378         zIdx = yIdx;
00379         zIdx2 = Conn[yIdx][zAxes];
00380         }
00381       }//else boundary edges fly mode
00382     this->InertiaAxes[0] = idx;
00383     this->InertiaAxes[1] = xIdx;
00384     this->InertiaAxes[2] = yIdx;
00385     this->InertiaAxes[3] = zIdx;
00386     this->InertiaAxes[4] = zIdx2;
00387     this->InertiaAxes[5] = xAxes;
00388     this->InertiaAxes[6] = yAxes;
00389     this->InertiaAxes[7] = zAxes;
00390     } //inertia
00391   else
00392     {
00393     idx = this->InertiaAxes[0];
00394     xIdx = this->InertiaAxes[1];
00395     yIdx = this->InertiaAxes[2];
00396     zIdx = this->InertiaAxes[3];
00397     zIdx2 = this->InertiaAxes[4];
00398     xAxes = this->InertiaAxes[5];
00399     yAxes = this->InertiaAxes[6];
00400     zAxes = this->InertiaAxes[7];
00401     }
00402 
00403   // Setup the axes for plotting
00404   vtkFloatingPointType xCoords[4], yCoords[4], zCoords[4], xRange[2], yRange[2], zRange[2];
00405   this->AdjustAxes(pts, bounds, idx, xIdx, yIdx, zIdx, zIdx2, 
00406                    xAxes, yAxes, zAxes, 
00407                    xCoords, yCoords, zCoords, xRange, yRange, zRange);
00408 
00409   // Upate axes
00410   this->Labels[0] = this->XLabel;
00411   this->Labels[1] = this->YLabel;
00412   this->Labels[2] = this->ZLabel;
00413 
00414   // correct XAxis, YAxis, ZAxis, which must be 
00415   // parallel OX, OY, OZ system coordinates
00416   // if xAxes=0 yAxes=1 zAxes=2 - good situation
00417   if (!(xAxes == 0 && yAxes == 1 && zAxes == 2))
00418     ChangeArrays(xCoords,yCoords,zCoords,
00419                  xRange,yRange,zRange,
00420                  xAxes,yAxes,zAxes);
00421 
00422   double aTScale[3];
00423   if(m_Transform.GetPointer() != NULL)
00424     m_Transform->GetMatrixScale(aTScale);
00425 
00426   this->XAxis->GetPositionCoordinate()->SetValue(xCoords[0], xCoords[1]);
00427   this->XAxis->GetPosition2Coordinate()->SetValue(xCoords[2], xCoords[3]);
00428   if(m_Transform.GetPointer() != NULL) this->XAxis->SetRange(xRange[0]/aTScale[0], xRange[1]/aTScale[0]);
00429   else this->XAxis->SetRange(xRange[0], xRange[1]);
00430 
00431   this->YAxis->GetPositionCoordinate()->SetValue(yCoords[2], yCoords[3]);
00432   this->YAxis->GetPosition2Coordinate()->SetValue(yCoords[0], yCoords[1]);
00433   if(m_Transform.GetPointer() != NULL) this->YAxis->SetRange(yRange[1]/aTScale[1], yRange[0]/aTScale[1]);
00434   else this->YAxis->SetRange(yRange[1], yRange[0]);
00435 
00436   this->ZAxis->GetPositionCoordinate()->SetValue(zCoords[0], zCoords[1]);
00437   this->ZAxis->GetPosition2Coordinate()->SetValue(zCoords[2], zCoords[3]);
00438   if(m_Transform.GetPointer() != NULL) this->ZAxis->SetRange(zRange[0]/aTScale[2], zRange[1]/aTScale[2]);
00439   else this->ZAxis->SetRange(zRange[0], zRange[1]);
00440 
00441   int numOfLabelsX = this->XAxis->GetNumberOfLabels();
00442   int numOfLabelsY = this->YAxis->GetNumberOfLabels();
00443   int numOfLabelsZ = this->ZAxis->GetNumberOfLabels();
00444 
00445   // XCoords coordinates for X grid
00446   vtkFloatArray *XCoords = vtkFloatArray::New();
00447   for(int i=0;i<numOfLabelsX;i++){
00448     vtkFloatingPointType val = bounds[0]+i*(bounds[1]-bounds[0])/(numOfLabelsX-1);
00449     XCoords->InsertNextValue(val);
00450   }
00451   // YCoords coordinates for Y grid
00452   vtkFloatArray *YCoords = vtkFloatArray::New();
00453   for(int i=0;i<numOfLabelsX;i++){
00454     vtkFloatingPointType val = bounds[2]+i*(bounds[3]-bounds[2])/(numOfLabelsY-1);
00455     YCoords->InsertNextValue(val);
00456   }
00457   // ZCoords coordinates for Z grid
00458   vtkFloatArray *ZCoords = vtkFloatArray::New();
00459   for(int i=0;i<numOfLabelsZ;i++){
00460     vtkFloatingPointType val = bounds[4]+i*(bounds[5]-bounds[4])/(numOfLabelsZ-1);
00461     ZCoords->InsertNextValue(val);
00462   }
00463 
00464   vtkRectilinearGrid *rgrid = vtkRectilinearGrid::New();
00465   rgrid->SetDimensions(numOfLabelsX,numOfLabelsY,numOfLabelsZ);
00466   rgrid->SetXCoordinates(XCoords);
00467   rgrid->SetYCoordinates(YCoords);
00468   rgrid->SetZCoordinates(ZCoords);
00469 
00470   this->planeXY->SetInput(rgrid);
00471   this->planeYZ->SetInput(rgrid);
00472   this->planeXZ->SetInput(rgrid);
00473 
00474   rgrid->Delete();
00475 
00476   vtkFloatingPointType aCPosition[3];
00477   vtkFloatingPointType aCDirection[3];
00478   this->Camera->GetPosition(aCPosition);
00479   this->Camera->GetDirectionOfProjection(aCDirection);
00480 
00481   // culculate placement of XY
00482   bool replaceXY=false;
00483   bool replaceYZ=false;
00484   bool replaceXZ=false;
00485   vtkFloatingPointType p[6][3]; // centers of planes
00486   vtkFloatingPointType vecs[6][3]; // 6 vectors from camera position to centers
00487 
00488   vtkFloatingPointType aMiddleX = (XCoords->GetValue(0) + XCoords->GetValue(numOfLabelsX-1))/2;
00489   vtkFloatingPointType aMiddleY = (YCoords->GetValue(0) + YCoords->GetValue(numOfLabelsY-1))/2;
00490   vtkFloatingPointType aMiddleZ = (ZCoords->GetValue(0) + ZCoords->GetValue(numOfLabelsZ-1))/2;
00491 
00492   // plane XY
00493   p[0][0] = aMiddleX; // plane X=0.5 Y=0.5 Z=0
00494   p[0][1] = aMiddleY;
00495   p[0][2] = ZCoords->GetValue(0);
00496 
00497   p[1][0] = aMiddleX; // plane X=0.5 Y=0.5 Z=1
00498   p[1][1] = aMiddleY;
00499   p[1][2] = ZCoords->GetValue(numOfLabelsZ-1);
00500 
00501   // plane YZ
00502   p[2][0] = XCoords->GetValue(0); // plane X=0 Y=0.5 Z=0.5
00503   p[2][1] = aMiddleY;
00504   p[2][2] = aMiddleZ;
00505 
00506   p[3][0] = XCoords->GetValue(numOfLabelsX-1);
00507   p[3][1] = aMiddleY;
00508   p[3][2] = aMiddleZ;
00509 
00510   // plane XZ
00511   p[4][0] = aMiddleX; // plane X=0.5 Y=0 Z=0.5
00512   p[4][1] = YCoords->GetValue(0);
00513   p[4][2] = aMiddleZ;
00514 
00515   p[5][0] = aMiddleX; // plane X=0.5 Y=1 Z=0.5
00516   p[5][1] = YCoords->GetValue(numOfLabelsY-1);
00517   p[5][2] = aMiddleZ;
00518 
00519   for(int i=0;i<3;i++) 
00520     for(int j=0;j<6;j++) vecs[j][i] = p[j][i] - aCPosition[i];
00521 
00522   if ( vtkMath::Dot(vecs[0],aCDirection) < vtkMath::Dot(vecs[1],aCDirection))
00523     replaceXY = true;
00524   if ( vtkMath::Dot(vecs[2],aCDirection) < vtkMath::Dot(vecs[3],aCDirection))
00525     replaceYZ = true;
00526   if ( vtkMath::Dot(vecs[4],aCDirection) < vtkMath::Dot(vecs[5],aCDirection))
00527     replaceXZ = true;
00528 
00529   if(replaceXY) this->planeXY->SetExtent(0,numOfLabelsX, 0,numOfLabelsY, numOfLabelsZ,numOfLabelsZ);
00530   else this->planeXY->SetExtent(0,numOfLabelsX, 0,numOfLabelsY, 0,0);
00531 
00532   if(replaceYZ) this->planeYZ->SetExtent(numOfLabelsX,numOfLabelsX, 0,numOfLabelsY, 0,numOfLabelsZ);
00533   else this->planeYZ->SetExtent(0,0, 0,numOfLabelsY, 0,numOfLabelsZ);
00534 
00535   if(replaceXZ) this->planeXZ->SetExtent(0,numOfLabelsX, numOfLabelsY,numOfLabelsY, 0,numOfLabelsZ);
00536   else this->planeXZ->SetExtent(0,numOfLabelsX, 0,0, 0,numOfLabelsZ);
00537 
00538   XCoords->Delete();
00539   YCoords->Delete();
00540   ZCoords->Delete();
00541 
00542   vtkFloatingPointType color[3];
00543 
00544   this->GetProperty()->GetColor(color);
00545   this->wireActorXY->GetProperty()->SetColor(color);
00546   this->wireActorYZ->GetProperty()->SetColor(color);
00547   this->wireActorXZ->GetProperty()->SetColor(color);
00548 
00549   /*
00550   // Rebuid text props
00551   // Perform shallow copy here since each individual axis can be
00552   // accessed through the class API (i.e. each individual axis text prop
00553   // can be changed). Therefore, we can not just assign pointers otherwise
00554   // each individual axis text prop would point to the same text prop.
00555 
00556   if (this->AxisLabelTextProperty &&
00557       this->AxisLabelTextProperty->GetMTime() > this->BuildTime)
00558     {
00559     if (this->XAxis->GetLabelTextProperty())
00560       {
00561       this->XAxis->GetLabelTextProperty()->ShallowCopy(
00562         this->AxisLabelTextProperty);
00563       }
00564     if (this->YAxis->GetLabelTextProperty())
00565       {
00566       this->YAxis->GetLabelTextProperty()->ShallowCopy(
00567         this->AxisLabelTextProperty);
00568       }
00569     if (this->ZAxis->GetLabelTextProperty())
00570       {
00571       this->ZAxis->GetLabelTextProperty()->ShallowCopy(
00572         this->AxisLabelTextProperty);
00573       }
00574     }
00575 
00576   if (this->AxisTitleTextProperty &&
00577       this->AxisTitleTextProperty->GetMTime() > this->BuildTime)
00578     {
00579     if (this->XAxis->GetLabelTextProperty())
00580       {
00581       this->XAxis->GetTitleTextProperty()->ShallowCopy(
00582         this->AxisTitleTextProperty);
00583       }
00584     if (this->YAxis->GetLabelTextProperty())
00585       {
00586       this->YAxis->GetTitleTextProperty()->ShallowCopy(
00587         this->AxisTitleTextProperty);
00588       }
00589     if (this->ZAxis->GetLabelTextProperty())
00590       {
00591       this->ZAxis->GetTitleTextProperty()->ShallowCopy(
00592         this->AxisTitleTextProperty);
00593       }
00594     }
00595   */  
00596   this->BuildTime.Modified();
00597 
00598   //Render the axes
00599   if ( this->XAxisVisibility )
00600   {
00601     renderedSomething += this->XAxis->RenderOpaqueGeometry(viewport);
00602   }
00603   if ( this->YAxisVisibility )
00604   {
00605     renderedSomething += this->YAxis->RenderOpaqueGeometry(viewport);
00606   }
00607   if ( this->ZAxisVisibility )
00608   {
00609     renderedSomething += this->ZAxis->RenderOpaqueGeometry(viewport);
00610   }
00611 
00612   bool RX=false,RY=false;
00613   if (this->XAxisVisibility){
00614     this->wireActorXY->RenderOpaqueGeometry(viewport);
00615     this->wireActorXZ->RenderOpaqueGeometry(viewport);
00616     RX = true;
00617   }
00618   if (this->YAxisVisibility){
00619     if(!RX) this->wireActorXY->RenderOpaqueGeometry(viewport);
00620     this->wireActorYZ->RenderOpaqueGeometry(viewport);
00621     RY = true;
00622   }
00623   if (this->ZAxisVisibility){
00624     if(!RX) this->wireActorXZ->RenderOpaqueGeometry(viewport);
00625     if(!RY) this->wireActorYZ->RenderOpaqueGeometry(viewport);
00626   }
00627 
00628   return renderedSomething;
00629 }
00630 
00631 // Release any graphics resources that are being consumed by this actor.
00632 // The parameter window could be used to determine which graphic
00633 // resources to release.
00634 void SVTK_CubeAxesActor2D::ReleaseGraphicsResources(vtkWindow *win)
00635 {
00636   this->XAxis->ReleaseGraphicsResources(win);
00637   this->YAxis->ReleaseGraphicsResources(win);
00638   this->ZAxis->ReleaseGraphicsResources(win);
00639 
00640   this->wireActorXY->ReleaseGraphicsResources(win);
00641   this->wireActorYZ->ReleaseGraphicsResources(win);
00642   this->wireActorXZ->ReleaseGraphicsResources(win);
00643 }
00644 
00645 void SVTK_CubeAxesActor2D::SetTransform(VTKViewer_Transform* theTransform){
00646   this->m_Transform = theTransform;
00647 }
00648 
00649 VTKViewer_Transform* SVTK_CubeAxesActor2D::GetTransform(){
00650   return (this->m_Transform.GetPointer());
00651 }