Version: 6.3.1

src/OBJECT/VISU_Actor.h

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  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 //  VISU OBJECT : interactive object for VISU entities implementation
00024 //  File   : 
00025 //  Author : 
00026 //  Module : VISU
00027 //
00028 #ifndef VISU_ACTOR_H
00029 #define VISU_ACTOR_H
00030 
00031 #include "VISU_OBJECT.h"
00032 
00033 #include "SALOME_Actor.h"
00034 #include "VISU_ActorBase.h"
00035 #include "VISU_BoostSignals.h"
00036 #include "SVTK_DeviceActor.h"
00037 
00038 #include <string>
00039 #include <vtkTimeStamp.h>
00040 #include <vtkSmartPointer.h>
00041 
00042 class vtkProp;
00043 class vtkProperty;
00044 class vtkTextMapper;
00045 class vtkTextActor;
00046 class vtkInteractorStyle;
00047 class vtkCallbackCommand;
00048 class VTKViewer_ShrinkFilter;
00049 class VISU_PipeLine;
00050 class vtkPlane;
00051 class vtkImplicitFunctionCollection;
00052 class vtkFeatureEdges;
00053 class vtkTextProperty;
00054 class vtkLabeledDataMapper;
00055 class vtkMaskPoints;
00056 class vtkActor2D;
00057 
00058 class VTKViewer_CellCenters;
00059 class VTKViewer_FramedTextActor;
00060 
00061 class VISU_SelectVisiblePoints;
00062 class VISU_UsedPointsFilter;
00063 
00064 #if !defined(VTK_XVERSION)
00065 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
00066 #endif
00067 
00068 namespace SVTK
00069 {
00070   namespace Representation
00071   {
00072     const Type Surfaceframe = Insideframe + 1;
00073     const Type FeatureEdges = Insideframe + 2;
00074   }
00075 }
00076 
00077 namespace VISU 
00078 {
00079   class Prs3d_i;
00080 }
00081 
00082 //----------------------------------------------------------------------------
00083 class VISU_OBJECT_EXPORT VISU_Actor : public VISU_ActorBase
00084 {
00085  public:
00086   vtkTypeMacro(VISU_Actor, VISU_ActorBase);
00087 
00088   //static 
00089   //VISU_Actor* 
00090   //New();
00091 
00093   virtual
00094   void
00095   DeepCopy(VISU_Actor *theActor);
00096 
00097   virtual
00098   void
00099   ShallowCopyPL(VISU_PipeLine* thePipeLine);
00100 
00101   //----------------------------------------------------------------------------
00102   virtual
00103   void
00104   setIO(const Handle(SALOME_InteractiveObject)& theIO);
00105 
00106   //----------------------------------------------------------------------------
00107   VISU::Prs3d_i* 
00108   GetPrs3d();
00109 
00110   virtual
00111   void
00112   SetPrs3d(VISU::Prs3d_i* thePrs3d);
00113 
00114   virtual
00115   void
00116   SetVisibility(int theMode);
00117 
00118   bool
00119   ShouldBeDisplayed();
00120 
00121   virtual
00122   void
00123   SetPosition( double thePosition[3] );
00124 
00125   virtual
00126   void
00127   SetPosition( double theX, double theY, double theZ );
00128 
00129   //----------------------------------------------------------------------------
00130   virtual
00131   VISU_PipeLine* 
00132   GetPipeLine();
00133 
00134   virtual 
00135   void
00136   SetPipeLine(VISU_PipeLine* thePipeLine);
00137 
00138   //----------------------------------------------------------------------------
00139   virtual
00140   void
00141   SetRepresentation(int theMode);
00142 
00143   //----------------------------------------------------------------------------
00144   virtual
00145   bool
00146   IsShrunkable();
00147 
00148   virtual
00149   bool
00150   IsShrunk();
00151 
00152   virtual
00153   void
00154   SetShrink();
00155 
00156   virtual
00157   void
00158   UnShrink(); 
00159 
00160   virtual
00161   void
00162   SetShrinkable(bool theIsShrinkable);
00163 
00164   virtual
00165   void
00166   SetShrinkFactor(vtkFloatingPointType theFactor = 0.8); 
00167 
00168   virtual
00169   vtkFloatingPointType
00170   GetShrinkFactor();
00171 
00172   //----------------------------------------------------------------------------
00173   virtual
00174   bool
00175   IsFeatureEdgesAllowed();
00176 
00177   virtual
00178   void
00179   SetFeatureEdgesAllowed(bool theIsFeatureEdgesAllowed);
00180 
00181   virtual
00182   bool
00183   IsFeatureEdgesEnabled();
00184 
00185   virtual
00186   void
00187   SetFeatureEdgesEnabled(bool theIsFeatureEdgesEnabled);
00188 
00189   virtual
00190   vtkFloatingPointType
00191   GetFeatureEdgesAngle();
00192 
00193   virtual
00194   void
00195   SetFeatureEdgesAngle(vtkFloatingPointType theAngle = 30.0); 
00196 
00197   virtual
00198   void
00199   GetFeatureEdgesFlags(bool& theIsFeatureEdges,
00200                        bool& theIsBoundaryEdges,
00201                        bool& theIsManifoldEdges,
00202                        bool& theIsNonManifoldEdges);
00203 
00204   virtual
00205   void
00206   SetFeatureEdgesFlags(bool theIsFeatureEdges,
00207                        bool theIsBoundaryEdges,
00208                        bool theIsManifoldEdges,
00209                        bool theIsNonManifoldEdges);
00210 
00211   virtual
00212   bool
00213   GetFeatureEdgesColoring();
00214 
00215   virtual
00216   void
00217   SetFeatureEdgesColoring(bool theIsColoring);
00218 
00219   //----------------------------------------------------------------------------
00220   virtual
00221   void
00222   SetOpacity(vtkFloatingPointType theValue);
00223 
00224   virtual
00225   vtkFloatingPointType
00226   GetOpacity();
00227 
00228   virtual
00229   void
00230   SetLineWidth(vtkFloatingPointType theLineWidth);
00231 
00232   virtual
00233   vtkFloatingPointType
00234   GetLineWidth();
00235  
00236   //----------------------------------------------------------------------------
00237   virtual
00238   void
00239   AddToRender( vtkRenderer* ); 
00240 
00241   virtual
00242   void
00243   RemoveFromRender( vtkRenderer* );
00244 
00245   //----------------------------------------------------------------------------
00247   virtual
00248   void
00249   highlight(bool theHighlight);  
00250 
00252   virtual
00253   bool
00254   PreHighlight(vtkInteractorStyle* theInteractorStyle, 
00255                SVTK_SelectionEvent* theSelectionEvent,
00256                bool theIsHighlight);
00257 
00259   virtual
00260   bool
00261   Highlight(vtkInteractorStyle* theInteractorStyle, 
00262             SVTK_SelectionEvent* theSelectionEvent,
00263             bool theIsHighlight);
00264 
00266   virtual
00267   void
00268   Highlight(bool theIsHighlight);
00269 
00270   virtual
00271   void 
00272   SetVTKMapping(bool theIsVTKMapping); 
00273 
00274   virtual
00275   bool 
00276   IsVTKMapping() const;
00277 
00278   virtual
00279   vtkDataSet* 
00280   GetInput(); 
00281 
00283   virtual
00284   unsigned long int
00285   GetMemorySize();
00286  
00287   //----------------------------------------------------------------------------
00288   virtual
00289   vtkIdType
00290   GetNodeObjId(vtkIdType theID);
00291 
00292   virtual
00293   vtkIdType
00294   GetNodeVTKID(vtkIdType theID);
00295 
00296   virtual
00297   vtkFloatingPointType* 
00298   GetNodeCoord(vtkIdType theObjID);
00299 
00300   virtual
00301   vtkIdType
00302   GetElemObjId(vtkIdType theID);
00303 
00304   virtual
00305   vtkIdType
00306   GetElemVTKID(vtkIdType theID);
00307 
00308   virtual
00309   vtkCell* 
00310   GetElemCell(vtkIdType theObjID);
00311 
00312   //----------------------------------------------------------------------------
00313   virtual void RemoveAllClippingPlanes();
00314 
00315   virtual vtkIdType GetNumberOfClippingPlanes();
00316 
00317   virtual bool AddClippingPlane(vtkPlane* thePlane);
00318 
00319   virtual vtkPlane* GetClippingPlane(vtkIdType theID);
00320 
00321   virtual vtkImplicitFunctionCollection* GetClippingPlanes();
00322 
00323   //----------------------------------------------------------------------------
00325   void
00326   UpdatePickingSettings();
00327 
00328   //----------------------------------------------------------------------------
00330   virtual 
00331   void 
00332   SetValuesLabeled( const bool theIsValLabeled );
00333 
00334   virtual 
00335   bool 
00336   GetValuesLabeled() const;
00337 
00338   virtual
00339   vtkDataSet*
00340   GetValLabelsInput();
00341 
00342   vtkTextProperty* 
00343   GetsValLabelsProps() const;
00344 
00345   enum EQuadratic2DRepresentation { eLines = 0, eArcs };
00346 
00347   virtual
00348     EQuadratic2DRepresentation GetQuadratic2DRepresentation() const;
00349   
00350   virtual void 
00351     SetQuadratic2DRepresentation( EQuadratic2DRepresentation theMode );
00352   
00353   
00354  protected:
00355   VISU_Actor();
00356 
00357   virtual
00358   ~VISU_Actor();
00359  
00360   virtual 
00361   void
00362   SetMapperInput(vtkDataSet* theDataSet) = 0;
00363 
00364   virtual
00365   VISU_PipeLine* 
00366   GetCurrentPL();
00367 
00368   //----------------------------------------------------------------------------
00369   bool
00370   isSubElementsHighlighted();
00371 
00372   //----------------------------------------------------------------------------
00373   vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
00374 
00376   static
00377   void
00378   ProcessEvents(vtkObject* theObject, 
00379                 unsigned long theEvent,
00380                 void* theClientData, 
00381                 void* theCallData);
00382 
00383   //----------------------------------------------------------------------------
00384  private:
00385   void
00386   ResetTextActor();
00387 
00388   //----------------------------------------------------------------------------
00389  protected:
00390   vtkFloatingPointType myPriority;
00391   bool myIsVTKMapping;
00392   VISU::Prs3d_i* myPrs3d;
00393   vtkSmartPointer<VISU_PipeLine> myPipeLine;
00394 
00395   vtkSmartPointer<VTKViewer_ShrinkFilter> myShrinkFilter;
00396   bool myIsShrinkable;
00397   bool myIsShrunk;
00398 
00399   vtkSmartPointer<vtkTextMapper> myAnnotationMapper;
00400 #if (VTK_XVERSION < 0x050100)
00401   vtkSmartPointer<vtkTextActor>  myAnnotationActor;
00402 #else
00403   vtkSmartPointer<vtkActor2D>  myAnnotationActor;
00404 #endif
00405 
00406   vtkSmartPointer<VTKViewer_FramedTextActor> myTextActor;
00407 
00408   vtkSmartPointer<vtkFeatureEdges> myFeatureEdges;
00409   bool myIsFeatureEdgesAllowed;
00410   bool myIsFeatureEdgesEnabled;
00411 
00412   Selection_Mode myLastSelectionMode;
00413   bool myIsSubElementsHighlighted;
00414   
00415   // fields for values labeling
00416   bool                    myIsValLabeled;
00417   vtkDataSet*             myValLblDataSet;
00418   vtkActor2D*             myValLabels;
00419   vtkMaskPoints*          myValMaskPoints;
00420   VTKViewer_CellCenters*  myValCellCenters;
00421   VISU_UsedPointsFilter*  myValUsedPoints;
00422   vtkLabeledDataMapper*   myValLabeledDataMapper;
00423   VISU_SelectVisiblePoints* myValSelectVisiblePoints;
00424 };
00425 
00426 #endif //VISU_ACTOR_H
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS