Back to index

salome-gui  6.5.0
VTKViewer_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 VTKVIEVER_ACTOR_H
00028 #define VTKVIEVER_ACTOR_H
00029 
00030 #include "VTKViewer.h"
00031 
00032 #include <string>
00033 #include <vector>
00034 
00035 #include <vtkLODActor.h>
00036 #include <vtkProperty.h>
00037 
00038 class vtkCell;
00039 class vtkPointPicker;
00040 class vtkCellPicker;
00041 class vtkDataSet;
00042 class vtkCamera;
00043 class vtkProperty;
00044 class vtkRenderer;
00045 class vtkPassThroughFilter;
00046 
00047 class VTKViewer_Transform;
00048 class VTKViewer_GeometryFilter;
00049 class VTKViewer_TransformFilter;
00050 
00051 extern int VTKViewer_POINT_SIZE;
00052 extern int VTKViewer_LINE_WIDTH;
00053 
00054 namespace VTKViewer
00055 {
00056   namespace Representation
00057   {
00058     typedef int Type;
00059     const Type Points = VTK_POINTS;
00060     const Type Wireframe = VTK_WIREFRAME;
00061     const Type Surface = VTK_SURFACE;
00062     const Type Insideframe = Surface + 1;
00063     const Type SurfaceWithEdges = Insideframe + 1;
00064   }
00065 }
00066 
00067 #ifdef WIN32
00068 #pragma warning ( disable:4251 )
00069 #endif
00070 
00074 class VTKVIEWER_EXPORT VTKViewer_Actor : public vtkLODActor 
00075 {
00076  public:
00077   static VTKViewer_Actor* New();
00078   
00079   vtkTypeMacro(VTKViewer_Actor,vtkLODActor);
00080 
00081   //----------------------------------------------------------------------------
00083   virtual 
00084   const char* 
00085   getName();
00086 
00088   virtual
00089   void
00090   setName(const char* theName);
00091 
00092   //----------------------------------------------------------------------------
00094   virtual
00095   void
00096   SetOpacity(vtkFloatingPointType theOpacity);
00097 
00099   virtual
00100   vtkFloatingPointType 
00101   GetOpacity();
00102 
00104   virtual
00105   void
00106   SetColor(vtkFloatingPointType r,
00107            vtkFloatingPointType g,
00108            vtkFloatingPointType b);
00109 
00111   virtual
00112   void
00113   GetColor(vtkFloatingPointType& r,
00114            vtkFloatingPointType& g,
00115            vtkFloatingPointType& b);
00116 
00118   virtual
00119   void
00120   SetColor(const vtkFloatingPointType theRGB[3]);
00121 
00123   virtual
00124   void
00125   SetMaterial(std::vector<vtkProperty*> theProps);
00126 
00128   virtual
00129   vtkProperty* 
00130   GetMaterial();
00131 
00132   //----------------------------------------------------------------------------
00133   // For selection mapping purpose
00135   virtual
00136   int 
00137   GetNodeObjId(int theVtkID);
00138 
00140   virtual
00141   vtkFloatingPointType*
00142   GetNodeCoord(int theObjID);
00143 
00145   virtual 
00146   int
00147   GetElemObjId(int theVtkID);
00148 
00150   virtual
00151   vtkCell* 
00152   GetElemCell(int theObjID);
00153 
00154   //----------------------------------------------------------------------------
00156   virtual
00157   int
00158   GetObjDimension( const int theObjId );
00159 
00161   virtual
00162   void
00163   SetMapper(vtkMapper* theMapper); 
00164 
00166   virtual
00167   vtkDataSet* 
00168   GetInput(); 
00169 
00171   virtual
00172   void
00173   SetTransform(VTKViewer_Transform* theTransform); 
00174 
00176   virtual
00177   unsigned long int
00178   GetMTime();
00179 
00180   //----------------------------------------------------------------------------
00182   virtual
00183   void
00184   SetRepresentation(int theMode);
00185 
00187   virtual
00188   int
00189   GetRepresentation();
00190 
00192   virtual
00193   int
00194   getDisplayMode();
00195 
00197   virtual
00198   void
00199   setDisplayMode(int theMode);
00200 
00201   //----------------------------------------------------------------------------
00203 
00207   void
00208   SetInfinitive(bool theIsInfinite);
00209 
00211   virtual
00212   bool
00213   IsInfinitive();
00214     
00216   virtual
00217   vtkFloatingPointType* 
00218   GetBounds();
00219 
00221   void
00222   GetBounds(vtkFloatingPointType bounds[6]);
00223 
00224   //----------------------------------------------------------------------------
00225   virtual
00226   bool
00227   IsSetCamera() const;
00228 
00229   virtual
00230   bool
00231   IsResizable() const;
00232 
00233   virtual
00234   void
00235   SetSize( const vtkFloatingPointType );
00236 
00237   virtual
00238   void 
00239   SetCamera( vtkCamera* );
00240 
00241   //----------------------------------------------------------------------------
00243   void
00244   SetResolveCoincidentTopology(bool theIsResolve);
00245 
00247   void
00248   SetPolygonOffsetParameters(vtkFloatingPointType factor, 
00249                              vtkFloatingPointType units);
00250 
00252   void
00253   GetPolygonOffsetParameters(vtkFloatingPointType& factor, 
00254                              vtkFloatingPointType& units);
00255 
00256   virtual
00257   void
00258   Render(vtkRenderer *, vtkMapper *);
00259 
00260   //----------------------------------------------------------------------------
00262   virtual
00263   vtkFloatingPointType
00264   GetShrinkFactor();
00265 
00267   virtual
00268   bool
00269   IsShrunkable();
00270 
00272   virtual
00273   bool
00274   IsShrunk();
00275 
00277   virtual
00278   void
00279   SetShrink();
00280 
00282   virtual
00283   void
00284   UnShrink();
00285 
00286   //----------------------------------------------------------------------------
00288   virtual
00289   void
00290   AddToRender(vtkRenderer* theRendere); 
00291 
00293   virtual
00294   void
00295   RemoveFromRender(vtkRenderer* theRendere);
00296 
00298   virtual
00299   void
00300   GetChildActors(vtkActorCollection*);
00301 
00302   //----------------------------------------------------------------------------
00304   virtual
00305   bool
00306   hasHighlight(); 
00307 
00309   virtual
00310   bool
00311   isHighlighted();
00312 
00314   virtual
00315   bool
00316   isPreselected();
00317 
00319   virtual
00320   void
00321   SetPreSelected(bool thePreselect = false);
00322 
00323   //----------------------------------------------------------------------------
00325   virtual
00326   void
00327   highlight(bool theHighlight);  
00328 
00329   void
00330   SetPreviewProperty(vtkProperty* theProperty);
00331 
00332   //----------------------------------------------------------------------------
00334   virtual void SetQuadraticArcMode(bool theFlag);
00335   virtual bool GetQuadraticArcMode() const;
00336 
00337   virtual void   SetQuadraticArcAngle(vtkFloatingPointType theMaxAngle);
00338   virtual vtkFloatingPointType GetQuadraticArcAngle() const;
00339 
00340   //----------------------------------------------------------------------------
00342   virtual vtkDataSet* GetHighlightedDataSet();
00343 
00344  protected:
00345   //----------------------------------------------------------------------------
00346   bool myIsResolveCoincidentTopology;
00347   vtkFloatingPointType myPolygonOffsetFactor;
00348   vtkFloatingPointType myPolygonOffsetUnits;
00349 
00350   std::string myName;
00351 
00352   vtkFloatingPointType myOpacity;
00353   int myDisplayMode;
00354   bool myIsInfinite;
00355 
00356   bool myStoreMapping;
00357   VTKViewer_GeometryFilter *myGeomFilter;
00358   VTKViewer_TransformFilter *myTransformFilter;
00359   std::vector<vtkPassThroughFilter*> myPassFilter;
00360 
00361   int myRepresentation;
00362   vtkProperty *myProperty;
00363 
00364   void
00365   InitPipeLine(vtkMapper* theMapper); 
00366 
00367   VTKViewer_Actor();
00368   ~VTKViewer_Actor();
00369 
00370  protected:
00371   vtkProperty *PreviewProperty;
00372   bool myIsPreselected;
00373   bool myIsHighlighted;
00374 };
00375 
00376 #ifdef WIN32
00377 #pragma warning ( default:4251 )
00378 #endif
00379 
00380 #endif // VTKVIEVER_ACTOR_H