]> SALOME platform Git repositories - modules/geom.git/blob - src/OBJECT/GEOM_Actor.h
Salome HOME
Remove unnecessary dependency on VTK from GEOM engine
[modules/geom.git] / src / OBJECT / GEOM_Actor.h
1 // Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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, or (at your option) any later version.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  GEOM OBJECT : interactive object for Geometry entities visualization
24 //  File   : GEOM_Actor.h
25 //  Author : Christophe ATTANASIO
26 //  Module : GEOM
27 //
28 #ifndef GEOM_ACTOR_H
29 #define GEOM_ACTOR_H
30
31 #include "GEOM_OBJECT_defs.hxx"
32 #include "GEOM_SmartPtr.h"
33
34 #include <SALOME_Actor.h>
35
36 #include <TopoDS_Shape.hxx>
37 #include <vtkSmartPointer.h>
38
39 class vtkCamera;
40
41 class GEOM_VertexSource;
42 typedef GEOM_SmartPtr<GEOM_VertexSource> PVertexSource;
43
44 class GEOM_EdgeSource;
45 typedef GEOM_SmartPtr<GEOM_EdgeSource> PEdgeSource;
46
47 class GEOM_WireframeFace;
48 typedef GEOM_SmartPtr<GEOM_WireframeFace> PWFaceSource;
49
50 class GEOM_ShadingFace;
51 typedef GEOM_SmartPtr<GEOM_ShadingFace> PSFaceSource;
52
53 class vtkRenderer;
54
55 class vtkAppendPolyData;
56 typedef GEOM_SmartPtr<vtkAppendPolyData> PAppendFilter;
57
58 class GEOM_OBJECT_EXPORT GEOM_Actor: public SALOME_Actor
59 {
60 public:
61   vtkTypeMacro(GEOM_Actor,SALOME_Actor);
62   static GEOM_Actor* New();
63
64   void SetShape(const TopoDS_Shape& theShape,
65                 double theDeflection,
66                 bool theIsVector = false);
67
68   void SetDeflection(double theDeflection);
69   double GetDeflection() const{ return myDeflection;}
70
71   void AddToRender(vtkRenderer* theRenderer);
72   void RemoveFromRender(vtkRenderer* theRenderer);
73
74   enum EDisplayMode{ eWireframe, eShading, eShadingWithEdges = eShading + 2 };
75
76 /*   void SetDisplayMode(EDisplayMode theMode);  */
77 /*   EDisplayMode GetDisplayMode() const { return myDisplayMode;}  */
78
79   void SetSelected(bool theIsSelected);
80   bool IsSelected() const { return myIsSelected;}
81
82   // OLD METHODS
83   // Properties
84   void SetHighlightProperty(vtkProperty* Prop);
85   void SetWireframeProperty(vtkProperty* Prop);
86   void SetShadingProperty(vtkProperty* Prop);
87
88   vtkProperty* GetWireframeProperty();
89   vtkProperty* GetShadingProperty();
90   vtkProperty* GetIsolatedEdgeProperty();
91   vtkProperty* GetVertexProperty();
92   vtkProperty* GetStandaloneVertexProperty();
93   vtkProperty* GetSharedEdgeProperty();
94   vtkProperty* GetFaceEdgeProperty();
95
96   virtual void setDisplayMode(int thenewmode);
97
98   // Description:
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 *);
102   // Description:
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 isVector();
111
112   // SubShape
113   void SubShapeOn();
114   void SubShapeOff();
115
116   // Highlight
117   virtual void highlight(bool theHighlight);
118   virtual bool hasHighlight() { return true; }
119
120   void ShallowCopy(vtkProp *prop);
121
122   // Opacity
123   void SetOpacity(double opa);
124   double GetOpacity();
125
126   // Color (same to all sub-actors/display modes)
127   void SetColor(double r,  double g,  double b);
128   void GetColor(double& r, double& g, double& b);
129   // Color of points
130   void SetPointColor(double r, double g, double b);
131   // Color of standalone edges, wires, vectors
132   void SetIsolatedEdgeColor(double r, double g, double b);
133   // Color of shared edges
134   void SetSharedEdgeColor(double r, double g, double b);
135   // Color of free edges
136   void SetFreeEdgeColor(double r, double g, double b);
137   // Color of edges in shading+edges display mode
138   void SetEdgesInShadingColor(double r, double g, double b);
139   // Color of iso-lines
140   void SetIsosColor(double r, double g, double b);
141
142
143   // Material
144   void SetMaterial(std::vector<vtkProperty*> theProps);
145   vtkProperty* GetFrontMaterial();
146   vtkProperty* GetBackMaterial();
147   virtual bool IsInfinitive();
148
149   // overloaded functions
150   //! To map current selection to VTK representation
151   virtual
152   void
153   Highlight(bool theHighlight);
154
155   //----------------------------------------------------------------------------
156   //! To process prehighlight (called from #SVTK_InteractorStyle)
157   virtual
158   bool
159   PreHighlight(vtkInteractorStyle* theInteractorStyle,
160                SVTK_SelectionEvent* theSelectionEvent,
161                bool theIsHighlight);
162
163   //! To process highlight (called from #SVTK_InteractorStyle)
164   virtual
165   bool
166   Highlight(vtkInteractorStyle* theInteractorStyle,
167             SVTK_SelectionEvent* theSelectionEvent,
168             bool theIsHighlight);
169
170   //! Visibility management
171   virtual
172   void
173   SetVisibility( int );
174
175   //! IsoLines management
176   // theNb[0] - number of U lines
177   // theNb[1] - number of V lines
178   virtual
179   void
180   SetNbIsos(const int theNb[2]);
181
182   virtual
183   void
184   GetNbIsos(int &theNbU,int &theNbV);
185   
186   virtual 
187   void SetIsosWidth(const int width);
188
189   int GetIsosWidth() const;
190
191   virtual void SetWidth(const int width);
192
193   int GetWidth() const;
194   
195   //! Vector mode management
196   virtual
197   void
198   SetVectorMode(const bool theMode);
199
200   virtual
201   bool
202   GetVectorMode();
203
204   //! Vertices mode management
205   virtual
206   void
207   SetVerticesMode(const bool theMode);
208
209   virtual
210   bool
211   GetVerticesMode();
212
213 protected:
214   void SetModified();
215
216   void GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result);
217
218   GEOM_Actor();
219   ~GEOM_Actor();
220
221 private:
222   TopoDS_Shape myShape;
223   bool isOnlyVertex;
224
225   double myDeflection;
226   bool myIsForced;
227
228   //  EDisplayMode myDisplayMode;
229   bool myIsSelected;
230   bool myVectorMode;
231   bool myVerticesMode;
232
233   PDeviceActor myVertexActor;
234   PVertexSource myVertexSource;
235
236   PDeviceActor myStandaloneVertexActor;
237   PVertexSource myStandaloneVertexSource;
238
239   PDeviceActor myIsolatedEdgeActor;
240   PEdgeSource myIsolatedEdgeSource;
241
242   PDeviceActor myOneFaceEdgeActor;
243   PEdgeSource myOneFaceEdgeSource;
244
245   PDeviceActor mySharedEdgeActor;
246   PEdgeSource mySharedEdgeSource;
247
248   PDeviceActor myWireframeFaceActor;
249   PWFaceSource myWireframeFaceSource;
250
251   PDeviceActor myShadingFaceActor;
252   PSFaceSource myShadingFaceSource;
253
254   PDeviceActor myHighlightActor;
255   vtkSmartPointer<vtkProperty>  myHighlightProp;
256   vtkSmartPointer<vtkProperty>  myPreHighlightProp;
257   vtkSmartPointer<vtkProperty>  myShadingFaceProp;
258   vtkSmartPointer<vtkProperty>  myShadingBackFaceProp;
259
260   PAppendFilter myAppendFilter;
261   PPolyGeomPainterDataMapper myPolyDataMapper;
262
263   virtual void SetMapper(vtkMapper*);
264
265   GEOM_Actor(const GEOM_Actor&);
266   void operator=(const GEOM_Actor&);
267
268   double myEdgesInWireframeColor[3];
269   double myEdgesInShadingColor[3];
270   double myIsolatedEdgeColor[3];
271   double mySharedEdgeColor[3];
272   double myOneFaceEdgeColor[3];
273 };
274
275 #endif //GEOM_ACTOR_H
276
277