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