Salome HOME
Return old behavior of point sprites
[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 unsigned long int vtkPVAxesActor::GetMTime()
433 {
434   unsigned long mTime=this->Superclass::GetMTime();
435
436
437   return mTime;
438 }
439
440 //-----------------------------------------------------------------------------
441 unsigned long int vtkPVAxesActor::GetRedrawMTime()
442 {
443   unsigned long mTime=this->GetMTime();
444
445   return mTime;
446 }
447
448 //-----------------------------------------------------------------------------
449 vtkProperty *vtkPVAxesActor::GetXAxisTipProperty()
450 {
451   return this->XAxisTip->GetProperty();
452 }
453
454 //-----------------------------------------------------------------------------
455 vtkProperty *vtkPVAxesActor::GetYAxisTipProperty()
456 {
457   return this->YAxisTip->GetProperty();
458 }
459
460 //-----------------------------------------------------------------------------
461 vtkProperty *vtkPVAxesActor::GetZAxisTipProperty()
462 {
463   return this->ZAxisTip->GetProperty();
464 }
465
466 //-----------------------------------------------------------------------------
467 vtkProperty *vtkPVAxesActor::GetXAxisShaftProperty()
468 {
469   return this->XAxisShaft->GetProperty();
470 }
471
472 //-----------------------------------------------------------------------------
473 vtkProperty *vtkPVAxesActor::GetYAxisShaftProperty()
474 {
475   return this->YAxisShaft->GetProperty();
476 }
477
478 //-----------------------------------------------------------------------------
479 vtkProperty *vtkPVAxesActor::GetZAxisShaftProperty()
480 {
481   return this->ZAxisShaft->GetProperty();
482 }
483
484 //-----------------------------------------------------------------------------
485 vtkProperty *vtkPVAxesActor::GetXAxisLabelProperty()
486 {
487   return this->XAxisLabel->GetProperty();
488 }
489
490 //-----------------------------------------------------------------------------
491 vtkProperty *vtkPVAxesActor::GetYAxisLabelProperty()
492 {
493   return this->YAxisLabel->GetProperty();
494 }
495
496 //-----------------------------------------------------------------------------
497 vtkProperty *vtkPVAxesActor::GetZAxisLabelProperty()
498 {
499   return this->ZAxisLabel->GetProperty();
500 }
501
502 //-----------------------------------------------------------------------------
503 void vtkPVAxesActor::SetTotalLength( float x, float y, float z )
504 {
505   if ( this->TotalLength[0] != x ||
506        this->TotalLength[1] != y ||
507        this->TotalLength[2] != z )
508     {
509     this->TotalLength[0] = x;
510     this->TotalLength[1] = y;
511     this->TotalLength[2] = z;
512   
513     this->Modified();
514     
515     this->UpdateProps();
516     }
517 }
518
519 //-----------------------------------------------------------------------------
520 void vtkPVAxesActor::SetNormalizedShaftLength( float x, float y, float z )
521 {
522   if ( this->NormalizedShaftLength[0] != x ||
523        this->NormalizedShaftLength[1] != y ||
524        this->NormalizedShaftLength[2] != z )
525     {
526     this->NormalizedShaftLength[0] = x;
527     this->NormalizedShaftLength[1] = y;
528     this->NormalizedShaftLength[2] = z;
529   
530     this->Modified();
531     
532     this->UpdateProps();
533     }
534 }
535
536 //-----------------------------------------------------------------------------
537 void vtkPVAxesActor::SetNormalizedTipLength( float x, float y, float z )
538 {
539   if ( this->NormalizedTipLength[0] != x ||
540        this->NormalizedTipLength[1] != y ||
541        this->NormalizedTipLength[2] != z )
542     {
543     this->NormalizedTipLength[0] = x;
544     this->NormalizedTipLength[1] = y;
545     this->NormalizedTipLength[2] = z;
546   
547     this->Modified();
548     
549     this->UpdateProps();
550     }
551 }
552
553 //-----------------------------------------------------------------------------
554 void vtkPVAxesActor::SetShaftType( int type )
555 {
556   if ( this->ShaftType != type )
557     {
558     this->ShaftType = type;
559   
560     this->Modified();
561     
562     this->UpdateProps();
563     }
564 }
565
566 //-----------------------------------------------------------------------------
567 void vtkPVAxesActor::SetTipType( int type )
568 {
569   if ( this->TipType != type )
570     {
571     this->TipType = type;
572   
573     this->Modified();
574     
575     this->UpdateProps();
576     }
577 }
578
579 //-----------------------------------------------------------------------------
580 void vtkPVAxesActor::UpdateProps()
581 {
582   this->CylinderSource->SetRadius(this->CylinderRadius);
583   this->CylinderSource->SetResolution(this->CylinderResolution);
584   
585   
586   this->ConeSource->SetResolution(this->ConeResolution);
587   this->ConeSource->SetRadius(this->ConeRadius);
588  
589   this->SphereSource->SetThetaResolution( this->SphereResolution );
590   this->SphereSource->SetPhiResolution( this->SphereResolution );
591   this->SphereSource->SetRadius(this->SphereRadius);
592   
593   switch ( this->ShaftType )
594     {
595     case vtkPVAxesActor::CYLINDER_SHAFT:
596       (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->
597         SetInputConnection( this->CylinderSource->GetOutputPort() );
598       break;
599     case vtkPVAxesActor::LINE_SHAFT:
600       (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->
601         SetInputConnection( this->LineSource->GetOutputPort() );
602       break;
603     case vtkPVAxesActor::USER_DEFINED_SHAFT:
604       (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->
605         SetInputData( this->UserDefinedShaft );
606     }
607   
608   switch ( this->TipType )
609     {
610     case vtkPVAxesActor::CONE_TIP:
611       (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->
612         SetInputConnection( this->ConeSource->GetOutputPort() );
613       break;      
614     case vtkPVAxesActor::SPHERE_TIP:
615       (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->
616         SetInputConnection( this->SphereSource->GetOutputPort() );
617       break;      
618     case vtkPVAxesActor::USER_DEFINED_TIP:
619       (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->
620         SetInputData( this->UserDefinedTip );
621     }
622   
623   (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->Update();
624   (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->Update();
625       
626   
627   
628   float scale[3];
629   double bounds[6];
630
631   (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->
632     GetInput()->GetBounds( bounds );
633   
634   int i;
635   for ( i = 0; i < 3; i++ )
636     {
637     scale[i] = 
638       this->NormalizedShaftLength[i]*this->TotalLength[i] / 
639       (bounds[3] - bounds[2]);
640     }
641   
642   vtkTransform *xTransform = vtkTransform::New();
643   vtkTransform *yTransform = vtkTransform::New();
644   vtkTransform *zTransform = vtkTransform::New();
645   
646   xTransform->RotateZ( -90 );
647   zTransform->RotateX( 90 );
648   
649   xTransform->Scale( scale[0], scale[0], scale[0] );
650   yTransform->Scale( scale[1], scale[1], scale[1] );
651   zTransform->Scale( scale[2], scale[2], scale[2] );
652
653   xTransform->Translate( -(bounds[0]+bounds[1])/2,
654                          -bounds[2],
655                          -(bounds[4]+bounds[5])/2 );
656   yTransform->Translate( -(bounds[0]+bounds[1])/2,
657                          -bounds[2],
658                          -(bounds[4]+bounds[5])/2 );
659   zTransform->Translate( -(bounds[0]+bounds[1])/2,
660                          -bounds[2],
661                          -(bounds[4]+bounds[5])/2 );
662   
663   
664
665   this->XAxisShaft->SetUserTransform( xTransform );
666   this->YAxisShaft->SetUserTransform( yTransform );
667   this->ZAxisShaft->SetUserTransform( zTransform );
668
669   xTransform->Delete();
670   yTransform->Delete();
671   zTransform->Delete();
672   
673   (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->
674     GetInput()->GetBounds( bounds );
675   
676   xTransform = vtkTransform::New();
677   yTransform = vtkTransform::New();
678   zTransform = vtkTransform::New();
679   
680   xTransform->RotateZ( -90 );
681   zTransform->RotateX( 90 );
682   
683   xTransform->Scale( this->TotalLength[0], this->TotalLength[0], this->TotalLength[0] );
684   yTransform->Scale( this->TotalLength[1], this->TotalLength[1], this->TotalLength[1] );
685   zTransform->Scale( this->TotalLength[2], this->TotalLength[2], this->TotalLength[2] );
686   
687   xTransform->Translate( 0, (1.0 - this->NormalizedTipLength[0]), 0 );
688   yTransform->Translate( 0, (1.0 - this->NormalizedTipLength[1]), 0 );
689   zTransform->Translate( 0, (1.0 - this->NormalizedTipLength[2]), 0 );
690   
691   xTransform->Scale( this->NormalizedTipLength[0], 
692                      this->NormalizedTipLength[0], 
693                      this->NormalizedTipLength[0] );
694
695   yTransform->Scale( this->NormalizedTipLength[1], 
696                      this->NormalizedTipLength[1], 
697                      this->NormalizedTipLength[1] );
698   
699   zTransform->Scale( this->NormalizedTipLength[2], 
700                      this->NormalizedTipLength[2], 
701                      this->NormalizedTipLength[2] );
702   
703   xTransform->Translate( -(bounds[0]+bounds[1])/2,
704                          -bounds[2],
705                          -(bounds[4]+bounds[5])/2 );
706   yTransform->Translate( -(bounds[0]+bounds[1])/2,
707                          -bounds[2],
708                          -(bounds[4]+bounds[5])/2 );
709   zTransform->Translate( -(bounds[0]+bounds[1])/2,
710                          -bounds[2],
711                          -(bounds[4]+bounds[5])/2 );
712
713   
714   this->XAxisTip->SetUserTransform( xTransform );
715   this->YAxisTip->SetUserTransform( yTransform );
716   this->ZAxisTip->SetUserTransform( zTransform );
717
718   xTransform->Delete();
719   yTransform->Delete();
720   zTransform->Delete();
721
722   this->XAxisVectorText->SetText( this->XAxisLabelText );
723   this->YAxisVectorText->SetText( this->YAxisLabelText );
724   this->ZAxisVectorText->SetText( this->ZAxisLabelText );
725   
726   
727   float avgScale = 
728     (this->TotalLength[0] + this->TotalLength[1] + this->TotalLength[2])/15;
729   
730   this->XAxisShaft->GetBounds(bounds);
731   this->XAxisLabel->SetScale( avgScale, avgScale, avgScale );
732   this->XAxisLabel->SetPosition( bounds[0] + this->XAxisLabelPosition *
733                                  (bounds[1]-bounds[0]),
734                                  bounds[2] - (bounds[3]-bounds[2])*2.0,
735                                  bounds[5] + (bounds[5]-bounds[4])/2.0 );
736
737   this->YAxisShaft->GetBounds(bounds);
738   this->YAxisLabel->SetScale( avgScale, avgScale, avgScale );
739   this->YAxisLabel->SetPosition( (bounds[0]+bounds[1])/2, 
740                                  bounds[2] + this->YAxisLabelPosition *
741                                  (bounds[3]-bounds[2]),
742                                  bounds[5] + (bounds[5]-bounds[4])/2.0 );
743
744   this->ZAxisShaft->GetBounds(bounds);
745   this->ZAxisLabel->SetScale( avgScale, avgScale, avgScale );
746   this->ZAxisLabel->SetPosition( bounds[0], 
747                                  bounds[2] - (bounds[3]-bounds[2])*2.0,
748                                  bounds[4] + this->ZAxisLabelPosition *
749                                  (bounds[5]-bounds[4]) );
750 }
751
752 //-----------------------------------------------------------------------------
753 void vtkPVAxesActor::PrintSelf(ostream& os, vtkIndent indent)
754 {
755   this->Superclass::PrintSelf(os,indent);
756   
757   os << indent << "UserDefinedShaft: ";
758   if (this->UserDefinedShaft)
759     {
760     os << this->UserDefinedShaft << endl;
761     }
762   else
763     {
764     os << "(none)" << endl;
765     }
766   
767   os << indent << "UserDefinedTip: ";
768   if (this->UserDefinedTip)
769     {
770     os << this->UserDefinedTip << endl;
771     }
772   else
773     {
774     os << "(none)" << endl;
775     }
776   
777   os << indent << "XAxisLabelText: " << (this->XAxisLabelText ?
778                                          this->XAxisLabelText : "(none)")
779      << endl;
780   os << indent << "YAxisLabelText: " << (this->YAxisLabelText ?
781                                          this->YAxisLabelText : "(none)")
782      << endl;
783   os << indent << "ZAxisLabelText: " << (this->ZAxisLabelText ?
784                                          this->ZAxisLabelText : "(none)")
785      << endl;
786   os << indent << "XAxisLabelPosition: " << this->XAxisLabelPosition << endl;
787   os << indent << "YAxisLabelPosition: " << this->YAxisLabelPosition << endl;
788   os << indent << "ZAxisLabelPosition: " << this->ZAxisLabelPosition << endl;
789   
790   os << indent << "SphereRadius: " << this->SphereRadius << endl;
791   os << indent << "SphereResolution: " << this->SphereResolution << endl;
792   os << indent << "CylinderRadius: " << this->CylinderRadius << endl;
793   os << indent << "CylinderResolution: " << this->CylinderResolution << endl;
794   os << indent << "ConeRadius: " << this->ConeRadius << endl;
795   os << indent << "ConeResolution: " << this->ConeResolution << endl;
796   
797   os << indent << "NormalizedShaftLength: " 
798      << this->NormalizedShaftLength[0] << ","
799      << this->NormalizedShaftLength[1] << ","
800      << this->NormalizedShaftLength[2] << endl;
801   os << indent << "NormalizedTipLength: " 
802      << this->NormalizedTipLength[0] << ","
803      << this->NormalizedTipLength[1] << ","
804      << this->NormalizedTipLength[2] << endl;
805   os << indent << "TotalLength: " 
806      << this->TotalLength[0] << ","
807      << this->TotalLength[1] << ","
808      << this->TotalLength[2] << endl;
809 }
810
811 //-----------------------------------------------------------------------------
812 // porting to VTK 5.0.x
813 void vtkPVAxesActor::AddToRender( vtkRenderer* theRenderer )
814 {
815   theRenderer->AddActor(this->XAxisLabel);
816   theRenderer->AddActor(this->YAxisLabel);
817   theRenderer->AddActor(this->ZAxisLabel);
818 }
819
820 } // end of salomevtk namespace