Back to index

salome-geom  6.5.0
GEOM_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 //  GEOM OBJECT : interactive object for Geometry entities visualization
00024 //  File   : GEOM_Actor.h
00025 //  Author : Christophe ATTANASIO
00026 //  Module : GEOM
00027 //  $Header: /home/server/cvs/GEOM/GEOM_SRC/src/OBJECT/GEOM_Actor.h,v 1.11.2.3.6.8.2.2 2012-04-13 11:02:12 ana Exp $
00028 //
00029 #ifndef GEOM_ACTOR_H
00030 #define GEOM_ACTOR_H
00031 
00032 #include "GEOM_OBJECT_defs.hxx"
00033 #include "GEOM_SmartPtr.h"
00034 
00035 #include <SALOME_Actor.h>
00036 
00037 #include <TopoDS_Shape.hxx>
00038 #include <vtkSmartPointer.h>
00039 
00040 class vtkCamera;
00041 
00042 class GEOM_VertexSource;
00043 typedef GEOM_SmartPtr<GEOM_VertexSource> PVertexSource;
00044 
00045 class GEOM_EdgeSource;
00046 typedef GEOM_SmartPtr<GEOM_EdgeSource> PEdgeSource;
00047 
00048 class GEOM_WireframeFace;
00049 typedef GEOM_SmartPtr<GEOM_WireframeFace> PWFaceSource;
00050 
00051 class GEOM_ShadingFace;
00052 typedef GEOM_SmartPtr<GEOM_ShadingFace> PSFaceSource;
00053 
00054 class vtkRenderer;
00055 
00056 class vtkAppendPolyData;
00057 typedef GEOM_SmartPtr<vtkAppendPolyData> PAppendFilter;
00058 
00059 class GEOM_OBJECT_EXPORT GEOM_Actor: public SALOME_Actor
00060 {
00061 public:
00062   vtkTypeMacro(GEOM_Actor,SALOME_Actor);
00063   static GEOM_Actor* New();
00064 
00065   void SetShape(const TopoDS_Shape& theShape,
00066               float theDeflection,
00067               bool theIsVector = false);
00068 
00069   void SetDeflection(float theDeflection);
00070   float GetDeflection() const{ return myDeflection;}
00071 
00072   void AddToRender(vtkRenderer* theRenderer);
00073   void RemoveFromRender(vtkRenderer* theRenderer);
00074 
00075   enum EDisplayMode{ eWireframe, eShading, eShadingWithEdges = eShading + 2 };
00076 
00077 /*   void SetDisplayMode(EDisplayMode theMode);  */
00078 /*   EDisplayMode GetDisplayMode() const { return myDisplayMode;}  */
00079 
00080   void SetSelected(bool theIsSelected);
00081   bool IsSelected() const { return myIsSelected;}
00082 
00083   // OLD METHODS
00084   // Properties
00085   void SetHighlightProperty(vtkProperty* Prop);
00086   void SetWireframeProperty(vtkProperty* Prop);
00087   void SetShadingProperty(vtkProperty* Prop);
00088 
00089   vtkProperty* GetWireframeProperty();
00090   vtkProperty* GetShadingProperty();
00091 
00092   void setDeflection(double adef);
00093   virtual void setDisplayMode(int thenewmode);
00094 
00095   // Description:
00096   // This causes the actor to be rendered. It, in turn, will render the actor's
00097   // property and then mapper.
00098   virtual void Render(vtkRenderer *, vtkMapper *);
00099   // Description:
00100   // Release any graphics resources that are being consumed by this actor.
00101   // The parameter window could be used to determine which graphic
00102   // resources to release.
00103   void ReleaseGraphicsResources(vtkWindow *);
00104   const TopoDS_Shape& getTopo();
00105   void setInputShape(const TopoDS_Shape& ashape, double adef1,
00106                      int imode, bool isVector = false);
00107   double getDeflection();
00108   double isVector();
00109 
00110   // SubShape
00111   void SubShapeOn();
00112   void SubShapeOff();
00113 
00114   // Highlight
00115   virtual void highlight(bool theHighlight);
00116   virtual bool hasHighlight() { return true; }
00117 
00118   void ShallowCopy(vtkProp *prop);
00119 
00120   // Opacity
00121   void SetOpacity(vtkFloatingPointType opa);
00122   vtkFloatingPointType GetOpacity();
00123 
00124   // Color
00125   void SetColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
00126   void GetColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
00127 
00128   // Material
00129   void SetMaterial(std::vector<vtkProperty*> theProps);
00130   vtkProperty* GetMaterial();
00131 
00132   virtual bool IsInfinitive();
00133 
00134   // overloaded functions
00136   virtual
00137   void
00138   Highlight(bool theHighlight);
00139 
00140   //----------------------------------------------------------------------------
00142   virtual
00143   bool
00144   PreHighlight(vtkInteractorStyle* theInteractorStyle,
00145                SVTK_SelectionEvent* theSelectionEvent,
00146                bool theIsHighlight);
00147 
00149   virtual
00150   bool
00151   Highlight(vtkInteractorStyle* theInteractorStyle,
00152             SVTK_SelectionEvent* theSelectionEvent,
00153             bool theIsHighlight);
00154 
00156   virtual
00157   void
00158   SetVisibility( int );
00159 
00161   // theNb[0] - number of U lines
00162   // theNb[1] - number of V lines
00163   virtual
00164   void
00165   SetNbIsos(const int theNb[2]);
00166 
00167   virtual
00168   void
00169   GetNbIsos(int &theNbU,int &theNbV);
00170   
00171   virtual 
00172   void SetIsosWidth(const int width);
00173 
00174   int GetIsosWidth() const;
00175 
00176   virtual void SetWidth(const int width);
00177 
00178   int GetWidth() const;
00179   
00181   virtual
00182   void
00183   SetVectorMode(const bool theMode);
00184 
00185   virtual
00186   bool
00187   GetVectorMode();
00188   
00190   void SetEdgesInShadingColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
00191 
00192   void
00193   StoreIsoNumbers();
00194 
00195   void
00196   RestoreIsoNumbers();
00197   
00198   void
00199   ResetIsoNumbers();
00200 
00201 protected:
00202   void SetModified();
00203 
00204   void GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result);
00205 
00206   void StoreBoundaryColors();
00207   void RestoreBoundaryColors();
00208 
00209   GEOM_Actor();
00210   ~GEOM_Actor();
00211 
00212 private:
00213   TopoDS_Shape myShape;
00214   int myNbIsos[2];
00215   bool isOnlyVertex;
00216 
00217   float myDeflection;
00218   bool myIsForced;
00219 
00220   //  EDisplayMode myDisplayMode;
00221   bool myIsSelected;
00222   bool myVectorMode;
00223 
00224   PDeviceActor myVertexActor;
00225   PVertexSource myVertexSource;
00226 
00227   PDeviceActor myIsolatedEdgeActor;
00228   PEdgeSource myIsolatedEdgeSource;
00229 
00230   PDeviceActor myOneFaceEdgeActor;
00231   PEdgeSource myOneFaceEdgeSource;
00232 
00233   PDeviceActor mySharedEdgeActor;
00234   PEdgeSource mySharedEdgeSource;
00235 
00236   PDeviceActor myWireframeFaceActor;
00237   PWFaceSource myWireframeFaceSource;
00238 
00239   PDeviceActor myShadingFaceActor;
00240   PSFaceSource myShadingFaceSource;
00241 
00242   PDeviceActor myHighlightActor;
00243   vtkSmartPointer<vtkProperty>  myHighlightProp;
00244   vtkSmartPointer<vtkProperty>  myPreHighlightProp;
00245   vtkSmartPointer<vtkProperty>  myShadingFaceProp;
00246 
00247   PAppendFilter myAppendFilter;
00248   PPolyGeomPainterDataMapper myPolyDataMapper;
00249 
00250   virtual void SetMapper(vtkMapper*);
00251 
00252   GEOM_Actor(const GEOM_Actor&);
00253   void operator=(const GEOM_Actor&);
00254 
00255   vtkFloatingPointType myEdgesInWireframeColor[3];
00256   vtkFloatingPointType myEdgesInShadingColor[3];
00257 };
00258 
00259 #endif //GEOM_ACTOR_H
00260 
00261