Salome HOME
API modif of vtkOpenGLTexture::ResampleToPowerOfTwo
[modules/gui.git] / src / SVTK / salomevtkPVAxesActor.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 // 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
68 class SVTK_EXPORT vtkPVAxesActor : public vtkProp3D
69 {
70 public:
71   static vtkPVAxesActor *New();
72   vtkTypeMacro(vtkPVAxesActor,vtkProp3D);
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 );
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 ); }
176
177   // Description:
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 ); }
186
187   //BTX
188   // Description:
189   // Set the user defined tip polydata.
190   void SetUserDefinedTip( vtkPolyData * );
191   vtkGetObjectMacro( UserDefinedTip, 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   {
226     CYLINDER_SHAFT,
227     LINE_SHAFT,
228     USER_DEFINED_SHAFT
229   };
230   
231   
232   enum
233   {
234     CONE_TIP,
235     SPHERE_TIP,
236     USER_DEFINED_TIP
237   };
238   
239 //ETX
240
241   void AddToRender( vtkRenderer* theRenderer ); // porting to VTK 5.0.x
242   
243 protected:
244   vtkPVAxesActor();
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   
266   int               ShaftType;
267   int               TipType;
268   
269   vtkPolyData      *UserDefinedTip;
270   vtkPolyData      *UserDefinedShaft;
271   
272   char             *XAxisLabelText;
273   char             *YAxisLabelText;
274   char             *ZAxisLabelText;
275   
276   vtkVectorText    *XAxisVectorText;
277   vtkVectorText    *YAxisVectorText;
278   vtkVectorText    *ZAxisVectorText;
279   
280   vtkFollower      *XAxisLabel;
281   vtkFollower      *YAxisLabel;
282   vtkFollower      *ZAxisLabel;
283   
284   int              ConeResolution;
285   int              SphereResolution;
286   int              CylinderResolution;
287   
288   float            ConeRadius;
289   float            SphereRadius;
290   float            CylinderRadius;
291
292   float            XAxisLabelPosition;
293   float            YAxisLabelPosition;
294   float            ZAxisLabelPosition;
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