Back to index

salome-smesh  6.5.0
SMESH_ActorDef.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 //  SMESH OBJECT : interactive object for SMESH visualization
00024 //  File   : SMESH_ActorDef.h
00025 //  Author : Nicolas REJNERI
00026 //  Module : SMESH
00027 //
00028 #ifndef SMESH_ACTORDEF_H
00029 #define SMESH_ACTORDEF_H
00030 
00031 #include "SMESH_Actor.h"
00032 #include "SMESH_Object.h"
00033 
00034 #include <vtkSmartPointer.h>
00035 
00036 template <class T>
00037 class TVTKSmartPtr: public vtkSmartPointer<T>
00038 {
00039 public:
00040   TVTKSmartPtr() {}
00041   TVTKSmartPtr(T* r, bool theIsOwner = false): vtkSmartPointer<T>(r) { 
00042     if(r && theIsOwner) 
00043       r->Delete();
00044   }
00045   TVTKSmartPtr& operator()(T* r, bool theIsOwner = false){ 
00046     vtkSmartPointer<T>::operator=(r); 
00047     if(r && theIsOwner) 
00048       r->Delete();
00049     return *this;
00050   }
00051   TVTKSmartPtr& operator=(T* r){ vtkSmartPointer<T>::operator=(r); return *this;}
00052   T* Get() const { return this->GetPointer();}
00053 };
00054 
00055 
00056 class vtkProperty;
00057 class vtkShrinkFilter;
00058 class vtkPolyDataMapper;
00059 class vtkUnstructuredGrid;
00060 class vtkMergeFilter;
00061 class vtkPolyData;
00062 class vtkMapper;
00063 class vtkActor2D;
00064 class vtkLookupTable;
00065 class vtkPlane;
00066 class vtkImplicitBoolean;
00067 class vtkTimeStamp;
00068 
00069 class SMESH_DeviceActor;
00070 class SMESH_NodeLabelActor;
00071 class SMESH_CellLabelActor;
00072 class SMESH_ScalarBarActor;
00073 
00074 #ifndef DISABLE_PLOT2DVIEWER
00075 class SPlot2d_Histogram;
00076 #endif
00077 
00078 
00079 class SMESH_ActorDef : public SMESH_Actor
00080 {
00081   friend class SMESH_VisualObj;
00082   friend class SMESH_Actor;
00083 
00084  public:
00085   vtkTypeMacro(SMESH_ActorDef,SMESH_Actor);
00086   
00087   virtual void Delete();
00088 
00089   virtual void ReleaseGraphicsResources(vtkWindow *renWin);
00090   virtual int RenderOpaqueGeometry(vtkViewport *viewport);
00091   virtual int RenderTranslucentGeometry(vtkViewport *viewport);
00092   virtual void Render(vtkRenderer *ren);
00093 
00094   virtual void AddToRender(vtkRenderer* theRenderer); 
00095   virtual void RemoveFromRender(vtkRenderer* theRenderer);
00096 
00097   virtual bool hasHighlight() { return true; }  
00098   virtual void highlight(bool theHighlight);  
00099   virtual void SetPreSelected(bool thePreselect = false);
00100 
00101   virtual bool IsInfinitive();  
00102 
00103   virtual void SetOpacity(vtkFloatingPointType theValue);
00104   virtual vtkFloatingPointType GetOpacity();
00105 
00106   virtual void SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b, int delta );
00107   virtual void GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b, int& delta);
00108 
00109   virtual void SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
00110   virtual void GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
00111 
00112   virtual void SetOutlineColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
00113   virtual void GetOutlineColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
00114 
00115 
00116   virtual void SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
00117   virtual void GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
00118 
00119   virtual void Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
00120   virtual void Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
00121 
00122   virtual void SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
00123   virtual void GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
00124 
00125   virtual void SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
00126   virtual void GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
00127  
00128   virtual vtkFloatingPointType GetLineWidth();
00129   virtual void SetLineWidth(vtkFloatingPointType theVal);
00130 
00131   virtual void Set0DSize(vtkFloatingPointType size);
00132   virtual vtkFloatingPointType Get0DSize();
00133 
00134   virtual int GetNodeObjId(int theVtkID);
00135   virtual vtkFloatingPointType* GetNodeCoord(int theObjID);
00136 
00137   virtual int GetElemObjId(int theVtkID);
00138   virtual vtkCell* GetElemCell(int theObjID);
00139 
00140   virtual int GetObjDimension( const int theObjId );
00141 
00142   virtual void SetVisibility(int theMode);
00143   void SetVisibility(int theMode, bool theIsUpdateRepersentation);
00144 
00145   virtual void SetRepresentation(int theMode);
00146   
00147   virtual unsigned int GetEntityMode() const { return myEntityMode;}
00148   virtual void SetEntityMode(unsigned int theMode);
00149 
00150   virtual void SetPointRepresentation(bool theIsPointsVisible);
00151   virtual bool GetPointRepresentation();
00152 
00153   virtual vtkFloatingPointType* GetBounds();
00154   virtual void SetTransform(VTKViewer_Transform* theTransform); 
00155 
00156   virtual vtkUnstructuredGrid* GetUnstructuredGrid();
00157   virtual vtkDataSet* GetInput();
00158   virtual vtkMapper* GetMapper();
00159 
00160   virtual vtkFloatingPointType GetShrinkFactor();
00161   virtual void SetShrinkFactor(vtkFloatingPointType theValue);
00162 
00163   virtual bool IsShrunkable() { return myIsShrinkable;}
00164   virtual bool IsShrunk() { return myIsShrunk;}
00165   virtual void SetShrink(); 
00166   virtual void UnShrink(); 
00167 
00168   virtual void SetPointsLabeled(bool theIsPointsLabeled);
00169   virtual bool GetPointsLabeled();
00170 
00171   virtual void SetCellsLabeled(bool theIsCellsLabeled);
00172   virtual bool GetCellsLabeled();
00173 
00174   virtual void SetFacesOriented(bool theIsFacesOriented);
00175   virtual bool GetFacesOriented();
00176 
00177   virtual void SetFacesOrientationColor(vtkFloatingPointType theColor[3]);
00178   virtual void GetFacesOrientationColor(vtkFloatingPointType theColor[3]);
00179 
00180   virtual void SetFacesOrientationScale(vtkFloatingPointType theScale);
00181   virtual vtkFloatingPointType GetFacesOrientationScale();
00182 
00183   virtual void SetFacesOrientation3DVectors(bool theState);
00184   virtual bool GetFacesOrientation3DVectors();
00185 
00186   virtual void SetControlMode(eControl theMode);
00187   virtual eControl GetControlMode(){ return myControlMode;}
00188   virtual SMESH::Controls::FunctorPtr GetFunctor() { return myFunctor; }
00189 
00190   virtual SMESH_ScalarBarActor* GetScalarBarActor(){ return myScalarBarActor;}
00191 
00192   virtual void RemoveAllClippingPlanes();
00193   virtual vtkIdType GetNumberOfClippingPlanes();
00194   virtual vtkPlane* GetClippingPlane(vtkIdType theID);
00195   virtual vtkIdType AddClippingPlane(vtkPlane* thePlane); 
00196 
00197   virtual TVisualObjPtr GetObject() { return myVisualObj;}
00198 
00199   virtual void SetControlsPrecision( const long p ) { myControlsPrecision = p; }
00200   virtual long GetControlsPrecision() const { return myControlsPrecision; }
00201 
00202   virtual void UpdateScalarBar();
00203   virtual void UpdateDistribution();
00204 
00205 #ifndef DISABLE_PLOT2DVIEWER
00206   virtual SPlot2d_Histogram* GetPlot2Histogram() { return my2dHistogram; }
00207   virtual SPlot2d_Histogram* UpdatePlot2Histogram();
00208 #endif
00209 
00210 
00211   virtual void SetQuadratic2DRepresentation(EQuadratic2DRepresentation);
00212   virtual EQuadratic2DRepresentation GetQuadratic2DRepresentation();
00213   
00214   virtual void SetMarkerStd( VTK::MarkerType, VTK::MarkerScale );
00215   virtual void SetMarkerTexture( int, VTK::MarkerTexture );
00216 
00217  protected:
00218   void SetControlMode(eControl theMode, bool theCheckEntityMode);
00219   void SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed);
00220   bool IsImplicitFunctionUsed() const;
00221 
00222   TVisualObjPtr myVisualObj;
00223   vtkTimeStamp* myTimeStamp;
00224 
00225   SMESH_ScalarBarActor* myScalarBarActor;
00226   vtkLookupTable* myLookupTable;
00227 
00228   vtkProperty* mySurfaceProp;
00229   vtkProperty* myBackSurfaceProp;
00230   vtkProperty* myEdgeProp;
00231   vtkProperty* myNodeProp;
00232 
00233   SMESH_DeviceActor* myBaseActor;
00234   SMESH_NodeLabelActor* myNodeActor;
00235   SMESH_DeviceActor* myPickableActor;
00236 
00237   vtkProperty* myHighlightProp;
00238   vtkProperty* myOutLineProp;
00239   vtkProperty* myPreselectProp;
00240           
00241   SMESH_DeviceActor* myHighlitableActor;
00242 
00243   eControl myControlMode;
00244   SMESH::Controls::FunctorPtr myFunctor;
00245   vtkProperty* my2DExtProp;
00246   SMESH_CellLabelActor* my2DActor;
00247   SMESH_DeviceActor* my2DExtActor;
00248   SMESH_CellLabelActor* my3DActor;
00249   SMESH_DeviceActor* my3DExtActor;
00250   SMESH_DeviceActor* myControlActor;
00251 
00252   vtkProperty* myNodeExtProp;
00253   SMESH_DeviceActor* myNodeExtActor;
00254 
00255   vtkProperty* my1DProp;
00256   SMESH_CellLabelActor* my1DActor;
00257   vtkProperty* my1DExtProp;
00258   SMESH_DeviceActor* my1DExtActor;
00259 
00260   vtkProperty* my0DProp;
00261   SMESH_CellLabelActor* my0DActor;
00262   vtkProperty* my0DExtProp;
00263   SMESH_DeviceActor* my0DExtActor;
00264 
00265   unsigned int myEntityMode;
00266   unsigned int myEntityState;
00267   unsigned int myEntityModeCache;
00268   bool myIsEntityModeCache;
00269   bool myIsPointsVisible;
00270 
00271   bool myIsShrinkable;
00272   bool myIsShrunk;
00273   
00274   vtkImplicitBoolean* myImplicitBoolean;
00275   typedef TVTKSmartPtr<vtkPlane> TPlanePtr;
00276   typedef std::vector<TPlanePtr> TCippingPlaneCont;
00277   TCippingPlaneCont myCippingPlaneCont;
00278   long myControlsPrecision;
00279 
00280 #ifndef DISABLE_PLOT2DVIEWER
00281   SPlot2d_Histogram* my2dHistogram;
00282 #endif
00283 
00284   bool myIsFacesOriented;
00285   
00286   int myDeltaBrightness;
00287 
00288   VTK::MarkerTexture myMarkerTexture;
00289 
00290   SMESH_ActorDef();
00291   ~SMESH_ActorDef();
00292 
00293   bool Init(TVisualObjPtr theVisualObj, 
00294             const char* theEntry, 
00295             const char* theName,
00296             int theIsClear);
00297 
00298   void SetIsShrunkable(bool theShrunkable);
00299   void UpdateHighlight();
00300   void Update();
00301 
00302  private:
00303   // hide the two parameter Render() method from the user and the compiler.
00304   virtual void Render(vtkRenderer *, vtkMapper *) {};
00305   virtual void ShallowCopy(vtkProp *prop);
00306   virtual void SetMapper(vtkMapper *);
00307   static SMESH_ActorDef* New();
00308 
00309   // Not implemented.
00310   SMESH_ActorDef(const SMESH_ActorDef&);  
00311   void operator=(const SMESH_ActorDef&);
00312 };
00313 
00314 
00315 #endif //SMESH_ACTORDEF_H