Back to index

salome-gui  6.5.0
SALOME_Actor.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 OBJECT : implementation of interactive object visualization for OCC and VTK viewers
00024 //  File   : SALOME_Actor.h
00025 //  Author : Nicolas REJNERI
00026 
00027 #ifndef SALOME_ACTOR_H
00028 #define SALOME_ACTOR_H
00029 
00030 #include "SVTK_SelectionEvent.h"
00031 #include "SVTK_Selector.h"
00032 #include "SVTK.h"
00033 
00034 class Handle(SALOME_InteractiveObject);
00035 
00036 // undefining min and max because CASCADE's defines them and
00037 // it clashes with std::min(), std::max()
00038 #undef min
00039 #undef max
00040 
00041 #include <VTKViewer_Actor.h>
00042 #include <VTKViewer_MarkerDef.h>
00043 
00044 #include <vtkSmartPointer.h>
00045 
00046 class vtkAbstractPicker;
00047 class vtkPointPicker;
00048 class vtkCellPicker;
00049 class vtkOutlineSource;
00050 class vtkInteractorStyle;
00051 class vtkRenderWindowInteractor;
00052 
00053 class VTKViewer_FramedTextActor;
00054 
00055 class SVTK_Actor;
00056 class SVTK_RectPicker;
00057 class SVTK_InteractorStyle;
00058 
00059 SVTK_EXPORT extern int SALOME_POINT_SIZE;
00060 SVTK_EXPORT extern int SALOME_LINE_WIDTH;
00061 
00062 #ifdef WIN32
00063 #pragma warning ( disable:4251 )
00064 #endif
00065 
00067 
00072 class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor 
00073 {
00074  public:
00075   static SALOME_Actor* New();
00076   
00077   vtkTypeMacro(SALOME_Actor,VTKViewer_Actor);
00078 
00079   //----------------------------------------------------------------------------
00081   virtual
00082   Standard_Boolean 
00083   hasIO();
00084 
00086   virtual 
00087   const Handle(SALOME_InteractiveObject)& 
00088   getIO(); 
00089 
00091   virtual
00092   void
00093   setIO(const Handle(SALOME_InteractiveObject)& theIO);
00094 
00096   virtual
00097   void
00098   setName(const char* theName);
00099 
00100   //----------------------------------------------------------------------------
00102   virtual
00103   void
00104   SetTransform(VTKViewer_Transform* theTransform); 
00105 
00107   virtual
00108   void
00109   SetPosition(vtkFloatingPointType _arg1, 
00110               vtkFloatingPointType _arg2, 
00111               vtkFloatingPointType _arg3);
00112 
00114   virtual
00115   void
00116   SetPosition(vtkFloatingPointType _arg[3]);
00117 
00118   //----------------------------------------------------------------------------
00120   virtual
00121   void
00122   SetVisibility( int );
00123 
00125   virtual
00126   bool
00127   ShouldBeDisplayed();
00128 
00129   //----------------------------------------------------------------------------
00131   virtual
00132   void
00133   AddToRender(vtkRenderer* theRendere); 
00134 
00136   virtual
00137   void
00138   RemoveFromRender(vtkRenderer* theRendere);
00139 
00141   vtkRenderer*
00142   GetRenderer();
00143 
00144   //----------------------------------------------------------------------------
00146   virtual
00147   void
00148   SetInteractor(vtkRenderWindowInteractor* theInteractor);
00149 
00151   virtual
00152   void
00153   Update();
00154 
00155   //----------------------------------------------------------------------------
00157   virtual
00158   void
00159   SetSelector(SVTK_Selector* theSelector);
00160 
00162   virtual
00163   void
00164   highlight(bool theHighlight);  
00165 
00167   virtual
00168   void
00169   Highlight(bool theHighlight);  
00170 
00171   //----------------------------------------------------------------------------
00173   virtual
00174   bool
00175   PreHighlight(vtkInteractorStyle* theInteractorStyle, 
00176                SVTK_SelectionEvent* theSelectionEvent,
00177                bool theIsHighlight);
00178 
00180   virtual 
00181   bool
00182   Highlight(vtkInteractorStyle* theInteractorStyle, 
00183             SVTK_SelectionEvent* theSelectionEvent,
00184             bool theIsHighlight);
00185 
00186   //----------------------------------------------------------------------------
00188   virtual
00189   bool
00190   IsDisplayNameActor() const;
00191 
00193   virtual
00194   void
00195   SetIsDisplayNameActor(bool theIsDisplayNameActor);
00196 
00198   virtual
00199   void
00200   SetNameActorText(const char* theText);
00201 
00203   virtual
00204   void
00205   SetNameActorOffset(int theOffset[2]);
00206 
00208   virtual
00209   void
00210   GetNameActorSize(vtkRenderer* theRenderer, int theSize[2]) const;
00211 
00213   virtual
00214   void
00215   UpdateNameActors();
00216 
00217   //----------------------------------------------------------------------------
00219   virtual
00220   void
00221   SetMarkerStd( VTK::MarkerType, VTK::MarkerScale );
00222 
00224   virtual
00225   void
00226   SetMarkerTexture( int, VTK::MarkerTexture );
00227 
00229   virtual
00230   VTK::MarkerType
00231   GetMarkerType();
00232 
00234   virtual
00235   VTK::MarkerScale
00236   GetMarkerScale();
00237 
00239   virtual
00240   int
00241   GetMarkerTexture();
00242 
00243   //----------------------------------------------------------------------------
00245   void
00246   SetPointPicker(vtkPointPicker* thePointPicker); 
00247 
00249   void
00250   SetCellPicker(vtkCellPicker* theCellPicker); 
00251 
00253   void
00254   SetPointRectPicker(SVTK_RectPicker* theRectPicker);
00255 
00257   void
00258   SetCellRectPicker(SVTK_RectPicker* theRectPicker);
00259 
00260   //----------------------------------------------------------------------------
00262   void
00263   SetPreHighlightProperty(vtkProperty* theProperty);
00264 
00266   void
00267   SetHighlightProperty(vtkProperty* theProperty);
00268 
00269  protected:
00270   //----------------------------------------------------------------------------
00271   vtkRenderWindowInteractor* myInteractor;
00272   vtkRenderer* myRenderer;
00273 
00274   Handle(SALOME_InteractiveObject) myIO;
00275 
00276   SALOME_Actor();
00277   ~SALOME_Actor();
00278 
00279  protected:
00280   Selection_Mode mySelectionMode;
00281   vtkSmartPointer<SVTK_Selector> mySelector;
00282 
00283   //----------------------------------------------------------------------------
00284   // Highlight/ Prehighlight devices
00285   vtkSmartPointer<vtkPointPicker> myPointPicker;
00286   vtkSmartPointer<vtkCellPicker> myCellPicker;
00287 
00288   vtkSmartPointer<SVTK_RectPicker> myPointRectPicker;
00289   vtkSmartPointer<SVTK_RectPicker> myCellRectPicker;
00290 
00291   vtkSmartPointer<SVTK_Actor> myPreHighlightActor;
00292   vtkSmartPointer<SVTK_Actor> myHighlightActor;
00293 
00294   vtkSmartPointer<VTKViewer_Actor> myOutlineActor;
00295   vtkSmartPointer<vtkOutlineSource> myOutline;
00296 
00297   bool myIsDisplayNameActor;
00298   vtkSmartPointer<VTKViewer_FramedTextActor> myNameActor;
00299 };
00300 
00301 namespace SVTK
00302 {
00303   class SVTK_EXPORT TPickLimiter
00304   {
00305     vtkAbstractPicker* myPicker;
00306   public:
00307     TPickLimiter(vtkAbstractPicker*, SALOME_Actor*);
00308     ~TPickLimiter();
00309   };
00310 }
00311 
00312 #ifdef WIN32
00313 #pragma warning ( default:4251 )
00314 #endif
00315 
00316 #endif // SALOME_ACTOR_H