Back to index

salome-gui  6.5.0
vtkPVAxesActor.cxx
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003    Program: ParaView
00004    Module:    $RCSfile: vtkPVAxesActor.cxx,v $
00005 
00006    Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
00007    All rights reserved.
00008 
00009    ParaView is a free software; you can redistribute it and/or modify it
00010    under the terms of the ParaView license version 1.2. 
00011 
00012    See License_v1.2.txt for the full ParaView license.
00013    A copy of this license can be obtained by contacting
00014    Kitware Inc.
00015    28 Corporate Drive
00016    Clifton Park, NY 12065
00017    USA
00018 
00019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00020 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00021 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00022 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
00023 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00024 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00025 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00026 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00027 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00028 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00029 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00030 
00031 =========================================================================*/
00032 #include "vtkPVAxesActor.h"
00033 #include "vtkObject.h"
00034 #include "vtkObjectFactory.h"
00035 
00036 #include "vtkActor.h"
00037 #include "vtkPropCollection.h"
00038 #include "vtkProperty.h"
00039 #include "vtkRenderWindow.h"
00040 #include "vtkTransform.h"
00041 #include "vtkCylinderSource.h"
00042 #include "vtkPolyDataMapper.h"
00043 #include "vtkLineSource.h"
00044 #include "vtkPolyData.h"
00045 #include "vtkConeSource.h"
00046 #include "vtkSphereSource.h"
00047 #include "vtkVectorText.h"
00048 #include "vtkFollower.h"
00049 #include "vtkRenderer.h"
00050 
00051 #include <math.h>
00052 
00053 vtkCxxRevisionMacro(vtkPVAxesActor, "$Revision: 1.1.6.2 $");
00054 vtkStandardNewMacro(vtkPVAxesActor);
00055 
00056 vtkCxxSetObjectMacro( vtkPVAxesActor, UserDefinedTip, vtkPolyData );
00057 vtkCxxSetObjectMacro( vtkPVAxesActor, UserDefinedShaft, vtkPolyData );
00058 
00059 //-----------------------------------------------------------------------------
00060 vtkPVAxesActor::vtkPVAxesActor()
00061 {
00062   this->XAxisLabelText = NULL;
00063   this->YAxisLabelText = NULL;
00064   this->ZAxisLabelText = NULL;
00065     
00066   this->SetXAxisLabelText("X");
00067   this->SetYAxisLabelText("Y");
00068   this->SetZAxisLabelText("Z");
00069   
00070   //colors chosen to match the output of vtkAxes.cxx's LUT.
00071   this->XAxisShaft = vtkActor::New();
00072   this->XAxisShaft->GetProperty()->SetColor(1, 0, 0);
00073   this->YAxisShaft = vtkActor::New();
00074   this->YAxisShaft->GetProperty()->SetColor(1, 1, 0);
00075   this->ZAxisShaft = vtkActor::New();
00076   this->ZAxisShaft->GetProperty()->SetColor(0, 1, 0);
00077 
00078   this->XAxisTip = vtkActor::New();
00079   this->XAxisTip->GetProperty()->SetColor(1, 0, 0);
00080   this->YAxisTip = vtkActor::New();
00081   this->YAxisTip->GetProperty()->SetColor(1, 1, 0);
00082   this->ZAxisTip = vtkActor::New();
00083   this->ZAxisTip->GetProperty()->SetColor(0, 1, 0);
00084 
00085   this->CylinderSource = vtkCylinderSource::New();
00086   this->CylinderSource->SetHeight(1.0);
00087   
00088   this->LineSource = vtkLineSource::New();
00089   this->LineSource->SetPoint1( 0.0, 0.0, 0.0 );
00090   this->LineSource->SetPoint2( 0.0, 1.0, 0.0 );
00091 
00092   this->ConeSource = vtkConeSource::New();
00093   this->ConeSource->SetDirection( 0, 1, 0 );
00094   this->ConeSource->SetHeight( 1.0 );
00095    
00096   this->SphereSource = vtkSphereSource::New();
00097   
00098   vtkPolyDataMapper *shaftMapper = vtkPolyDataMapper::New();
00099   
00100   this->XAxisShaft->SetMapper( shaftMapper );
00101   this->YAxisShaft->SetMapper( shaftMapper );
00102   this->ZAxisShaft->SetMapper( shaftMapper );
00103   
00104   shaftMapper->Delete();
00105 
00106   vtkPolyDataMapper *tipMapper = vtkPolyDataMapper::New();
00107   
00108   this->XAxisTip->SetMapper( tipMapper );
00109   this->YAxisTip->SetMapper( tipMapper );
00110   this->ZAxisTip->SetMapper( tipMapper );
00111   
00112   tipMapper->Delete();
00113 
00114   this->TotalLength[0] = 1.0;
00115   this->TotalLength[1] = 1.0;
00116   this->TotalLength[2] = 1.0;
00117  
00118   this->NormalizedShaftLength[0] = 0.8;
00119   this->NormalizedShaftLength[1] = 0.8;
00120   this->NormalizedShaftLength[2] = 0.8;
00121 
00122   this->NormalizedTipLength[0] = 0.2;
00123   this->NormalizedTipLength[1] = 0.2;
00124   this->NormalizedTipLength[2] = 0.2;
00125 
00126   this->ConeResolution = 16;
00127   this->SphereResolution = 16;
00128   this->CylinderResolution = 16;
00129   
00130   this->ConeRadius = 0.4;
00131   this->SphereRadius = 0.5;
00132   this->CylinderRadius = 0.05;
00133   
00134   this->XAxisLabelPosition = 1;
00135   this->YAxisLabelPosition = 1;
00136   this->ZAxisLabelPosition = 1;
00137   
00138   this->ShaftType = vtkPVAxesActor::LINE_SHAFT;
00139   this->TipType   = vtkPVAxesActor::CONE_TIP;
00140 
00141   this->UserDefinedTip = NULL;
00142   this->UserDefinedShaft = NULL;
00143 
00144   this->XAxisVectorText = vtkVectorText::New();
00145   this->YAxisVectorText = vtkVectorText::New();
00146   this->ZAxisVectorText = vtkVectorText::New();
00147   
00148   this->XAxisLabel = vtkFollower::New();
00149   this->YAxisLabel = vtkFollower::New();
00150   this->ZAxisLabel = vtkFollower::New();
00151   
00152   vtkPolyDataMapper *xmapper = vtkPolyDataMapper::New();
00153   vtkPolyDataMapper *ymapper = vtkPolyDataMapper::New();
00154   vtkPolyDataMapper *zmapper = vtkPolyDataMapper::New();
00155   
00156   xmapper->SetInput( this->XAxisVectorText->GetOutput() );
00157   ymapper->SetInput( this->YAxisVectorText->GetOutput() );
00158   zmapper->SetInput( this->ZAxisVectorText->GetOutput() );
00159   
00160   this->XAxisLabel->SetMapper( xmapper );
00161   this->YAxisLabel->SetMapper( ymapper );
00162   this->ZAxisLabel->SetMapper( zmapper );
00163   
00164   xmapper->Delete();
00165   ymapper->Delete();
00166   zmapper->Delete();
00167   
00168   this->UpdateProps();
00169 }
00170 
00171 //-----------------------------------------------------------------------------
00172 vtkPVAxesActor::~vtkPVAxesActor()
00173 {
00174   this->CylinderSource->Delete();
00175   this->LineSource->Delete();
00176   this->ConeSource->Delete();
00177   this->SphereSource->Delete();  
00178   
00179   this->XAxisShaft->Delete();
00180   this->YAxisShaft->Delete();
00181   this->ZAxisShaft->Delete();  
00182 
00183   this->XAxisTip->Delete();
00184   this->YAxisTip->Delete();
00185   this->ZAxisTip->Delete();  
00186   
00187   this->SetUserDefinedTip( NULL );
00188   this->SetUserDefinedShaft( NULL );
00189   
00190   this->SetXAxisLabelText( NULL );
00191   this->SetYAxisLabelText( NULL );
00192   this->SetZAxisLabelText( NULL );
00193   
00194   this->XAxisVectorText->Delete();
00195   this->YAxisVectorText->Delete();
00196   this->ZAxisVectorText->Delete();
00197 
00198   this->XAxisLabel->Delete();
00199   this->YAxisLabel->Delete();
00200   this->ZAxisLabel->Delete();
00201 }
00202 
00203 //-----------------------------------------------------------------------------
00204 // Shallow copy of an actor.
00205 void vtkPVAxesActor::ShallowCopy(vtkProp *prop)
00206 {
00207   vtkPVAxesActor *a = vtkPVAxesActor::SafeDownCast(prop);
00208   if ( a != NULL )
00209     {
00210     }
00211 
00212   // Now do superclass
00213   this->vtkProp3D::ShallowCopy(prop);
00214 }
00215 
00216 //-----------------------------------------------------------------------------
00217 void vtkPVAxesActor::GetActors(vtkPropCollection *ac)
00218 {
00219   ac->AddItem(this->XAxisShaft);
00220   ac->AddItem(this->YAxisShaft);
00221   ac->AddItem(this->ZAxisShaft);
00222   ac->AddItem(this->XAxisTip);
00223   ac->AddItem(this->YAxisTip);
00224   ac->AddItem(this->ZAxisTip);
00225   ac->AddItem(this->XAxisLabel);
00226   ac->AddItem(this->YAxisLabel);
00227   ac->AddItem(this->ZAxisLabel);
00228 
00229 }
00230 
00231 //-----------------------------------------------------------------------------
00232 int vtkPVAxesActor::RenderOpaqueGeometry(vtkViewport *vp)
00233 {
00234   int          renderedSomething = 0; 
00235 
00236   vtkRenderer *ren = vtkRenderer::SafeDownCast( vp );
00237 
00238   this->UpdateProps();
00239   
00240   this->XAxisLabel->SetCamera( ren->GetActiveCamera() );
00241   this->YAxisLabel->SetCamera( ren->GetActiveCamera() );
00242   this->ZAxisLabel->SetCamera( ren->GetActiveCamera() );
00243   
00244   this->XAxisShaft->RenderOpaqueGeometry(vp);
00245   this->YAxisShaft->RenderOpaqueGeometry(vp);
00246   this->ZAxisShaft->RenderOpaqueGeometry(vp);
00247 
00248   this->XAxisTip->RenderOpaqueGeometry(vp);
00249   this->YAxisTip->RenderOpaqueGeometry(vp);
00250   this->ZAxisTip->RenderOpaqueGeometry(vp);
00251 
00252   this->XAxisLabel->RenderOpaqueGeometry(vp);
00253   this->YAxisLabel->RenderOpaqueGeometry(vp);
00254   this->ZAxisLabel->RenderOpaqueGeometry(vp);
00255   
00256   return renderedSomething;
00257 }
00258 
00259 //-----------------------------------------------------------------------------
00260 #if (VTK_MINOR_VERSION>=2)
00261 // porting to VTK 5.0.x
00262 int vtkPVAxesActor::RenderTranslucentPolygonalGeometry(vtkViewport *vp)
00263 {
00264   int renderedSomething=0; 
00265 
00266   this->UpdateProps();
00267   
00268   renderedSomething += this->XAxisShaft->RenderTranslucentPolygonalGeometry(vp);
00269   renderedSomething += this->YAxisShaft->RenderTranslucentPolygonalGeometry(vp);
00270   renderedSomething += this->ZAxisShaft->RenderTranslucentPolygonalGeometry(vp);
00271 
00272   renderedSomething += this->XAxisTip->RenderTranslucentPolygonalGeometry(vp);
00273   renderedSomething += this->YAxisTip->RenderTranslucentPolygonalGeometry(vp);
00274   renderedSomething += this->ZAxisTip->RenderTranslucentPolygonalGeometry(vp);
00275   
00276   renderedSomething += this->XAxisLabel->RenderTranslucentPolygonalGeometry(vp);
00277   renderedSomething += this->YAxisLabel->RenderTranslucentPolygonalGeometry(vp);
00278   renderedSomething += this->ZAxisLabel->RenderTranslucentPolygonalGeometry(vp);
00279   
00280   return renderedSomething;
00281 }
00282 
00283 //-----------------------------------------------------------------------------
00284 // porting to VTK 5.0.x
00285 int vtkPVAxesActor::HasTranslucentPolygonalGeometry()
00286 {
00287   int result = 0; 
00288 
00289   this->UpdateProps();
00290   
00291   result |= this->XAxisShaft->HasTranslucentPolygonalGeometry();
00292   result |= this->YAxisShaft->HasTranslucentPolygonalGeometry();
00293   result |= this->ZAxisShaft->HasTranslucentPolygonalGeometry();
00294 
00295   result |= this->XAxisTip->HasTranslucentPolygonalGeometry();
00296   result |= this->YAxisTip->HasTranslucentPolygonalGeometry();
00297   result |= this->ZAxisTip->HasTranslucentPolygonalGeometry();
00298   
00299   result |= this->XAxisLabel->HasTranslucentPolygonalGeometry();
00300   result |= this->YAxisLabel->HasTranslucentPolygonalGeometry();
00301   result |= this->ZAxisLabel->HasTranslucentPolygonalGeometry();
00302   
00303   return result;
00304 }
00305 
00306 #else
00307 //-----------------------------------------------------------------------------
00308 // porting to VTK 5.0.x
00309 int vtkPVAxesActor::RenderTranslucentGeometry(vtkViewport *vp)
00310 {
00311   int renderedSomething=0; 
00312 
00313   this->UpdateProps();
00314   
00315   renderedSomething += this->XAxisShaft->RenderTranslucentGeometry(vp);
00316   renderedSomething += this->YAxisShaft->RenderTranslucentGeometry(vp);
00317   renderedSomething += this->ZAxisShaft->RenderTranslucentGeometry(vp);
00318 
00319   renderedSomething += this->XAxisTip->RenderTranslucentGeometry(vp);
00320   renderedSomething += this->YAxisTip->RenderTranslucentGeometry(vp);
00321   renderedSomething += this->ZAxisTip->RenderTranslucentGeometry(vp);
00322   
00323   renderedSomething += this->XAxisLabel->RenderTranslucentGeometry(vp);
00324   renderedSomething += this->YAxisLabel->RenderTranslucentGeometry(vp);
00325   renderedSomething += this->ZAxisLabel->RenderTranslucentGeometry(vp);
00326   
00327   return renderedSomething;
00328 }
00329 #endif
00330 
00331 //-----------------------------------------------------------------------------
00332 void vtkPVAxesActor::ReleaseGraphicsResources(vtkWindow *win)
00333 {
00334   this->XAxisShaft->ReleaseGraphicsResources( win );
00335   this->YAxisShaft->ReleaseGraphicsResources( win );
00336   this->ZAxisShaft->ReleaseGraphicsResources( win );
00337 
00338   this->XAxisTip->ReleaseGraphicsResources( win );
00339   this->YAxisTip->ReleaseGraphicsResources( win );
00340   this->ZAxisTip->ReleaseGraphicsResources( win );
00341     
00342   this->XAxisLabel->ReleaseGraphicsResources( win );
00343   this->YAxisLabel->ReleaseGraphicsResources( win );
00344   this->ZAxisLabel->ReleaseGraphicsResources( win );
00345 }
00346 
00347 //-----------------------------------------------------------------------------
00348 void vtkPVAxesActor::GetBounds(double bounds[6])
00349 {
00350   double *bds = this->GetBounds();
00351   bounds[0] = bds[0];
00352   bounds[1] = bds[1];
00353   bounds[2] = bds[2];
00354   bounds[3] = bds[3];
00355   bounds[4] = bds[4];
00356   bounds[5] = bds[5];
00357 }
00358 
00359 //-----------------------------------------------------------------------------
00360 // Get the bounds for this Actor as (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax).
00361 double *vtkPVAxesActor::GetBounds()
00362 {
00363   double bounds[6];
00364   int i;
00365   
00366   this->XAxisShaft->GetBounds(this->Bounds);
00367 
00368   this->YAxisShaft->GetBounds(bounds);
00369   for (i=0; i<3; i++)
00370     {
00371     this->Bounds[2*i+1] = 
00372       (bounds[2*i+1]>this->Bounds[2*i+1])?(bounds[2*i+1]):(this->Bounds[2*i+1]);    
00373     }
00374 
00375   this->ZAxisShaft->GetBounds(bounds);
00376   for (i=0; i<3; i++)
00377     {
00378     this->Bounds[2*i+1] = 
00379       (bounds[2*i+1]>this->Bounds[2*i+1])?(bounds[2*i+1]):(this->Bounds[2*i+1]);    
00380     }
00381 
00382   this->XAxisTip->GetBounds(bounds);
00383   for (i=0; i<3; i++)
00384     {
00385     this->Bounds[2*i+1] = 
00386       (bounds[2*i+1]>this->Bounds[2*i+1])?(bounds[2*i+1]):(this->Bounds[2*i+1]);    
00387     }
00388 
00389   this->YAxisTip->GetBounds(bounds);
00390   for (i=0; i<3; i++)
00391     {
00392     this->Bounds[2*i+1] = 
00393       (bounds[2*i+1]>this->Bounds[2*i+1])?(bounds[2*i+1]):(this->Bounds[2*i+1]);    
00394     }
00395 
00396   this->ZAxisTip->GetBounds(bounds);
00397   for (i=0; i<3; i++)
00398     {
00399     this->Bounds[2*i+1] = 
00400       (bounds[2*i+1]>this->Bounds[2*i+1])?(bounds[2*i+1]):(this->Bounds[2*i+1]);    
00401     }
00402 
00403   double dbounds[6];
00404   (vtkPolyDataMapper::SafeDownCast(this->YAxisShaft->GetMapper()))->
00405     GetInput()->GetBounds( dbounds );
00406   
00407   for (i=0; i<3; i++)
00408     {
00409     this->Bounds[2*i+1] = 
00410       (dbounds[2*i+1]>this->Bounds[2*i+1])?(dbounds[2*i+1]):(this->Bounds[2*i+1]);    
00411     }
00412 
00413   // We want this actor to rotate / re-center about the origin, so give it
00414   // the bounds it would have if the axes were symmetrical.
00415   for (i = 0; i < 3; i++)
00416     {
00417     this->Bounds[2*i] = -this->Bounds[2*i+1];
00418     }
00419 
00420   return this->Bounds;
00421 }
00422 
00423 //-----------------------------------------------------------------------------
00424 unsigned long int vtkPVAxesActor::GetMTime()
00425 {
00426   unsigned long mTime=this->Superclass::GetMTime();
00427 
00428 
00429   return mTime;
00430 }
00431 
00432 //-----------------------------------------------------------------------------
00433 unsigned long int vtkPVAxesActor::GetRedrawMTime()
00434 {
00435   unsigned long mTime=this->GetMTime();
00436 
00437   return mTime;
00438 }
00439 
00440 //-----------------------------------------------------------------------------
00441 vtkProperty *vtkPVAxesActor::GetXAxisTipProperty()
00442 {
00443   return this->XAxisTip->GetProperty();
00444 }
00445 
00446 //-----------------------------------------------------------------------------
00447 vtkProperty *vtkPVAxesActor::GetYAxisTipProperty()
00448 {
00449   return this->YAxisTip->GetProperty();
00450 }
00451 
00452 //-----------------------------------------------------------------------------
00453 vtkProperty *vtkPVAxesActor::GetZAxisTipProperty()
00454 {
00455   return this->ZAxisTip->GetProperty();
00456 }
00457 
00458 //-----------------------------------------------------------------------------
00459 vtkProperty *vtkPVAxesActor::GetXAxisShaftProperty()
00460 {
00461   return this->XAxisShaft->GetProperty();
00462 }
00463 
00464 //-----------------------------------------------------------------------------
00465 vtkProperty *vtkPVAxesActor::GetYAxisShaftProperty()
00466 {
00467   return this->YAxisShaft->GetProperty();
00468 }
00469 
00470 //-----------------------------------------------------------------------------
00471 vtkProperty *vtkPVAxesActor::GetZAxisShaftProperty()
00472 {
00473   return this->ZAxisShaft->GetProperty();
00474 }
00475 
00476 //-----------------------------------------------------------------------------
00477 vtkProperty *vtkPVAxesActor::GetXAxisLabelProperty()
00478 {
00479   return this->XAxisLabel->GetProperty();
00480 }
00481 
00482 //-----------------------------------------------------------------------------
00483 vtkProperty *vtkPVAxesActor::GetYAxisLabelProperty()
00484 {
00485   return this->YAxisLabel->GetProperty();
00486 }
00487 
00488 //-----------------------------------------------------------------------------
00489 vtkProperty *vtkPVAxesActor::GetZAxisLabelProperty()
00490 {
00491   return this->ZAxisLabel->GetProperty();
00492 }
00493 
00494 //-----------------------------------------------------------------------------
00495 void vtkPVAxesActor::SetTotalLength( float x, float y, float z )
00496 {
00497   if ( this->TotalLength[0] != x ||
00498        this->TotalLength[1] != y ||
00499        this->TotalLength[2] != z )
00500     {
00501     this->TotalLength[0] = x;
00502     this->TotalLength[1] = y;
00503     this->TotalLength[2] = z;
00504   
00505     this->Modified();
00506     
00507     this->UpdateProps();
00508     }
00509 }
00510 
00511 //-----------------------------------------------------------------------------
00512 void vtkPVAxesActor::SetNormalizedShaftLength( float x, float y, float z )
00513 {
00514   if ( this->NormalizedShaftLength[0] != x ||
00515        this->NormalizedShaftLength[1] != y ||
00516        this->NormalizedShaftLength[2] != z )
00517     {
00518     this->NormalizedShaftLength[0] = x;
00519     this->NormalizedShaftLength[1] = y;
00520     this->NormalizedShaftLength[2] = z;
00521   
00522     this->Modified();
00523     
00524     this->UpdateProps();
00525     }
00526 }
00527 
00528 //-----------------------------------------------------------------------------
00529 void vtkPVAxesActor::SetNormalizedTipLength( float x, float y, float z )
00530 {
00531   if ( this->NormalizedTipLength[0] != x ||
00532        this->NormalizedTipLength[1] != y ||
00533        this->NormalizedTipLength[2] != z )
00534     {
00535     this->NormalizedTipLength[0] = x;
00536     this->NormalizedTipLength[1] = y;
00537     this->NormalizedTipLength[2] = z;
00538   
00539     this->Modified();
00540     
00541     this->UpdateProps();
00542     }
00543 }
00544 
00545 //-----------------------------------------------------------------------------
00546 void vtkPVAxesActor::SetShaftType( int type )
00547 {
00548   if ( this->ShaftType != type )
00549     {
00550     this->ShaftType = type;
00551   
00552     this->Modified();
00553     
00554     this->UpdateProps();
00555     }
00556 }
00557 
00558 //-----------------------------------------------------------------------------
00559 void vtkPVAxesActor::SetTipType( int type )
00560 {
00561   if ( this->TipType != type )
00562     {
00563     this->TipType = type;
00564   
00565     this->Modified();
00566     
00567     this->UpdateProps();
00568     }
00569 }
00570 
00571 //-----------------------------------------------------------------------------
00572 void vtkPVAxesActor::UpdateProps()
00573 {
00574   this->CylinderSource->SetRadius(this->CylinderRadius);
00575   this->CylinderSource->SetResolution(this->CylinderResolution);
00576   
00577   
00578   this->ConeSource->SetResolution(this->ConeResolution);
00579   this->ConeSource->SetRadius(this->ConeRadius);
00580  
00581   this->SphereSource->SetThetaResolution( this->SphereResolution );
00582   this->SphereSource->SetPhiResolution( this->SphereResolution );
00583   this->SphereSource->SetRadius(this->SphereRadius);
00584   
00585   switch ( this->ShaftType )
00586     {
00587     case vtkPVAxesActor::CYLINDER_SHAFT:
00588       (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->
00589         SetInput( this->CylinderSource->GetOutput() );
00590       break;
00591     case vtkPVAxesActor::LINE_SHAFT:
00592       (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->
00593         SetInput( this->LineSource->GetOutput() );
00594       break;
00595     case vtkPVAxesActor::USER_DEFINED_SHAFT:
00596       (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->
00597         SetInput( this->UserDefinedShaft );
00598     }
00599   
00600   switch ( this->TipType )
00601     {
00602     case vtkPVAxesActor::CONE_TIP:
00603       (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->
00604         SetInput( this->ConeSource->GetOutput() );
00605       break;      
00606     case vtkPVAxesActor::SPHERE_TIP:
00607       (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->
00608         SetInput( this->SphereSource->GetOutput() );
00609       break;      
00610     case vtkPVAxesActor::USER_DEFINED_TIP:
00611       (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->
00612         SetInput( this->UserDefinedTip );
00613     }
00614   
00615   (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->
00616     GetInput()->Update();
00617   (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->
00618     GetInput()->Update();
00619       
00620   
00621   
00622   float scale[3];
00623   double bounds[6];
00624 
00625   (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->
00626     GetInput()->GetBounds( bounds );
00627   
00628   int i;
00629   for ( i = 0; i < 3; i++ )
00630     {
00631     scale[i] = 
00632       this->NormalizedShaftLength[i]*this->TotalLength[i] / 
00633       (bounds[3] - bounds[2]);
00634     }
00635   
00636   vtkTransform *xTransform = vtkTransform::New();
00637   vtkTransform *yTransform = vtkTransform::New();
00638   vtkTransform *zTransform = vtkTransform::New();
00639   
00640   xTransform->RotateZ( -90 );
00641   zTransform->RotateX( 90 );
00642   
00643   xTransform->Scale( scale[0], scale[0], scale[0] );
00644   yTransform->Scale( scale[1], scale[1], scale[1] );
00645   zTransform->Scale( scale[2], scale[2], scale[2] );
00646 
00647   xTransform->Translate( -(bounds[0]+bounds[1])/2,
00648                          -bounds[2],
00649                          -(bounds[4]+bounds[5])/2 );
00650   yTransform->Translate( -(bounds[0]+bounds[1])/2,
00651                          -bounds[2],
00652                          -(bounds[4]+bounds[5])/2 );
00653   zTransform->Translate( -(bounds[0]+bounds[1])/2,
00654                          -bounds[2],
00655                          -(bounds[4]+bounds[5])/2 );
00656   
00657   
00658 
00659   this->XAxisShaft->SetUserTransform( xTransform );
00660   this->YAxisShaft->SetUserTransform( yTransform );
00661   this->ZAxisShaft->SetUserTransform( zTransform );
00662 
00663   xTransform->Delete();
00664   yTransform->Delete();
00665   zTransform->Delete();
00666   
00667   (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->
00668     GetInput()->GetBounds( bounds );
00669   
00670   xTransform = vtkTransform::New();
00671   yTransform = vtkTransform::New();
00672   zTransform = vtkTransform::New();
00673   
00674   xTransform->RotateZ( -90 );
00675   zTransform->RotateX( 90 );
00676   
00677   xTransform->Scale( this->TotalLength[0], this->TotalLength[0], this->TotalLength[0] );
00678   yTransform->Scale( this->TotalLength[1], this->TotalLength[1], this->TotalLength[1] );
00679   zTransform->Scale( this->TotalLength[2], this->TotalLength[2], this->TotalLength[2] );
00680   
00681   xTransform->Translate( 0, (1.0 - this->NormalizedTipLength[0]), 0 );
00682   yTransform->Translate( 0, (1.0 - this->NormalizedTipLength[1]), 0 );
00683   zTransform->Translate( 0, (1.0 - this->NormalizedTipLength[2]), 0 );
00684   
00685   xTransform->Scale( this->NormalizedTipLength[0], 
00686                      this->NormalizedTipLength[0], 
00687                      this->NormalizedTipLength[0] );
00688 
00689   yTransform->Scale( this->NormalizedTipLength[1], 
00690                      this->NormalizedTipLength[1], 
00691                      this->NormalizedTipLength[1] );
00692   
00693   zTransform->Scale( this->NormalizedTipLength[2], 
00694                      this->NormalizedTipLength[2], 
00695                      this->NormalizedTipLength[2] );
00696   
00697   xTransform->Translate( -(bounds[0]+bounds[1])/2,
00698                          -bounds[2],
00699                          -(bounds[4]+bounds[5])/2 );
00700   yTransform->Translate( -(bounds[0]+bounds[1])/2,
00701                          -bounds[2],
00702                          -(bounds[4]+bounds[5])/2 );
00703   zTransform->Translate( -(bounds[0]+bounds[1])/2,
00704                          -bounds[2],
00705                          -(bounds[4]+bounds[5])/2 );
00706 
00707   
00708   this->XAxisTip->SetUserTransform( xTransform );
00709   this->YAxisTip->SetUserTransform( yTransform );
00710   this->ZAxisTip->SetUserTransform( zTransform );
00711 
00712   xTransform->Delete();
00713   yTransform->Delete();
00714   zTransform->Delete();
00715 
00716   this->XAxisVectorText->SetText( this->XAxisLabelText );
00717   this->YAxisVectorText->SetText( this->YAxisLabelText );
00718   this->ZAxisVectorText->SetText( this->ZAxisLabelText );
00719   
00720   
00721   float avgScale = 
00722     (this->TotalLength[0] + this->TotalLength[1] + this->TotalLength[2])/15;
00723   
00724   this->XAxisShaft->GetBounds(bounds);
00725   this->XAxisLabel->SetScale( avgScale, avgScale, avgScale );
00726   this->XAxisLabel->SetPosition( bounds[0] + this->XAxisLabelPosition *
00727                                  (bounds[1]-bounds[0]),
00728                                  bounds[2] - (bounds[3]-bounds[2])*2.0,
00729                                  bounds[5] + (bounds[5]-bounds[4])/2.0 );
00730 
00731   this->YAxisShaft->GetBounds(bounds);
00732   this->YAxisLabel->SetScale( avgScale, avgScale, avgScale );
00733   this->YAxisLabel->SetPosition( (bounds[0]+bounds[1])/2, 
00734                                  bounds[2] + this->YAxisLabelPosition *
00735                                  (bounds[3]-bounds[2]),
00736                                  bounds[5] + (bounds[5]-bounds[4])/2.0 );
00737 
00738   this->ZAxisShaft->GetBounds(bounds);
00739   this->ZAxisLabel->SetScale( avgScale, avgScale, avgScale );
00740   this->ZAxisLabel->SetPosition( bounds[0], 
00741                                  bounds[2] - (bounds[3]-bounds[2])*2.0,
00742                                  bounds[4] + this->ZAxisLabelPosition *
00743                                  (bounds[5]-bounds[4]) );
00744 }
00745 
00746 //-----------------------------------------------------------------------------
00747 void vtkPVAxesActor::PrintSelf(ostream& os, vtkIndent indent)
00748 {
00749   this->Superclass::PrintSelf(os,indent);
00750   
00751   os << indent << "UserDefinedShaft: ";
00752   if (this->UserDefinedShaft)
00753     {
00754     os << this->UserDefinedShaft << endl;
00755     }
00756   else
00757     {
00758     os << "(none)" << endl;
00759     }
00760   
00761   os << indent << "UserDefinedTip: ";
00762   if (this->UserDefinedTip)
00763     {
00764     os << this->UserDefinedTip << endl;
00765     }
00766   else
00767     {
00768     os << "(none)" << endl;
00769     }
00770   
00771   os << indent << "XAxisLabelText: " << (this->XAxisLabelText ?
00772                                          this->XAxisLabelText : "(none)")
00773      << endl;
00774   os << indent << "YAxisLabelText: " << (this->YAxisLabelText ?
00775                                          this->YAxisLabelText : "(none)")
00776      << endl;
00777   os << indent << "ZAxisLabelText: " << (this->ZAxisLabelText ?
00778                                          this->ZAxisLabelText : "(none)")
00779      << endl;
00780   os << indent << "XAxisLabelPosition: " << this->XAxisLabelPosition << endl;
00781   os << indent << "YAxisLabelPosition: " << this->YAxisLabelPosition << endl;
00782   os << indent << "ZAxisLabelPosition: " << this->ZAxisLabelPosition << endl;
00783   
00784   os << indent << "SphereRadius: " << this->SphereRadius << endl;
00785   os << indent << "SphereResolution: " << this->SphereResolution << endl;
00786   os << indent << "CylinderRadius: " << this->CylinderRadius << endl;
00787   os << indent << "CylinderResolution: " << this->CylinderResolution << endl;
00788   os << indent << "ConeRadius: " << this->ConeRadius << endl;
00789   os << indent << "ConeResolution: " << this->ConeResolution << endl;
00790   
00791   os << indent << "NormalizedShaftLength: " 
00792      << this->NormalizedShaftLength[0] << ","
00793      << this->NormalizedShaftLength[1] << ","
00794      << this->NormalizedShaftLength[2] << endl;
00795   os << indent << "NormalizedTipLength: " 
00796      << this->NormalizedTipLength[0] << ","
00797      << this->NormalizedTipLength[1] << ","
00798      << this->NormalizedTipLength[2] << endl;
00799   os << indent << "TotalLength: " 
00800      << this->TotalLength[0] << ","
00801      << this->TotalLength[1] << ","
00802      << this->TotalLength[2] << endl;
00803 }
00804 
00805 //-----------------------------------------------------------------------------
00806 // porting to VTK 5.0.x
00807 void vtkPVAxesActor::AddToRender( vtkRenderer* theRenderer )
00808 {
00809   theRenderer->AddActor(this->XAxisLabel);
00810   theRenderer->AddActor(this->YAxisLabel);
00811   theRenderer->AddActor(this->ZAxisLabel);
00812 }