Back to index

salome-gui  6.5.0
vtkPVAxesActor.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003    Program: ParaView
00004    Module:    $RCSfile: vtkPVAxesActor.h,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 // .NAME vtkPVAxesActor - a 3D axes representation
00033 // .SECTION Description
00034 // 
00035 // vtkPVAxesActor is used to represent 3D axes in the scene. The user can
00036 // define the geometry to use for the shaft and the tip, and the user can
00037 // set the text for the three axes. The text will follow the camera.
00038 
00039 
00040 #ifndef __vtkPVAxesActor_h
00041 #define __vtkPVAxesActor_h
00042 
00043 #include "SVTK.h"
00044 #include "vtkProp3D.h"
00045 
00046 class vtkRenderer;
00047 class vtkPropCollection;
00048 class vtkMapper;
00049 class vtkProperty;
00050 class vtkActor;
00051 class vtkFollower;
00052 class vtkCylinderSource;
00053 class vtkLineSource;
00054 class vtkConeSource;
00055 class vtkSphereSource;
00056 class vtkPolyData;
00057 class vtkVectorText;
00058 
00059 class SVTK_EXPORT vtkPVAxesActor : public vtkProp3D
00060 {
00061 public:
00062   static vtkPVAxesActor *New();
00063   vtkTypeRevisionMacro(vtkPVAxesActor,vtkProp3D);
00064   void PrintSelf(ostream& os, vtkIndent indent);
00065 
00066 
00067   // Description: 
00068   // For some exporters and other other operations we must be
00069   // able to collect all the actors or volumes. These methods
00070   // are used in that process.
00071   virtual void GetActors(vtkPropCollection *);
00072 
00073   // Description:
00074   // Support the standard render methods.
00075   virtual int RenderOpaqueGeometry(vtkViewport *viewport);
00076 #if (VTK_MINOR_VERSION>=2)
00077   virtual int RenderTranslucentPolygonalGeometry(vtkViewport *viewport); // porting to VTK 5.0.x
00078   virtual int HasTranslucentPolygonalGeometry();                         // porting to VTK 5.0.x
00079 #else
00080   virtual int RenderTranslucentGeometry(vtkViewport *viewport);            // porting to VTK 5.0.x
00081 #endif
00082 
00083   // Description:
00084   // Shallow copy of an axes actor. Overloads the virtual vtkProp method.
00085   void ShallowCopy(vtkProp *prop);
00086 
00087   // Description:
00088   // Release any graphics resources that are being consumed by this actor.
00089   // The parameter window could be used to determine which graphic
00090   // resources to release.
00091   void ReleaseGraphicsResources(vtkWindow *);
00092 
00093   // Description:
00094   // Get the bounds for this Actor as (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax). (The
00095   // method GetBounds(double bounds[6]) is available from the superclass.)
00096   void GetBounds(double bounds[6]);
00097   double *GetBounds();
00098 
00099   // Description:
00100   // Get the actors mtime plus consider its properties and texture if set.
00101   unsigned long int GetMTime();
00102   
00103   // Description:
00104   // Return the mtime of anything that would cause the rendered image to 
00105   // appear differently. Usually this involves checking the mtime of the 
00106   // prop plus anything else it depends on such as properties, textures
00107   // etc.
00108   virtual unsigned long GetRedrawMTime();
00109 
00110   // Description:
00111   // Set the total length of the axes in 3 dimensions.
00112   void SetTotalLength( float v[3] ) 
00113     { this->SetTotalLength( v[0], v[1], v[2] ); }
00114   void SetTotalLength( float x, float y, float z );
00115   vtkGetVectorMacro( TotalLength, float, 3 );
00116   
00117   // Description:
00118   // Set the normalized (0-1) length of the shaft.
00119   void SetNormalizedShaftLength( float v[3] ) 
00120     { this->SetNormalizedShaftLength( v[0], v[1], v[2] ); }
00121   void SetNormalizedShaftLength( float x, float y, float z );
00122   vtkGetVectorMacro( NormalizedShaftLength, float, 3 );
00123   
00124   // Description:
00125   // Set the normalized (0-1) length of the tip.
00126   void SetNormalizedTipLength( float v[3] ) 
00127     { this->SetNormalizedTipLength( v[0], v[1], v[2] ); }
00128   void SetNormalizedTipLength( float x, float y, float z );
00129   vtkGetVectorMacro( NormalizedTipLength, float, 3 );
00130 
00131   // Description:
00132   // Set/get the resolution of the pieces of the axes actor
00133   vtkSetClampMacro(ConeResolution, int, 3, 128);
00134   vtkGetMacro(ConeResolution, int);
00135   vtkSetClampMacro(SphereResolution, int, 3, 128);
00136   vtkGetMacro(SphereResolution, int);
00137   vtkSetClampMacro(CylinderResolution, int, 3, 128);
00138   vtkGetMacro(CylinderResolution, int);
00139   
00140   // Description:
00141   // Set/get the radius of the pieces of the axes actor
00142   vtkSetClampMacro(ConeRadius, float, 0, VTK_LARGE_FLOAT);
00143   vtkGetMacro(ConeRadius, float);
00144   vtkSetClampMacro(SphereRadius, float, 0, VTK_LARGE_FLOAT);
00145   vtkGetMacro(SphereRadius, float);
00146   vtkSetClampMacro(CylinderRadius, float, 0, VTK_LARGE_FLOAT);
00147   vtkGetMacro(CylinderRadius, float);
00148   
00149   // Description:
00150   // Set/get the positions of the axis labels
00151   vtkSetClampMacro(XAxisLabelPosition, float, 0, 1);
00152   vtkGetMacro(XAxisLabelPosition, float);
00153   vtkSetClampMacro(YAxisLabelPosition, float, 0, 1);
00154   vtkGetMacro(YAxisLabelPosition, float);
00155   vtkSetClampMacro(ZAxisLabelPosition, float, 0, 1);
00156   vtkGetMacro(ZAxisLabelPosition, float);
00157   
00158   // Description:
00159   // Set the type of the shaft to a cylinder, line, or user defined geometry.
00160   void SetShaftType( int type );
00161   void SetShaftTypeToCylinder()
00162     { this->SetShaftType( vtkPVAxesActor::CYLINDER_SHAFT ); }
00163   void SetShaftTypeToLine()
00164     { this->SetShaftType( vtkPVAxesActor::LINE_SHAFT ); }
00165   void SetShaftTypeToUserDefined()
00166     { this->SetShaftType( vtkPVAxesActor::USER_DEFINED_SHAFT ); }
00167 
00168   // Description:
00169   // Set the type of the tip to a cone, sphere, or user defined geometry.
00170   void SetTipType( int type );
00171   void SetTipTypeToCone()
00172     { this->SetTipType( vtkPVAxesActor::CONE_TIP ); }
00173   void SetTipTypeToSphere()
00174     { this->SetTipType( vtkPVAxesActor::SPHERE_TIP ); }
00175   void SetTipTypeToUserDefined()
00176     { this->SetTipType( vtkPVAxesActor::USER_DEFINED_TIP ); }
00177 
00178   //BTX
00179   // Description:
00180   // Set the user defined tip polydata.
00181   void SetUserDefinedTip( vtkPolyData * );
00182   vtkGetObjectMacro( UserDefinedTip, vtkPolyData );
00183   
00184   // Description:
00185   // Set the user defined shaft polydata.
00186   void SetUserDefinedShaft( vtkPolyData * );
00187   vtkGetObjectMacro( UserDefinedShaft, vtkPolyData );
00188 
00189   // Description:
00190   // Get the tip properties.
00191   vtkProperty *GetXAxisTipProperty();
00192   vtkProperty *GetYAxisTipProperty();
00193   vtkProperty *GetZAxisTipProperty();
00194   
00195   // Description:
00196   // Get the shaft properties.
00197   vtkProperty *GetXAxisShaftProperty();
00198   vtkProperty *GetYAxisShaftProperty();
00199   vtkProperty *GetZAxisShaftProperty();
00200 
00201   // Description:
00202   // Get the label properties.
00203   vtkProperty *GetXAxisLabelProperty();
00204   vtkProperty *GetYAxisLabelProperty();
00205   vtkProperty *GetZAxisLabelProperty();
00206   //ETX
00207   //
00208   // Description:
00209   // Set the label text.
00210   vtkSetStringMacro( XAxisLabelText );
00211   vtkSetStringMacro( YAxisLabelText );
00212   vtkSetStringMacro( ZAxisLabelText );
00213   
00214 //BTX
00215   enum
00216   {
00217     CYLINDER_SHAFT,
00218     LINE_SHAFT,
00219     USER_DEFINED_SHAFT
00220   };
00221   
00222   
00223   enum
00224   {
00225     CONE_TIP,
00226     SPHERE_TIP,
00227     USER_DEFINED_TIP
00228   };
00229   
00230 //ETX
00231 
00232   void AddToRender( vtkRenderer* theRenderer ); // porting to VTK 5.0.x
00233   
00234 protected:
00235   vtkPVAxesActor();
00236   ~vtkPVAxesActor();
00237 
00238   vtkCylinderSource *CylinderSource;
00239   vtkLineSource     *LineSource;
00240   vtkConeSource     *ConeSource;
00241   vtkSphereSource   *SphereSource;
00242   
00243   vtkActor          *XAxisShaft;
00244   vtkActor          *YAxisShaft;
00245   vtkActor          *ZAxisShaft;
00246 
00247   vtkActor          *XAxisTip;
00248   vtkActor          *YAxisTip;
00249   vtkActor          *ZAxisTip;
00250 
00251   void              UpdateProps();
00252 
00253   float             TotalLength[3];
00254   float             NormalizedShaftLength[3];
00255   float             NormalizedTipLength[3];
00256   
00257   int               ShaftType;
00258   int               TipType;
00259   
00260   vtkPolyData      *UserDefinedTip;
00261   vtkPolyData      *UserDefinedShaft;
00262   
00263   char             *XAxisLabelText;
00264   char             *YAxisLabelText;
00265   char             *ZAxisLabelText;
00266   
00267   vtkVectorText    *XAxisVectorText;
00268   vtkVectorText    *YAxisVectorText;
00269   vtkVectorText    *ZAxisVectorText;
00270   
00271   vtkFollower      *XAxisLabel;
00272   vtkFollower      *YAxisLabel;
00273   vtkFollower      *ZAxisLabel;
00274   
00275   int              ConeResolution;
00276   int              SphereResolution;
00277   int              CylinderResolution;
00278   
00279   float            ConeRadius;
00280   float            SphereRadius;
00281   float            CylinderRadius;
00282 
00283   float            XAxisLabelPosition;
00284   float            YAxisLabelPosition;
00285   float            ZAxisLabelPosition;
00286   
00287 private:
00288   vtkPVAxesActor(const vtkPVAxesActor&);  // Not implemented.
00289   void operator=(const vtkPVAxesActor&);  // Not implemented.
00290 };
00291 
00292 #endif
00293