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