Version: 9.15.0
salomevtkPVAxesActor.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: $RCSfile$
5 
6  Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
7  All rights reserved.
8 
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.
11 
12  See License_v1.2.txt for the full ParaView license.
13  A copy of this license can be obtained by contacting
14  Kitware Inc.
15  28 Corporate Drive
16  Clifton Park, NY 12065
17  USA
18 
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.
30 
31 =========================================================================*/
32 // .NAME vtkPVAxesActor - a 3D axes representation
33 // .SECTION Description
34 //
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.
38 //
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
41 
42 #ifndef __salomevtkPVAxesActor_h
43 #define __salomevtkPVAxesActor_h
44 
45 #include "SVTK.h" // added by SALOME
46 #include "vtkProp3D.h"
47 
48 #include <vtkVersion.h>
49 
50 class vtkRenderer;
51 class vtkPropCollection;
52 class vtkMapper;
53 class vtkProperty;
54 class vtkActor;
55 class vtkFollower;
56 class vtkCylinderSource;
57 class vtkLineSource;
58 class vtkConeSource;
59 class vtkSphereSource;
60 class vtkPolyData;
61 class vtkVectorText;
62 
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
65 namespace salomevtk
66 {
67 
69 {
70 public:
71  static vtkPVAxesActor *New();
73  void PrintSelf(ostream& os, vtkIndent indent);
74 
75 
76  // Description:
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 *);
81 
82  // Description:
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
88 #else
89  virtual int RenderTranslucentGeometry(vtkViewport *viewport); // porting to VTK 5.0.x
90 #endif
91 
92  // Description:
93  // Shallow copy of an axes actor. Overloads the virtual vtkProp method.
94  void ShallowCopy(vtkProp *prop);
95 
96  // Description:
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 *);
101 
102  // Description:
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]);
106  double *GetBounds();
107 
108  // Description:
109  // Get the actors mtime plus consider its properties and texture if set.
110  vtkMTimeType GetMTime();
111 
112  // Description:
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
116  // etc.
117  vtkMTimeType GetRedrawMTime();
118 
119  // Description:
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 );
125 
126  // Description:
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 );
132 
133  // Description:
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 );
139 
140  // Description:
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);
148 
149  // Description:
150  // Set/get the radius of the pieces of the axes actor
151  vtkSetClampMacro(ConeRadius, float, 0, VTK_FLOAT_MAX);
152  vtkGetMacro(ConeRadius, float);
153  vtkSetClampMacro(SphereRadius, float, 0, VTK_FLOAT_MAX);
154  vtkGetMacro(SphereRadius, float);
155  vtkSetClampMacro(CylinderRadius, float, 0, VTK_FLOAT_MAX);
156  vtkGetMacro(CylinderRadius, float);
157 
158  // Description:
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);
166 
167  // Description:
168  // Set the type of the shaft to a cylinder, line, or user defined geometry.
169  void SetShaftType( int type );
171  { this->SetShaftType( vtkPVAxesActor::CYLINDER_SHAFT ); }
173  { this->SetShaftType( vtkPVAxesActor::LINE_SHAFT ); }
175  { this->SetShaftType( vtkPVAxesActor::USER_DEFINED_SHAFT ); }
176 
177  // Description:
178  // Set the type of the tip to a cone, sphere, or user defined geometry.
179  void SetTipType( int type );
181  { this->SetTipType( vtkPVAxesActor::CONE_TIP ); }
183  { this->SetTipType( vtkPVAxesActor::SPHERE_TIP ); }
185  { this->SetTipType( vtkPVAxesActor::USER_DEFINED_TIP ); }
186 
187  //BTX
188  // Description:
189  // Set the user defined tip polydata.
190  void SetUserDefinedTip( vtkPolyData * );
192 
193  // Description:
194  // Set the user defined shaft polydata.
195  void SetUserDefinedShaft( vtkPolyData * );
196  vtkGetObjectMacro( UserDefinedShaft, vtkPolyData );
197 
198  // Description:
199  // Get the tip properties.
200  vtkProperty *GetXAxisTipProperty();
201  vtkProperty *GetYAxisTipProperty();
202  vtkProperty *GetZAxisTipProperty();
203 
204  // Description:
205  // Get the shaft properties.
206  vtkProperty *GetXAxisShaftProperty();
207  vtkProperty *GetYAxisShaftProperty();
208  vtkProperty *GetZAxisShaftProperty();
209 
210  // Description:
211  // Get the label properties.
212  vtkProperty *GetXAxisLabelProperty();
213  vtkProperty *GetYAxisLabelProperty();
214  vtkProperty *GetZAxisLabelProperty();
215  //ETX
216  //
217  // Description:
218  // Set the label text.
219  vtkSetStringMacro( XAxisLabelText );
220  vtkSetStringMacro( YAxisLabelText );
221  vtkSetStringMacro( ZAxisLabelText );
222 
223 //BTX
224  enum
225  {
228  USER_DEFINED_SHAFT
229  };
230 
231 
232  enum
233  {
236  USER_DEFINED_TIP
237  };
238 
239 //ETX
240 
241  void AddToRender( vtkRenderer* theRenderer ); // porting to VTK 5.0.x
242 
243 protected:
245  ~vtkPVAxesActor();
246 
247  vtkCylinderSource *CylinderSource;
248  vtkLineSource *LineSource;
249  vtkConeSource *ConeSource;
250  vtkSphereSource *SphereSource;
251 
252  vtkActor *XAxisShaft;
253  vtkActor *YAxisShaft;
254  vtkActor *ZAxisShaft;
255 
256  vtkActor *XAxisTip;
257  vtkActor *YAxisTip;
258  vtkActor *ZAxisTip;
259 
260  void UpdateProps();
261 
262  float TotalLength[3];
263  float NormalizedShaftLength[3];
264  float NormalizedTipLength[3];
265 
267  int TipType;
268 
269  vtkPolyData *UserDefinedTip;
270  vtkPolyData *UserDefinedShaft;
271 
275 
276  vtkVectorText *XAxisVectorText;
277  vtkVectorText *YAxisVectorText;
278  vtkVectorText *ZAxisVectorText;
279 
283 
287 
288  float ConeRadius;
291 
295 
296 private:
297  vtkPVAxesActor(const vtkPVAxesActor&); // Not implemented.
298  void operator=(const vtkPVAxesActor&); // Not implemented.
299 };
300 
301 } // end of salomevtk namespace
302 
303 #endif
304 
#define SVTK_EXPORT
Definition: SVTK.h:37
unsigned long int vtkMTimeType
Definition: VTKViewer.h:42
Definition: salomevtkPVAxesActor.h:69
vtkLineSource * LineSource
Definition: salomevtkPVAxesActor.h:248
vtkGetMacro(SphereRadius, float)
vtkGetMacro(ConeResolution, int)
vtkGetMacro(XAxisLabelPosition, float)
vtkGetVectorMacro(NormalizedShaftLength, float, 3)
vtkSetClampMacro(ConeRadius, float, 0, VTK_FLOAT_MAX)
void SetShaftTypeToCylinder()
Definition: salomevtkPVAxesActor.h:170
vtkSetStringMacro(XAxisLabelText)
vtkSetStringMacro(ZAxisLabelText)
char * XAxisLabelText
Definition: salomevtkPVAxesActor.h:272
void SetUserDefinedShaft(vtkPolyData *)
vtkVectorText * YAxisVectorText
Definition: salomevtkPVAxesActor.h:277
void SetNormalizedShaftLength(float v[3])
Definition: salomevtkPVAxesActor.h:128
vtkActor * XAxisTip
Definition: salomevtkPVAxesActor.h:256
vtkSetClampMacro(CylinderResolution, int, 3, 128)
vtkVectorText * ZAxisVectorText
Definition: salomevtkPVAxesActor.h:278
float SphereRadius
Definition: salomevtkPVAxesActor.h:289
void SetNormalizedTipLength(float v[3])
Definition: salomevtkPVAxesActor.h:135
@ SPHERE_TIP
Definition: salomevtkPVAxesActor.h:235
@ USER_DEFINED_TIP
Definition: salomevtkPVAxesActor.h:236
@ CONE_TIP
Definition: salomevtkPVAxesActor.h:234
vtkSetClampMacro(YAxisLabelPosition, float, 0, 1)
float YAxisLabelPosition
Definition: salomevtkPVAxesActor.h:293
void SetUserDefinedTip(vtkPolyData *)
vtkTypeMacro(vtkPVAxesActor, vtkProp3D) void PrintSelf(ostream &os
vtkGetMacro(CylinderRadius, float)
vtkGetMacro(SphereResolution, int)
vtkGetObjectMacro(UserDefinedShaft, vtkPolyData)
vtkGetMacro(CylinderResolution, int)
void SetTipTypeToUserDefined()
Definition: salomevtkPVAxesActor.h:184
vtkCylinderSource * CylinderSource
Definition: salomevtkPVAxesActor.h:247
void SetTipTypeToSphere()
Definition: salomevtkPVAxesActor.h:182
vtkActor * ZAxisShaft
Definition: salomevtkPVAxesActor.h:254
vtkSetClampMacro(SphereResolution, int, 3, 128)
vtkFollower * YAxisLabel
Definition: salomevtkPVAxesActor.h:281
@ LINE_SHAFT
Definition: salomevtkPVAxesActor.h:227
@ CYLINDER_SHAFT
Definition: salomevtkPVAxesActor.h:226
@ USER_DEFINED_SHAFT
Definition: salomevtkPVAxesActor.h:228
int TipType
Definition: salomevtkPVAxesActor.h:267
vtkSphereSource * SphereSource
Definition: salomevtkPVAxesActor.h:250
int ConeResolution
Definition: salomevtkPVAxesActor.h:284
vtkVectorText * XAxisVectorText
Definition: salomevtkPVAxesActor.h:276
vtkPolyData * UserDefinedShaft
Definition: salomevtkPVAxesActor.h:270
int ShaftType
Definition: salomevtkPVAxesActor.h:266
int CylinderResolution
Definition: salomevtkPVAxesActor.h:286
vtkSetClampMacro(SphereRadius, float, 0, VTK_FLOAT_MAX)
vtkSetClampMacro(CylinderRadius, float, 0, VTK_FLOAT_MAX)
vtkGetMacro(ZAxisLabelPosition, float)
char * YAxisLabelText
Definition: salomevtkPVAxesActor.h:273
vtkGetVectorMacro(TotalLength, float, 3)
vtkConeSource * ConeSource
Definition: salomevtkPVAxesActor.h:249
vtkActor * YAxisTip
Definition: salomevtkPVAxesActor.h:257
static vtkPVAxesActor * New()
void SetTotalLength(float v[3])
Definition: salomevtkPVAxesActor.h:121
float ConeRadius
Definition: salomevtkPVAxesActor.h:288
char * ZAxisLabelText
Definition: salomevtkPVAxesActor.h:274
vtkGetVectorMacro(NormalizedTipLength, float, 3)
vtkSetStringMacro(YAxisLabelText)
vtkActor * YAxisShaft
Definition: salomevtkPVAxesActor.h:253
vtkGetMacro(YAxisLabelPosition, float)
vtkSetClampMacro(ConeResolution, int, 3, 128)
vtkSetClampMacro(ZAxisLabelPosition, float, 0, 1)
vtkPolyData * UserDefinedTip
Definition: salomevtkPVAxesActor.h:269
vtkActor * XAxisShaft
Definition: salomevtkPVAxesActor.h:252
void SetShaftTypeToUserDefined()
Definition: salomevtkPVAxesActor.h:174
vtkFollower * XAxisLabel
Definition: salomevtkPVAxesActor.h:280
vtkFollower * ZAxisLabel
Definition: salomevtkPVAxesActor.h:282
int SphereResolution
Definition: salomevtkPVAxesActor.h:285
float XAxisLabelPosition
Definition: salomevtkPVAxesActor.h:292
vtkGetMacro(ConeRadius, float)
float ZAxisLabelPosition
Definition: salomevtkPVAxesActor.h:294
vtkGetObjectMacro(UserDefinedTip, vtkPolyData)
void operator=(const vtkPVAxesActor &)
vtkPVAxesActor(const vtkPVAxesActor &)
void SetTipTypeToCone()
Definition: salomevtkPVAxesActor.h:180
void SetShaftTypeToLine()
Definition: salomevtkPVAxesActor.h:172
float CylinderRadius
Definition: salomevtkPVAxesActor.h:290
vtkActor * ZAxisTip
Definition: salomevtkPVAxesActor.h:258
vtkSetClampMacro(XAxisLabelPosition, float, 0, 1)
Definition: salomevtkPVAxesActor.cxx:60
UserDefinedTip
Definition: salomevtkPVAxesActor.cxx:64