Back to index

salome-gui  6.5.0
SVTK_Renderer.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 //  SALOME VTKViewer : build VTK viewer into Salome desktop
00024 //  File   : 
00025 //  Author : 
00026 
00027 #ifndef SVTK_Renderer_h
00028 #define SVTK_Renderer_h
00029 
00030 #include "SVTK.h"
00031 #include "VTKViewer.h"
00032 
00033 #include <vtkObject.h>
00034 #include <vtkSmartPointer.h>
00035 
00036 class vtkRenderer;
00037 class vtkCallbackCommand;
00038 class vtkRenderWindowInteractor;
00039 
00040 class vtkPicker;
00041 class vtkPointPicker;
00042 class vtkCellPicker;
00043 class vtkProperty;
00044 
00045 class SVTK_RectPicker;
00046 
00047 class VTKViewer_Trihedron;
00048 class VTKViewer_Transform;
00049 class SVTK_CubeAxesActor2D;
00050 class VTKViewer_Actor;
00051 class SVTK_Selector;
00052 
00053 #ifdef WIN32
00054 #pragma warning ( disable:4251 )
00055 #endif
00056 
00064 class SVTK_EXPORT SVTK_Renderer : public vtkObject
00065 {
00066  public:
00067   vtkTypeMacro(SVTK_Renderer,vtkObject);
00068   static SVTK_Renderer* New();
00069 
00070   //----------------------------------------------------------------------------
00072   vtkRenderer* 
00073   GetDevice();
00074 
00076   virtual
00077   void 
00078   Initialize(vtkRenderWindowInteractor* theInteractor,
00079              SVTK_Selector* theSelector);
00080 
00081   //----------------------------------------------------------------------------
00083   virtual
00084   void 
00085   AddActor(VTKViewer_Actor* theActor, bool theIsAdjustActors = true);
00086 
00088   virtual
00089   void 
00090   RemoveActor(VTKViewer_Actor* theActor, bool theIsAdjustActors = true);
00091 
00093   VTKViewer_Transform* 
00094   GetTransform();
00095 
00097   virtual
00098   void
00099   SetScale( double theScale[3] );
00100 
00102   void
00103   GetScale( double theScale[3] );
00104 
00105   //----------------------------------------------------------------------------
00107   void
00108   SetSelectionProp(const double& theRed = 1, 
00109                    const double& theGreen = 1,
00110                    const double& theBlue = 0, 
00111                    const int& theWidth = 5);
00112 
00114   void
00115   SetPreselectionProp(const double& theRed = 0, 
00116                       const double& theGreen = 1,
00117                       const double& theBlue = 1, 
00118                       const int& theWidth = 5);
00119 
00121   void
00122   SetSelectionTolerance(const double& theTolNodes = 0.025, 
00123                         const double& theTolCell = 0.001,
00124                         const double& theTolObjects = 0.025);
00125 
00126   //----------------------------------------------------------------------------
00128   void
00129   AdjustActors();
00130 
00132   void
00133   SetTrihedronSize(vtkFloatingPointType theSize, const bool theRelative = true);
00134  
00136   vtkFloatingPointType  
00137   GetTrihedronSize() const;
00138 
00140   bool  
00141   IsTrihedronRelative() const;
00142 
00143   //----------------------------------------------------------------------------
00145   VTKViewer_Trihedron* 
00146   GetTrihedron();
00147 
00149   bool 
00150   IsTrihedronDisplayed();
00151 
00153   void 
00154   OnViewTrihedron(); 
00155 
00157   void 
00158   OnAdjustTrihedron();
00159 
00160   //----------------------------------------------------------------------------
00162   SVTK_CubeAxesActor2D* 
00163   GetCubeAxes();
00164 
00166   bool 
00167   IsCubeAxesDisplayed();
00168 
00170   void 
00171   OnViewCubeAxes();
00172 
00174   void 
00175   OnAdjustCubeAxes();
00176 
00177   //----------------------------------------------------------------------------
00179   void OnFitAll(); 
00180   
00182   void OnResetView(); 
00183 
00185   void OnResetClippingRange(); 
00186 
00188   void OnFrontView(); 
00189 
00191   void OnBackView(); 
00192 
00194   void OnTopView();
00195 
00197   void OnBottomView();
00198 
00200   void OnRightView(); 
00201 
00203   void OnLeftView();     
00204 
00206   void onClockWiseView();
00207 
00209   void onAntiClockWiseView();
00210 
00211 protected:
00212   SVTK_Renderer();
00213   ~SVTK_Renderer();
00214 
00215   virtual
00216   bool
00217   OnAdjustActors();
00218 
00219   //----------------------------------------------------------------------------
00220   // Priority at which events are processed
00221   vtkFloatingPointType myPriority;
00222 
00223   // Used to process events
00224   vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
00225 
00226   // Description:
00227   // Main process event method
00228   static void ProcessEvents(vtkObject* object, 
00229                             unsigned long event,
00230                             void* clientdata, 
00231                             void* calldata);
00232   
00233   vtkSmartPointer<vtkRenderer> myDevice;
00234   vtkRenderWindowInteractor* myInteractor;
00235   vtkSmartPointer<SVTK_Selector> mySelector;
00236 
00237   //----------------------------------------------------------------------------
00238   vtkSmartPointer<VTKViewer_Transform> myTransform;
00239 
00240   //----------------------------------------------------------------------------
00241   // Highlight/ Prehighlight devices
00242   vtkSmartPointer<vtkPointPicker> myPointPicker;
00243   vtkSmartPointer<vtkCellPicker> myCellPicker;
00244 
00245   vtkSmartPointer<SVTK_RectPicker> myPointRectPicker;
00246   vtkSmartPointer<SVTK_RectPicker> myCellRectPicker;
00247 
00248   vtkSmartPointer<vtkProperty> myPreHighlightProperty;
00249   vtkSmartPointer<vtkProperty> myHighlightProperty;
00250 
00251   //----------------------------------------------------------------------------
00252   vtkSmartPointer<SVTK_CubeAxesActor2D> myCubeAxes;
00253   vtkSmartPointer<VTKViewer_Trihedron> myTrihedron;  
00254   vtkFloatingPointType myTrihedronSize;
00255   bool myIsTrihedronRelative;
00256   vtkFloatingPointType myBndBox[6];
00257 };
00258 
00259 #ifdef WIN32
00260 #pragma warning ( default:4251 )
00261 #endif
00262 
00263 #endif