1 // GEOM OBJECT : interactive object for Geometry entities visualization
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : GEOM_Actor.h
25 // Author : Christophe ATTANASIO
32 #include "GEOM_OBJECT_defs.hxx"
33 #include "GEOM_SmartPtr.h"
35 #include <SALOME_Actor.h>
37 #include <TopoDS_Shape.hxx>
38 #include <vtkSmartPointer.h>
42 class GEOM_VertexSource;
43 typedef GEOM_SmartPtr<GEOM_VertexSource> PVertexSource;
45 class GEOM_EdgeSource;
46 typedef GEOM_SmartPtr<GEOM_EdgeSource> PEdgeSource;
48 class GEOM_WireframeFace;
49 typedef GEOM_SmartPtr<GEOM_WireframeFace> PWFaceSource;
51 class GEOM_ShadingFace;
52 typedef GEOM_SmartPtr<GEOM_ShadingFace> PSFaceSource;
54 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
57 class vtkAppendPolyData;
58 typedef GEOM_SmartPtr<vtkAppendPolyData> PAppendFilter;
60 class GEOM_OBJECT_EXPORT GEOM_Actor: public SALOME_Actor
63 vtkTypeMacro(GEOM_Actor,SALOME_Actor);
64 static GEOM_Actor* New();
66 void SetShape(const TopoDS_Shape& theShape,
69 bool theIsVector = false);
71 void SetDeflection(float theDeflection, bool theIsRelative);
72 float GetDeflection() const{ return myDeflection;}
73 bool GetIsRelative() const{ return myIsRelative;}
75 void AddToRender(vtkRenderer* theRenderer);
76 void RemoveFromRender(vtkRenderer* theRenderer);
78 enum EDisplayMode{ eWireframe, eShading};
80 /* void SetDisplayMode(EDisplayMode theMode); */
81 /* EDisplayMode GetDisplayMode() const { return myDisplayMode;} */
83 void SetSelected(bool theIsSelected);
84 bool IsSelected() const { return myIsSelected;}
88 void SetHighlightProperty(vtkProperty* Prop);
89 void SetWireframeProperty(vtkProperty* Prop);
90 void SetShadingProperty(vtkProperty* Prop);
92 void setDeflection(double adef);
93 virtual void setDisplayMode(int thenewmode);
96 // This causes the actor to be rendered. It, in turn, will render the actor's
97 // property and then mapper.
98 virtual void Render(vtkRenderer *, vtkMapper *);
100 // Release any graphics resources that are being consumed by this actor.
101 // The parameter window could be used to determine which graphic
102 // resources to release.
103 void ReleaseGraphicsResources(vtkWindow *);
104 const TopoDS_Shape& getTopo();
105 void setInputShape(const TopoDS_Shape& ashape, double adef1,
106 int imode, bool isVector = false);
107 double getDeflection();
115 virtual void highlight(bool theHighlight);
116 virtual bool hasHighlight() { return true; }
118 void ShallowCopy(vtkProp *prop);
121 void SetOpacity(vtkFloatingPointType opa);
122 vtkFloatingPointType GetOpacity();
125 void SetColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
126 void GetColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
128 virtual bool IsInfinitive();
130 // overloaded functions
131 //! To map current selection to VTK representation
134 Highlight(bool theHighlight);
136 //----------------------------------------------------------------------------
137 //! To process prehighlight (called from #SVTK_InteractorStyle)
140 PreHighlight(vtkInteractorStyle* theInteractorStyle,
141 SVTK_SelectionEvent* theSelectionEvent,
142 bool theIsHighlight);
144 //! To process highlight (called from #SVTK_InteractorStyle)
147 Highlight(vtkInteractorStyle* theInteractorStyle,
148 SVTK_SelectionEvent* theSelectionEvent,
149 bool theIsHighlight);
151 //! Visibility management
154 SetVisibility( int );
156 //! IsoLines management
157 // theNb[0] - number of U lines
158 // theNb[1] - number of V lines
161 SetNbIsos(const int theNb[2]);
165 GetNbIsos(int &theNbU,int &theNbV);
168 void SetShape(const TopoDS_Shape& theShape,
169 const TopTools_IndexedDataMapOfShapeListOfShape& theEdgeMap,
170 bool theIsVector = false);
174 void GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result);
180 TopoDS_Shape myShape;
187 // EDisplayMode myDisplayMode;
190 PDeviceActor myVertexActor;
191 PVertexSource myVertexSource;
193 PDeviceActor myIsolatedEdgeActor;
194 PEdgeSource myIsolatedEdgeSource;
196 PDeviceActor myOneFaceEdgeActor;
197 PEdgeSource myOneFaceEdgeSource;
199 PDeviceActor mySharedEdgeActor;
200 PEdgeSource mySharedEdgeSource;
202 PDeviceActor myWireframeFaceActor;
203 PWFaceSource myWireframeFaceSource;
205 PDeviceActor myShadingFaceActor;
206 PSFaceSource myShadingFaceSource;
208 PDeviceActor myHighlightActor;
209 vtkSmartPointer<vtkProperty> myHighlightProp;
210 vtkSmartPointer<vtkProperty> myPreHighlightProp;
211 vtkSmartPointer<vtkProperty> myShadingFaceProp;
213 PAppendFilter myAppendFilter;
214 PPolyDataMapper myPolyDataMapper;
216 virtual void SetMapper(vtkMapper*);
218 GEOM_Actor(const GEOM_Actor&);
219 void operator=(const GEOM_Actor&);
222 #endif //GEOM_ACTOR_H