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