Version: 6.3.1

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