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