Salome HOME
refs #416: to store the open state of object browser items in the binary array
[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 #include <vtkVersion.h>
47
48 class vtkRenderer;
49 class vtkPropCollection;
50 class vtkMapper;
51 class vtkProperty;
52 class vtkActor;
53 class vtkFollower;
54 class vtkCylinderSource;
55 class vtkLineSource;
56 class vtkConeSource;
57 class vtkSphereSource;
58 class vtkPolyData;
59 class vtkVectorText;
60
61 class SVTK_EXPORT vtkPVAxesActor : public vtkProp3D
62 {
63 public:
64   static vtkPVAxesActor *New();
65   vtkTypeMacro(vtkPVAxesActor,vtkProp3D);
66   void PrintSelf(ostream& os, vtkIndent indent);
67
68
69   // Description: 
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 *);
74
75   // Description:
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
81 #else
82   virtual int RenderTranslucentGeometry(vtkViewport *viewport);            // porting to VTK 5.0.x
83 #endif
84
85   // Description:
86   // Shallow copy of an axes actor. Overloads the virtual vtkProp method.
87   void ShallowCopy(vtkProp *prop);
88
89   // Description:
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 *);
94
95   // Description:
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]);
99   double *GetBounds();
100
101   // Description:
102   // Get the actors mtime plus consider its properties and texture if set.
103   unsigned long int GetMTime();
104   
105   // Description:
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
109   // etc.
110   virtual unsigned long GetRedrawMTime();
111
112   // Description:
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 );
118   
119   // Description:
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 );
125   
126   // Description:
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 );
132
133   // Description:
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);
141   
142   // Description:
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);
150   
151   // Description:
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);
159   
160   // Description:
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 ); }
169
170   // Description:
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 ); }
179
180   //BTX
181   // Description:
182   // Set the user defined tip polydata.
183   void SetUserDefinedTip( vtkPolyData * );
184   vtkGetObjectMacro( UserDefinedTip, vtkPolyData );
185   
186   // Description:
187   // Set the user defined shaft polydata.
188   void SetUserDefinedShaft( vtkPolyData * );
189   vtkGetObjectMacro( UserDefinedShaft, vtkPolyData );
190
191   // Description:
192   // Get the tip properties.
193   vtkProperty *GetXAxisTipProperty();
194   vtkProperty *GetYAxisTipProperty();
195   vtkProperty *GetZAxisTipProperty();
196   
197   // Description:
198   // Get the shaft properties.
199   vtkProperty *GetXAxisShaftProperty();
200   vtkProperty *GetYAxisShaftProperty();
201   vtkProperty *GetZAxisShaftProperty();
202
203   // Description:
204   // Get the label properties.
205   vtkProperty *GetXAxisLabelProperty();
206   vtkProperty *GetYAxisLabelProperty();
207   vtkProperty *GetZAxisLabelProperty();
208   //ETX
209   //
210   // Description:
211   // Set the label text.
212   vtkSetStringMacro( XAxisLabelText );
213   vtkSetStringMacro( YAxisLabelText );
214   vtkSetStringMacro( ZAxisLabelText );
215   
216 //BTX
217   enum
218   {
219     CYLINDER_SHAFT,
220     LINE_SHAFT,
221     USER_DEFINED_SHAFT
222   };
223   
224   
225   enum
226   {
227     CONE_TIP,
228     SPHERE_TIP,
229     USER_DEFINED_TIP
230   };
231   
232 //ETX
233
234   void AddToRender( vtkRenderer* theRenderer ); // porting to VTK 5.0.x
235   
236 protected:
237   vtkPVAxesActor();
238   ~vtkPVAxesActor();
239
240   vtkCylinderSource *CylinderSource;
241   vtkLineSource     *LineSource;
242   vtkConeSource     *ConeSource;
243   vtkSphereSource   *SphereSource;
244   
245   vtkActor          *XAxisShaft;
246   vtkActor          *YAxisShaft;
247   vtkActor          *ZAxisShaft;
248
249   vtkActor          *XAxisTip;
250   vtkActor          *YAxisTip;
251   vtkActor          *ZAxisTip;
252
253   void              UpdateProps();
254
255   float             TotalLength[3];
256   float             NormalizedShaftLength[3];
257   float             NormalizedTipLength[3];
258   
259   int               ShaftType;
260   int               TipType;
261   
262   vtkPolyData      *UserDefinedTip;
263   vtkPolyData      *UserDefinedShaft;
264   
265   char             *XAxisLabelText;
266   char             *YAxisLabelText;
267   char             *ZAxisLabelText;
268   
269   vtkVectorText    *XAxisVectorText;
270   vtkVectorText    *YAxisVectorText;
271   vtkVectorText    *ZAxisVectorText;
272   
273   vtkFollower      *XAxisLabel;
274   vtkFollower      *YAxisLabel;
275   vtkFollower      *ZAxisLabel;
276   
277   int              ConeResolution;
278   int              SphereResolution;
279   int              CylinderResolution;
280   
281   float            ConeRadius;
282   float            SphereRadius;
283   float            CylinderRadius;
284
285   float            XAxisLabelPosition;
286   float            YAxisLabelPosition;
287   float            ZAxisLabelPosition;
288   
289 private:
290   vtkPVAxesActor(const vtkPVAxesActor&);  // Not implemented.
291   void operator=(const vtkPVAxesActor&);  // Not implemented.
292 };
293
294 #endif
295