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