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 // .NAME vtkPVAxesActor - a 3D axes representation
33 // .SECTION Description
35 // vtkPVAxesActor is used to represent 3D axes in the scene. The user can
36 // define the geometry to use for the shaft and the tip, and the user can
37 // set the text for the three axes. The text will follow the camera.
40 #ifndef __vtkPVAxesActor_h
41 #define __vtkPVAxesActor_h
44 #include "vtkProp3D.h"
46 #include <vtkVersion.h>
49 class vtkPropCollection;
54 class vtkCylinderSource;
57 class vtkSphereSource;
61 class SVTK_EXPORT vtkPVAxesActor : public vtkProp3D
64 static vtkPVAxesActor *New();
65 vtkTypeMacro(vtkPVAxesActor,vtkProp3D);
66 void PrintSelf(ostream& os, vtkIndent indent);
70 // For some exporters and other other operations we must be
71 // able to collect all the actors or volumes. These methods
72 // are used in that process.
73 virtual void GetActors(vtkPropCollection *);
76 // Support the standard render methods.
77 virtual int RenderOpaqueGeometry(vtkViewport *viewport);
78 #if (VTK_MAJOR_VERSION>5 || VTK_MINOR_VERSION>=2)
79 virtual int RenderTranslucentPolygonalGeometry(vtkViewport *viewport); // porting to VTK 5.0.x
80 virtual int HasTranslucentPolygonalGeometry(); // porting to VTK 5.0.x
82 virtual int RenderTranslucentGeometry(vtkViewport *viewport); // porting to VTK 5.0.x
86 // Shallow copy of an axes actor. Overloads the virtual vtkProp method.
87 void ShallowCopy(vtkProp *prop);
90 // Release any graphics resources that are being consumed by this actor.
91 // The parameter window could be used to determine which graphic
92 // resources to release.
93 void ReleaseGraphicsResources(vtkWindow *);
96 // Get the bounds for this Actor as (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax). (The
97 // method GetBounds(double bounds[6]) is available from the superclass.)
98 void GetBounds(double bounds[6]);
102 // Get the actors mtime plus consider its properties and texture if set.
103 unsigned long int GetMTime();
106 // Return the mtime of anything that would cause the rendered image to
107 // appear differently. Usually this involves checking the mtime of the
108 // prop plus anything else it depends on such as properties, textures
110 virtual unsigned long GetRedrawMTime();
113 // Set the total length of the axes in 3 dimensions.
114 void SetTotalLength( float v[3] )
115 { this->SetTotalLength( v[0], v[1], v[2] ); }
116 void SetTotalLength( float x, float y, float z );
117 vtkGetVectorMacro( TotalLength, float, 3 );
120 // Set the normalized (0-1) length of the shaft.
121 void SetNormalizedShaftLength( float v[3] )
122 { this->SetNormalizedShaftLength( v[0], v[1], v[2] ); }
123 void SetNormalizedShaftLength( float x, float y, float z );
124 vtkGetVectorMacro( NormalizedShaftLength, float, 3 );
127 // Set the normalized (0-1) length of the tip.
128 void SetNormalizedTipLength( float v[3] )
129 { this->SetNormalizedTipLength( v[0], v[1], v[2] ); }
130 void SetNormalizedTipLength( float x, float y, float z );
131 vtkGetVectorMacro( NormalizedTipLength, float, 3 );
134 // Set/get the resolution of the pieces of the axes actor
135 vtkSetClampMacro(ConeResolution, int, 3, 128);
136 vtkGetMacro(ConeResolution, int);
137 vtkSetClampMacro(SphereResolution, int, 3, 128);
138 vtkGetMacro(SphereResolution, int);
139 vtkSetClampMacro(CylinderResolution, int, 3, 128);
140 vtkGetMacro(CylinderResolution, int);
143 // Set/get the radius of the pieces of the axes actor
144 vtkSetClampMacro(ConeRadius, float, 0, VTK_LARGE_FLOAT);
145 vtkGetMacro(ConeRadius, float);
146 vtkSetClampMacro(SphereRadius, float, 0, VTK_LARGE_FLOAT);
147 vtkGetMacro(SphereRadius, float);
148 vtkSetClampMacro(CylinderRadius, float, 0, VTK_LARGE_FLOAT);
149 vtkGetMacro(CylinderRadius, float);
152 // Set/get the positions of the axis labels
153 vtkSetClampMacro(XAxisLabelPosition, float, 0, 1);
154 vtkGetMacro(XAxisLabelPosition, float);
155 vtkSetClampMacro(YAxisLabelPosition, float, 0, 1);
156 vtkGetMacro(YAxisLabelPosition, float);
157 vtkSetClampMacro(ZAxisLabelPosition, float, 0, 1);
158 vtkGetMacro(ZAxisLabelPosition, float);
161 // Set the type of the shaft to a cylinder, line, or user defined geometry.
162 void SetShaftType( int type );
163 void SetShaftTypeToCylinder()
164 { this->SetShaftType( vtkPVAxesActor::CYLINDER_SHAFT ); }
165 void SetShaftTypeToLine()
166 { this->SetShaftType( vtkPVAxesActor::LINE_SHAFT ); }
167 void SetShaftTypeToUserDefined()
168 { this->SetShaftType( vtkPVAxesActor::USER_DEFINED_SHAFT ); }
171 // Set the type of the tip to a cone, sphere, or user defined geometry.
172 void SetTipType( int type );
173 void SetTipTypeToCone()
174 { this->SetTipType( vtkPVAxesActor::CONE_TIP ); }
175 void SetTipTypeToSphere()
176 { this->SetTipType( vtkPVAxesActor::SPHERE_TIP ); }
177 void SetTipTypeToUserDefined()
178 { this->SetTipType( vtkPVAxesActor::USER_DEFINED_TIP ); }
182 // Set the user defined tip polydata.
183 void SetUserDefinedTip( vtkPolyData * );
184 vtkGetObjectMacro( UserDefinedTip, vtkPolyData );
187 // Set the user defined shaft polydata.
188 void SetUserDefinedShaft( vtkPolyData * );
189 vtkGetObjectMacro( UserDefinedShaft, vtkPolyData );
192 // Get the tip properties.
193 vtkProperty *GetXAxisTipProperty();
194 vtkProperty *GetYAxisTipProperty();
195 vtkProperty *GetZAxisTipProperty();
198 // Get the shaft properties.
199 vtkProperty *GetXAxisShaftProperty();
200 vtkProperty *GetYAxisShaftProperty();
201 vtkProperty *GetZAxisShaftProperty();
204 // Get the label properties.
205 vtkProperty *GetXAxisLabelProperty();
206 vtkProperty *GetYAxisLabelProperty();
207 vtkProperty *GetZAxisLabelProperty();
211 // Set the label text.
212 vtkSetStringMacro( XAxisLabelText );
213 vtkSetStringMacro( YAxisLabelText );
214 vtkSetStringMacro( ZAxisLabelText );
234 void AddToRender( vtkRenderer* theRenderer ); // porting to VTK 5.0.x
240 vtkCylinderSource *CylinderSource;
241 vtkLineSource *LineSource;
242 vtkConeSource *ConeSource;
243 vtkSphereSource *SphereSource;
245 vtkActor *XAxisShaft;
246 vtkActor *YAxisShaft;
247 vtkActor *ZAxisShaft;
255 float TotalLength[3];
256 float NormalizedShaftLength[3];
257 float NormalizedTipLength[3];
262 vtkPolyData *UserDefinedTip;
263 vtkPolyData *UserDefinedShaft;
265 char *XAxisLabelText;
266 char *YAxisLabelText;
267 char *ZAxisLabelText;
269 vtkVectorText *XAxisVectorText;
270 vtkVectorText *YAxisVectorText;
271 vtkVectorText *ZAxisVectorText;
273 vtkFollower *XAxisLabel;
274 vtkFollower *YAxisLabel;
275 vtkFollower *ZAxisLabel;
278 int SphereResolution;
279 int CylinderResolution;
283 float CylinderRadius;
285 float XAxisLabelPosition;
286 float YAxisLabelPosition;
287 float ZAxisLabelPosition;
290 vtkPVAxesActor(const vtkPVAxesActor&); // Not implemented.
291 void operator=(const vtkPVAxesActor&); // Not implemented.