1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // GEOM OBJECT : interactive object for Geometry entities visualization
20 // File : GEOM_Actor.h
21 // Author : Christophe ATTANASIO
27 #include "GEOM_OBJECT_defs.hxx"
28 #include "GEOM_SmartPtr.h"
30 #include <SALOME_Actor.h>
32 #include <TopoDS_Shape.hxx>
33 #include <vtkSmartPointer.h>
37 class GEOM_VertexSource;
38 typedef GEOM_SmartPtr<GEOM_VertexSource> PVertexSource;
40 class GEOM_EdgeSource;
41 typedef GEOM_SmartPtr<GEOM_EdgeSource> PEdgeSource;
43 class GEOM_WireframeFace;
44 typedef GEOM_SmartPtr<GEOM_WireframeFace> PWFaceSource;
46 class GEOM_ShadingFace;
47 typedef GEOM_SmartPtr<GEOM_ShadingFace> PSFaceSource;
52 class vtkAppendPolyData;
53 typedef GEOM_SmartPtr<vtkAppendPolyData> PAppendFilter;
55 class GEOM_OBJECT_EXPORT GEOM_Actor: public SALOME_Actor
58 vtkTypeMacro(GEOM_Actor,SALOME_Actor);
59 static GEOM_Actor* New();
61 void SetShape(const TopoDS_Shape& theShape,
63 bool theIsVector = false);
65 void SetDeflection(double theDeflection);
66 double GetDeflection() const{ return myDeflection;}
68 void AddToRender(vtkRenderer* theRenderer);
69 void RemoveFromRender(vtkRenderer* theRenderer);
71 enum EDisplayMode{ eWireframe, eShading, eShadingWithEdges = eShading + 2 };
73 /* void SetDisplayMode(EDisplayMode theMode); */
74 /* EDisplayMode GetDisplayMode() const { return myDisplayMode;} */
76 void SetSelected(bool theIsSelected);
77 bool IsSelected() const { return myIsSelected;}
81 void SetHighlightProperty(vtkProperty* Prop);
82 void SetWireframeProperty(vtkProperty* Prop);
83 void SetShadingProperty(vtkProperty* Prop);
85 vtkProperty* GetWireframeProperty();
86 vtkProperty* GetShadingProperty();
87 vtkProperty* GetIsolatedEdgeProperty();
88 vtkProperty* GetVertexProperty();
89 vtkProperty* GetStandaloneVertexProperty();
90 vtkProperty* GetSharedEdgeProperty();
91 vtkProperty* GetFaceEdgeProperty();
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);
114 virtual void highlight(bool theHighlight);
115 virtual bool hasHighlight() { return true; }
117 void ShallowCopy(vtkProp *prop);
120 void SetOpacity(double opa);
123 // Color (same to all sub-actors/display modes)
124 void SetColor(double r, double g, double b);
125 void GetColor(double& r, double& g, double& b);
127 void SetPointColor(double r, double g, double b);
128 // Color of standalone edges, wires, vectors
129 void SetIsolatedEdgeColor(double r, double g, double b);
130 // Color of shared edges
131 void SetSharedEdgeColor(double r, double g, double b);
132 // Color of free edges
133 void SetFreeEdgeColor(double r, double g, double b);
134 // Color of edges in shading+edges display mode
135 void SetEdgesInShadingColor(double r, double g, double b);
136 // Color of iso-lines
137 void SetIsosColor(double r, double g, double b);
141 void SetMaterial(std::vector<vtkProperty*> theProps);
142 vtkProperty* GetFrontMaterial();
143 vtkProperty* GetBackMaterial();
144 virtual bool IsInfinitive();
146 // overloaded functions
147 //! To map current selection to VTK representation
150 Highlight(bool theHighlight);
152 //----------------------------------------------------------------------------
153 //! To process prehighlight (called from #SVTK_InteractorStyle)
156 PreHighlight(vtkInteractorStyle* theInteractorStyle,
157 SVTK_SelectionEvent* theSelectionEvent,
158 bool theIsHighlight);
160 //! To process highlight (called from #SVTK_InteractorStyle)
163 Highlight(vtkInteractorStyle* theInteractorStyle,
164 SVTK_SelectionEvent* theSelectionEvent,
165 bool theIsHighlight);
167 //! Visibility management
170 SetVisibility( int );
172 //! IsoLines management
173 // theNb[0] - number of U lines
174 // theNb[1] - number of V lines
177 SetNbIsos(const int theNb[2]);
181 GetNbIsos(int &theNbU,int &theNbV);
184 void SetIsosWidth(const int width);
186 int GetIsosWidth() const;
188 virtual void SetWidth(const int width);
190 int GetWidth() const;
192 //! Vector mode management
195 SetVectorMode(const bool theMode);
201 //! Vertices mode management
204 SetVerticesMode(const bool theMode);
210 //! Name mode management
213 SetNameMode(const bool theMode);
222 void GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result);
223 void SetShapeName(const TopoDS_Shape& theShape);
229 TopoDS_Shape myShape;
235 // EDisplayMode myDisplayMode;
242 PDeviceActor myVertexActor;
243 PVertexSource myVertexSource;
245 PDeviceActor myStandaloneVertexActor;
246 PVertexSource myStandaloneVertexSource;
248 PDeviceActor myIsolatedEdgeActor;
249 PEdgeSource myIsolatedEdgeSource;
251 PDeviceActor myOneFaceEdgeActor;
252 PEdgeSource myOneFaceEdgeSource;
254 PDeviceActor mySharedEdgeActor;
255 PEdgeSource mySharedEdgeSource;
257 PDeviceActor myWireframeFaceActor;
258 PWFaceSource myWireframeFaceSource;
260 PDeviceActor myShadingFaceActor;
261 PSFaceSource myShadingFaceSource;
263 PDeviceActor myHighlightActor;
265 vtkTextActor* myTextActor;
267 vtkSmartPointer<vtkProperty> myHighlightProp;
268 vtkSmartPointer<vtkProperty> myPreHighlightProp;
269 vtkSmartPointer<vtkProperty> myShadingFaceProp;
270 vtkSmartPointer<vtkProperty> myShadingBackFaceProp;
272 PAppendFilter myAppendFilter;
273 PPolyGeomPainterDataMapper myPolyDataMapper;
276 virtual void SetMapper(vtkMapper*);
278 GEOM_Actor(const GEOM_Actor&);
279 void operator=(const GEOM_Actor&);
282 double myEdgesInWireframeColor[3];
283 double myEdgesInShadingColor[3];
284 double myIsolatedEdgeColor[3];
285 double mySharedEdgeColor[3];
286 double myOneFaceEdgeColor[3];
289 #endif //GEOM_ACTOR_H