Salome HOME
Add some missing math.h include (fix compilation error).
[modules/gui.git] / src / VTKViewer / VTKViewer_Trihedron.h
old mode 100755 (executable)
new mode 100644 (file)
index 4618931..aa5cc59
@@ -1,3 +1,25 @@
+// Copyright (C) 2007-2022  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
 #ifndef VTKVIEWER_TRIHEDRON_H
 #define VTKVIEWER_TRIHEDRON_H
 
@@ -5,6 +27,7 @@
 
 #include <vtkObject.h>
 #include <vtkFollower.h>
+#include <vtkVersion.h>
 
 class vtkRenderer;
 class vtkActorCollection;
@@ -13,339 +36,305 @@ class vtkProperty;
 class vtkPolyDataMapper;
 class vtkLineSource;
 class vtkConeSource;
+class vtkVectorText;
+class vtkTextActor;
+class vtkTextMapper;
 
 class VTKViewer_Axis;
-class VTKViewer_VectorText;
 
-//****************************************************************
-/*! \class VTKViewer_UnScaledActor
- * \brief Same as VTK class vtkFollower
+#if !defined(VTK_XVERSION)
+#define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
+#endif
+
+// VTKViewer_UnScaledActor is temporarily replaced with simple vtkTextActor
+// This workaround caused by the bug with disappeared labels of the trihedron
+// reproduced after migration from qt-4.4.3 to qt-4.5.2
+#if (VTK_XVERSION < 0x050200)
+#define IPAL21440
+#endif
+
+/*! \class vtkFollower
+ * See <a href="http://www.vtk.org/">vtk documentation</a>
+ */
+/*!a subclass of actor that always faces the camera
+ *@see vtkFollower
  */
-class VTKViewer_UnScaledActor: public vtkFollower
+class VTKVIEWER_EXPORT VTKViewer_UnScaledActor: public vtkFollower
 {
-  /*! \fn VTKViewer_UnScaledActor(const VTKViewer_UnScaledActor&)
-   */
   VTKViewer_UnScaledActor(const VTKViewer_UnScaledActor&);
   
 public:
   
-  /*! \fn vtkTypeMacro(VTKViewer_UnScaledActor,vtkFollower);
-   *  \brief VTK type macros.
-   */
-  vtkTypeMacro(VTKViewer_UnScaledActor,vtkFollower);
+  vtkTypeMacro(VTKViewer_UnScaledActor,vtkFollower)
   
-  /*! \fn static VTKViewer_UnScaledActor *New();
-   */
+  /*!Create new instance of VTKViewer_UnScaledActor.*/
   static VTKViewer_UnScaledActor *New();
   
-  /*! \fn virtual void SetSize(int theSize);
-   * \brief Sets \a mySize= \a theSize variable.
-   * \param  theSize - integer size
-   */
+  virtual double* GetBounds();
   virtual void SetSize(int theSize);
-  /*! \fn virtual void Render(vtkRenderer *theRenderer);
-   * \brief Render function.
-   */
   virtual void Render(vtkRenderer *theRenderer);
-  
+
 protected:
-  /*! \fn VTKViewer_UnScaledActor();
-   * \brief Constructor.
-   */
   VTKViewer_UnScaledActor();
-  /*! \fn VTKViewer_UnScaledActor();
-   * \brief Destructor..
-   */
+  /*!Destructor. Do nothing.*/
   ~VTKViewer_UnScaledActor(){}
   
   int mySize;
 };
 
-//****************************************************************
-/*! \class VTKViewer_LineActor
+/*!a subclass of actor that always faces the camera
+ *@see vtkFollower
  */
-class VTKViewer_LineActor: public vtkFollower
+class VTKVIEWER_EXPORT VTKViewer_LineActor: public vtkFollower
 {
-  /*! \fn VTKViewer_LineActor(const VTKViewer_LineActor&);
-   */
   VTKViewer_LineActor(const VTKViewer_LineActor&);
   
 public:
-  /*! \fn vtkTypeMacro(VTKViewer_LineActor,vtkFollower);
-   *  \brief VTK type macros.
-   */
-  vtkTypeMacro(VTKViewer_LineActor,vtkFollower);
+  /*!vtk type macros.*/
+  vtkTypeMacro(VTKViewer_LineActor,vtkFollower)
   
-  /*! \fn static VTKViewer_LineActor *New();
-   */
+  /*!Create new instance of VTKViewer_LineActor.*/
   static VTKViewer_LineActor *New();
   
-  /*! \fn void SetLabelActor(VTKViewer_UnScaledActor* theLabelActor);
-   * \brief Sets Lable actor.
+#ifdef IPAL21440
+  /*! Sets Label actor.
+   * \param theLabelActor - vtkTextActor
+   */
+  void SetLabelActor(vtkTextActor* theLabelActor);
+#else
+  /*! Sets Label actor.
    * \param theLabelActor - VTKViewer_UnScaledActor
    */
   void SetLabelActor(VTKViewer_UnScaledActor* theLabelActor);
+#endif
   
-  /*! \fn void SetArrowActor(VTKViewer_UnScaledActor* theLabelActor);
-   * \brief Sets Arrow actor.
+  /*! Sets Arrow actor.
    * \param theLabelActor - VTKViewer_UnScaledActor
    */
-  void SetArrowActor(VTKViewer_UnScaledActor* theLabelActor);
+  void SetArrowActor(vtkFollower* theArrowActor);
 
-  /*! \fn virtual void Render(vtkRenderer *theRenderer);
-   * \brief Adds theRenderer to \a LabelActor and \a ArrowActor, if need.
-   */
   virtual void Render(vtkRenderer *theRenderer);
   
 protected:
   
-  /*! \fn VTKViewer_LineActor()
-   * \brief Constructor which sets \a LabelActor and \a ArrowActor to NULL
-   */
+  /*! Constructor which sets \a LabelActor and \a ArrowActor to NULL*/
   VTKViewer_LineActor(){
     LabelActor = NULL;
     ArrowActor = NULL;
   }
 
-  /*! \fn ~VTKViewer_LineActor()
-   * \brief Destructor which call SetLabelActor(NULL) and SetArrowActor(NULL)
-   */
+  /*!Destructor which call SetLabelActor(NULL) and SetArrowActor(NULL)*/
   ~VTKViewer_LineActor(){
     SetLabelActor(NULL);
     SetArrowActor(NULL);
   }
 
-  /*! \var LabelActor
-   * \brief Label actor pointer
-   */
+  /*!Label actor pointer*/
+#ifdef IPAL21440
+  vtkTextActor* LabelActor;
+#else
   VTKViewer_UnScaledActor* LabelActor;
+#endif
 
-  /*! \var ArrowActor
-   * \brief Arrow actor pointer
-   */
-  VTKViewer_UnScaledActor* ArrowActor;
+  /*!Arrow actor pointer*/
+  vtkFollower* ArrowActor;
 };
 
-//****************************************************************
-/*! \class VTKViewer_Trihedron
- */
+/*!This class provide support trihedron object in vtk viewer.*/
 class VTKVIEWER_EXPORT VTKViewer_Trihedron : public vtkObject
 {
 protected:
-  /*! \fn VTKViewer_Trihedron();
-   * \brief Initialize fields by default values.
-   */
+  /*!Initialize fields by default values.*/
   VTKViewer_Trihedron();
   
-  /*! \fn VTKViewer_Trihedron(const VTKViewer_Trihedron&);
-   * \brief Const copy constructor.
-   */
+  /*!Const copy constructor.*/
   VTKViewer_Trihedron(const VTKViewer_Trihedron&);
 
-  /*! \fn ~VTKViewer_Trihedron();
-   * \brief Destructor. Remove all fileds.
-   */
+  /*!Destructor. Remove all fileds.*/
   virtual ~VTKViewer_Trihedron();
 
 public:
-  /*! \fn vtkTypeMacro(VTKViewer_Trihedron,vtkObject);
-   *  \brief VTK type macros.
-   */
-  vtkTypeMacro(VTKViewer_Trihedron,vtkObject);
+  /*!vtk type macros.*/
+  vtkTypeMacro(VTKViewer_Trihedron,vtkObject)
   
-  /*! \fn static VTKViewer_Trihedron *New();
-   */
+  /*!Create new instance of VTKViewer_Trihedron.*/
   static VTKViewer_Trihedron *New();
   
-  /*! \fn virtual void        SetSize(float theSize);
-   * \brief Sets size of trihedron.
-   * \param theSize - float value
+  /*!Sets size of trihedron.
+   * \param theSize - double value
    */
-  virtual void        SetSize(float theSize);
+  virtual void        SetSize(double theSize);
 
-  /*! \fn virtual float       GetSize() { return mySize;}
-   * \brief Get size of trihedron.
-   * \retval mySize - float value
+  /*! Get size of trihedron.
+   * \retval mySize - double value
    */
-  virtual float       GetSize() { return mySize;}
+  virtual double  GetSize() { return mySize;}
   
   enum TVisibility{eOff, eOn, eOnlyLineOn};
   
-  /*! \fn virtual void        SetVisibility(TVisibility theVis);
-   * \brief Sets visibility for all Axis in \a theVis
-   */
+  /*! Sets visibility for all Axis to \a theVis*/
   virtual void        SetVisibility(TVisibility theVis);
   
-  /*! \fn virtual void        VisibilityOff()
-   * \brief OFF visibility for all Axis.
-   */
+  /*! OFF visibility for all Axis.*/
   virtual void        VisibilityOff() { SetVisibility(eOff);}
 
-  /*! \fn virtual void        VisibilityOn()
-   * \brief ON visibility for all Axis.
-   */
+  /*! ON visibility for all Axis.*/
   virtual void        VisibilityOn() { SetVisibility(eOn);}
 
-  /*! \fn virtual TVisibility GetVisibility();
-   * \brief Gets visibility of myAxis[0] actor.
-   */
+  /*! Gets visibility of myAxis[0] actor.*/
   virtual TVisibility GetVisibility();
   
-  /*! \fn virtual void        AddToRender(vtkRenderer* theRenderer);
-   * \brief Add to render all Axis
+  /*! Add to render all Axis
    * \param theRenderer - vtkRenderer pointer
    */
   virtual void        AddToRender(vtkRenderer* theRenderer);
   
-  /*! \fn virtual void        RemoveFromRender(vtkRenderer* theRenderer);
-   * \brief Remove all actors from \a theRenderer which are in myPresent.
+  /*! Remove all actors from \a theRenderer which are in myPresent.
    * \param theRenderer - vtkRenderer pointer
    */
   virtual void        RemoveFromRender(vtkRenderer* theRenderer);
   
-  /*! \fn virtual int         GetVisibleActorCount(vtkRenderer* theRenderer);
-   * \brief Return count of visible actors.
+  /*! Return count of visible actors.
    * \param theRenderer - vtkRenderer pointer
    */
   virtual int         GetVisibleActorCount(vtkRenderer* theRenderer);
   
-protected:
-  /*! \var myPresent
-   * \brief Actor collection
+  /*! Check if actor belongs to the trihedron object
+   * \param theActor - vtkActor pointer
+   * \retval Return true if the actor belongs to the trihedron object
    */
+  virtual bool        OwnActor(const vtkActor* theActor);
+
+protected:
+  /*! Actor collection*/
   vtkActorCollection* myPresent;
   
-  /*! \var myAxis[3]
-   * \brief \li myAxis[0] - X Axis actor
-   * \brief \li myAxis[1] - Y Axis actor
-   * \brief \li myAxis[2] - Z Axis actor
+  /*! \li myAxis[0] - X Axis actor
+   *  \li myAxis[1] - Y Axis actor
+   *  \li myAxis[2] - Z Axis actor
    */
   VTKViewer_Axis*     myAxis[3];
   
-  /*! \var mySize
-   * \brief Common size for trihedron, for each axis.
-   */
-  float               mySize;
+  /*! Common size for trihedron, for each axis.*/
+  double mySize;
 };
 
-//****************************************************************
-/*! \class VTKViewer_Axis
- * \brief The base class for concreate Axis.
+/*!The base class for concreate Axis.
  * Its only duty is to give correct initialization and destruction
  * of its pipe-lines
  */
-class VTKViewer_Axis : public vtkObject
+class VTKVIEWER_EXPORT VTKViewer_Axis : public vtkObject
 {
 protected:
-  /*! \fn VTKViewer_Axis()
-   */
   VTKViewer_Axis();
-  /*! \fn VTKViewer_Axis(const VTKViewer_Axis&)
-   */
   VTKViewer_Axis(const VTKViewer_Axis&);
-  /*! \fn virtual ~VTKViewer_Axis()
-   */
   virtual ~VTKViewer_Axis();
   
 public:
-  /*! \fn vtkTypeMacro(VTKViewer_Axis,vtkObject);
-   * \brief VTK type macros.
-   */
-  vtkTypeMacro(VTKViewer_Axis,vtkObject);
+  /*!vtk type macros.*/
+  vtkTypeMacro(VTKViewer_Axis,vtkObject)
   
-  /*! \fn virtual void AddToRender(vtkRenderer* theRenderer);
-   * \brief Add to \a theRenderer actors: myLineActor,myLabelActor,myArrowActor
+  /*! Add to \a theRenderer actors: myLineActor,myLabelActor,myArrowActor
    */
   virtual void AddToRender(vtkRenderer* theRenderer);
+  virtual void RemoveFromRender(vtkRenderer* theRenderer);
   
-  /*! \fn virtual void SetVisibility(VTKViewer_Trihedron::TVisibility theVis);
-   * \brief Sets visibility for actors: myLineActor,myLabelActor,myArrowActor
+  /*! Sets visibility for actors: myLineActor,myLabelActor,myArrowActor
    */
   virtual void SetVisibility(VTKViewer_Trihedron::TVisibility theVis);
   
-  /*! \fn virtual VTKViewer_Trihedron::TVisibility GetVisibility()
-   * \brief Return visibility of VTKViewer_Axis
+  /*! Return visibility of VTKViewer_Axis
    * \retval myVisibility
    */
   virtual VTKViewer_Trihedron::TVisibility GetVisibility() { return myVisibility; }
   
-  /*! \fn virtual void SetCamera(vtkCamera* theCamera);
-   * \brief Set camera for myLabelActor
+  /*! Set camera for myLabelActor
    */
   virtual void SetCamera(vtkCamera* theCamera);
 
-  /*! \fn virtual void SetProperty(vtkProperty* theProperty);
-   * \brief Sets \a theProperty for actors: myLineActor,myLabelActor,myArrowActor
+  /*! Sets color for actors: myLineActor,myLabelActor,myArrowActor
+   * \param theRed - red component of the color
+   * \param theGreen - green component of the color
+   * \param theBlue - blue component of the color
    */
-  virtual void SetProperty(vtkProperty* theProperty);
+  virtual void SetColor(double theRed, double theGreen, double theBlue);
   
-  /*! \fn virtual void SetSize(float theSize);
-   * \brief Set size of VTKViewer_Axis
+  /*! Set size of VTKViewer_Axis
    */
-  virtual void SetSize(float theSize);
+  virtual void SetSize(double theSize);
   
-  /*! \fn virtual VTKViewer_UnScaledActor* GetLabel()
-   * \brief Get label actor.
+  /*! Get label actor.
    * \retval Return myLabelActor.
    */
+#ifdef IPAL21440
+  virtual vtkTextActor* GetLabel() { return myLabelActor; }
+#else
   virtual VTKViewer_UnScaledActor* GetLabel() { return myLabelActor; }
+#endif
   
-  /*! \fn virtual VTKViewer_UnScaledActor* GetArrow()
-   * \brief Get arrow actor.
+  /*! Get arrow actor.
    * \retval Return myArrowActor
    */
-  virtual VTKViewer_UnScaledActor* GetArrow() { return myArrowActor; }
+  virtual vtkFollower* GetArrow() { return myArrowActor; }
+
+  /*! Check if actor belongs to the axis object
+   * \param theActor - vtkActor pointer
+   * \retval Return true if the actor belongs to the axis object
+   */
+  virtual bool OwnActor(const vtkActor* theActor);
   
 protected:
-  /*! \var myVisibility
-   * \brief Visibility flag.
+  /*! Visibility flag.
    */
   VTKViewer_Trihedron::TVisibility myVisibility;
 
   /*! \var myDir[3]
-   * \brief Direction vector
+   * Direction vector
    */
   /*! \var myRot[3]
-   * \brief Orientation vector
+   * Orientation vector
    */
-  float myDir[3], myRot[3];
+  double myDir[3], myRot[3];
   
-  /*! \var myLineActor
-   * \brief VTKViewer_LineActor actor pointer
+  /*! VTKViewer_LineActor actor pointer
    */
   VTKViewer_LineActor *myLineActor;
 
-  /*! \var myArrowActor
-   * \brief VTKViewer_UnScaledActor actor pointer
+  /*! vtkFollower actor pointer
    */
-  VTKViewer_UnScaledActor *myArrowActor;
+  vtkFollower *myArrowActor;
 
-  /*! \var myLabelActor
-   * \brief VTKViewer_UnScaledActor actor pointer
+  /*! VTKViewer_UnScaledActor actor pointer
    */
+#ifdef IPAL21440
+  vtkTextActor *myLabelActor;
+#else
   VTKViewer_UnScaledActor *myLabelActor;
+#endif
   
-  /*! \var myMapper[3]
-   * \brief \li myMapper[0] - for the Line pipe-line representation
-   * \brief \li myMapper[1] - for the Arrow pipe-line representation
-   * \brief \li myMapper[2] - for the Label pipe-line representation
+  /*! \li myMapper[0] - for the Line pipe-line representation
+   *  \li myMapper[1] - for the Arrow pipe-line representation
+   *  \li myMapper[2] - for the Label pipe-line representation
    */
   vtkPolyDataMapper *myMapper[3];
 
-  /*! \var myLineSource
-   * \brief vtkLineSource pointer (Line)
+  /*! vtkLineSource pointer (Line)
    */
   vtkLineSource *myLineSource;
 
-  /*! \var myConeSource
-   * \brief vtkConeSource pointer (Arrow)
+  /*! vtkConeSource pointer (Arrow)
    */
   vtkConeSource *myConeSource;
 
-  /*! \var myVectorText
-   * \brief VTKViewer_VectorText pointer (Label)
+#ifdef IPAL21440
+  /*! vtkTextMapper pointer (Label)
+   */
+  vtkTextMapper *myTextMapper;
+#else
+  /*! VTKViewer_VectorText pointer (Label)
    */
-  VTKViewer_VectorText* myVectorText;
+  vtkVectorText* myVectorText;
+#endif
 };
 
 #endif