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.
39 // VSR 03/12/2014: the original file vtkPVAxesActor.h has been renamed to salomevtkPVAxesActor.h
40 // to avoid collisions with native VTK/ParaView classes
42 #ifndef __salomevtkPVAxesActor_h
43 #define __salomevtkPVAxesActor_h
45 #include "SVTK.h" // added by SALOME
46 #include "vtkProp3D.h"
48 #include <vtkVersion.h>
51 class vtkPropCollection;
56 class vtkCylinderSource;
59 class vtkSphereSource;
63 // VSR 03/12/2014: we put classes copied from VTK/ParaView to the specific namespace
64 // to avoid collisions with native VTK/ParaView classes
68 class SVTK_EXPORT vtkPVAxesActor : public vtkProp3D
71 static vtkPVAxesActor *New();
72 vtkTypeMacro(vtkPVAxesActor,vtkProp3D);
73 void PrintSelf(ostream& os, vtkIndent indent);
77 // For some exporters and other other operations we must be
78 // able to collect all the actors or volumes. These methods
79 // are used in that process.
80 virtual void GetActors(vtkPropCollection *);
83 // Support the standard render methods.
84 virtual int RenderOpaqueGeometry(vtkViewport *viewport);
85 #if (VTK_MAJOR_VERSION>5 || VTK_MINOR_VERSION>=2)
86 virtual int RenderTranslucentPolygonalGeometry(vtkViewport *viewport); // porting to VTK 5.0.x
87 virtual int HasTranslucentPolygonalGeometry(); // porting to VTK 5.0.x
89 virtual int RenderTranslucentGeometry(vtkViewport *viewport); // porting to VTK 5.0.x
93 // Shallow copy of an axes actor. Overloads the virtual vtkProp method.
94 void ShallowCopy(vtkProp *prop);
97 // Release any graphics resources that are being consumed by this actor.
98 // The parameter window could be used to determine which graphic
99 // resources to release.
100 void ReleaseGraphicsResources(vtkWindow *);
103 // Get the bounds for this Actor as (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax). (The
104 // method GetBounds(double bounds[6]) is available from the superclass.)
105 void GetBounds(double bounds[6]);
109 // Get the actors mtime plus consider its properties and texture if set.
110 unsigned long int GetMTime();
113 // Return the mtime of anything that would cause the rendered image to
114 // appear differently. Usually this involves checking the mtime of the
115 // prop plus anything else it depends on such as properties, textures
117 virtual unsigned long GetRedrawMTime();
120 // Set the total length of the axes in 3 dimensions.
121 void SetTotalLength( float v[3] )
122 { this->SetTotalLength( v[0], v[1], v[2] ); }
123 void SetTotalLength( float x, float y, float z );
124 vtkGetVectorMacro( TotalLength, float, 3 );
127 // Set the normalized (0-1) length of the shaft.
128 void SetNormalizedShaftLength( float v[3] )
129 { this->SetNormalizedShaftLength( v[0], v[1], v[2] ); }
130 void SetNormalizedShaftLength( float x, float y, float z );
131 vtkGetVectorMacro( NormalizedShaftLength, float, 3 );
134 // Set the normalized (0-1) length of the tip.
135 void SetNormalizedTipLength( float v[3] )
136 { this->SetNormalizedTipLength( v[0], v[1], v[2] ); }
137 void SetNormalizedTipLength( float x, float y, float z );
138 vtkGetVectorMacro( NormalizedTipLength, float, 3 );
141 // Set/get the resolution of the pieces of the axes actor
142 vtkSetClampMacro(ConeResolution, int, 3, 128);
143 vtkGetMacro(ConeResolution, int);
144 vtkSetClampMacro(SphereResolution, int, 3, 128);
145 vtkGetMacro(SphereResolution, int);
146 vtkSetClampMacro(CylinderResolution, int, 3, 128);
147 vtkGetMacro(CylinderResolution, int);
150 // Set/get the radius of the pieces of the axes actor
151 vtkSetClampMacro(ConeRadius, float, 0, VTK_LARGE_FLOAT);
152 vtkGetMacro(ConeRadius, float);
153 vtkSetClampMacro(SphereRadius, float, 0, VTK_LARGE_FLOAT);
154 vtkGetMacro(SphereRadius, float);
155 vtkSetClampMacro(CylinderRadius, float, 0, VTK_LARGE_FLOAT);
156 vtkGetMacro(CylinderRadius, float);
159 // Set/get the positions of the axis labels
160 vtkSetClampMacro(XAxisLabelPosition, float, 0, 1);
161 vtkGetMacro(XAxisLabelPosition, float);
162 vtkSetClampMacro(YAxisLabelPosition, float, 0, 1);
163 vtkGetMacro(YAxisLabelPosition, float);
164 vtkSetClampMacro(ZAxisLabelPosition, float, 0, 1);
165 vtkGetMacro(ZAxisLabelPosition, float);
168 // Set the type of the shaft to a cylinder, line, or user defined geometry.
169 void SetShaftType( int type );
170 void SetShaftTypeToCylinder()
171 { this->SetShaftType( vtkPVAxesActor::CYLINDER_SHAFT ); }
172 void SetShaftTypeToLine()
173 { this->SetShaftType( vtkPVAxesActor::LINE_SHAFT ); }
174 void SetShaftTypeToUserDefined()
175 { this->SetShaftType( vtkPVAxesActor::USER_DEFINED_SHAFT ); }
178 // Set the type of the tip to a cone, sphere, or user defined geometry.
179 void SetTipType( int type );
180 void SetTipTypeToCone()
181 { this->SetTipType( vtkPVAxesActor::CONE_TIP ); }
182 void SetTipTypeToSphere()
183 { this->SetTipType( vtkPVAxesActor::SPHERE_TIP ); }
184 void SetTipTypeToUserDefined()
185 { this->SetTipType( vtkPVAxesActor::USER_DEFINED_TIP ); }
189 // Set the user defined tip polydata.
190 void SetUserDefinedTip( vtkPolyData * );
191 vtkGetObjectMacro( UserDefinedTip, vtkPolyData );
194 // Set the user defined shaft polydata.
195 void SetUserDefinedShaft( vtkPolyData * );
196 vtkGetObjectMacro( UserDefinedShaft, vtkPolyData );
199 // Get the tip properties.
200 vtkProperty *GetXAxisTipProperty();
201 vtkProperty *GetYAxisTipProperty();
202 vtkProperty *GetZAxisTipProperty();
205 // Get the shaft properties.
206 vtkProperty *GetXAxisShaftProperty();
207 vtkProperty *GetYAxisShaftProperty();
208 vtkProperty *GetZAxisShaftProperty();
211 // Get the label properties.
212 vtkProperty *GetXAxisLabelProperty();
213 vtkProperty *GetYAxisLabelProperty();
214 vtkProperty *GetZAxisLabelProperty();
218 // Set the label text.
219 vtkSetStringMacro( XAxisLabelText );
220 vtkSetStringMacro( YAxisLabelText );
221 vtkSetStringMacro( ZAxisLabelText );
241 void AddToRender( vtkRenderer* theRenderer ); // porting to VTK 5.0.x
247 vtkCylinderSource *CylinderSource;
248 vtkLineSource *LineSource;
249 vtkConeSource *ConeSource;
250 vtkSphereSource *SphereSource;
252 vtkActor *XAxisShaft;
253 vtkActor *YAxisShaft;
254 vtkActor *ZAxisShaft;
262 float TotalLength[3];
263 float NormalizedShaftLength[3];
264 float NormalizedTipLength[3];
269 vtkPolyData *UserDefinedTip;
270 vtkPolyData *UserDefinedShaft;
272 char *XAxisLabelText;
273 char *YAxisLabelText;
274 char *ZAxisLabelText;
276 vtkVectorText *XAxisVectorText;
277 vtkVectorText *YAxisVectorText;
278 vtkVectorText *ZAxisVectorText;
280 vtkFollower *XAxisLabel;
281 vtkFollower *YAxisLabel;
282 vtkFollower *ZAxisLabel;
285 int SphereResolution;
286 int CylinderResolution;
290 float CylinderRadius;
292 float XAxisLabelPosition;
293 float YAxisLabelPosition;
294 float ZAxisLabelPosition;
297 vtkPVAxesActor(const vtkPVAxesActor&); // Not implemented.
298 void operator=(const vtkPVAxesActor&); // Not implemented.
301 } // end of salomevtk namespace