Version: 6.3.1

src/OBJECT/GEOM_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 //  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.5.4.1 2011-06-01 13:57:19 vsr 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};
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   void setDeflection(double adef);
00090   virtual void setDisplayMode(int thenewmode);
00091 
00092   // Description:
00093   // This causes the actor to be rendered. It, in turn, will render the actor's
00094   // property and then mapper.
00095   virtual void Render(vtkRenderer *, vtkMapper *);
00096   // Description:
00097   // Release any graphics resources that are being consumed by this actor.
00098   // The parameter window could be used to determine which graphic
00099   // resources to release.
00100   void ReleaseGraphicsResources(vtkWindow *);
00101   const TopoDS_Shape& getTopo();
00102   void setInputShape(const TopoDS_Shape& ashape, double adef1,
00103                      int imode, bool isVector = false);
00104   double getDeflection();
00105   double isVector();
00106 
00107   // SubShape
00108   void SubShapeOn();
00109   void SubShapeOff();
00110 
00111   // Highlight
00112   virtual void highlight(bool theHighlight);
00113   virtual bool hasHighlight() { return true; }
00114 
00115   void ShallowCopy(vtkProp *prop);
00116 
00117   // Opacity
00118   void SetOpacity(vtkFloatingPointType opa);
00119   vtkFloatingPointType GetOpacity();
00120 
00121   // Color
00122   void SetColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
00123   void GetColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
00124 
00125   virtual bool IsInfinitive();
00126 
00127   // overloaded functions
00129   virtual
00130   void
00131   Highlight(bool theHighlight);
00132 
00133   //----------------------------------------------------------------------------
00135   virtual
00136   bool
00137   PreHighlight(vtkInteractorStyle* theInteractorStyle,
00138                SVTK_SelectionEvent* theSelectionEvent,
00139                bool theIsHighlight);
00140 
00142   virtual
00143   bool
00144   Highlight(vtkInteractorStyle* theInteractorStyle,
00145             SVTK_SelectionEvent* theSelectionEvent,
00146             bool theIsHighlight);
00147 
00149   virtual
00150   void
00151   SetVisibility( int );
00152 
00154   // theNb[0] - number of U lines
00155   // theNb[1] - number of V lines
00156   virtual
00157   void
00158   SetNbIsos(const int theNb[2]);
00159 
00160   virtual
00161   void
00162   GetNbIsos(int &theNbU,int &theNbV);
00163   
00165   virtual
00166   void
00167   SetVectorMode(const bool theMode);
00168 
00169   virtual
00170   bool
00171   GetVectorMode();
00172 
00173 protected:
00174   void SetModified();
00175 
00176   void GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result);
00177 
00178   GEOM_Actor();
00179   ~GEOM_Actor();
00180 
00181 private:
00182   TopoDS_Shape myShape;
00183   int myNbIsos[2];
00184   bool isOnlyVertex;
00185 
00186   float myDeflection;
00187   bool myIsForced;
00188 
00189   //  EDisplayMode myDisplayMode;
00190   bool myIsSelected;
00191   bool myVectorMode;
00192 
00193   PDeviceActor myVertexActor;
00194   PVertexSource myVertexSource;
00195 
00196   PDeviceActor myIsolatedEdgeActor;
00197   PEdgeSource myIsolatedEdgeSource;
00198 
00199   PDeviceActor myOneFaceEdgeActor;
00200   PEdgeSource myOneFaceEdgeSource;
00201 
00202   PDeviceActor mySharedEdgeActor;
00203   PEdgeSource mySharedEdgeSource;
00204 
00205   PDeviceActor myWireframeFaceActor;
00206   PWFaceSource myWireframeFaceSource;
00207 
00208   PDeviceActor myShadingFaceActor;
00209   PSFaceSource myShadingFaceSource;
00210 
00211   PDeviceActor myHighlightActor;
00212   vtkSmartPointer<vtkProperty>  myHighlightProp;
00213   vtkSmartPointer<vtkProperty>  myPreHighlightProp;
00214   vtkSmartPointer<vtkProperty>  myShadingFaceProp;
00215 
00216   PAppendFilter myAppendFilter;
00217   PPolyDataMapper myPolyDataMapper;
00218 
00219   virtual void SetMapper(vtkMapper*);
00220 
00221   GEOM_Actor(const GEOM_Actor&);
00222   void operator=(const GEOM_Actor&);
00223 };
00224 
00225 #endif //GEOM_ACTOR_H
00226 
00227 
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