]> SALOME platform Git repositories - modules/gui.git/blob - src/VTKViewer/VTKViewer_Trihedron.h
Salome HOME
74aebace8218f81b744c081043726f1a657ca7cb
[modules/gui.git] / src / VTKViewer / VTKViewer_Trihedron.h
1 #ifndef VTKVIEWER_TRIHEDRON_H
2 #define VTKVIEWER_TRIHEDRON_H
3
4 #include "VTKViewer.h"
5
6 #include <vtkObject.h>
7 #include <vtkFollower.h>
8
9 class vtkRenderer;
10 class vtkActorCollection;
11 class vtkCamera;
12 class vtkProperty;
13 class vtkPolyDataMapper;
14 class vtkLineSource;
15 class vtkConeSource;
16
17 class VTKViewer_Axis;
18 class VTKViewer_VectorText;
19
20 /*! \class vtkFollower
21  * See <a href="http://www.vtk.org/">vtk documentation</a>
22  */
23 /*!a subclass of actor that always faces the camera
24  *@see vtkFollower
25  */
26 class VTKVIEWER_EXPORT VTKViewer_UnScaledActor: public vtkFollower
27 {
28   VTKViewer_UnScaledActor(const VTKViewer_UnScaledActor&);
29   
30 public:
31   
32   vtkTypeMacro(VTKViewer_UnScaledActor,vtkFollower);
33   
34   /*!Create new instance of VTKViewer_UnScaledActor.*/
35   static VTKViewer_UnScaledActor *New();
36   
37   virtual float* GetBounds();
38   virtual void SetSize(int theSize);
39   virtual void Render(vtkRenderer *theRenderer);
40
41 protected:
42   VTKViewer_UnScaledActor();
43   /*!Destructor. Do nothing.*/
44   ~VTKViewer_UnScaledActor(){}
45   
46   int mySize;
47 };
48
49 /*!a subclass of actor that always faces the camera
50  *@see vtkFollower
51  */
52 class VTKVIEWER_EXPORT VTKViewer_LineActor: public vtkFollower
53 {
54   VTKViewer_LineActor(const VTKViewer_LineActor&);
55   
56 public:
57   /*!vtk type macros.*/
58   vtkTypeMacro(VTKViewer_LineActor,vtkFollower);
59   
60   /*!Create new instance of VTKViewer_LineActor.*/
61   static VTKViewer_LineActor *New();
62   
63   /*! Sets Lable actor.
64    * \param theLabelActor - VTKViewer_UnScaledActor
65    */
66   void SetLabelActor(VTKViewer_UnScaledActor* theLabelActor);
67   
68   /*! Sets Arrow actor.
69    * \param theLabelActor - VTKViewer_UnScaledActor
70    */
71   void SetArrowActor(VTKViewer_UnScaledActor* theLabelActor);
72
73   virtual void Render(vtkRenderer *theRenderer);
74   
75 protected:
76   
77   /*! Constructor which sets \a LabelActor and \a ArrowActor to NULL*/
78   VTKViewer_LineActor(){
79     LabelActor = NULL;
80     ArrowActor = NULL;
81   }
82
83   /*!Destructor which call SetLabelActor(NULL) and SetArrowActor(NULL)*/
84   ~VTKViewer_LineActor(){
85     SetLabelActor(NULL);
86     SetArrowActor(NULL);
87   }
88
89   /*!Label actor pointer*/
90   VTKViewer_UnScaledActor* LabelActor;
91
92   /*!Arrow actor pointer*/
93   VTKViewer_UnScaledActor* ArrowActor;
94 };
95
96 //****************************************************************
97 /*!This class provide support trihedron object in vtk viewer.*/
98 class VTKVIEWER_EXPORT VTKVIEWER_EXPORT VTKViewer_Trihedron : public vtkObject
99 {
100 protected:
101   /*!Initialize fields by default values.*/
102   VTKViewer_Trihedron();
103   
104   /*!Const copy constructor.*/
105   VTKViewer_Trihedron(const VTKViewer_Trihedron&);
106
107   /*!Destructor. Remove all fileds.*/
108   virtual ~VTKViewer_Trihedron();
109
110 public:
111   /*!vtk type macros.*/
112   vtkTypeMacro(VTKViewer_Trihedron,vtkObject);
113   
114   /*!Create new instance of VTKViewer_Trihedron.*/
115   static VTKViewer_Trihedron *New();
116   
117   /*!Sets size of trihedron.
118    * \param theSize - float value
119    */
120   virtual void        SetSize(float theSize);
121
122   /*! Get size of trihedron.
123    * \retval mySize - float value
124    */
125   virtual float       GetSize() { return mySize;}
126   
127   enum TVisibility{eOff, eOn, eOnlyLineOn};
128   
129   /*! Sets visibility for all Axis to \a theVis*/
130   virtual void        SetVisibility(TVisibility theVis);
131   
132   /*! OFF visibility for all Axis.*/
133   virtual void        VisibilityOff() { SetVisibility(eOff);}
134
135   /*! ON visibility for all Axis.*/
136   virtual void        VisibilityOn() { SetVisibility(eOn);}
137
138   /*! Gets visibility of myAxis[0] actor.*/
139   virtual TVisibility GetVisibility();
140   
141   /*! Add to render all Axis
142    * \param theRenderer - vtkRenderer pointer
143    */
144   virtual void        AddToRender(vtkRenderer* theRenderer);
145   
146   /*! Remove all actors from \a theRenderer which are in myPresent.
147    * \param theRenderer - vtkRenderer pointer
148    */
149   virtual void        RemoveFromRender(vtkRenderer* theRenderer);
150   
151   /*! Return count of visible actors.
152    * \param theRenderer - vtkRenderer pointer
153    */
154   virtual int         GetVisibleActorCount(vtkRenderer* theRenderer);
155   
156 protected:
157   /*! Actor collection*/
158   vtkActorCollection* myPresent;
159   
160   /*! \li myAxis[0] - X Axis actor
161    *  \li myAxis[1] - Y Axis actor
162    *  \li myAxis[2] - Z Axis actor
163    */
164   VTKViewer_Axis*     myAxis[3];
165   
166   /*! Common size for trihedron, for each axis.*/
167   float               mySize;
168 };
169
170 //****************************************************************
171 /*!The base class for concreate Axis.
172  * Its only duty is to give correct initialization and destruction
173  * of its pipe-lines
174  */
175 class VTKVIEWER_EXPORT VTKViewer_Axis : public vtkObject
176 {
177 protected:
178   VTKViewer_Axis();
179   VTKViewer_Axis(const VTKViewer_Axis&);
180   virtual ~VTKViewer_Axis();
181   
182 public:
183   /*!vtk type macros.*/
184   vtkTypeMacro(VTKViewer_Axis,vtkObject);
185   
186   /*! Add to \a theRenderer actors: myLineActor,myLabelActor,myArrowActor
187    */
188   virtual void AddToRender(vtkRenderer* theRenderer);
189   virtual void RemoveFromRender(vtkRenderer* theRenderer);
190   
191   /*! Sets visibility for actors: myLineActor,myLabelActor,myArrowActor
192    */
193   virtual void SetVisibility(VTKViewer_Trihedron::TVisibility theVis);
194   
195   /*! Return visibility of VTKViewer_Axis
196    * \retval myVisibility
197    */
198   virtual VTKViewer_Trihedron::TVisibility GetVisibility() { return myVisibility; }
199   
200   /*! Set camera for myLabelActor
201    */
202   virtual void SetCamera(vtkCamera* theCamera);
203
204   /*! Sets \a theProperty for actors: myLineActor,myLabelActor,myArrowActor
205    */
206   virtual void SetProperty(vtkProperty* theProperty);
207   
208   /*! Set size of VTKViewer_Axis
209    */
210   virtual void SetSize(float theSize);
211   
212   /*! Get label actor.
213    * \retval Return myLabelActor.
214    */
215   virtual VTKViewer_UnScaledActor* GetLabel() { return myLabelActor; }
216   
217   /*! Get arrow actor.
218    * \retval Return myArrowActor
219    */
220   virtual VTKViewer_UnScaledActor* GetArrow() { return myArrowActor; }
221   
222 protected:
223   /*! Visibility flag.
224    */
225   VTKViewer_Trihedron::TVisibility myVisibility;
226
227   /*! \var myDir[3]
228    * Direction vector
229    */
230   /*! \var myRot[3]
231    * Orientation vector
232    */
233   float myDir[3], myRot[3];
234   
235   /*! VTKViewer_LineActor actor pointer
236    */
237   VTKViewer_LineActor *myLineActor;
238
239   /*! VTKViewer_UnScaledActor actor pointer
240    */
241   VTKViewer_UnScaledActor *myArrowActor;
242
243   /*! VTKViewer_UnScaledActor actor pointer
244    */
245   VTKViewer_UnScaledActor *myLabelActor;
246   
247   /*! \li myMapper[0] - for the Line pipe-line representation
248    *  \li myMapper[1] - for the Arrow pipe-line representation
249    *  \li myMapper[2] - for the Label pipe-line representation
250    */
251   vtkPolyDataMapper *myMapper[3];
252
253   /*! vtkLineSource pointer (Line)
254    */
255   vtkLineSource *myLineSource;
256
257   /*! vtkConeSource pointer (Arrow)
258    */
259   vtkConeSource *myConeSource;
260
261   /*! VTKViewer_VectorText pointer (Label)
262    */
263   VTKViewer_VectorText* myVectorText;
264 };
265
266 #endif