Salome HOME
ENV: Windows porting
[modules/gui.git] / src / SVTK / SVTK_CubeAxesActor2D.cxx
1 //  SALOME OBJECT : kernel of SALOME component
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SVTK_CubeAxesActor2D.cxx
25 //  Author : Eugeny Nikolaev
26 //  Module : SALOME
27 //  $Header$
28
29 #include "SVTK_CubeAxesActor2D.h"
30 #include "VTKViewer_Transform.h"
31
32 #include <vtkPolyDataMapper.h>
33 #include <vtkRectilinearGridGeometryFilter.h>
34 #include <vtkActor.h>
35 #include <vtkCubeAxesActor2D.h>
36 #include <vtkAxisActor2D.h>
37 #include <vtkCamera.h>
38 #include <vtkDataSet.h>
39 #include <vtkMath.h>
40 #include <vtkObjectFactory.h>
41 #include <vtkTextProperty.h>
42 #include <vtkViewport.h>
43 #include <vtkFloatArray.h>
44 #include <vtkRectilinearGrid.h>
45 #include <vtkProperty.h>
46 #include <vtkProperty2D.h>
47
48 vtkCxxRevisionMacro(SVTK_CubeAxesActor2D, "$Revision$");
49 vtkStandardNewMacro(SVTK_CubeAxesActor2D);
50
51 //----------------------------------------------------------------------------
52 // Instantiate this object.
53 SVTK_CubeAxesActor2D::SVTK_CubeAxesActor2D()
54 {
55   this->wireActorXY = vtkActor::New();
56   this->wireActorYZ = vtkActor::New();
57   this->wireActorXZ = vtkActor::New();
58
59   this->planeXY = vtkRectilinearGridGeometryFilter::New();
60   this->planeYZ = vtkRectilinearGridGeometryFilter::New();
61   this->planeXZ = vtkRectilinearGridGeometryFilter::New();
62
63   this->rgridMapperXY = vtkPolyDataMapper::New();
64   this->rgridMapperYZ = vtkPolyDataMapper::New();
65   this->rgridMapperXZ = vtkPolyDataMapper::New();
66
67   this->rgridMapperXY->SetInput(this->planeXY->GetOutput());
68   this->rgridMapperYZ->SetInput(this->planeYZ->GetOutput());
69   this->rgridMapperXZ->SetInput(this->planeXZ->GetOutput());
70
71   this->wireActorXY->SetMapper(rgridMapperXY);
72   this->wireActorYZ->SetMapper(rgridMapperYZ);
73   this->wireActorXZ->SetMapper(rgridMapperXZ);
74
75   this->wireActorXY->GetProperty()->SetRepresentationToWireframe();
76   this->wireActorYZ->GetProperty()->SetRepresentationToWireframe();
77   this->wireActorXZ->GetProperty()->SetRepresentationToWireframe();
78
79   // setting ambient to 1 (if no - incorrect reaction on light)
80   this->wireActorXY->GetProperty()->SetAmbient(1);
81   this->wireActorYZ->GetProperty()->SetAmbient(1);
82   this->wireActorXZ->GetProperty()->SetAmbient(1);
83
84   this->XAxis->SetTitle(this->XLabel);
85   this->YAxis->SetTitle(this->YLabel);
86   this->ZAxis->SetTitle(this->ZLabel);
87   
88   this->XAxis->SetNumberOfLabels(this->NumberOfLabels);
89   this->YAxis->SetNumberOfLabels(this->NumberOfLabels);
90   this->ZAxis->SetNumberOfLabels(this->NumberOfLabels);
91  
92   this->XAxis->SetLabelFormat(this->LabelFormat);
93   this->YAxis->SetLabelFormat(this->LabelFormat);
94   this->ZAxis->SetLabelFormat(this->LabelFormat);
95   
96   this->XAxis->SetFontFactor(this->FontFactor);
97   this->YAxis->SetFontFactor(this->FontFactor);
98   this->ZAxis->SetFontFactor(this->FontFactor);
99   
100   this->XAxis->SetProperty(this->GetProperty());
101   this->YAxis->SetProperty(this->GetProperty());
102   this->ZAxis->SetProperty(this->GetProperty());
103
104   vtkTextProperty* aTLProp = vtkTextProperty::New();
105   aTLProp->SetBold(0);
106   aTLProp->SetItalic(0);
107   aTLProp->SetShadow(0);
108   aTLProp->SetFontFamilyToArial();
109   aTLProp->SetColor(1,0,0);
110   if (this->XAxis->GetLabelTextProperty())
111     this->XAxis->GetLabelTextProperty()->ShallowCopy(aTLProp);
112   aTLProp->SetColor(0,1,0);
113   if (this->YAxis->GetLabelTextProperty())
114     this->YAxis->GetLabelTextProperty()->ShallowCopy(aTLProp);
115   aTLProp->SetColor(0,0,1);
116   if (this->ZAxis->GetLabelTextProperty())
117     this->ZAxis->GetLabelTextProperty()->ShallowCopy(aTLProp);;
118
119   aTLProp->SetColor(1,0,0);
120   if (this->XAxis->GetLabelTextProperty())
121     this->XAxis->GetTitleTextProperty()->ShallowCopy(aTLProp);
122   aTLProp->SetColor(0,1,0);
123   if (this->YAxis->GetLabelTextProperty())
124     this->YAxis->GetTitleTextProperty()->ShallowCopy(aTLProp);
125   aTLProp->SetColor(0,0,1);
126   if (this->ZAxis->GetLabelTextProperty())
127     this->ZAxis->GetTitleTextProperty()->ShallowCopy(aTLProp);
128   
129   aTLProp->Delete();
130   
131 }
132
133 //----------------------------------------------------------------------------
134 SVTK_CubeAxesActor2D::~SVTK_CubeAxesActor2D()
135 {
136   this->wireActorXY->Delete();
137   this->wireActorYZ->Delete();
138   this->wireActorXZ->Delete();
139
140   this->planeXY->Delete();
141   this->planeYZ->Delete();
142   this->planeXZ->Delete();
143
144   this->rgridMapperXY->Delete();
145   this->rgridMapperYZ->Delete();
146   this->rgridMapperXZ->Delete();
147 }
148
149 //----------------------------------------------------------------------------
150 // Static variable describes connections in cube.
151 static int Conn[8][3] = {{1,2,4}, {0,3,5}, {3,0,6}, {2,1,7},
152                          {5,6,0}, {4,7,1}, {7,4,2}, {6,5,3}};
153
154 //----------------------------------------------------------------------------
155 // Project the bounding box and compute edges on the border of the bounding
156 // cube. Determine which parts of the edges are visible via intersection 
157 // with the boundary of the viewport (minus borders).
158 int SVTK_CubeAxesActor2D::RenderOverlay(vtkViewport *viewport)
159 {
160   int renderedSomething=0;
161
162   // Initialization
163   if ( ! this->RenderSomething )
164     {
165     return 0;
166     }
167   
168   //Render the axes
169   if ( this->XAxisVisibility )
170     {
171     renderedSomething += this->XAxis->RenderOverlay(viewport);
172     }
173   if ( this->YAxisVisibility )
174     {
175     renderedSomething += this->YAxis->RenderOverlay(viewport);
176     }
177   if ( this->ZAxisVisibility )
178     {
179     renderedSomething += this->ZAxis->RenderOverlay(viewport);
180     }
181   
182   bool RX=false,RY=false;
183   if (this->XAxisVisibility){
184     this->wireActorXY->RenderOverlay(viewport);
185     this->wireActorXZ->RenderOverlay(viewport);
186     RX = true;
187   }
188   if (this->YAxisVisibility){
189     if(!RX) this->wireActorXY->RenderOverlay(viewport);
190     this->wireActorYZ->RenderOverlay(viewport);
191     RY = true;
192   }
193   if (this->ZAxisVisibility){
194     if(!RX) this->wireActorXZ->RenderOverlay(viewport);
195     if(!RY) this->wireActorYZ->RenderOverlay(viewport);
196   }
197
198   return renderedSomething;
199 }
200
201 static void ChangeValues(float* aArray1,float* aArray2,float *aRange1,float* aRange2,bool theY){
202   float tmp=-1000;
203   if (!theY){
204     for (int i=0; i<4; i++){
205       tmp = aArray1[i]; aArray1[i] = aArray2[i]; aArray2[i] = tmp;
206     }
207 #ifndef WNT
208     for(int i=0;i<2; i++){
209 #else
210     for(i=0;i<2; i++){
211 #endif
212       tmp = aRange1[i]; aRange1[i] = aRange2[i]; aRange2[i] = tmp;
213     }
214   }
215   else{
216     tmp = aArray1[2]; aArray1[2] = aArray2[0]; aArray2[0] = tmp;
217     tmp = aArray1[3]; aArray1[3] = aArray2[1]; aArray2[1] = tmp;
218     tmp = aArray1[0]; aArray1[0] = aArray2[2]; aArray2[2] = tmp;
219     tmp = aArray1[1]; aArray1[1] = aArray2[3]; aArray2[3] = tmp;
220
221     tmp = aRange1[0]; aRange1[0] = aRange2[1]; aRange2[1] = tmp;
222     tmp = aRange1[1]; aRange1[1] = aRange2[0]; aRange2[0] = tmp;
223   }
224 }
225
226 static void ChangeArrays(float* xCoords,float* yCoords,float* zCoords,
227                          float* xRange,float* yRange,float* zRange,
228                          const int xAxes,const int yAxes, const int zAxes)
229 {
230   if ( xAxes == 0 && yAxes == 2 && zAxes == 1)
231     ChangeValues(yCoords,zCoords,yRange,zRange,true);
232   else if (xAxes == 1 && yAxes == 0 && zAxes == 2)
233     ChangeValues(xCoords,yCoords,xRange,yRange,true);
234   else if (xAxes == 1 && yAxes == 2 && zAxes == 0){
235     ChangeValues(xCoords,zCoords,xRange,zRange,false);
236     // xAxes == 0 && yAxes == 2 && zAxes == 1
237     ChangeValues(yCoords,zCoords,yRange,zRange,true);
238   } else if (xAxes == 2 && yAxes == 0 && zAxes == 1){
239     ChangeValues(xCoords,yCoords,xRange,yRange,true);
240     // xAxes == 0 && yAxes == 2 && zAxes == 1
241     ChangeValues(zCoords,yCoords,zRange,yRange,true);
242   } else if (xAxes == 2 && yAxes == 1 && zAxes == 0)
243     ChangeValues(zCoords,xCoords,zRange,xRange,false);
244 }
245
246 //----------------------------------------------------------------------------
247 // Project the bounding box and compute edges on the border of the bounding
248 // cube. Determine which parts of the edges are visible via intersection 
249 // with the boundary of the viewport (minus borders).
250 int SVTK_CubeAxesActor2D::RenderOpaqueGeometry(vtkViewport *viewport)
251 {
252   float bounds[6], slope = 0.0, minSlope, num, den;
253   float pts[8][3], d2, d2Min, min;
254   int i, idx = 0;
255   int xIdx, yIdx = 0, zIdx = 0, zIdx2, renderedSomething=0;
256   int xAxes = 0, yAxes, zAxes;
257
258   // Initialization
259   if ( !this->Camera )
260     {
261     vtkErrorMacro(<<"No camera!");
262     this->RenderSomething = 0;
263     return 0;
264     }
265   
266   this->RenderSomething = 1;
267
268   // determine the bounds to use
269   this->GetBounds(bounds);
270
271   // Build the axes (almost always needed so we don't check mtime)
272   // Transform all points into display coordinates
273   this->TransformBounds(viewport, bounds, pts);
274
275   // Find the portion of the bounding box that fits within the viewport,
276   if ( this->ClipBounds(viewport, pts, bounds) == 0 )
277     {
278     this->RenderSomething = 0;
279     return 0;
280     }
281
282   // Take into account the inertia. Process only so often.
283   if ( this->RenderCount++ == 0 || !(this->RenderCount % this->Inertia) )
284     {
285     // Okay, we have a bounding box, maybe clipped and scaled, that is visible.
286     // We setup the axes depending on the fly mode.
287     if ( this->FlyMode == VTK_FLY_CLOSEST_TRIAD )
288       {
289       // Loop over points and find the closest point to the camera
290       min = VTK_LARGE_FLOAT;
291       for (i=0; i < 8; i++)
292         {
293         if ( pts[i][2] < min )
294           {
295           idx = i;
296           min = pts[i][2];
297           }
298         }
299
300       // Setup the three axes to be drawn
301       xAxes = 0;
302       xIdx = Conn[idx][0];
303       yAxes = 1;
304       yIdx = Conn[idx][1];
305       zAxes = 2;
306       zIdx = idx;
307       zIdx2 = Conn[idx][2];
308       }
309     else
310       {
311       float e1[2], e2[2], e3[2];
312
313       // Find distance to origin
314       d2Min = VTK_LARGE_FLOAT;
315       for (i=0; i < 8; i++)
316         {
317         d2 = pts[i][0]*pts[i][0] + pts[i][1]*pts[i][1];
318         if ( d2 < d2Min )
319           {
320           d2Min = d2;
321           idx = i;
322           }
323         }
324
325       // find minimum slope point connected to closest point and on 
326       // right side (in projected coordinates). This is the first edge.
327       minSlope = VTK_LARGE_FLOAT;
328       for (xIdx=0, i=0; i<3; i++)
329         {
330         num = (pts[Conn[idx][i]][1] - pts[idx][1]);
331         den = (pts[Conn[idx][i]][0] - pts[idx][0]);
332         if ( den != 0.0 )
333           {
334           slope = num / den;
335           }
336         if ( slope < minSlope && den > 0 )
337           {
338           xIdx = Conn[idx][i];
339           yIdx = Conn[idx][(i+1)%3];
340           zIdx = Conn[idx][(i+2)%3];
341           xAxes = i;
342           minSlope = slope;
343           }
344         }
345
346       // find edge (connected to closest point) on opposite side
347       for ( i=0; i<2; i++)
348         {
349         e1[i] = (pts[xIdx][i] - pts[idx][i]);
350         e2[i] = (pts[yIdx][i] - pts[idx][i]);
351         e3[i] = (pts[zIdx][i] - pts[idx][i]);
352         }
353       vtkMath::Normalize2D(e1);
354       vtkMath::Normalize2D(e2);
355       vtkMath::Normalize2D(e3);
356
357       if ( vtkMath::Dot2D(e1,e2) < vtkMath::Dot2D(e1,e3) )
358         {
359         yAxes = (xAxes + 1) % 3;
360         }
361       else
362         {
363         yIdx = zIdx;
364         yAxes = (xAxes + 2) % 3;
365         }
366
367       // Find the final point by determining which global x-y-z axes have not 
368       // been represented, and then determine the point closest to the viewer.
369       zAxes = (xAxes != 0 && yAxes != 0 ? 0 :
370               (xAxes != 1 && yAxes != 1 ? 1 : 2));
371       if ( pts[Conn[xIdx][zAxes]][2] < pts[Conn[yIdx][zAxes]][2] )
372         {
373         zIdx = xIdx;
374         zIdx2 = Conn[xIdx][zAxes];
375         }
376       else
377         {
378         zIdx = yIdx;
379         zIdx2 = Conn[yIdx][zAxes];
380         }
381       }//else boundary edges fly mode
382     this->InertiaAxes[0] = idx;
383     this->InertiaAxes[1] = xIdx;
384     this->InertiaAxes[2] = yIdx;
385     this->InertiaAxes[3] = zIdx;
386     this->InertiaAxes[4] = zIdx2;
387     this->InertiaAxes[5] = xAxes;
388     this->InertiaAxes[6] = yAxes;
389     this->InertiaAxes[7] = zAxes;
390     } //inertia
391   else
392     {
393     idx = this->InertiaAxes[0];
394     xIdx = this->InertiaAxes[1];
395     yIdx = this->InertiaAxes[2];
396     zIdx = this->InertiaAxes[3];
397     zIdx2 = this->InertiaAxes[4];
398     xAxes = this->InertiaAxes[5];
399     yAxes = this->InertiaAxes[6];
400     zAxes = this->InertiaAxes[7];
401     }
402
403   // Setup the axes for plotting
404   float xCoords[4], yCoords[4], zCoords[4], xRange[2], yRange[2], zRange[2];
405   this->AdjustAxes(pts, bounds, idx, xIdx, yIdx, zIdx, zIdx2, 
406                    xAxes, yAxes, zAxes, 
407                    xCoords, yCoords, zCoords, xRange, yRange, zRange);
408
409   // Upate axes
410   this->Labels[0] = this->XLabel;
411   this->Labels[1] = this->YLabel;
412   this->Labels[2] = this->ZLabel;
413
414   // correct XAxis, YAxis, ZAxis, which must be 
415   // parallel OX, OY, OZ system coordinates
416   // if xAxes=0 yAxes=1 zAxes=2 - good situation
417   if (!(xAxes == 0 && yAxes == 1 && zAxes == 2))
418     ChangeArrays(xCoords,yCoords,zCoords,
419                  xRange,yRange,zRange,
420                  xAxes,yAxes,zAxes);
421
422   double aTScale[3];
423   if(m_Transform.GetPointer() != NULL)
424     m_Transform->GetMatrixScale(aTScale);
425
426   this->XAxis->GetPositionCoordinate()->SetValue(xCoords[0], xCoords[1]);
427   this->XAxis->GetPosition2Coordinate()->SetValue(xCoords[2], xCoords[3]);
428   if(m_Transform.GetPointer() != NULL) this->XAxis->SetRange(xRange[0]/aTScale[0], xRange[1]/aTScale[0]);
429   else this->XAxis->SetRange(xRange[0], xRange[1]);
430
431   this->YAxis->GetPositionCoordinate()->SetValue(yCoords[2], yCoords[3]);
432   this->YAxis->GetPosition2Coordinate()->SetValue(yCoords[0], yCoords[1]);
433   if(m_Transform.GetPointer() != NULL) this->YAxis->SetRange(yRange[1]/aTScale[1], yRange[0]/aTScale[1]);
434   else this->YAxis->SetRange(yRange[1], yRange[0]);
435
436   this->ZAxis->GetPositionCoordinate()->SetValue(zCoords[0], zCoords[1]);
437   this->ZAxis->GetPosition2Coordinate()->SetValue(zCoords[2], zCoords[3]);
438   if(m_Transform.GetPointer() != NULL) this->ZAxis->SetRange(zRange[0]/aTScale[2], zRange[1]/aTScale[2]);
439   else this->ZAxis->SetRange(zRange[0], zRange[1]);
440
441   int numOfLabelsX = this->XAxis->GetNumberOfLabels();
442   int numOfLabelsY = this->YAxis->GetNumberOfLabels();
443   int numOfLabelsZ = this->ZAxis->GetNumberOfLabels();
444
445   // XCoords coordinates for X grid
446   vtkFloatArray *XCoords = vtkFloatArray::New();
447 #ifndef WNT
448   for(int i=0;i<numOfLabelsX;i++){
449 #else
450   for(i=0;i<numOfLabelsX;i++){
451 #endif
452     float val = bounds[0]+i*(bounds[1]-bounds[0])/(numOfLabelsX-1);
453     XCoords->InsertNextValue(val);
454   }
455   // YCoords coordinates for Y grid
456   vtkFloatArray *YCoords = vtkFloatArray::New();
457 #ifndef WNT
458   for(int i=0;i<numOfLabelsX;i++){
459 #else
460   for(i=0;i<numOfLabelsX;i++){
461 #endif
462     float val = bounds[2]+i*(bounds[3]-bounds[2])/(numOfLabelsY-1);
463     YCoords->InsertNextValue(val);
464   }
465   // ZCoords coordinates for Z grid
466   vtkFloatArray *ZCoords = vtkFloatArray::New();
467 #ifndef WNT
468   for(int i=0;i<numOfLabelsZ;i++){
469 #else
470   for(i=0;i<numOfLabelsZ;i++){
471 #endif
472     float val = bounds[4]+i*(bounds[5]-bounds[4])/(numOfLabelsZ-1);
473     ZCoords->InsertNextValue(val);
474   }
475
476   vtkRectilinearGrid *rgrid = vtkRectilinearGrid::New();
477   rgrid->SetDimensions(numOfLabelsX,numOfLabelsY,numOfLabelsZ);
478   rgrid->SetXCoordinates(XCoords);
479   rgrid->SetYCoordinates(YCoords);
480   rgrid->SetZCoordinates(ZCoords);
481
482   this->planeXY->SetInput(rgrid);
483   this->planeYZ->SetInput(rgrid);
484   this->planeXZ->SetInput(rgrid);
485
486   rgrid->Delete();
487
488   float aCPosition[3];
489   float aCDirection[3];
490   this->Camera->GetPosition(aCPosition);
491   this->Camera->GetDirectionOfProjection(aCDirection);
492
493   // culculate placement of XY
494   bool replaceXY=false;
495   bool replaceYZ=false;
496   bool replaceXZ=false;
497   float p[6][3]; // centers of planes
498   float vecs[6][3]; // 6 vectors from camera position to centers
499
500   float aMiddleX = (XCoords->GetValue(0) + XCoords->GetValue(numOfLabelsX-1))/2;
501   float aMiddleY = (YCoords->GetValue(0) + YCoords->GetValue(numOfLabelsY-1))/2;
502   float aMiddleZ = (ZCoords->GetValue(0) + ZCoords->GetValue(numOfLabelsZ-1))/2;
503
504   // plane XY
505   p[0][0] = aMiddleX; // plane X=0.5 Y=0.5 Z=0
506   p[0][1] = aMiddleY;
507   p[0][2] = ZCoords->GetValue(0);
508
509   p[1][0] = aMiddleX; // plane X=0.5 Y=0.5 Z=1
510   p[1][1] = aMiddleY;
511   p[1][2] = ZCoords->GetValue(numOfLabelsZ-1);
512
513   // plane YZ
514   p[2][0] = XCoords->GetValue(0); // plane X=0 Y=0.5 Z=0.5
515   p[2][1] = aMiddleY;
516   p[2][2] = aMiddleZ;
517
518   p[3][0] = XCoords->GetValue(numOfLabelsX-1);
519   p[3][1] = aMiddleY;
520   p[3][2] = aMiddleZ;
521
522   // plane XZ
523   p[4][0] = aMiddleX; // plane X=0.5 Y=0 Z=0.5
524   p[4][1] = YCoords->GetValue(0);
525   p[4][2] = aMiddleZ;
526
527   p[5][0] = aMiddleX; // plane X=0.5 Y=1 Z=0.5
528   p[5][1] = YCoords->GetValue(numOfLabelsY-1);
529   p[5][2] = aMiddleZ;
530
531 #ifndef WNT
532   for(int i=0;i<3;i++) 
533 #else
534   for(i=0;i<3;i++) 
535 #endif
536     for(int j=0;j<6;j++) vecs[j][i] = p[j][i] - aCPosition[i];
537
538   if ( vtkMath::Dot(vecs[0],aCDirection) < vtkMath::Dot(vecs[1],aCDirection))
539     replaceXY = true;
540   if ( vtkMath::Dot(vecs[2],aCDirection) < vtkMath::Dot(vecs[3],aCDirection))
541     replaceYZ = true;
542   if ( vtkMath::Dot(vecs[4],aCDirection) < vtkMath::Dot(vecs[5],aCDirection))
543     replaceXZ = true;
544
545   if(replaceXY) this->planeXY->SetExtent(0,numOfLabelsX, 0,numOfLabelsY, numOfLabelsZ,numOfLabelsZ);
546   else this->planeXY->SetExtent(0,numOfLabelsX, 0,numOfLabelsY, 0,0);
547
548   if(replaceYZ) this->planeYZ->SetExtent(numOfLabelsX,numOfLabelsX, 0,numOfLabelsY, 0,numOfLabelsZ);
549   else this->planeYZ->SetExtent(0,0, 0,numOfLabelsY, 0,numOfLabelsZ);
550
551   if(replaceXZ) this->planeXZ->SetExtent(0,numOfLabelsX, numOfLabelsY,numOfLabelsY, 0,numOfLabelsZ);
552   else this->planeXZ->SetExtent(0,numOfLabelsX, 0,0, 0,numOfLabelsZ);
553
554   XCoords->Delete();
555   YCoords->Delete();
556   ZCoords->Delete();
557
558   float color[3];
559
560   this->GetProperty()->GetColor(color);
561   this->wireActorXY->GetProperty()->SetColor(color);
562   this->wireActorYZ->GetProperty()->SetColor(color);
563   this->wireActorXZ->GetProperty()->SetColor(color);
564
565   /*
566   // Rebuid text props
567   // Perform shallow copy here since each individual axis can be
568   // accessed through the class API (i.e. each individual axis text prop
569   // can be changed). Therefore, we can not just assign pointers otherwise
570   // each individual axis text prop would point to the same text prop.
571
572   if (this->AxisLabelTextProperty &&
573       this->AxisLabelTextProperty->GetMTime() > this->BuildTime)
574     {
575     if (this->XAxis->GetLabelTextProperty())
576       {
577       this->XAxis->GetLabelTextProperty()->ShallowCopy(
578         this->AxisLabelTextProperty);
579       }
580     if (this->YAxis->GetLabelTextProperty())
581       {
582       this->YAxis->GetLabelTextProperty()->ShallowCopy(
583         this->AxisLabelTextProperty);
584       }
585     if (this->ZAxis->GetLabelTextProperty())
586       {
587       this->ZAxis->GetLabelTextProperty()->ShallowCopy(
588         this->AxisLabelTextProperty);
589       }
590     }
591
592   if (this->AxisTitleTextProperty &&
593       this->AxisTitleTextProperty->GetMTime() > this->BuildTime)
594     {
595     if (this->XAxis->GetLabelTextProperty())
596       {
597       this->XAxis->GetTitleTextProperty()->ShallowCopy(
598         this->AxisTitleTextProperty);
599       }
600     if (this->YAxis->GetLabelTextProperty())
601       {
602       this->YAxis->GetTitleTextProperty()->ShallowCopy(
603         this->AxisTitleTextProperty);
604       }
605     if (this->ZAxis->GetLabelTextProperty())
606       {
607       this->ZAxis->GetTitleTextProperty()->ShallowCopy(
608         this->AxisTitleTextProperty);
609       }
610     }
611   */  
612   this->BuildTime.Modified();
613
614   //Render the axes
615   if ( this->XAxisVisibility )
616   {
617     renderedSomething += this->XAxis->RenderOpaqueGeometry(viewport);
618   }
619   if ( this->YAxisVisibility )
620   {
621     renderedSomething += this->YAxis->RenderOpaqueGeometry(viewport);
622   }
623   if ( this->ZAxisVisibility )
624   {
625     renderedSomething += this->ZAxis->RenderOpaqueGeometry(viewport);
626   }
627
628   bool RX=false,RY=false;
629   if (this->XAxisVisibility){
630     this->wireActorXY->RenderOpaqueGeometry(viewport);
631     this->wireActorXZ->RenderOpaqueGeometry(viewport);
632     RX = true;
633   }
634   if (this->YAxisVisibility){
635     if(!RX) this->wireActorXY->RenderOpaqueGeometry(viewport);
636     this->wireActorYZ->RenderOpaqueGeometry(viewport);
637     RY = true;
638   }
639   if (this->ZAxisVisibility){
640     if(!RX) this->wireActorXZ->RenderOpaqueGeometry(viewport);
641     if(!RY) this->wireActorYZ->RenderOpaqueGeometry(viewport);
642   }
643
644   return renderedSomething;
645 }
646
647 //----------------------------------------------------------------------------
648 // Release any graphics resources that are being consumed by this actor.
649 // The parameter window could be used to determine which graphic
650 // resources to release.
651 void SVTK_CubeAxesActor2D::ReleaseGraphicsResources(vtkWindow *win)
652 {
653   this->XAxis->ReleaseGraphicsResources(win);
654   this->YAxis->ReleaseGraphicsResources(win);
655   this->ZAxis->ReleaseGraphicsResources(win);
656
657   this->wireActorXY->ReleaseGraphicsResources(win);
658   this->wireActorYZ->ReleaseGraphicsResources(win);
659   this->wireActorXZ->ReleaseGraphicsResources(win);
660 }
661
662 void SVTK_CubeAxesActor2D::SetTransform(VTKViewer_Transform* theTransform){
663   this->m_Transform = theTransform;
664 }
665
666 VTKViewer_Transform* SVTK_CubeAxesActor2D::GetTransform(){
667   return (this->m_Transform.GetPointer());
668 }