]> SALOME platform Git repositories - modules/gui.git/blob - src/SVTK/vtkPVAxesActor.h
Salome HOME
Merge from V6_main 11/02/2013
[modules/gui.git] / src / SVTK / vtkPVAxesActor.h
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
40 #ifndef __vtkPVAxesActor_h
41 #define __vtkPVAxesActor_h
42
43 #include "SVTK.h"
44 #include "vtkProp3D.h"
45
46 class vtkRenderer;
47 class vtkPropCollection;
48 class vtkMapper;
49 class vtkProperty;
50 class vtkActor;
51 class vtkFollower;
52 class vtkCylinderSource;
53 class vtkLineSource;
54 class vtkConeSource;
55 class vtkSphereSource;
56 class vtkPolyData;
57 class vtkVectorText;
58
59 class SVTK_EXPORT vtkPVAxesActor : public vtkProp3D
60 {
61 public:
62   static vtkPVAxesActor *New();
63   vtkTypeRevisionMacro(vtkPVAxesActor,vtkProp3D);
64   void PrintSelf(ostream& os, vtkIndent indent);
65
66
67   // Description: 
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 *);
72
73   // Description:
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
79 #else
80   virtual int RenderTranslucentGeometry(vtkViewport *viewport);            // porting to VTK 5.0.x
81 #endif
82
83   // Description:
84   // Shallow copy of an axes actor. Overloads the virtual vtkProp method.
85   void ShallowCopy(vtkProp *prop);
86
87   // Description:
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 *);
92
93   // Description:
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]);
97   double *GetBounds();
98
99   // Description:
100   // Get the actors mtime plus consider its properties and texture if set.
101   unsigned long int GetMTime();
102   
103   // Description:
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
107   // etc.
108   virtual unsigned long GetRedrawMTime();
109
110   // Description:
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 );
116   
117   // Description:
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 );
123   
124   // Description:
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 );
130
131   // Description:
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);
139   
140   // Description:
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);
148   
149   // Description:
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);
157   
158   // Description:
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 ); }
167
168   // Description:
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 ); }
177
178   //BTX
179   // Description:
180   // Set the user defined tip polydata.
181   void SetUserDefinedTip( vtkPolyData * );
182   vtkGetObjectMacro( UserDefinedTip, vtkPolyData );
183   
184   // Description:
185   // Set the user defined shaft polydata.
186   void SetUserDefinedShaft( vtkPolyData * );
187   vtkGetObjectMacro( UserDefinedShaft, vtkPolyData );
188
189   // Description:
190   // Get the tip properties.
191   vtkProperty *GetXAxisTipProperty();
192   vtkProperty *GetYAxisTipProperty();
193   vtkProperty *GetZAxisTipProperty();
194   
195   // Description:
196   // Get the shaft properties.
197   vtkProperty *GetXAxisShaftProperty();
198   vtkProperty *GetYAxisShaftProperty();
199   vtkProperty *GetZAxisShaftProperty();
200
201   // Description:
202   // Get the label properties.
203   vtkProperty *GetXAxisLabelProperty();
204   vtkProperty *GetYAxisLabelProperty();
205   vtkProperty *GetZAxisLabelProperty();
206   //ETX
207   //
208   // Description:
209   // Set the label text.
210   vtkSetStringMacro( XAxisLabelText );
211   vtkSetStringMacro( YAxisLabelText );
212   vtkSetStringMacro( ZAxisLabelText );
213   
214 //BTX
215   enum
216   {
217     CYLINDER_SHAFT,
218     LINE_SHAFT,
219     USER_DEFINED_SHAFT
220   };
221   
222   
223   enum
224   {
225     CONE_TIP,
226     SPHERE_TIP,
227     USER_DEFINED_TIP
228   };
229   
230 //ETX
231
232   void AddToRender( vtkRenderer* theRenderer ); // porting to VTK 5.0.x
233   
234 protected:
235   vtkPVAxesActor();
236   ~vtkPVAxesActor();
237
238   vtkCylinderSource *CylinderSource;
239   vtkLineSource     *LineSource;
240   vtkConeSource     *ConeSource;
241   vtkSphereSource   *SphereSource;
242   
243   vtkActor          *XAxisShaft;
244   vtkActor          *YAxisShaft;
245   vtkActor          *ZAxisShaft;
246
247   vtkActor          *XAxisTip;
248   vtkActor          *YAxisTip;
249   vtkActor          *ZAxisTip;
250
251   void              UpdateProps();
252
253   float             TotalLength[3];
254   float             NormalizedShaftLength[3];
255   float             NormalizedTipLength[3];
256   
257   int               ShaftType;
258   int               TipType;
259   
260   vtkPolyData      *UserDefinedTip;
261   vtkPolyData      *UserDefinedShaft;
262   
263   char             *XAxisLabelText;
264   char             *YAxisLabelText;
265   char             *ZAxisLabelText;
266   
267   vtkVectorText    *XAxisVectorText;
268   vtkVectorText    *YAxisVectorText;
269   vtkVectorText    *ZAxisVectorText;
270   
271   vtkFollower      *XAxisLabel;
272   vtkFollower      *YAxisLabel;
273   vtkFollower      *ZAxisLabel;
274   
275   int              ConeResolution;
276   int              SphereResolution;
277   int              CylinderResolution;
278   
279   float            ConeRadius;
280   float            SphereRadius;
281   float            CylinderRadius;
282
283   float            XAxisLabelPosition;
284   float            YAxisLabelPosition;
285   float            ZAxisLabelPosition;
286   
287 private:
288   vtkPVAxesActor(const vtkPVAxesActor&);  // Not implemented.
289   void operator=(const vtkPVAxesActor&);  // Not implemented.
290 };
291
292 #endif
293