1 // Copyright (C) 2007-2024 CEA, EDF, 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, or (at your option) any later version.
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>
30 #include <vtkVersion.h>
33 class vtkActorCollection;
36 class vtkPolyDataMapper;
45 #if !defined(VTK_XVERSION)
46 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
49 // VTKViewer_UnScaledActor is temporarily replaced with simple vtkTextActor
50 // This workaround caused by the bug with disappeared labels of the trihedron
51 // reproduced after migration from qt-4.4.3 to qt-4.5.2
52 #if (VTK_XVERSION < 0x050200)
56 /*! \class vtkFollower
57 * See <a href="http://www.vtk.org/">vtk documentation</a>
59 /*!a subclass of actor that always faces the camera
62 class VTKVIEWER_EXPORT VTKViewer_UnScaledActor: public vtkFollower
64 VTKViewer_UnScaledActor(const VTKViewer_UnScaledActor&);
68 vtkTypeMacro(VTKViewer_UnScaledActor,vtkFollower)
70 /*!Create new instance of VTKViewer_UnScaledActor.*/
71 static VTKViewer_UnScaledActor *New();
73 virtual double* GetBounds();
74 virtual void SetSize(int theSize);
75 virtual void Render(vtkRenderer *theRenderer);
78 VTKViewer_UnScaledActor();
79 /*!Destructor. Do nothing.*/
80 ~VTKViewer_UnScaledActor(){}
85 /*!a subclass of actor that always faces the camera
88 class VTKVIEWER_EXPORT VTKViewer_LineActor: public vtkFollower
90 VTKViewer_LineActor(const VTKViewer_LineActor&);
94 vtkTypeMacro(VTKViewer_LineActor,vtkFollower)
96 /*!Create new instance of VTKViewer_LineActor.*/
97 static VTKViewer_LineActor *New();
100 /*! Sets Label actor.
101 * \param theLabelActor - vtkTextActor
103 void SetLabelActor(vtkTextActor* theLabelActor);
105 /*! Sets Label actor.
106 * \param theLabelActor - VTKViewer_UnScaledActor
108 void SetLabelActor(VTKViewer_UnScaledActor* theLabelActor);
111 /*! Sets Arrow actor.
112 * \param theLabelActor - VTKViewer_UnScaledActor
114 void SetArrowActor(vtkFollower* theArrowActor);
116 virtual void Render(vtkRenderer *theRenderer);
120 /*! Constructor which sets \a LabelActor and \a ArrowActor to NULL*/
121 VTKViewer_LineActor(){
126 /*!Destructor which call SetLabelActor(NULL) and SetArrowActor(NULL)*/
127 ~VTKViewer_LineActor(){
132 /*!Label actor pointer*/
134 vtkTextActor* LabelActor;
136 VTKViewer_UnScaledActor* LabelActor;
139 /*!Arrow actor pointer*/
140 vtkFollower* ArrowActor;
143 /*!This class provide support trihedron object in vtk viewer.*/
144 class VTKVIEWER_EXPORT VTKViewer_Trihedron : public vtkObject
147 /*!Initialize fields by default values.*/
148 VTKViewer_Trihedron();
150 /*!Const copy constructor.*/
151 VTKViewer_Trihedron(const VTKViewer_Trihedron&);
153 /*!Destructor. Remove all fileds.*/
154 virtual ~VTKViewer_Trihedron();
157 /*!vtk type macros.*/
158 vtkTypeMacro(VTKViewer_Trihedron,vtkObject)
160 /*!Create new instance of VTKViewer_Trihedron.*/
161 static VTKViewer_Trihedron *New();
163 /*!Sets size of trihedron.
164 * \param theSize - double value
166 virtual void SetSize(double theSize);
168 /*! Get size of trihedron.
169 * \retval mySize - double value
171 virtual double GetSize() { return mySize;}
173 enum TVisibility{eOff, eOn, eOnlyLineOn};
175 /*! Sets visibility for all Axis to \a theVis*/
176 virtual void SetVisibility(TVisibility theVis);
178 /*! OFF visibility for all Axis.*/
179 virtual void VisibilityOff() { SetVisibility(eOff);}
181 /*! ON visibility for all Axis.*/
182 virtual void VisibilityOn() { SetVisibility(eOn);}
184 /*! Gets visibility of myAxis[0] actor.*/
185 virtual TVisibility GetVisibility();
187 /*! Add to render all Axis
188 * \param theRenderer - vtkRenderer pointer
190 virtual void AddToRender(vtkRenderer* theRenderer);
192 /*! Remove all actors from \a theRenderer which are in myPresent.
193 * \param theRenderer - vtkRenderer pointer
195 virtual void RemoveFromRender(vtkRenderer* theRenderer);
197 /*! Return count of visible actors.
198 * \param theRenderer - vtkRenderer pointer
200 virtual int GetVisibleActorCount(vtkRenderer* theRenderer);
202 /*! Check if actor belongs to the trihedron object
203 * \param theActor - vtkActor pointer
204 * \retval Return true if the actor belongs to the trihedron object
206 virtual bool OwnActor(const vtkActor* theActor);
209 /*! Actor collection*/
210 vtkActorCollection* myPresent;
212 /*! \li myAxis[0] - X Axis actor
213 * \li myAxis[1] - Y Axis actor
214 * \li myAxis[2] - Z Axis actor
216 VTKViewer_Axis* myAxis[3];
218 /*! Common size for trihedron, for each axis.*/
222 /*!The base class for concreate Axis.
223 * Its only duty is to give correct initialization and destruction
226 class VTKVIEWER_EXPORT VTKViewer_Axis : public vtkObject
230 VTKViewer_Axis(const VTKViewer_Axis&);
231 virtual ~VTKViewer_Axis();
234 /*!vtk type macros.*/
235 vtkTypeMacro(VTKViewer_Axis,vtkObject)
237 /*! Add to \a theRenderer actors: myLineActor,myLabelActor,myArrowActor
239 virtual void AddToRender(vtkRenderer* theRenderer);
240 virtual void RemoveFromRender(vtkRenderer* theRenderer);
242 /*! Sets visibility for actors: myLineActor,myLabelActor,myArrowActor
244 virtual void SetVisibility(VTKViewer_Trihedron::TVisibility theVis);
246 /*! Return visibility of VTKViewer_Axis
247 * \retval myVisibility
249 virtual VTKViewer_Trihedron::TVisibility GetVisibility() { return myVisibility; }
251 /*! Set camera for myLabelActor
253 virtual void SetCamera(vtkCamera* theCamera);
255 /*! Sets color for actors: myLineActor,myLabelActor,myArrowActor
256 * \param theRed - red component of the color
257 * \param theGreen - green component of the color
258 * \param theBlue - blue component of the color
260 virtual void SetColor(double theRed, double theGreen, double theBlue);
262 /*! Set size of VTKViewer_Axis
264 virtual void SetSize(double theSize);
267 * \retval Return myLabelActor.
270 virtual vtkTextActor* GetLabel() { return myLabelActor; }
272 virtual VTKViewer_UnScaledActor* GetLabel() { return myLabelActor; }
276 * \retval Return myArrowActor
278 virtual vtkFollower* GetArrow() { return myArrowActor; }
280 /*! Check if actor belongs to the axis object
281 * \param theActor - vtkActor pointer
282 * \retval Return true if the actor belongs to the axis object
284 virtual bool OwnActor(const vtkActor* theActor);
289 VTKViewer_Trihedron::TVisibility myVisibility;
297 double myDir[3], myRot[3];
299 /*! VTKViewer_LineActor actor pointer
301 VTKViewer_LineActor *myLineActor;
303 /*! vtkFollower actor pointer
305 vtkFollower *myArrowActor;
307 /*! VTKViewer_UnScaledActor actor pointer
310 vtkTextActor *myLabelActor;
312 VTKViewer_UnScaledActor *myLabelActor;
315 /*! \li myMapper[0] - for the Line pipe-line representation
316 * \li myMapper[1] - for the Arrow pipe-line representation
317 * \li myMapper[2] - for the Label pipe-line representation
319 vtkPolyDataMapper *myMapper[3];
321 /*! vtkLineSource pointer (Line)
323 vtkLineSource *myLineSource;
325 /*! vtkConeSource pointer (Arrow)
327 vtkConeSource *myConeSource;
330 /*! vtkTextMapper pointer (Label)
332 vtkTextMapper *myTextMapper;
334 /*! VTKViewer_VectorText pointer (Label)
336 vtkVectorText* myVectorText;