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"
47 class vtkPropCollection;
52 class vtkCylinderSource;
55 class vtkSphereSource;
59 class SVTK_EXPORT vtkPVAxesActor : public vtkProp3D
62 static vtkPVAxesActor *New();
63 vtkTypeRevisionMacro(vtkPVAxesActor,vtkProp3D);
64 void PrintSelf(ostream& os, vtkIndent indent);
68 // For some exporters and other other operations we must be
69 // able to collect all the actors or volumes. These methods
70 // are used in that process.
71 virtual void GetActors(vtkPropCollection *);
74 // Support the standard render methods.
75 virtual int RenderOpaqueGeometry(vtkViewport *viewport);
76 #if (VTK_MINOR_VERSION>=2)
77 virtual int RenderTranslucentPolygonalGeometry(vtkViewport *viewport); // porting to VTK 5.0.x
78 virtual int HasTranslucentPolygonalGeometry(); // porting to VTK 5.0.x
80 virtual int RenderTranslucentGeometry(vtkViewport *viewport); // porting to VTK 5.0.x
84 // Shallow copy of an axes actor. Overloads the virtual vtkProp method.
85 void ShallowCopy(vtkProp *prop);
88 // Release any graphics resources that are being consumed by this actor.
89 // The parameter window could be used to determine which graphic
90 // resources to release.
91 void ReleaseGraphicsResources(vtkWindow *);
94 // Get the bounds for this Actor as (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax). (The
95 // method GetBounds(double bounds[6]) is available from the superclass.)
96 void GetBounds(double bounds[6]);
100 // Get the actors mtime plus consider its properties and texture if set.
101 unsigned long int GetMTime();
104 // Return the mtime of anything that would cause the rendered image to
105 // appear differently. Usually this involves checking the mtime of the
106 // prop plus anything else it depends on such as properties, textures
108 virtual unsigned long GetRedrawMTime();
111 // Set the total length of the axes in 3 dimensions.
112 void SetTotalLength( float v[3] )
113 { this->SetTotalLength( v[0], v[1], v[2] ); }
114 void SetTotalLength( float x, float y, float z );
115 vtkGetVectorMacro( TotalLength, float, 3 );
118 // Set the normalized (0-1) length of the shaft.
119 void SetNormalizedShaftLength( float v[3] )
120 { this->SetNormalizedShaftLength( v[0], v[1], v[2] ); }
121 void SetNormalizedShaftLength( float x, float y, float z );
122 vtkGetVectorMacro( NormalizedShaftLength, float, 3 );
125 // Set the normalized (0-1) length of the tip.
126 void SetNormalizedTipLength( float v[3] )
127 { this->SetNormalizedTipLength( v[0], v[1], v[2] ); }
128 void SetNormalizedTipLength( float x, float y, float z );
129 vtkGetVectorMacro( NormalizedTipLength, float, 3 );
132 // Set/get the resolution of the pieces of the axes actor
133 vtkSetClampMacro(ConeResolution, int, 3, 128);
134 vtkGetMacro(ConeResolution, int);
135 vtkSetClampMacro(SphereResolution, int, 3, 128);
136 vtkGetMacro(SphereResolution, int);
137 vtkSetClampMacro(CylinderResolution, int, 3, 128);
138 vtkGetMacro(CylinderResolution, int);
141 // Set/get the radius of the pieces of the axes actor
142 vtkSetClampMacro(ConeRadius, float, 0, VTK_LARGE_FLOAT);
143 vtkGetMacro(ConeRadius, float);
144 vtkSetClampMacro(SphereRadius, float, 0, VTK_LARGE_FLOAT);
145 vtkGetMacro(SphereRadius, float);
146 vtkSetClampMacro(CylinderRadius, float, 0, VTK_LARGE_FLOAT);
147 vtkGetMacro(CylinderRadius, float);
150 // Set/get the positions of the axis labels
151 vtkSetClampMacro(XAxisLabelPosition, float, 0, 1);
152 vtkGetMacro(XAxisLabelPosition, float);
153 vtkSetClampMacro(YAxisLabelPosition, float, 0, 1);
154 vtkGetMacro(YAxisLabelPosition, float);
155 vtkSetClampMacro(ZAxisLabelPosition, float, 0, 1);
156 vtkGetMacro(ZAxisLabelPosition, float);
159 // Set the type of the shaft to a cylinder, line, or user defined geometry.
160 void SetShaftType( int type );
161 void SetShaftTypeToCylinder()
162 { this->SetShaftType( vtkPVAxesActor::CYLINDER_SHAFT ); }
163 void SetShaftTypeToLine()
164 { this->SetShaftType( vtkPVAxesActor::LINE_SHAFT ); }
165 void SetShaftTypeToUserDefined()
166 { this->SetShaftType( vtkPVAxesActor::USER_DEFINED_SHAFT ); }
169 // Set the type of the tip to a cone, sphere, or user defined geometry.
170 void SetTipType( int type );
171 void SetTipTypeToCone()
172 { this->SetTipType( vtkPVAxesActor::CONE_TIP ); }
173 void SetTipTypeToSphere()
174 { this->SetTipType( vtkPVAxesActor::SPHERE_TIP ); }
175 void SetTipTypeToUserDefined()
176 { this->SetTipType( vtkPVAxesActor::USER_DEFINED_TIP ); }
180 // Set the user defined tip polydata.
181 void SetUserDefinedTip( vtkPolyData * );
182 vtkGetObjectMacro( UserDefinedTip, vtkPolyData );
185 // Set the user defined shaft polydata.
186 void SetUserDefinedShaft( vtkPolyData * );
187 vtkGetObjectMacro( UserDefinedShaft, vtkPolyData );
190 // Get the tip properties.
191 vtkProperty *GetXAxisTipProperty();
192 vtkProperty *GetYAxisTipProperty();
193 vtkProperty *GetZAxisTipProperty();
196 // Get the shaft properties.
197 vtkProperty *GetXAxisShaftProperty();
198 vtkProperty *GetYAxisShaftProperty();
199 vtkProperty *GetZAxisShaftProperty();
202 // Get the label properties.
203 vtkProperty *GetXAxisLabelProperty();
204 vtkProperty *GetYAxisLabelProperty();
205 vtkProperty *GetZAxisLabelProperty();
209 // Set the label text.
210 vtkSetStringMacro( XAxisLabelText );
211 vtkSetStringMacro( YAxisLabelText );
212 vtkSetStringMacro( ZAxisLabelText );
232 void AddToRender( vtkRenderer* theRenderer ); // porting to VTK 5.0.x
238 vtkCylinderSource *CylinderSource;
239 vtkLineSource *LineSource;
240 vtkConeSource *ConeSource;
241 vtkSphereSource *SphereSource;
243 vtkActor *XAxisShaft;
244 vtkActor *YAxisShaft;
245 vtkActor *ZAxisShaft;
253 float TotalLength[3];
254 float NormalizedShaftLength[3];
255 float NormalizedTipLength[3];
260 vtkPolyData *UserDefinedTip;
261 vtkPolyData *UserDefinedShaft;
263 char *XAxisLabelText;
264 char *YAxisLabelText;
265 char *ZAxisLabelText;
267 vtkVectorText *XAxisVectorText;
268 vtkVectorText *YAxisVectorText;
269 vtkVectorText *ZAxisVectorText;
271 vtkFollower *XAxisLabel;
272 vtkFollower *YAxisLabel;
273 vtkFollower *ZAxisLabel;
276 int SphereResolution;
277 int CylinderResolution;
281 float CylinderRadius;
283 float XAxisLabelPosition;
284 float YAxisLabelPosition;
285 float ZAxisLabelPosition;
288 vtkPVAxesActor(const vtkPVAxesActor&); // Not implemented.
289 void operator=(const vtkPVAxesActor&); // Not implemented.