1 /*=========================================================================
6 Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
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.
12 See License_v1.2.txt for the full ParaView license.
13 A copy of this license can be obtained by contacting
16 Clifton Park, NY 12065
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.
31 =========================================================================*/
32 #include "vtkPVAxesActor.h"
33 #include "vtkObject.h"
34 #include "vtkObjectFactory.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"
53 vtkStandardNewMacro(vtkPVAxesActor);
55 vtkCxxSetObjectMacro( vtkPVAxesActor, UserDefinedTip, vtkPolyData );
56 vtkCxxSetObjectMacro( vtkPVAxesActor, UserDefinedShaft, vtkPolyData );
58 //-----------------------------------------------------------------------------
59 vtkPVAxesActor::vtkPVAxesActor()
61 this->XAxisLabelText = NULL;
62 this->YAxisLabelText = NULL;
63 this->ZAxisLabelText = NULL;
65 this->SetXAxisLabelText("X");
66 this->SetYAxisLabelText("Y");
67 this->SetZAxisLabelText("Z");
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);
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);
84 this->CylinderSource = vtkCylinderSource::New();
85 this->CylinderSource->SetHeight(1.0);
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 );
91 this->ConeSource = vtkConeSource::New();
92 this->ConeSource->SetDirection( 0, 1, 0 );
93 this->ConeSource->SetHeight( 1.0 );
95 this->SphereSource = vtkSphereSource::New();
97 vtkPolyDataMapper *shaftMapper = vtkPolyDataMapper::New();
99 this->XAxisShaft->SetMapper( shaftMapper );
100 this->YAxisShaft->SetMapper( shaftMapper );
101 this->ZAxisShaft->SetMapper( shaftMapper );
103 shaftMapper->Delete();
105 vtkPolyDataMapper *tipMapper = vtkPolyDataMapper::New();
107 this->XAxisTip->SetMapper( tipMapper );
108 this->YAxisTip->SetMapper( tipMapper );
109 this->ZAxisTip->SetMapper( tipMapper );
113 this->TotalLength[0] = 1.0;
114 this->TotalLength[1] = 1.0;
115 this->TotalLength[2] = 1.0;
117 this->NormalizedShaftLength[0] = 0.8;
118 this->NormalizedShaftLength[1] = 0.8;
119 this->NormalizedShaftLength[2] = 0.8;
121 this->NormalizedTipLength[0] = 0.2;
122 this->NormalizedTipLength[1] = 0.2;
123 this->NormalizedTipLength[2] = 0.2;
125 this->ConeResolution = 16;
126 this->SphereResolution = 16;
127 this->CylinderResolution = 16;
129 this->ConeRadius = 0.4;
130 this->SphereRadius = 0.5;
131 this->CylinderRadius = 0.05;
133 this->XAxisLabelPosition = 1;
134 this->YAxisLabelPosition = 1;
135 this->ZAxisLabelPosition = 1;
137 this->ShaftType = vtkPVAxesActor::LINE_SHAFT;
138 this->TipType = vtkPVAxesActor::CONE_TIP;
140 this->UserDefinedTip = NULL;
141 this->UserDefinedShaft = NULL;
143 this->XAxisVectorText = vtkVectorText::New();
144 this->YAxisVectorText = vtkVectorText::New();
145 this->ZAxisVectorText = vtkVectorText::New();
147 this->XAxisLabel = vtkFollower::New();
148 this->YAxisLabel = vtkFollower::New();
149 this->ZAxisLabel = vtkFollower::New();
151 vtkPolyDataMapper *xmapper = vtkPolyDataMapper::New();
152 vtkPolyDataMapper *ymapper = vtkPolyDataMapper::New();
153 vtkPolyDataMapper *zmapper = vtkPolyDataMapper::New();
155 xmapper->SetInputConnection( this->XAxisVectorText->GetOutputPort() );
156 ymapper->SetInputConnection( this->YAxisVectorText->GetOutputPort() );
157 zmapper->SetInputConnection( this->ZAxisVectorText->GetOutputPort() );
159 this->XAxisLabel->SetMapper( xmapper );
160 this->YAxisLabel->SetMapper( ymapper );
161 this->ZAxisLabel->SetMapper( zmapper );
170 //-----------------------------------------------------------------------------
171 vtkPVAxesActor::~vtkPVAxesActor()
173 this->CylinderSource->Delete();
174 this->LineSource->Delete();
175 this->ConeSource->Delete();
176 this->SphereSource->Delete();
178 this->XAxisShaft->Delete();
179 this->YAxisShaft->Delete();
180 this->ZAxisShaft->Delete();
182 this->XAxisTip->Delete();
183 this->YAxisTip->Delete();
184 this->ZAxisTip->Delete();
186 this->SetUserDefinedTip( NULL );
187 this->SetUserDefinedShaft( NULL );
189 this->SetXAxisLabelText( NULL );
190 this->SetYAxisLabelText( NULL );
191 this->SetZAxisLabelText( NULL );
193 this->XAxisVectorText->Delete();
194 this->YAxisVectorText->Delete();
195 this->ZAxisVectorText->Delete();
197 this->XAxisLabel->Delete();
198 this->YAxisLabel->Delete();
199 this->ZAxisLabel->Delete();
202 //-----------------------------------------------------------------------------
203 // Shallow copy of an actor.
204 void vtkPVAxesActor::ShallowCopy(vtkProp *prop)
206 vtkPVAxesActor *a = vtkPVAxesActor::SafeDownCast(prop);
212 this->vtkProp3D::ShallowCopy(prop);
215 //-----------------------------------------------------------------------------
216 void vtkPVAxesActor::GetActors(vtkPropCollection *ac)
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);
230 //-----------------------------------------------------------------------------
231 int vtkPVAxesActor::RenderOpaqueGeometry(vtkViewport *vp)
233 int renderedSomething = 0;
235 vtkRenderer *ren = vtkRenderer::SafeDownCast( vp );
239 this->XAxisLabel->SetCamera( ren->GetActiveCamera() );
240 this->YAxisLabel->SetCamera( ren->GetActiveCamera() );
241 this->ZAxisLabel->SetCamera( ren->GetActiveCamera() );
243 this->XAxisShaft->RenderOpaqueGeometry(vp);
244 this->YAxisShaft->RenderOpaqueGeometry(vp);
245 this->ZAxisShaft->RenderOpaqueGeometry(vp);
247 this->XAxisTip->RenderOpaqueGeometry(vp);
248 this->YAxisTip->RenderOpaqueGeometry(vp);
249 this->ZAxisTip->RenderOpaqueGeometry(vp);
251 this->XAxisLabel->RenderOpaqueGeometry(vp);
252 this->YAxisLabel->RenderOpaqueGeometry(vp);
253 this->ZAxisLabel->RenderOpaqueGeometry(vp);
255 return renderedSomething;
258 //-----------------------------------------------------------------------------
259 #if (VTK_MAJOR_VERSION>5 || VTK_MINOR_VERSION>=2)
260 // porting to VTK 5.0.x
261 int vtkPVAxesActor::RenderTranslucentPolygonalGeometry(vtkViewport *vp)
263 int renderedSomething=0;
267 renderedSomething += this->XAxisShaft->RenderTranslucentPolygonalGeometry(vp);
268 renderedSomething += this->YAxisShaft->RenderTranslucentPolygonalGeometry(vp);
269 renderedSomething += this->ZAxisShaft->RenderTranslucentPolygonalGeometry(vp);
271 renderedSomething += this->XAxisTip->RenderTranslucentPolygonalGeometry(vp);
272 renderedSomething += this->YAxisTip->RenderTranslucentPolygonalGeometry(vp);
273 renderedSomething += this->ZAxisTip->RenderTranslucentPolygonalGeometry(vp);
275 renderedSomething += this->XAxisLabel->RenderTranslucentPolygonalGeometry(vp);
276 renderedSomething += this->YAxisLabel->RenderTranslucentPolygonalGeometry(vp);
277 renderedSomething += this->ZAxisLabel->RenderTranslucentPolygonalGeometry(vp);
279 return renderedSomething;
282 //-----------------------------------------------------------------------------
283 // porting to VTK 5.0.x
284 int vtkPVAxesActor::HasTranslucentPolygonalGeometry()
290 result |= this->XAxisShaft->HasTranslucentPolygonalGeometry();
291 result |= this->YAxisShaft->HasTranslucentPolygonalGeometry();
292 result |= this->ZAxisShaft->HasTranslucentPolygonalGeometry();
294 result |= this->XAxisTip->HasTranslucentPolygonalGeometry();
295 result |= this->YAxisTip->HasTranslucentPolygonalGeometry();
296 result |= this->ZAxisTip->HasTranslucentPolygonalGeometry();
298 result |= this->XAxisLabel->HasTranslucentPolygonalGeometry();
299 result |= this->YAxisLabel->HasTranslucentPolygonalGeometry();
300 result |= this->ZAxisLabel->HasTranslucentPolygonalGeometry();
306 //-----------------------------------------------------------------------------
307 // porting to VTK 5.0.x
308 int vtkPVAxesActor::RenderTranslucentGeometry(vtkViewport *vp)
310 int renderedSomething=0;
314 renderedSomething += this->XAxisShaft->RenderTranslucentGeometry(vp);
315 renderedSomething += this->YAxisShaft->RenderTranslucentGeometry(vp);
316 renderedSomething += this->ZAxisShaft->RenderTranslucentGeometry(vp);
318 renderedSomething += this->XAxisTip->RenderTranslucentGeometry(vp);
319 renderedSomething += this->YAxisTip->RenderTranslucentGeometry(vp);
320 renderedSomething += this->ZAxisTip->RenderTranslucentGeometry(vp);
322 renderedSomething += this->XAxisLabel->RenderTranslucentGeometry(vp);
323 renderedSomething += this->YAxisLabel->RenderTranslucentGeometry(vp);
324 renderedSomething += this->ZAxisLabel->RenderTranslucentGeometry(vp);
326 return renderedSomething;
330 //-----------------------------------------------------------------------------
331 void vtkPVAxesActor::ReleaseGraphicsResources(vtkWindow *win)
333 this->XAxisShaft->ReleaseGraphicsResources( win );
334 this->YAxisShaft->ReleaseGraphicsResources( win );
335 this->ZAxisShaft->ReleaseGraphicsResources( win );
337 this->XAxisTip->ReleaseGraphicsResources( win );
338 this->YAxisTip->ReleaseGraphicsResources( win );
339 this->ZAxisTip->ReleaseGraphicsResources( win );
341 this->XAxisLabel->ReleaseGraphicsResources( win );
342 this->YAxisLabel->ReleaseGraphicsResources( win );
343 this->ZAxisLabel->ReleaseGraphicsResources( win );
346 //-----------------------------------------------------------------------------
347 void vtkPVAxesActor::GetBounds(double bounds[6])
349 double *bds = this->GetBounds();
358 //-----------------------------------------------------------------------------
359 // Get the bounds for this Actor as (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax).
360 double *vtkPVAxesActor::GetBounds()
365 this->XAxisShaft->GetBounds(this->Bounds);
367 this->YAxisShaft->GetBounds(bounds);
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]);
374 this->ZAxisShaft->GetBounds(bounds);
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]);
381 this->XAxisTip->GetBounds(bounds);
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]);
388 this->YAxisTip->GetBounds(bounds);
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]);
395 this->ZAxisTip->GetBounds(bounds);
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]);
403 (vtkPolyDataMapper::SafeDownCast(this->YAxisShaft->GetMapper()))->
404 GetInput()->GetBounds( dbounds );
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]);
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++)
416 this->Bounds[2*i] = -this->Bounds[2*i+1];
422 //-----------------------------------------------------------------------------
423 unsigned long int vtkPVAxesActor::GetMTime()
425 unsigned long mTime=this->Superclass::GetMTime();
431 //-----------------------------------------------------------------------------
432 unsigned long int vtkPVAxesActor::GetRedrawMTime()
434 unsigned long mTime=this->GetMTime();
439 //-----------------------------------------------------------------------------
440 vtkProperty *vtkPVAxesActor::GetXAxisTipProperty()
442 return this->XAxisTip->GetProperty();
445 //-----------------------------------------------------------------------------
446 vtkProperty *vtkPVAxesActor::GetYAxisTipProperty()
448 return this->YAxisTip->GetProperty();
451 //-----------------------------------------------------------------------------
452 vtkProperty *vtkPVAxesActor::GetZAxisTipProperty()
454 return this->ZAxisTip->GetProperty();
457 //-----------------------------------------------------------------------------
458 vtkProperty *vtkPVAxesActor::GetXAxisShaftProperty()
460 return this->XAxisShaft->GetProperty();
463 //-----------------------------------------------------------------------------
464 vtkProperty *vtkPVAxesActor::GetYAxisShaftProperty()
466 return this->YAxisShaft->GetProperty();
469 //-----------------------------------------------------------------------------
470 vtkProperty *vtkPVAxesActor::GetZAxisShaftProperty()
472 return this->ZAxisShaft->GetProperty();
475 //-----------------------------------------------------------------------------
476 vtkProperty *vtkPVAxesActor::GetXAxisLabelProperty()
478 return this->XAxisLabel->GetProperty();
481 //-----------------------------------------------------------------------------
482 vtkProperty *vtkPVAxesActor::GetYAxisLabelProperty()
484 return this->YAxisLabel->GetProperty();
487 //-----------------------------------------------------------------------------
488 vtkProperty *vtkPVAxesActor::GetZAxisLabelProperty()
490 return this->ZAxisLabel->GetProperty();
493 //-----------------------------------------------------------------------------
494 void vtkPVAxesActor::SetTotalLength( float x, float y, float z )
496 if ( this->TotalLength[0] != x ||
497 this->TotalLength[1] != y ||
498 this->TotalLength[2] != z )
500 this->TotalLength[0] = x;
501 this->TotalLength[1] = y;
502 this->TotalLength[2] = z;
510 //-----------------------------------------------------------------------------
511 void vtkPVAxesActor::SetNormalizedShaftLength( float x, float y, float z )
513 if ( this->NormalizedShaftLength[0] != x ||
514 this->NormalizedShaftLength[1] != y ||
515 this->NormalizedShaftLength[2] != z )
517 this->NormalizedShaftLength[0] = x;
518 this->NormalizedShaftLength[1] = y;
519 this->NormalizedShaftLength[2] = z;
527 //-----------------------------------------------------------------------------
528 void vtkPVAxesActor::SetNormalizedTipLength( float x, float y, float z )
530 if ( this->NormalizedTipLength[0] != x ||
531 this->NormalizedTipLength[1] != y ||
532 this->NormalizedTipLength[2] != z )
534 this->NormalizedTipLength[0] = x;
535 this->NormalizedTipLength[1] = y;
536 this->NormalizedTipLength[2] = z;
544 //-----------------------------------------------------------------------------
545 void vtkPVAxesActor::SetShaftType( int type )
547 if ( this->ShaftType != type )
549 this->ShaftType = type;
557 //-----------------------------------------------------------------------------
558 void vtkPVAxesActor::SetTipType( int type )
560 if ( this->TipType != type )
562 this->TipType = type;
570 //-----------------------------------------------------------------------------
571 void vtkPVAxesActor::UpdateProps()
573 this->CylinderSource->SetRadius(this->CylinderRadius);
574 this->CylinderSource->SetResolution(this->CylinderResolution);
577 this->ConeSource->SetResolution(this->ConeResolution);
578 this->ConeSource->SetRadius(this->ConeRadius);
580 this->SphereSource->SetThetaResolution( this->SphereResolution );
581 this->SphereSource->SetPhiResolution( this->SphereResolution );
582 this->SphereSource->SetRadius(this->SphereRadius);
584 switch ( this->ShaftType )
586 case vtkPVAxesActor::CYLINDER_SHAFT:
587 (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->
588 SetInputConnection( this->CylinderSource->GetOutputPort() );
590 case vtkPVAxesActor::LINE_SHAFT:
591 (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->
592 SetInputConnection( this->LineSource->GetOutputPort() );
594 case vtkPVAxesActor::USER_DEFINED_SHAFT:
595 (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->
596 SetInputData( this->UserDefinedShaft );
599 switch ( this->TipType )
601 case vtkPVAxesActor::CONE_TIP:
602 (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->
603 SetInputConnection( this->ConeSource->GetOutputPort() );
605 case vtkPVAxesActor::SPHERE_TIP:
606 (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->
607 SetInputConnection( this->SphereSource->GetOutputPort() );
609 case vtkPVAxesActor::USER_DEFINED_TIP:
610 (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->
611 SetInputData( this->UserDefinedTip );
614 (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->Update();
615 (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->Update();
622 (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->
623 GetInput()->GetBounds( bounds );
626 for ( i = 0; i < 3; i++ )
629 this->NormalizedShaftLength[i]*this->TotalLength[i] /
630 (bounds[3] - bounds[2]);
633 vtkTransform *xTransform = vtkTransform::New();
634 vtkTransform *yTransform = vtkTransform::New();
635 vtkTransform *zTransform = vtkTransform::New();
637 xTransform->RotateZ( -90 );
638 zTransform->RotateX( 90 );
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] );
644 xTransform->Translate( -(bounds[0]+bounds[1])/2,
646 -(bounds[4]+bounds[5])/2 );
647 yTransform->Translate( -(bounds[0]+bounds[1])/2,
649 -(bounds[4]+bounds[5])/2 );
650 zTransform->Translate( -(bounds[0]+bounds[1])/2,
652 -(bounds[4]+bounds[5])/2 );
656 this->XAxisShaft->SetUserTransform( xTransform );
657 this->YAxisShaft->SetUserTransform( yTransform );
658 this->ZAxisShaft->SetUserTransform( zTransform );
660 xTransform->Delete();
661 yTransform->Delete();
662 zTransform->Delete();
664 (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->
665 GetInput()->GetBounds( bounds );
667 xTransform = vtkTransform::New();
668 yTransform = vtkTransform::New();
669 zTransform = vtkTransform::New();
671 xTransform->RotateZ( -90 );
672 zTransform->RotateX( 90 );
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] );
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 );
682 xTransform->Scale( this->NormalizedTipLength[0],
683 this->NormalizedTipLength[0],
684 this->NormalizedTipLength[0] );
686 yTransform->Scale( this->NormalizedTipLength[1],
687 this->NormalizedTipLength[1],
688 this->NormalizedTipLength[1] );
690 zTransform->Scale( this->NormalizedTipLength[2],
691 this->NormalizedTipLength[2],
692 this->NormalizedTipLength[2] );
694 xTransform->Translate( -(bounds[0]+bounds[1])/2,
696 -(bounds[4]+bounds[5])/2 );
697 yTransform->Translate( -(bounds[0]+bounds[1])/2,
699 -(bounds[4]+bounds[5])/2 );
700 zTransform->Translate( -(bounds[0]+bounds[1])/2,
702 -(bounds[4]+bounds[5])/2 );
705 this->XAxisTip->SetUserTransform( xTransform );
706 this->YAxisTip->SetUserTransform( yTransform );
707 this->ZAxisTip->SetUserTransform( zTransform );
709 xTransform->Delete();
710 yTransform->Delete();
711 zTransform->Delete();
713 this->XAxisVectorText->SetText( this->XAxisLabelText );
714 this->YAxisVectorText->SetText( this->YAxisLabelText );
715 this->ZAxisVectorText->SetText( this->ZAxisLabelText );
719 (this->TotalLength[0] + this->TotalLength[1] + this->TotalLength[2])/15;
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 );
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 );
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]) );
743 //-----------------------------------------------------------------------------
744 void vtkPVAxesActor::PrintSelf(ostream& os, vtkIndent indent)
746 this->Superclass::PrintSelf(os,indent);
748 os << indent << "UserDefinedShaft: ";
749 if (this->UserDefinedShaft)
751 os << this->UserDefinedShaft << endl;
755 os << "(none)" << endl;
758 os << indent << "UserDefinedTip: ";
759 if (this->UserDefinedTip)
761 os << this->UserDefinedTip << endl;
765 os << "(none)" << endl;
768 os << indent << "XAxisLabelText: " << (this->XAxisLabelText ?
769 this->XAxisLabelText : "(none)")
771 os << indent << "YAxisLabelText: " << (this->YAxisLabelText ?
772 this->YAxisLabelText : "(none)")
774 os << indent << "ZAxisLabelText: " << (this->ZAxisLabelText ?
775 this->ZAxisLabelText : "(none)")
777 os << indent << "XAxisLabelPosition: " << this->XAxisLabelPosition << endl;
778 os << indent << "YAxisLabelPosition: " << this->YAxisLabelPosition << endl;
779 os << indent << "ZAxisLabelPosition: " << this->ZAxisLabelPosition << endl;
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;
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;
802 //-----------------------------------------------------------------------------
803 // porting to VTK 5.0.x
804 void vtkPVAxesActor::AddToRender( vtkRenderer* theRenderer )
806 theRenderer->AddActor(this->XAxisLabel);
807 theRenderer->AddActor(this->YAxisLabel);
808 theRenderer->AddActor(this->ZAxisLabel);