Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/gui.git] / src / SVTK / SVTK_CubeAxesActor2D.cxx
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  SALOME OBJECT : kernel of SALOME component
24 //  File   : SVTK_CubeAxesActor2D.cxx
25 //  Author : Eugeny Nikolaev
26
27 #include "SVTK_CubeAxesActor2D.h"
28 #include "VTKViewer_Transform.h"
29
30 #include <vtkPolyDataMapper.h>
31 #include <vtkRectilinearGridGeometryFilter.h>
32 #include <vtkActor.h>
33 #include <vtkCubeAxesActor2D.h>
34 #include <vtkAxisActor2D.h>
35 #include <vtkCamera.h>
36 #include <vtkDataSet.h>
37 #include <vtkMath.h>
38 #include <vtkObjectFactory.h>
39 #include <vtkTextProperty.h>
40 #include <vtkViewport.h>
41 #include <vtkFloatArray.h>
42 #include <vtkRectilinearGrid.h>
43 #include <vtkProperty.h>
44 #include <vtkProperty2D.h>
45
46 vtkCxxRevisionMacro(SVTK_CubeAxesActor2D, "$Revision$");
47 vtkStandardNewMacro(SVTK_CubeAxesActor2D);
48
49 // Instantiate this object.
50 SVTK_CubeAxesActor2D::SVTK_CubeAxesActor2D()
51 {
52   this->wireActorXY = vtkActor::New();
53   this->wireActorYZ = vtkActor::New();
54   this->wireActorXZ = vtkActor::New();
55
56   this->planeXY = vtkRectilinearGridGeometryFilter::New();
57   this->planeYZ = vtkRectilinearGridGeometryFilter::New();
58   this->planeXZ = vtkRectilinearGridGeometryFilter::New();
59
60   this->rgridMapperXY = vtkPolyDataMapper::New();
61   this->rgridMapperYZ = vtkPolyDataMapper::New();
62   this->rgridMapperXZ = vtkPolyDataMapper::New();
63
64   this->rgridMapperXY->SetInput(this->planeXY->GetOutput());
65   this->rgridMapperYZ->SetInput(this->planeYZ->GetOutput());
66   this->rgridMapperXZ->SetInput(this->planeXZ->GetOutput());
67
68   this->wireActorXY->SetMapper(rgridMapperXY);
69   this->wireActorYZ->SetMapper(rgridMapperYZ);
70   this->wireActorXZ->SetMapper(rgridMapperXZ);
71
72   this->wireActorXY->GetProperty()->SetRepresentationToWireframe();
73   this->wireActorYZ->GetProperty()->SetRepresentationToWireframe();
74   this->wireActorXZ->GetProperty()->SetRepresentationToWireframe();
75
76   // setting ambient to 1 (if no - incorrect reaction on light)
77   this->wireActorXY->GetProperty()->SetAmbient(1);
78   this->wireActorYZ->GetProperty()->SetAmbient(1);
79   this->wireActorXZ->GetProperty()->SetAmbient(1);
80
81   this->XAxis->SetTitle(this->XLabel);
82   this->YAxis->SetTitle(this->YLabel);
83   this->ZAxis->SetTitle(this->ZLabel);
84   
85   this->XAxis->SetNumberOfLabels(this->NumberOfLabels);
86   this->YAxis->SetNumberOfLabels(this->NumberOfLabels);
87   this->ZAxis->SetNumberOfLabels(this->NumberOfLabels);
88  
89   this->XAxis->SetLabelFormat(this->LabelFormat);
90   this->YAxis->SetLabelFormat(this->LabelFormat);
91   this->ZAxis->SetLabelFormat(this->LabelFormat);
92   
93   this->XAxis->SetFontFactor(this->FontFactor);
94   this->YAxis->SetFontFactor(this->FontFactor);
95   this->ZAxis->SetFontFactor(this->FontFactor);
96   
97   this->XAxis->SetProperty(this->GetProperty());
98   this->YAxis->SetProperty(this->GetProperty());
99   this->ZAxis->SetProperty(this->GetProperty());
100
101   vtkTextProperty* aTLProp = vtkTextProperty::New();
102   aTLProp->SetBold(0);
103   aTLProp->SetItalic(0);
104   aTLProp->SetShadow(0);
105   aTLProp->SetFontFamilyToArial();
106   aTLProp->SetColor(1,0,0);
107   if (this->XAxis->GetLabelTextProperty())
108     this->XAxis->GetLabelTextProperty()->ShallowCopy(aTLProp);
109   aTLProp->SetColor(0,1,0);
110   if (this->YAxis->GetLabelTextProperty())
111     this->YAxis->GetLabelTextProperty()->ShallowCopy(aTLProp);
112   aTLProp->SetColor(0,0,1);
113   if (this->ZAxis->GetLabelTextProperty())
114     this->ZAxis->GetLabelTextProperty()->ShallowCopy(aTLProp);;
115
116   aTLProp->SetColor(1,0,0);
117   if (this->XAxis->GetLabelTextProperty())
118     this->XAxis->GetTitleTextProperty()->ShallowCopy(aTLProp);
119   aTLProp->SetColor(0,1,0);
120   if (this->YAxis->GetLabelTextProperty())
121     this->YAxis->GetTitleTextProperty()->ShallowCopy(aTLProp);
122   aTLProp->SetColor(0,0,1);
123   if (this->ZAxis->GetLabelTextProperty())
124     this->ZAxis->GetTitleTextProperty()->ShallowCopy(aTLProp);
125   
126   aTLProp->Delete();
127   
128 }
129
130 SVTK_CubeAxesActor2D::~SVTK_CubeAxesActor2D()
131 {
132   this->wireActorXY->Delete();
133   this->wireActorYZ->Delete();
134   this->wireActorXZ->Delete();
135
136   this->planeXY->Delete();
137   this->planeYZ->Delete();
138   this->planeXZ->Delete();
139
140   this->rgridMapperXY->Delete();
141   this->rgridMapperYZ->Delete();
142   this->rgridMapperXZ->Delete();
143 }
144
145 // Static variable describes connections in cube.
146 static int Conn[8][3] = {{1,2,4}, {0,3,5}, {3,0,6}, {2,1,7},
147                          {5,6,0}, {4,7,1}, {7,4,2}, {6,5,3}};
148
149 // Project the bounding box and compute edges on the border of the bounding
150 // cube. Determine which parts of the edges are visible via intersection 
151 // with the boundary of the viewport (minus borders).
152 int SVTK_CubeAxesActor2D::RenderOverlay(vtkViewport *viewport)
153 {
154   int renderedSomething=0;
155
156   // Initialization
157   if ( ! this->RenderSomething )
158     {
159     return 0;
160     }
161   
162   //Render the axes
163   if ( this->XAxisVisibility )
164     {
165     renderedSomething += this->XAxis->RenderOverlay(viewport);
166     }
167   if ( this->YAxisVisibility )
168     {
169     renderedSomething += this->YAxis->RenderOverlay(viewport);
170     }
171   if ( this->ZAxisVisibility )
172     {
173     renderedSomething += this->ZAxis->RenderOverlay(viewport);
174     }
175   
176   bool RX=false,RY=false;
177   if (this->XAxisVisibility){
178     this->wireActorXY->RenderOverlay(viewport);
179     this->wireActorXZ->RenderOverlay(viewport);
180     RX = true;
181   }
182   if (this->YAxisVisibility){
183     if(!RX) this->wireActorXY->RenderOverlay(viewport);
184     this->wireActorYZ->RenderOverlay(viewport);
185     RY = true;
186   }
187   if (this->ZAxisVisibility){
188     if(!RX) this->wireActorXZ->RenderOverlay(viewport);
189     if(!RY) this->wireActorYZ->RenderOverlay(viewport);
190   }
191
192   return renderedSomething;
193 }
194
195 static void ChangeValues(vtkFloatingPointType* aArray1,
196                          vtkFloatingPointType* aArray2,
197                          vtkFloatingPointType *aRange1,
198                          vtkFloatingPointType* aRange2,
199                          bool theY)
200 {
201   vtkFloatingPointType tmp=-1000;
202   if (!theY){
203     for (int i=0; i<4; i++){
204       tmp = aArray1[i]; aArray1[i] = aArray2[i]; aArray2[i] = tmp;
205     }
206     for(int i=0;i<2; i++){
207       tmp = aRange1[i]; aRange1[i] = aRange2[i]; aRange2[i] = tmp;
208     }
209   }
210   else{
211     tmp = aArray1[2]; aArray1[2] = aArray2[0]; aArray2[0] = tmp;
212     tmp = aArray1[3]; aArray1[3] = aArray2[1]; aArray2[1] = tmp;
213     tmp = aArray1[0]; aArray1[0] = aArray2[2]; aArray2[2] = tmp;
214     tmp = aArray1[1]; aArray1[1] = aArray2[3]; aArray2[3] = tmp;
215
216     tmp = aRange1[0]; aRange1[0] = aRange2[1]; aRange2[1] = tmp;
217     tmp = aRange1[1]; aRange1[1] = aRange2[0]; aRange2[0] = tmp;
218   }
219 }
220
221 static void ChangeArrays(vtkFloatingPointType* xCoords,
222                          vtkFloatingPointType* yCoords,
223                          vtkFloatingPointType* zCoords,
224                          vtkFloatingPointType* xRange,
225                          vtkFloatingPointType* yRange,
226                          vtkFloatingPointType* zRange,
227                          const int xAxes,
228                          const int yAxes, 
229                          const int zAxes)
230 {
231   if ( xAxes == 0 && yAxes == 2 && zAxes == 1)
232     ChangeValues(yCoords,zCoords,yRange,zRange,true);
233   else if (xAxes == 1 && yAxes == 0 && zAxes == 2)
234     ChangeValues(xCoords,yCoords,xRange,yRange,true);
235   else if (xAxes == 1 && yAxes == 2 && zAxes == 0){
236     ChangeValues(xCoords,zCoords,xRange,zRange,false);
237     // xAxes == 0 && yAxes == 2 && zAxes == 1
238     ChangeValues(yCoords,zCoords,yRange,zRange,true);
239   } else if (xAxes == 2 && yAxes == 0 && zAxes == 1){
240     ChangeValues(xCoords,yCoords,xRange,yRange,true);
241     // xAxes == 0 && yAxes == 2 && zAxes == 1
242     ChangeValues(zCoords,yCoords,zRange,yRange,true);
243   } else if (xAxes == 2 && yAxes == 1 && zAxes == 0)
244     ChangeValues(zCoords,xCoords,zRange,xRange,false);
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   vtkFloatingPointType bounds[6], slope = 0.0, minSlope, num, den;
253   vtkFloatingPointType 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       vtkFloatingPointType 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   vtkFloatingPointType 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   for(int i=0;i<numOfLabelsX;i++){
448     vtkFloatingPointType val = bounds[0]+i*(bounds[1]-bounds[0])/(numOfLabelsX-1);
449     XCoords->InsertNextValue(val);
450   }
451   // YCoords coordinates for Y grid
452   vtkFloatArray *YCoords = vtkFloatArray::New();
453   for(int i=0;i<numOfLabelsX;i++){
454     vtkFloatingPointType val = bounds[2]+i*(bounds[3]-bounds[2])/(numOfLabelsY-1);
455     YCoords->InsertNextValue(val);
456   }
457   // ZCoords coordinates for Z grid
458   vtkFloatArray *ZCoords = vtkFloatArray::New();
459   for(int i=0;i<numOfLabelsZ;i++){
460     vtkFloatingPointType val = bounds[4]+i*(bounds[5]-bounds[4])/(numOfLabelsZ-1);
461     ZCoords->InsertNextValue(val);
462   }
463
464   vtkRectilinearGrid *rgrid = vtkRectilinearGrid::New();
465   rgrid->SetDimensions(numOfLabelsX,numOfLabelsY,numOfLabelsZ);
466   rgrid->SetXCoordinates(XCoords);
467   rgrid->SetYCoordinates(YCoords);
468   rgrid->SetZCoordinates(ZCoords);
469
470   this->planeXY->SetInput(rgrid);
471   this->planeYZ->SetInput(rgrid);
472   this->planeXZ->SetInput(rgrid);
473
474   rgrid->Delete();
475
476   vtkFloatingPointType aCPosition[3];
477   vtkFloatingPointType aCDirection[3];
478   this->Camera->GetPosition(aCPosition);
479   this->Camera->GetDirectionOfProjection(aCDirection);
480
481   // culculate placement of XY
482   bool replaceXY=false;
483   bool replaceYZ=false;
484   bool replaceXZ=false;
485   vtkFloatingPointType p[6][3]; // centers of planes
486   vtkFloatingPointType vecs[6][3]; // 6 vectors from camera position to centers
487
488   vtkFloatingPointType aMiddleX = (XCoords->GetValue(0) + XCoords->GetValue(numOfLabelsX-1))/2;
489   vtkFloatingPointType aMiddleY = (YCoords->GetValue(0) + YCoords->GetValue(numOfLabelsY-1))/2;
490   vtkFloatingPointType aMiddleZ = (ZCoords->GetValue(0) + ZCoords->GetValue(numOfLabelsZ-1))/2;
491
492   // plane XY
493   p[0][0] = aMiddleX; // plane X=0.5 Y=0.5 Z=0
494   p[0][1] = aMiddleY;
495   p[0][2] = ZCoords->GetValue(0);
496
497   p[1][0] = aMiddleX; // plane X=0.5 Y=0.5 Z=1
498   p[1][1] = aMiddleY;
499   p[1][2] = ZCoords->GetValue(numOfLabelsZ-1);
500
501   // plane YZ
502   p[2][0] = XCoords->GetValue(0); // plane X=0 Y=0.5 Z=0.5
503   p[2][1] = aMiddleY;
504   p[2][2] = aMiddleZ;
505
506   p[3][0] = XCoords->GetValue(numOfLabelsX-1);
507   p[3][1] = aMiddleY;
508   p[3][2] = aMiddleZ;
509
510   // plane XZ
511   p[4][0] = aMiddleX; // plane X=0.5 Y=0 Z=0.5
512   p[4][1] = YCoords->GetValue(0);
513   p[4][2] = aMiddleZ;
514
515   p[5][0] = aMiddleX; // plane X=0.5 Y=1 Z=0.5
516   p[5][1] = YCoords->GetValue(numOfLabelsY-1);
517   p[5][2] = aMiddleZ;
518
519   for(int i=0;i<3;i++) 
520     for(int j=0;j<6;j++) vecs[j][i] = p[j][i] - aCPosition[i];
521
522   if ( vtkMath::Dot(vecs[0],aCDirection) < vtkMath::Dot(vecs[1],aCDirection))
523     replaceXY = true;
524   if ( vtkMath::Dot(vecs[2],aCDirection) < vtkMath::Dot(vecs[3],aCDirection))
525     replaceYZ = true;
526   if ( vtkMath::Dot(vecs[4],aCDirection) < vtkMath::Dot(vecs[5],aCDirection))
527     replaceXZ = true;
528
529   if(replaceXY) this->planeXY->SetExtent(0,numOfLabelsX, 0,numOfLabelsY, numOfLabelsZ,numOfLabelsZ);
530   else this->planeXY->SetExtent(0,numOfLabelsX, 0,numOfLabelsY, 0,0);
531
532   if(replaceYZ) this->planeYZ->SetExtent(numOfLabelsX,numOfLabelsX, 0,numOfLabelsY, 0,numOfLabelsZ);
533   else this->planeYZ->SetExtent(0,0, 0,numOfLabelsY, 0,numOfLabelsZ);
534
535   if(replaceXZ) this->planeXZ->SetExtent(0,numOfLabelsX, numOfLabelsY,numOfLabelsY, 0,numOfLabelsZ);
536   else this->planeXZ->SetExtent(0,numOfLabelsX, 0,0, 0,numOfLabelsZ);
537
538   XCoords->Delete();
539   YCoords->Delete();
540   ZCoords->Delete();
541
542   vtkFloatingPointType color[3];
543
544   this->GetProperty()->GetColor(color);
545   this->wireActorXY->GetProperty()->SetColor(color);
546   this->wireActorYZ->GetProperty()->SetColor(color);
547   this->wireActorXZ->GetProperty()->SetColor(color);
548
549   /*
550   // Rebuid text props
551   // Perform shallow copy here since each individual axis can be
552   // accessed through the class API (i.e. each individual axis text prop
553   // can be changed). Therefore, we can not just assign pointers otherwise
554   // each individual axis text prop would point to the same text prop.
555
556   if (this->AxisLabelTextProperty &&
557       this->AxisLabelTextProperty->GetMTime() > this->BuildTime)
558     {
559     if (this->XAxis->GetLabelTextProperty())
560       {
561       this->XAxis->GetLabelTextProperty()->ShallowCopy(
562         this->AxisLabelTextProperty);
563       }
564     if (this->YAxis->GetLabelTextProperty())
565       {
566       this->YAxis->GetLabelTextProperty()->ShallowCopy(
567         this->AxisLabelTextProperty);
568       }
569     if (this->ZAxis->GetLabelTextProperty())
570       {
571       this->ZAxis->GetLabelTextProperty()->ShallowCopy(
572         this->AxisLabelTextProperty);
573       }
574     }
575
576   if (this->AxisTitleTextProperty &&
577       this->AxisTitleTextProperty->GetMTime() > this->BuildTime)
578     {
579     if (this->XAxis->GetLabelTextProperty())
580       {
581       this->XAxis->GetTitleTextProperty()->ShallowCopy(
582         this->AxisTitleTextProperty);
583       }
584     if (this->YAxis->GetLabelTextProperty())
585       {
586       this->YAxis->GetTitleTextProperty()->ShallowCopy(
587         this->AxisTitleTextProperty);
588       }
589     if (this->ZAxis->GetLabelTextProperty())
590       {
591       this->ZAxis->GetTitleTextProperty()->ShallowCopy(
592         this->AxisTitleTextProperty);
593       }
594     }
595   */  
596   this->BuildTime.Modified();
597
598   //Render the axes
599   if ( this->XAxisVisibility )
600   {
601     renderedSomething += this->XAxis->RenderOpaqueGeometry(viewport);
602   }
603   if ( this->YAxisVisibility )
604   {
605     renderedSomething += this->YAxis->RenderOpaqueGeometry(viewport);
606   }
607   if ( this->ZAxisVisibility )
608   {
609     renderedSomething += this->ZAxis->RenderOpaqueGeometry(viewport);
610   }
611
612   bool RX=false,RY=false;
613   if (this->XAxisVisibility){
614     this->wireActorXY->RenderOpaqueGeometry(viewport);
615     this->wireActorXZ->RenderOpaqueGeometry(viewport);
616     RX = true;
617   }
618   if (this->YAxisVisibility){
619     if(!RX) this->wireActorXY->RenderOpaqueGeometry(viewport);
620     this->wireActorYZ->RenderOpaqueGeometry(viewport);
621     RY = true;
622   }
623   if (this->ZAxisVisibility){
624     if(!RX) this->wireActorXZ->RenderOpaqueGeometry(viewport);
625     if(!RY) this->wireActorYZ->RenderOpaqueGeometry(viewport);
626   }
627
628   return renderedSomething;
629 }
630
631 // Release any graphics resources that are being consumed by this actor.
632 // The parameter window could be used to determine which graphic
633 // resources to release.
634 void SVTK_CubeAxesActor2D::ReleaseGraphicsResources(vtkWindow *win)
635 {
636   this->XAxis->ReleaseGraphicsResources(win);
637   this->YAxis->ReleaseGraphicsResources(win);
638   this->ZAxis->ReleaseGraphicsResources(win);
639
640   this->wireActorXY->ReleaseGraphicsResources(win);
641   this->wireActorYZ->ReleaseGraphicsResources(win);
642   this->wireActorXZ->ReleaseGraphicsResources(win);
643 }
644
645 void SVTK_CubeAxesActor2D::SetTransform(VTKViewer_Transform* theTransform){
646   this->m_Transform = theTransform;
647 }
648
649 VTKViewer_Transform* SVTK_CubeAxesActor2D::GetTransform(){
650   return (this->m_Transform.GetPointer());
651 }