1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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
23 // GEOM OBJECT : interactive object for Geometry entities visualization
24 // File : GEOM_Actor.h
25 // Author : Christophe ATTANASIO
31 #include "GEOM_OBJECT_defs.hxx"
32 #include "GEOM_SmartPtr.h"
34 #include <SALOME_Actor.h>
36 #include <TopoDS_Shape.hxx>
37 #include <vtkSmartPointer.h>
41 class GEOM_VertexSource;
42 typedef GEOM_SmartPtr<GEOM_VertexSource> PVertexSource;
44 class GEOM_EdgeSource;
45 typedef GEOM_SmartPtr<GEOM_EdgeSource> PEdgeSource;
47 class GEOM_WireframeFace;
48 typedef GEOM_SmartPtr<GEOM_WireframeFace> PWFaceSource;
50 class GEOM_ShadingFace;
51 typedef GEOM_SmartPtr<GEOM_ShadingFace> PSFaceSource;
55 class vtkAppendPolyData;
56 typedef GEOM_SmartPtr<vtkAppendPolyData> PAppendFilter;
58 class GEOM_OBJECT_EXPORT GEOM_Actor: public SALOME_Actor
61 vtkTypeMacro(GEOM_Actor,SALOME_Actor);
62 static GEOM_Actor* New();
64 void SetShape(const TopoDS_Shape& theShape,
66 bool theIsVector = false);
68 void SetDeflection(float theDeflection);
69 float GetDeflection() const{ return myDeflection;}
71 void AddToRender(vtkRenderer* theRenderer);
72 void RemoveFromRender(vtkRenderer* theRenderer);
74 enum EDisplayMode{ eWireframe, eShading, eShadingWithEdges = eShading + 2 };
76 /* void SetDisplayMode(EDisplayMode theMode); */
77 /* EDisplayMode GetDisplayMode() const { return myDisplayMode;} */
79 void SetSelected(bool theIsSelected);
80 bool IsSelected() const { return myIsSelected;}
84 void SetHighlightProperty(vtkProperty* Prop);
85 void SetWireframeProperty(vtkProperty* Prop);
86 void SetShadingProperty(vtkProperty* Prop);
88 vtkProperty* GetWireframeProperty();
89 vtkProperty* GetShadingProperty();
90 vtkProperty* GetIsolatedEdgeProperty();
91 vtkProperty* GetVertexProperty();
92 vtkProperty* GetSharedEdgeProperty();
93 vtkProperty* GetFaceEdgeProperty();
95 void setDeflection(double adef);
96 virtual void setDisplayMode(int thenewmode);
99 // This causes the actor to be rendered. It, in turn, will render the actor's
100 // property and then mapper.
101 virtual void Render(vtkRenderer *, vtkMapper *);
103 // Release any graphics resources that are being consumed by this actor.
104 // The parameter window could be used to determine which graphic
105 // resources to release.
106 void ReleaseGraphicsResources(vtkWindow *);
107 const TopoDS_Shape& getTopo();
108 void setInputShape(const TopoDS_Shape& ashape, double adef1,
109 int imode, bool isVector = false);
110 double getDeflection();
118 virtual void highlight(bool theHighlight);
119 virtual bool hasHighlight() { return true; }
121 void ShallowCopy(vtkProp *prop);
124 void SetOpacity(double opa);
127 // Color (same to all sub-actors/display modes)
128 void SetColor(double r, double g, double b);
129 void GetColor(double& r, double& g, double& b);
131 void SetPointColor(double r, double g, double b);
132 // Color of standalone edges, wires, vectors
133 void SetIsolatedEdgeColor(double r, double g, double b);
134 // Color of shared edges
135 void SetSharedEdgeColor(double r, double g, double b);
136 // Color of free edges
137 void SetFreeEdgeColor(double r, double g, double b);
138 // Color of edges in shading+edges display mode
139 void SetEdgesInShadingColor(double r, double g, double b);
140 // Color of iso-lines
141 void SetIsosColor(double r, double g, double b);
145 void SetMaterial(std::vector<vtkProperty*> theProps);
146 vtkProperty* GetFrontMaterial();
147 vtkProperty* GetBackMaterial();
148 virtual bool IsInfinitive();
150 // overloaded functions
151 //! To map current selection to VTK representation
154 Highlight(bool theHighlight);
156 //----------------------------------------------------------------------------
157 //! To process prehighlight (called from #SVTK_InteractorStyle)
160 PreHighlight(vtkInteractorStyle* theInteractorStyle,
161 SVTK_SelectionEvent* theSelectionEvent,
162 bool theIsHighlight);
164 //! To process highlight (called from #SVTK_InteractorStyle)
167 Highlight(vtkInteractorStyle* theInteractorStyle,
168 SVTK_SelectionEvent* theSelectionEvent,
169 bool theIsHighlight);
171 //! Visibility management
174 SetVisibility( int );
176 //! IsoLines management
177 // theNb[0] - number of U lines
178 // theNb[1] - number of V lines
181 SetNbIsos(const int theNb[2]);
185 GetNbIsos(int &theNbU,int &theNbV);
188 void SetIsosWidth(const int width);
190 int GetIsosWidth() const;
192 virtual void SetWidth(const int width);
194 int GetWidth() const;
196 //! Vector mode management
199 SetVectorMode(const bool theMode);
217 void GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result);
223 TopoDS_Shape myShape;
230 // EDisplayMode myDisplayMode;
235 PDeviceActor myVertexActor;
236 PVertexSource myVertexSource;
238 PDeviceActor myIsolatedEdgeActor;
239 PEdgeSource myIsolatedEdgeSource;
241 PDeviceActor myOneFaceEdgeActor;
242 PEdgeSource myOneFaceEdgeSource;
244 PDeviceActor mySharedEdgeActor;
245 PEdgeSource mySharedEdgeSource;
247 PDeviceActor myWireframeFaceActor;
248 PWFaceSource myWireframeFaceSource;
250 PDeviceActor myShadingFaceActor;
251 PSFaceSource myShadingFaceSource;
253 PDeviceActor myHighlightActor;
256 vtkSmartPointer<vtkProperty> myHighlightProp;
257 vtkSmartPointer<vtkProperty> myPreHighlightProp;
258 vtkSmartPointer<vtkProperty> myShadingFaceProp;
259 vtkSmartPointer<vtkProperty> myShadingBackFaceProp;
261 PAppendFilter myAppendFilter;
264 PPolyGeomPainterDataMapper myPolyDataMapper;
267 virtual void SetMapper(vtkMapper*);
269 GEOM_Actor(const GEOM_Actor&);
270 void operator=(const GEOM_Actor&);
272 double myEdgesInWireframeColor[3];
273 double myEdgesInShadingColor[3];
274 double myIsolatedEdgeColor[3];
275 double mySharedEdgeColor[3];
276 double myOneFaceEdgeColor[3];
279 #endif //GEOM_ACTOR_H