]> SALOME platform Git repositories - modules/gui.git/blob - src/SVTK/vtkPVAxesActor.cxx
Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/gui.git] / src / SVTK / vtkPVAxesActor.cxx
1 /*=========================================================================
2
3    Program: ParaView
4    Module:    $RCSfile$
5
6    Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
7    All rights reserved.
8
9    ParaView is a free software; you can redistribute it and/or modify it
10    under the terms of the ParaView license version 1.2. 
11
12    See License_v1.2.txt for the full ParaView license.
13    A copy of this license can be obtained by contacting
14    Kitware Inc.
15    28 Corporate Drive
16    Clifton Park, NY 12065
17    USA
18
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
23 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31 =========================================================================*/
32 #include "vtkPVAxesActor.h"
33 #include "vtkObject.h"
34 #include "vtkObjectFactory.h"
35
36 #include "vtkActor.h"
37 #include "vtkPropCollection.h"
38 #include "vtkProperty.h"
39 #include "vtkRenderWindow.h"
40 #include "vtkTransform.h"
41 #include "vtkCylinderSource.h"
42 #include "vtkPolyDataMapper.h"
43 #include "vtkLineSource.h"
44 #include "vtkPolyData.h"
45 #include "vtkConeSource.h"
46 #include "vtkSphereSource.h"
47 #include "vtkVectorText.h"
48 #include "vtkFollower.h"
49 #include "vtkRenderer.h"
50
51 #include <math.h>
52
53 vtkCxxRevisionMacro(vtkPVAxesActor, "$Revision$");
54 vtkStandardNewMacro(vtkPVAxesActor);
55
56 vtkCxxSetObjectMacro( vtkPVAxesActor, UserDefinedTip, vtkPolyData );
57 vtkCxxSetObjectMacro( vtkPVAxesActor, UserDefinedShaft, vtkPolyData );
58
59 //-----------------------------------------------------------------------------
60 vtkPVAxesActor::vtkPVAxesActor()
61 {
62   this->XAxisLabelText = NULL;
63   this->YAxisLabelText = NULL;
64   this->ZAxisLabelText = NULL;
65     
66   this->SetXAxisLabelText("X");
67   this->SetYAxisLabelText("Y");
68   this->SetZAxisLabelText("Z");
69   
70   //colors chosen to match the output of vtkAxes.cxx's LUT.
71   this->XAxisShaft = vtkActor::New();
72   this->XAxisShaft->GetProperty()->SetColor(1, 0, 0);
73   this->YAxisShaft = vtkActor::New();
74   this->YAxisShaft->GetProperty()->SetColor(1, 1, 0);
75   this->ZAxisShaft = vtkActor::New();
76   this->ZAxisShaft->GetProperty()->SetColor(0, 1, 0);
77
78   this->XAxisTip = vtkActor::New();
79   this->XAxisTip->GetProperty()->SetColor(1, 0, 0);
80   this->YAxisTip = vtkActor::New();
81   this->YAxisTip->GetProperty()->SetColor(1, 1, 0);
82   this->ZAxisTip = vtkActor::New();
83   this->ZAxisTip->GetProperty()->SetColor(0, 1, 0);
84
85   this->CylinderSource = vtkCylinderSource::New();
86   this->CylinderSource->SetHeight(1.0);
87   
88   this->LineSource = vtkLineSource::New();
89   this->LineSource->SetPoint1( 0.0, 0.0, 0.0 );
90   this->LineSource->SetPoint2( 0.0, 1.0, 0.0 );
91
92   this->ConeSource = vtkConeSource::New();
93   this->ConeSource->SetDirection( 0, 1, 0 );
94   this->ConeSource->SetHeight( 1.0 );
95    
96   this->SphereSource = vtkSphereSource::New();
97   
98   vtkPolyDataMapper *shaftMapper = vtkPolyDataMapper::New();
99   
100   this->XAxisShaft->SetMapper( shaftMapper );
101   this->YAxisShaft->SetMapper( shaftMapper );
102   this->ZAxisShaft->SetMapper( shaftMapper );
103   
104   shaftMapper->Delete();
105
106   vtkPolyDataMapper *tipMapper = vtkPolyDataMapper::New();
107   
108   this->XAxisTip->SetMapper( tipMapper );
109   this->YAxisTip->SetMapper( tipMapper );
110   this->ZAxisTip->SetMapper( tipMapper );
111   
112   tipMapper->Delete();
113
114   this->TotalLength[0] = 1.0;
115   this->TotalLength[1] = 1.0;
116   this->TotalLength[2] = 1.0;
117  
118   this->NormalizedShaftLength[0] = 0.8;
119   this->NormalizedShaftLength[1] = 0.8;
120   this->NormalizedShaftLength[2] = 0.8;
121
122   this->NormalizedTipLength[0] = 0.2;
123   this->NormalizedTipLength[1] = 0.2;
124   this->NormalizedTipLength[2] = 0.2;
125
126   this->ConeResolution = 16;
127   this->SphereResolution = 16;
128   this->CylinderResolution = 16;
129   
130   this->ConeRadius = 0.4;
131   this->SphereRadius = 0.5;
132   this->CylinderRadius = 0.05;
133   
134   this->XAxisLabelPosition = 1;
135   this->YAxisLabelPosition = 1;
136   this->ZAxisLabelPosition = 1;
137   
138   this->ShaftType = vtkPVAxesActor::LINE_SHAFT;
139   this->TipType   = vtkPVAxesActor::CONE_TIP;
140
141   this->UserDefinedTip = NULL;
142   this->UserDefinedShaft = NULL;
143
144   this->XAxisVectorText = vtkVectorText::New();
145   this->YAxisVectorText = vtkVectorText::New();
146   this->ZAxisVectorText = vtkVectorText::New();
147   
148   this->XAxisLabel = vtkFollower::New();
149   this->YAxisLabel = vtkFollower::New();
150   this->ZAxisLabel = vtkFollower::New();
151   
152   vtkPolyDataMapper *xmapper = vtkPolyDataMapper::New();
153   vtkPolyDataMapper *ymapper = vtkPolyDataMapper::New();
154   vtkPolyDataMapper *zmapper = vtkPolyDataMapper::New();
155   
156   xmapper->SetInput( this->XAxisVectorText->GetOutput() );
157   ymapper->SetInput( this->YAxisVectorText->GetOutput() );
158   zmapper->SetInput( this->ZAxisVectorText->GetOutput() );
159   
160   this->XAxisLabel->SetMapper( xmapper );
161   this->YAxisLabel->SetMapper( ymapper );
162   this->ZAxisLabel->SetMapper( zmapper );
163   
164   xmapper->Delete();
165   ymapper->Delete();
166   zmapper->Delete();
167   
168   this->UpdateProps();
169 }
170
171 //-----------------------------------------------------------------------------
172 vtkPVAxesActor::~vtkPVAxesActor()
173 {
174   this->CylinderSource->Delete();
175   this->LineSource->Delete();
176   this->ConeSource->Delete();
177   this->SphereSource->Delete();  
178   
179   this->XAxisShaft->Delete();
180   this->YAxisShaft->Delete();
181   this->ZAxisShaft->Delete();  
182
183   this->XAxisTip->Delete();
184   this->YAxisTip->Delete();
185   this->ZAxisTip->Delete();  
186   
187   this->SetUserDefinedTip( NULL );
188   this->SetUserDefinedShaft( NULL );
189   
190   this->SetXAxisLabelText( NULL );
191   this->SetYAxisLabelText( NULL );
192   this->SetZAxisLabelText( NULL );
193   
194   this->XAxisVectorText->Delete();
195   this->YAxisVectorText->Delete();
196   this->ZAxisVectorText->Delete();
197
198   this->XAxisLabel->Delete();
199   this->YAxisLabel->Delete();
200   this->ZAxisLabel->Delete();
201 }
202
203 //-----------------------------------------------------------------------------
204 // Shallow copy of an actor.
205 void vtkPVAxesActor::ShallowCopy(vtkProp *prop)
206 {
207   vtkPVAxesActor *a = vtkPVAxesActor::SafeDownCast(prop);
208   if ( a != NULL )
209     {
210     }
211
212   // Now do superclass
213   this->vtkProp3D::ShallowCopy(prop);
214 }
215
216 //-----------------------------------------------------------------------------
217 void vtkPVAxesActor::GetActors(vtkPropCollection *ac)
218 {
219   ac->AddItem(this->XAxisShaft);
220   ac->AddItem(this->YAxisShaft);
221   ac->AddItem(this->ZAxisShaft);
222   ac->AddItem(this->XAxisTip);
223   ac->AddItem(this->YAxisTip);
224   ac->AddItem(this->ZAxisTip);
225   ac->AddItem(this->XAxisLabel);
226   ac->AddItem(this->YAxisLabel);
227   ac->AddItem(this->ZAxisLabel);
228
229 }
230
231 //-----------------------------------------------------------------------------
232 int vtkPVAxesActor::RenderOpaqueGeometry(vtkViewport *vp)
233 {
234   int          renderedSomething = 0; 
235
236   vtkRenderer *ren = vtkRenderer::SafeDownCast( vp );
237
238   this->UpdateProps();
239   
240   this->XAxisLabel->SetCamera( ren->GetActiveCamera() );
241   this->YAxisLabel->SetCamera( ren->GetActiveCamera() );
242   this->ZAxisLabel->SetCamera( ren->GetActiveCamera() );
243   
244   this->XAxisShaft->RenderOpaqueGeometry(vp);
245   this->YAxisShaft->RenderOpaqueGeometry(vp);
246   this->ZAxisShaft->RenderOpaqueGeometry(vp);
247
248   this->XAxisTip->RenderOpaqueGeometry(vp);
249   this->YAxisTip->RenderOpaqueGeometry(vp);
250   this->ZAxisTip->RenderOpaqueGeometry(vp);
251
252   this->XAxisLabel->RenderOpaqueGeometry(vp);
253   this->YAxisLabel->RenderOpaqueGeometry(vp);
254   this->ZAxisLabel->RenderOpaqueGeometry(vp);
255   
256   return renderedSomething;
257 }
258
259 //-----------------------------------------------------------------------------
260 #if (VTK_MINOR_VERSION>=2)
261 // porting to VTK 5.0.x
262 int vtkPVAxesActor::RenderTranslucentPolygonalGeometry(vtkViewport *vp)
263 {
264   int renderedSomething=0; 
265
266   this->UpdateProps();
267   
268   renderedSomething += this->XAxisShaft->RenderTranslucentPolygonalGeometry(vp);
269   renderedSomething += this->YAxisShaft->RenderTranslucentPolygonalGeometry(vp);
270   renderedSomething += this->ZAxisShaft->RenderTranslucentPolygonalGeometry(vp);
271
272   renderedSomething += this->XAxisTip->RenderTranslucentPolygonalGeometry(vp);
273   renderedSomething += this->YAxisTip->RenderTranslucentPolygonalGeometry(vp);
274   renderedSomething += this->ZAxisTip->RenderTranslucentPolygonalGeometry(vp);
275   
276   renderedSomething += this->XAxisLabel->RenderTranslucentPolygonalGeometry(vp);
277   renderedSomething += this->YAxisLabel->RenderTranslucentPolygonalGeometry(vp);
278   renderedSomething += this->ZAxisLabel->RenderTranslucentPolygonalGeometry(vp);
279   
280   return renderedSomething;
281 }
282
283 //-----------------------------------------------------------------------------
284 // porting to VTK 5.0.x
285 int vtkPVAxesActor::HasTranslucentPolygonalGeometry()
286 {
287   int result = 0; 
288
289   this->UpdateProps();
290   
291   result |= this->XAxisShaft->HasTranslucentPolygonalGeometry();
292   result |= this->YAxisShaft->HasTranslucentPolygonalGeometry();
293   result |= this->ZAxisShaft->HasTranslucentPolygonalGeometry();
294
295   result |= this->XAxisTip->HasTranslucentPolygonalGeometry();
296   result |= this->YAxisTip->HasTranslucentPolygonalGeometry();
297   result |= this->ZAxisTip->HasTranslucentPolygonalGeometry();
298   
299   result |= this->XAxisLabel->HasTranslucentPolygonalGeometry();
300   result |= this->YAxisLabel->HasTranslucentPolygonalGeometry();
301   result |= this->ZAxisLabel->HasTranslucentPolygonalGeometry();
302   
303   return result;
304 }
305
306 #else
307 //-----------------------------------------------------------------------------
308 // porting to VTK 5.0.x
309 int vtkPVAxesActor::RenderTranslucentGeometry(vtkViewport *vp)
310 {
311   int renderedSomething=0; 
312
313   this->UpdateProps();
314   
315   renderedSomething += this->XAxisShaft->RenderTranslucentGeometry(vp);
316   renderedSomething += this->YAxisShaft->RenderTranslucentGeometry(vp);
317   renderedSomething += this->ZAxisShaft->RenderTranslucentGeometry(vp);
318
319   renderedSomething += this->XAxisTip->RenderTranslucentGeometry(vp);
320   renderedSomething += this->YAxisTip->RenderTranslucentGeometry(vp);
321   renderedSomething += this->ZAxisTip->RenderTranslucentGeometry(vp);
322   
323   renderedSomething += this->XAxisLabel->RenderTranslucentGeometry(vp);
324   renderedSomething += this->YAxisLabel->RenderTranslucentGeometry(vp);
325   renderedSomething += this->ZAxisLabel->RenderTranslucentGeometry(vp);
326   
327   return renderedSomething;
328 }
329 #endif
330
331 //-----------------------------------------------------------------------------
332 void vtkPVAxesActor::ReleaseGraphicsResources(vtkWindow *win)
333 {
334   this->XAxisShaft->ReleaseGraphicsResources( win );
335   this->YAxisShaft->ReleaseGraphicsResources( win );
336   this->ZAxisShaft->ReleaseGraphicsResources( win );
337
338   this->XAxisTip->ReleaseGraphicsResources( win );
339   this->YAxisTip->ReleaseGraphicsResources( win );
340   this->ZAxisTip->ReleaseGraphicsResources( win );
341     
342   this->XAxisLabel->ReleaseGraphicsResources( win );
343   this->YAxisLabel->ReleaseGraphicsResources( win );
344   this->ZAxisLabel->ReleaseGraphicsResources( win );
345 }
346
347 //-----------------------------------------------------------------------------
348 void vtkPVAxesActor::GetBounds(double bounds[6])
349 {
350   double *bds = this->GetBounds();
351   bounds[0] = bds[0];
352   bounds[1] = bds[1];
353   bounds[2] = bds[2];
354   bounds[3] = bds[3];
355   bounds[4] = bds[4];
356   bounds[5] = bds[5];
357 }
358
359 //-----------------------------------------------------------------------------
360 // Get the bounds for this Actor as (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax).
361 double *vtkPVAxesActor::GetBounds()
362 {
363   double bounds[6];
364   int i;
365   
366   this->XAxisShaft->GetBounds(this->Bounds);
367
368   this->YAxisShaft->GetBounds(bounds);
369   for (i=0; i<3; i++)
370     {
371     this->Bounds[2*i+1] = 
372       (bounds[2*i+1]>this->Bounds[2*i+1])?(bounds[2*i+1]):(this->Bounds[2*i+1]);    
373     }
374
375   this->ZAxisShaft->GetBounds(bounds);
376   for (i=0; i<3; i++)
377     {
378     this->Bounds[2*i+1] = 
379       (bounds[2*i+1]>this->Bounds[2*i+1])?(bounds[2*i+1]):(this->Bounds[2*i+1]);    
380     }
381
382   this->XAxisTip->GetBounds(bounds);
383   for (i=0; i<3; i++)
384     {
385     this->Bounds[2*i+1] = 
386       (bounds[2*i+1]>this->Bounds[2*i+1])?(bounds[2*i+1]):(this->Bounds[2*i+1]);    
387     }
388
389   this->YAxisTip->GetBounds(bounds);
390   for (i=0; i<3; i++)
391     {
392     this->Bounds[2*i+1] = 
393       (bounds[2*i+1]>this->Bounds[2*i+1])?(bounds[2*i+1]):(this->Bounds[2*i+1]);    
394     }
395
396   this->ZAxisTip->GetBounds(bounds);
397   for (i=0; i<3; i++)
398     {
399     this->Bounds[2*i+1] = 
400       (bounds[2*i+1]>this->Bounds[2*i+1])?(bounds[2*i+1]):(this->Bounds[2*i+1]);    
401     }
402
403   double dbounds[6];
404   (vtkPolyDataMapper::SafeDownCast(this->YAxisShaft->GetMapper()))->
405     GetInput()->GetBounds( dbounds );
406   
407   for (i=0; i<3; i++)
408     {
409     this->Bounds[2*i+1] = 
410       (dbounds[2*i+1]>this->Bounds[2*i+1])?(dbounds[2*i+1]):(this->Bounds[2*i+1]);    
411     }
412
413   // We want this actor to rotate / re-center about the origin, so give it
414   // the bounds it would have if the axes were symmetrical.
415   for (i = 0; i < 3; i++)
416     {
417     this->Bounds[2*i] = -this->Bounds[2*i+1];
418     }
419
420   return this->Bounds;
421 }
422
423 //-----------------------------------------------------------------------------
424 unsigned long int vtkPVAxesActor::GetMTime()
425 {
426   unsigned long mTime=this->Superclass::GetMTime();
427
428
429   return mTime;
430 }
431
432 //-----------------------------------------------------------------------------
433 unsigned long int vtkPVAxesActor::GetRedrawMTime()
434 {
435   unsigned long mTime=this->GetMTime();
436
437   return mTime;
438 }
439
440 //-----------------------------------------------------------------------------
441 vtkProperty *vtkPVAxesActor::GetXAxisTipProperty()
442 {
443   return this->XAxisTip->GetProperty();
444 }
445
446 //-----------------------------------------------------------------------------
447 vtkProperty *vtkPVAxesActor::GetYAxisTipProperty()
448 {
449   return this->YAxisTip->GetProperty();
450 }
451
452 //-----------------------------------------------------------------------------
453 vtkProperty *vtkPVAxesActor::GetZAxisTipProperty()
454 {
455   return this->ZAxisTip->GetProperty();
456 }
457
458 //-----------------------------------------------------------------------------
459 vtkProperty *vtkPVAxesActor::GetXAxisShaftProperty()
460 {
461   return this->XAxisShaft->GetProperty();
462 }
463
464 //-----------------------------------------------------------------------------
465 vtkProperty *vtkPVAxesActor::GetYAxisShaftProperty()
466 {
467   return this->YAxisShaft->GetProperty();
468 }
469
470 //-----------------------------------------------------------------------------
471 vtkProperty *vtkPVAxesActor::GetZAxisShaftProperty()
472 {
473   return this->ZAxisShaft->GetProperty();
474 }
475
476 //-----------------------------------------------------------------------------
477 vtkProperty *vtkPVAxesActor::GetXAxisLabelProperty()
478 {
479   return this->XAxisLabel->GetProperty();
480 }
481
482 //-----------------------------------------------------------------------------
483 vtkProperty *vtkPVAxesActor::GetYAxisLabelProperty()
484 {
485   return this->YAxisLabel->GetProperty();
486 }
487
488 //-----------------------------------------------------------------------------
489 vtkProperty *vtkPVAxesActor::GetZAxisLabelProperty()
490 {
491   return this->ZAxisLabel->GetProperty();
492 }
493
494 //-----------------------------------------------------------------------------
495 void vtkPVAxesActor::SetTotalLength( float x, float y, float z )
496 {
497   if ( this->TotalLength[0] != x ||
498        this->TotalLength[1] != y ||
499        this->TotalLength[2] != z )
500     {
501     this->TotalLength[0] = x;
502     this->TotalLength[1] = y;
503     this->TotalLength[2] = z;
504   
505     this->Modified();
506     
507     this->UpdateProps();
508     }
509 }
510
511 //-----------------------------------------------------------------------------
512 void vtkPVAxesActor::SetNormalizedShaftLength( float x, float y, float z )
513 {
514   if ( this->NormalizedShaftLength[0] != x ||
515        this->NormalizedShaftLength[1] != y ||
516        this->NormalizedShaftLength[2] != z )
517     {
518     this->NormalizedShaftLength[0] = x;
519     this->NormalizedShaftLength[1] = y;
520     this->NormalizedShaftLength[2] = z;
521   
522     this->Modified();
523     
524     this->UpdateProps();
525     }
526 }
527
528 //-----------------------------------------------------------------------------
529 void vtkPVAxesActor::SetNormalizedTipLength( float x, float y, float z )
530 {
531   if ( this->NormalizedTipLength[0] != x ||
532        this->NormalizedTipLength[1] != y ||
533        this->NormalizedTipLength[2] != z )
534     {
535     this->NormalizedTipLength[0] = x;
536     this->NormalizedTipLength[1] = y;
537     this->NormalizedTipLength[2] = z;
538   
539     this->Modified();
540     
541     this->UpdateProps();
542     }
543 }
544
545 //-----------------------------------------------------------------------------
546 void vtkPVAxesActor::SetShaftType( int type )
547 {
548   if ( this->ShaftType != type )
549     {
550     this->ShaftType = type;
551   
552     this->Modified();
553     
554     this->UpdateProps();
555     }
556 }
557
558 //-----------------------------------------------------------------------------
559 void vtkPVAxesActor::SetTipType( int type )
560 {
561   if ( this->TipType != type )
562     {
563     this->TipType = type;
564   
565     this->Modified();
566     
567     this->UpdateProps();
568     }
569 }
570
571 //-----------------------------------------------------------------------------
572 void vtkPVAxesActor::UpdateProps()
573 {
574   this->CylinderSource->SetRadius(this->CylinderRadius);
575   this->CylinderSource->SetResolution(this->CylinderResolution);
576   
577   
578   this->ConeSource->SetResolution(this->ConeResolution);
579   this->ConeSource->SetRadius(this->ConeRadius);
580  
581   this->SphereSource->SetThetaResolution( this->SphereResolution );
582   this->SphereSource->SetPhiResolution( this->SphereResolution );
583   this->SphereSource->SetRadius(this->SphereRadius);
584   
585   switch ( this->ShaftType )
586     {
587     case vtkPVAxesActor::CYLINDER_SHAFT:
588       (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->
589         SetInput( this->CylinderSource->GetOutput() );
590       break;
591     case vtkPVAxesActor::LINE_SHAFT:
592       (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->
593         SetInput( this->LineSource->GetOutput() );
594       break;
595     case vtkPVAxesActor::USER_DEFINED_SHAFT:
596       (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->
597         SetInput( this->UserDefinedShaft );
598     }
599   
600   switch ( this->TipType )
601     {
602     case vtkPVAxesActor::CONE_TIP:
603       (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->
604         SetInput( this->ConeSource->GetOutput() );
605       break;      
606     case vtkPVAxesActor::SPHERE_TIP:
607       (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->
608         SetInput( this->SphereSource->GetOutput() );
609       break;      
610     case vtkPVAxesActor::USER_DEFINED_TIP:
611       (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->
612         SetInput( this->UserDefinedTip );
613     }
614   
615   (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->
616     GetInput()->Update();
617   (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->
618     GetInput()->Update();
619       
620   
621   
622   float scale[3];
623   double bounds[6];
624
625   (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->
626     GetInput()->GetBounds( bounds );
627   
628   int i;
629   for ( i = 0; i < 3; i++ )
630     {
631     scale[i] = 
632       this->NormalizedShaftLength[i]*this->TotalLength[i] / 
633       (bounds[3] - bounds[2]);
634     }
635   
636   vtkTransform *xTransform = vtkTransform::New();
637   vtkTransform *yTransform = vtkTransform::New();
638   vtkTransform *zTransform = vtkTransform::New();
639   
640   xTransform->RotateZ( -90 );
641   zTransform->RotateX( 90 );
642   
643   xTransform->Scale( scale[0], scale[0], scale[0] );
644   yTransform->Scale( scale[1], scale[1], scale[1] );
645   zTransform->Scale( scale[2], scale[2], scale[2] );
646
647   xTransform->Translate( -(bounds[0]+bounds[1])/2,
648                          -bounds[2],
649                          -(bounds[4]+bounds[5])/2 );
650   yTransform->Translate( -(bounds[0]+bounds[1])/2,
651                          -bounds[2],
652                          -(bounds[4]+bounds[5])/2 );
653   zTransform->Translate( -(bounds[0]+bounds[1])/2,
654                          -bounds[2],
655                          -(bounds[4]+bounds[5])/2 );
656   
657   
658
659   this->XAxisShaft->SetUserTransform( xTransform );
660   this->YAxisShaft->SetUserTransform( yTransform );
661   this->ZAxisShaft->SetUserTransform( zTransform );
662
663   xTransform->Delete();
664   yTransform->Delete();
665   zTransform->Delete();
666   
667   (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->
668     GetInput()->GetBounds( bounds );
669   
670   xTransform = vtkTransform::New();
671   yTransform = vtkTransform::New();
672   zTransform = vtkTransform::New();
673   
674   xTransform->RotateZ( -90 );
675   zTransform->RotateX( 90 );
676   
677   xTransform->Scale( this->TotalLength[0], this->TotalLength[0], this->TotalLength[0] );
678   yTransform->Scale( this->TotalLength[1], this->TotalLength[1], this->TotalLength[1] );
679   zTransform->Scale( this->TotalLength[2], this->TotalLength[2], this->TotalLength[2] );
680   
681   xTransform->Translate( 0, (1.0 - this->NormalizedTipLength[0]), 0 );
682   yTransform->Translate( 0, (1.0 - this->NormalizedTipLength[1]), 0 );
683   zTransform->Translate( 0, (1.0 - this->NormalizedTipLength[2]), 0 );
684   
685   xTransform->Scale( this->NormalizedTipLength[0], 
686                      this->NormalizedTipLength[0], 
687                      this->NormalizedTipLength[0] );
688
689   yTransform->Scale( this->NormalizedTipLength[1], 
690                      this->NormalizedTipLength[1], 
691                      this->NormalizedTipLength[1] );
692   
693   zTransform->Scale( this->NormalizedTipLength[2], 
694                      this->NormalizedTipLength[2], 
695                      this->NormalizedTipLength[2] );
696   
697   xTransform->Translate( -(bounds[0]+bounds[1])/2,
698                          -bounds[2],
699                          -(bounds[4]+bounds[5])/2 );
700   yTransform->Translate( -(bounds[0]+bounds[1])/2,
701                          -bounds[2],
702                          -(bounds[4]+bounds[5])/2 );
703   zTransform->Translate( -(bounds[0]+bounds[1])/2,
704                          -bounds[2],
705                          -(bounds[4]+bounds[5])/2 );
706
707   
708   this->XAxisTip->SetUserTransform( xTransform );
709   this->YAxisTip->SetUserTransform( yTransform );
710   this->ZAxisTip->SetUserTransform( zTransform );
711
712   xTransform->Delete();
713   yTransform->Delete();
714   zTransform->Delete();
715
716   this->XAxisVectorText->SetText( this->XAxisLabelText );
717   this->YAxisVectorText->SetText( this->YAxisLabelText );
718   this->ZAxisVectorText->SetText( this->ZAxisLabelText );
719   
720   
721   float avgScale = 
722     (this->TotalLength[0] + this->TotalLength[1] + this->TotalLength[2])/15;
723   
724   this->XAxisShaft->GetBounds(bounds);
725   this->XAxisLabel->SetScale( avgScale, avgScale, avgScale );
726   this->XAxisLabel->SetPosition( bounds[0] + this->XAxisLabelPosition *
727                                  (bounds[1]-bounds[0]),
728                                  bounds[2] - (bounds[3]-bounds[2])*2.0,
729                                  bounds[5] + (bounds[5]-bounds[4])/2.0 );
730
731   this->YAxisShaft->GetBounds(bounds);
732   this->YAxisLabel->SetScale( avgScale, avgScale, avgScale );
733   this->YAxisLabel->SetPosition( (bounds[0]+bounds[1])/2, 
734                                  bounds[2] + this->YAxisLabelPosition *
735                                  (bounds[3]-bounds[2]),
736                                  bounds[5] + (bounds[5]-bounds[4])/2.0 );
737
738   this->ZAxisShaft->GetBounds(bounds);
739   this->ZAxisLabel->SetScale( avgScale, avgScale, avgScale );
740   this->ZAxisLabel->SetPosition( bounds[0], 
741                                  bounds[2] - (bounds[3]-bounds[2])*2.0,
742                                  bounds[4] + this->ZAxisLabelPosition *
743                                  (bounds[5]-bounds[4]) );
744 }
745
746 //-----------------------------------------------------------------------------
747 void vtkPVAxesActor::PrintSelf(ostream& os, vtkIndent indent)
748 {
749   this->Superclass::PrintSelf(os,indent);
750   
751   os << indent << "UserDefinedShaft: ";
752   if (this->UserDefinedShaft)
753     {
754     os << this->UserDefinedShaft << endl;
755     }
756   else
757     {
758     os << "(none)" << endl;
759     }
760   
761   os << indent << "UserDefinedTip: ";
762   if (this->UserDefinedTip)
763     {
764     os << this->UserDefinedTip << endl;
765     }
766   else
767     {
768     os << "(none)" << endl;
769     }
770   
771   os << indent << "XAxisLabelText: " << (this->XAxisLabelText ?
772                                          this->XAxisLabelText : "(none)")
773      << endl;
774   os << indent << "YAxisLabelText: " << (this->YAxisLabelText ?
775                                          this->YAxisLabelText : "(none)")
776      << endl;
777   os << indent << "ZAxisLabelText: " << (this->ZAxisLabelText ?
778                                          this->ZAxisLabelText : "(none)")
779      << endl;
780   os << indent << "XAxisLabelPosition: " << this->XAxisLabelPosition << endl;
781   os << indent << "YAxisLabelPosition: " << this->YAxisLabelPosition << endl;
782   os << indent << "ZAxisLabelPosition: " << this->ZAxisLabelPosition << endl;
783   
784   os << indent << "SphereRadius: " << this->SphereRadius << endl;
785   os << indent << "SphereResolution: " << this->SphereResolution << endl;
786   os << indent << "CylinderRadius: " << this->CylinderRadius << endl;
787   os << indent << "CylinderResolution: " << this->CylinderResolution << endl;
788   os << indent << "ConeRadius: " << this->ConeRadius << endl;
789   os << indent << "ConeResolution: " << this->ConeResolution << endl;
790   
791   os << indent << "NormalizedShaftLength: " 
792      << this->NormalizedShaftLength[0] << ","
793      << this->NormalizedShaftLength[1] << ","
794      << this->NormalizedShaftLength[2] << endl;
795   os << indent << "NormalizedTipLength: " 
796      << this->NormalizedTipLength[0] << ","
797      << this->NormalizedTipLength[1] << ","
798      << this->NormalizedTipLength[2] << endl;
799   os << indent << "TotalLength: " 
800      << this->TotalLength[0] << ","
801      << this->TotalLength[1] << ","
802      << this->TotalLength[2] << endl;
803 }
804
805 //-----------------------------------------------------------------------------
806 // porting to VTK 5.0.x
807 void vtkPVAxesActor::AddToRender( vtkRenderer* theRenderer )
808 {
809   theRenderer->AddActor(this->XAxisLabel);
810   theRenderer->AddActor(this->YAxisLabel);
811   theRenderer->AddActor(this->ZAxisLabel);
812 }