Back to index

salome-gui  6.5.0
VTKViewer_Trihedron.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #ifndef VTKVIEWER_TRIHEDRON_H
00024 #define VTKVIEWER_TRIHEDRON_H
00025 
00026 #include "VTKViewer.h"
00027 
00028 #include <vtkObject.h>
00029 #include <vtkFollower.h>
00030 
00031 class vtkRenderer;
00032 class vtkActorCollection;
00033 class vtkCamera;
00034 class vtkProperty;
00035 class vtkPolyDataMapper;
00036 class vtkLineSource;
00037 class vtkConeSource;
00038 class vtkVectorText;
00039 class vtkTextActor;
00040 class vtkTextMapper;
00041 
00042 class VTKViewer_Axis;
00043 
00044 #if !defined(VTK_XVERSION)
00045 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
00046 #endif
00047 
00048 // VTKViewer_UnScaledActor is temporarily replaced with simple vtkTextActor
00049 // This workaround caused by the bug with disappeared labels of the trihedron
00050 // reproduced after migration from qt-4.4.3 to qt-4.5.2
00051 #if (VTK_XVERSION < 0x050200)
00052 #define IPAL21440
00053 #endif
00054 
00061 class VTKVIEWER_EXPORT VTKViewer_UnScaledActor: public vtkFollower
00062 {
00063   VTKViewer_UnScaledActor(const VTKViewer_UnScaledActor&);
00064   
00065 public:
00066   
00067   vtkTypeMacro(VTKViewer_UnScaledActor,vtkFollower);
00068   
00070   static VTKViewer_UnScaledActor *New();
00071   
00072   virtual vtkFloatingPointType* GetBounds();
00073   virtual void SetSize(int theSize);
00074   virtual void Render(vtkRenderer *theRenderer);
00075 
00076 protected:
00077   VTKViewer_UnScaledActor();
00079   ~VTKViewer_UnScaledActor(){}
00080   
00081   int mySize;
00082 };
00083 
00087 class VTKVIEWER_EXPORT VTKViewer_LineActor: public vtkFollower
00088 {
00089   VTKViewer_LineActor(const VTKViewer_LineActor&);
00090   
00091 public:
00093   vtkTypeMacro(VTKViewer_LineActor,vtkFollower);
00094   
00096   static VTKViewer_LineActor *New();
00097   
00098 #ifdef IPAL21440
00099 
00102   void SetLabelActor(vtkTextActor* theLabelActor);
00103 #else
00104 
00107   void SetLabelActor(VTKViewer_UnScaledActor* theLabelActor);
00108 #endif
00109   
00113   void SetArrowActor(vtkFollower* theArrowActor);
00114 
00115   virtual void Render(vtkRenderer *theRenderer);
00116   
00117 protected:
00118   
00120   VTKViewer_LineActor(){
00121     LabelActor = NULL;
00122     ArrowActor = NULL;
00123   }
00124 
00126   ~VTKViewer_LineActor(){
00127     SetLabelActor(NULL);
00128     SetArrowActor(NULL);
00129   }
00130 
00132 #ifdef IPAL21440
00133   vtkTextActor* LabelActor;
00134 #else
00135   VTKViewer_UnScaledActor* LabelActor;
00136 #endif
00137 
00139   vtkFollower* ArrowActor;
00140 };
00141 
00143 class VTKVIEWER_EXPORT VTKViewer_Trihedron : public vtkObject
00144 {
00145 protected:
00147   VTKViewer_Trihedron();
00148   
00150   VTKViewer_Trihedron(const VTKViewer_Trihedron&);
00151 
00153   virtual ~VTKViewer_Trihedron();
00154 
00155 public:
00157   vtkTypeMacro(VTKViewer_Trihedron,vtkObject);
00158   
00160   static VTKViewer_Trihedron *New();
00161   
00165   virtual void        SetSize(vtkFloatingPointType theSize);
00166 
00170   virtual vtkFloatingPointType  GetSize() { return mySize;}
00171   
00172   enum TVisibility{eOff, eOn, eOnlyLineOn};
00173   
00175   virtual void        SetVisibility(TVisibility theVis);
00176   
00178   virtual void        VisibilityOff() { SetVisibility(eOff);}
00179 
00181   virtual void        VisibilityOn() { SetVisibility(eOn);}
00182 
00184   virtual TVisibility GetVisibility();
00185   
00189   virtual void        AddToRender(vtkRenderer* theRenderer);
00190   
00194   virtual void        RemoveFromRender(vtkRenderer* theRenderer);
00195   
00199   virtual int         GetVisibleActorCount(vtkRenderer* theRenderer);
00200   
00205   virtual bool        OwnActor(const vtkActor* theActor);
00206 
00207 protected:
00209   vtkActorCollection* myPresent;
00210   
00215   VTKViewer_Axis*     myAxis[3];
00216   
00218   vtkFloatingPointType mySize;
00219 };
00220 
00225 class VTKVIEWER_EXPORT VTKViewer_Axis : public vtkObject
00226 {
00227 protected:
00228   VTKViewer_Axis();
00229   VTKViewer_Axis(const VTKViewer_Axis&);
00230   virtual ~VTKViewer_Axis();
00231   
00232 public:
00234   vtkTypeMacro(VTKViewer_Axis,vtkObject);
00235   
00238   virtual void AddToRender(vtkRenderer* theRenderer);
00239   virtual void RemoveFromRender(vtkRenderer* theRenderer);
00240   
00243   virtual void SetVisibility(VTKViewer_Trihedron::TVisibility theVis);
00244   
00248   virtual VTKViewer_Trihedron::TVisibility GetVisibility() { return myVisibility; }
00249   
00252   virtual void SetCamera(vtkCamera* theCamera);
00253 
00259   virtual void SetColor(double theRed, double theGreen, double theBlue);
00260   
00263   virtual void SetSize(vtkFloatingPointType theSize);
00264   
00268 #ifdef IPAL21440
00269   virtual vtkTextActor* GetLabel() { return myLabelActor; }
00270 #else
00271   virtual VTKViewer_UnScaledActor* GetLabel() { return myLabelActor; }
00272 #endif
00273   
00277   virtual vtkFollower* GetArrow() { return myArrowActor; }
00278 
00283   virtual bool OwnActor(const vtkActor* theActor);
00284   
00285 protected:
00288   VTKViewer_Trihedron::TVisibility myVisibility;
00289 
00296   vtkFloatingPointType myDir[3], myRot[3];
00297   
00300   VTKViewer_LineActor *myLineActor;
00301 
00304   vtkFollower *myArrowActor;
00305 
00308 #ifdef IPAL21440
00309   vtkTextActor *myLabelActor;
00310 #else
00311   VTKViewer_UnScaledActor *myLabelActor;
00312 #endif
00313   
00318   vtkPolyDataMapper *myMapper[3];
00319 
00322   vtkLineSource *myLineSource;
00323 
00326   vtkConeSource *myConeSource;
00327 
00328 #ifdef IPAL21440
00329 
00331   vtkTextMapper *myTextMapper;
00332 #else
00333 
00335   vtkVectorText* myVectorText;
00336 #endif
00337 };
00338 
00339 #endif