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