1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #ifndef VTKVIEWER_TRIHEDRON_H
24 #define VTKVIEWER_TRIHEDRON_H
26 #include "VTKViewer.h"
28 #include <vtkObject.h>
29 #include <vtkFollower.h>
32 class vtkActorCollection;
35 class vtkPolyDataMapper;
44 #if !defined(VTK_XVERSION)
45 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
48 // VTKViewer_UnScaledActor is temporarily replaced with simple vtkTextActor
49 // This workaround caused by the bug with disappeared labels of the trihedron
50 // reproduced after migration from qt-4.4.3 to qt-4.5.2
51 #if (VTK_XVERSION < 0x050200)
55 /*! \class vtkFollower
56 * See <a href="http://www.vtk.org/">vtk documentation</a>
58 /*!a subclass of actor that always faces the camera
61 class VTKVIEWER_EXPORT VTKViewer_UnScaledActor: public vtkFollower
63 VTKViewer_UnScaledActor(const VTKViewer_UnScaledActor&);
67 vtkTypeMacro(VTKViewer_UnScaledActor,vtkFollower);
69 /*!Create new instance of VTKViewer_UnScaledActor.*/
70 static VTKViewer_UnScaledActor *New();
72 virtual vtkFloatingPointType* GetBounds();
73 virtual void SetSize(int theSize);
74 virtual void Render(vtkRenderer *theRenderer);
77 VTKViewer_UnScaledActor();
78 /*!Destructor. Do nothing.*/
79 ~VTKViewer_UnScaledActor(){}
84 /*!a subclass of actor that always faces the camera
87 class VTKVIEWER_EXPORT VTKViewer_LineActor: public vtkFollower
89 VTKViewer_LineActor(const VTKViewer_LineActor&);
93 vtkTypeMacro(VTKViewer_LineActor,vtkFollower);
95 /*!Create new instance of VTKViewer_LineActor.*/
96 static VTKViewer_LineActor *New();
100 * \param theLabelActor - vtkTextActor
102 void SetLabelActor(vtkTextActor* theLabelActor);
104 /*! Sets Label actor.
105 * \param theLabelActor - VTKViewer_UnScaledActor
107 void SetLabelActor(VTKViewer_UnScaledActor* theLabelActor);
110 /*! Sets Arrow actor.
111 * \param theLabelActor - VTKViewer_UnScaledActor
113 void SetArrowActor(vtkFollower* theArrowActor);
115 virtual void Render(vtkRenderer *theRenderer);
119 /*! Constructor which sets \a LabelActor and \a ArrowActor to NULL*/
120 VTKViewer_LineActor(){
125 /*!Destructor which call SetLabelActor(NULL) and SetArrowActor(NULL)*/
126 ~VTKViewer_LineActor(){
131 /*!Label actor pointer*/
133 vtkTextActor* LabelActor;
135 VTKViewer_UnScaledActor* LabelActor;
138 /*!Arrow actor pointer*/
139 vtkFollower* ArrowActor;
142 /*!This class provide support trihedron object in vtk viewer.*/
143 class VTKVIEWER_EXPORT VTKViewer_Trihedron : public vtkObject
146 /*!Initialize fields by default values.*/
147 VTKViewer_Trihedron();
149 /*!Const copy constructor.*/
150 VTKViewer_Trihedron(const VTKViewer_Trihedron&);
152 /*!Destructor. Remove all fileds.*/
153 virtual ~VTKViewer_Trihedron();
156 /*!vtk type macros.*/
157 vtkTypeMacro(VTKViewer_Trihedron,vtkObject);
159 /*!Create new instance of VTKViewer_Trihedron.*/
160 static VTKViewer_Trihedron *New();
162 /*!Sets size of trihedron.
163 * \param theSize - vtkFloatingPointType value
165 virtual void SetSize(vtkFloatingPointType theSize);
167 /*! Get size of trihedron.
168 * \retval mySize - vtkFloatingPointType value
170 virtual vtkFloatingPointType GetSize() { return mySize;}
172 enum TVisibility{eOff, eOn, eOnlyLineOn};
174 /*! Sets visibility for all Axis to \a theVis*/
175 virtual void SetVisibility(TVisibility theVis);
177 /*! OFF visibility for all Axis.*/
178 virtual void VisibilityOff() { SetVisibility(eOff);}
180 /*! ON visibility for all Axis.*/
181 virtual void VisibilityOn() { SetVisibility(eOn);}
183 /*! Gets visibility of myAxis[0] actor.*/
184 virtual TVisibility GetVisibility();
186 /*! Add to render all Axis
187 * \param theRenderer - vtkRenderer pointer
189 virtual void AddToRender(vtkRenderer* theRenderer);
191 /*! Remove all actors from \a theRenderer which are in myPresent.
192 * \param theRenderer - vtkRenderer pointer
194 virtual void RemoveFromRender(vtkRenderer* theRenderer);
196 /*! Return count of visible actors.
197 * \param theRenderer - vtkRenderer pointer
199 virtual int GetVisibleActorCount(vtkRenderer* theRenderer);
201 /*! Check if actor belongs to the trihedron object
202 * \param theActor - vtkActor pointer
203 * \retval Return true if the actor belongs to the trihedron object
205 virtual bool OwnActor(const vtkActor* theActor);
208 /*! Actor collection*/
209 vtkActorCollection* myPresent;
211 /*! \li myAxis[0] - X Axis actor
212 * \li myAxis[1] - Y Axis actor
213 * \li myAxis[2] - Z Axis actor
215 VTKViewer_Axis* myAxis[3];
217 /*! Common size for trihedron, for each axis.*/
218 vtkFloatingPointType mySize;
221 /*!The base class for concreate Axis.
222 * Its only duty is to give correct initialization and destruction
225 class VTKVIEWER_EXPORT VTKViewer_Axis : public vtkObject
229 VTKViewer_Axis(const VTKViewer_Axis&);
230 virtual ~VTKViewer_Axis();
233 /*!vtk type macros.*/
234 vtkTypeMacro(VTKViewer_Axis,vtkObject);
236 /*! Add to \a theRenderer actors: myLineActor,myLabelActor,myArrowActor
238 virtual void AddToRender(vtkRenderer* theRenderer);
239 virtual void RemoveFromRender(vtkRenderer* theRenderer);
241 /*! Sets visibility for actors: myLineActor,myLabelActor,myArrowActor
243 virtual void SetVisibility(VTKViewer_Trihedron::TVisibility theVis);
245 /*! Return visibility of VTKViewer_Axis
246 * \retval myVisibility
248 virtual VTKViewer_Trihedron::TVisibility GetVisibility() { return myVisibility; }
250 /*! Set camera for myLabelActor
252 virtual void SetCamera(vtkCamera* theCamera);
254 /*! Sets color for actors: myLineActor,myLabelActor,myArrowActor
255 * \param theRed - red component of the color
256 * \param theGreen - green component of the color
257 * \param theBlue - blue component of the color
259 virtual void SetColor(double theRed, double theGreen, double theBlue);
261 /*! Set size of VTKViewer_Axis
263 virtual void SetSize(vtkFloatingPointType theSize);
266 * \retval Return myLabelActor.
269 virtual vtkTextActor* GetLabel() { return myLabelActor; }
271 virtual VTKViewer_UnScaledActor* GetLabel() { return myLabelActor; }
275 * \retval Return myArrowActor
277 virtual vtkFollower* GetArrow() { return myArrowActor; }
279 /*! Check if actor belongs to the axis object
280 * \param theActor - vtkActor pointer
281 * \retval Return true if the actor belongs to the axis object
283 virtual bool OwnActor(const vtkActor* theActor);
288 VTKViewer_Trihedron::TVisibility myVisibility;
296 vtkFloatingPointType myDir[3], myRot[3];
298 /*! VTKViewer_LineActor actor pointer
300 VTKViewer_LineActor *myLineActor;
302 /*! vtkFollower actor pointer
304 vtkFollower *myArrowActor;
306 /*! VTKViewer_UnScaledActor actor pointer
309 vtkTextActor *myLabelActor;
311 VTKViewer_UnScaledActor *myLabelActor;
314 /*! \li myMapper[0] - for the Line pipe-line representation
315 * \li myMapper[1] - for the Arrow pipe-line representation
316 * \li myMapper[2] - for the Label pipe-line representation
318 vtkPolyDataMapper *myMapper[3];
320 /*! vtkLineSource pointer (Line)
322 vtkLineSource *myLineSource;
324 /*! vtkConeSource pointer (Arrow)
326 vtkConeSource *myConeSource;
329 /*! vtkTextMapper pointer (Label)
331 vtkTextMapper *myTextMapper;
333 /*! VTKViewer_VectorText pointer (Label)
335 vtkVectorText* myVectorText;