Salome HOME
Mantis issue 0021465: EDF 2067 GEOM: Extrusion along a path leads to a self-intersect...
[modules/geom.git] / src / OBJECT / GEOM_Actor.h
1 // Copyright (C) 2007-2011  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.
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 //  $Header$
28 //
29 #ifndef GEOM_ACTOR_H
30 #define GEOM_ACTOR_H
31
32 #include "GEOM_OBJECT_defs.hxx"
33 #include "GEOM_SmartPtr.h"
34
35 #include <SALOME_Actor.h>
36
37 #include <TopoDS_Shape.hxx>
38 #include <vtkSmartPointer.h>
39
40 class vtkCamera;
41
42 class GEOM_VertexSource;
43 typedef GEOM_SmartPtr<GEOM_VertexSource> PVertexSource;
44
45 class GEOM_EdgeSource;
46 typedef GEOM_SmartPtr<GEOM_EdgeSource> PEdgeSource;
47
48 class GEOM_WireframeFace;
49 typedef GEOM_SmartPtr<GEOM_WireframeFace> PWFaceSource;
50
51 class GEOM_ShadingFace;
52 typedef GEOM_SmartPtr<GEOM_ShadingFace> PSFaceSource;
53
54 class vtkRenderer;
55
56 class vtkAppendPolyData;
57 typedef GEOM_SmartPtr<vtkAppendPolyData> PAppendFilter;
58
59 class GEOM_OBJECT_EXPORT GEOM_Actor: public SALOME_Actor
60 {
61 public:
62   vtkTypeMacro(GEOM_Actor,SALOME_Actor);
63   static GEOM_Actor* New();
64
65   void SetShape(const TopoDS_Shape& theShape,
66                 float theDeflection,
67                 bool theIsVector = false);
68
69   void SetDeflection(float theDeflection);
70   float GetDeflection() const{ return myDeflection;}
71
72   void AddToRender(vtkRenderer* theRenderer);
73   void RemoveFromRender(vtkRenderer* theRenderer);
74
75   enum EDisplayMode{ eWireframe, eShading, eShadingWithEdges = eShading + 2 };
76
77 /*   void SetDisplayMode(EDisplayMode theMode);  */
78 /*   EDisplayMode GetDisplayMode() const { return myDisplayMode;}  */
79
80   void SetSelected(bool theIsSelected);
81   bool IsSelected() const { return myIsSelected;}
82
83   // OLD METHODS
84   // Properties
85   void SetHighlightProperty(vtkProperty* Prop);
86   void SetWireframeProperty(vtkProperty* Prop);
87   void SetShadingProperty(vtkProperty* Prop);
88
89   void setDeflection(double adef);
90   virtual void setDisplayMode(int thenewmode);
91
92   // Description:
93   // This causes the actor to be rendered. It, in turn, will render the actor's
94   // property and then mapper.
95   virtual void Render(vtkRenderer *, vtkMapper *);
96   // Description:
97   // Release any graphics resources that are being consumed by this actor.
98   // The parameter window could be used to determine which graphic
99   // resources to release.
100   void ReleaseGraphicsResources(vtkWindow *);
101   const TopoDS_Shape& getTopo();
102   void setInputShape(const TopoDS_Shape& ashape, double adef1,
103                      int imode, bool isVector = false);
104   double getDeflection();
105   double isVector();
106
107   // SubShape
108   void SubShapeOn();
109   void SubShapeOff();
110
111   // Highlight
112   virtual void highlight(bool theHighlight);
113   virtual bool hasHighlight() { return true; }
114
115   void ShallowCopy(vtkProp *prop);
116
117   // Opacity
118   void SetOpacity(vtkFloatingPointType opa);
119   vtkFloatingPointType GetOpacity();
120
121   // Color
122   void SetColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
123   void GetColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
124
125   // Material
126   void SetMaterial(std::vector<vtkProperty*> theProps);
127   vtkProperty* GetFrontMaterial();
128   vtkProperty* GetBackMaterial();
129
130   virtual bool IsInfinitive();
131
132   // overloaded functions
133   //! To map current selection to VTK representation
134   virtual
135   void
136   Highlight(bool theHighlight);
137
138   //----------------------------------------------------------------------------
139   //! To process prehighlight (called from #SVTK_InteractorStyle)
140   virtual
141   bool
142   PreHighlight(vtkInteractorStyle* theInteractorStyle,
143                SVTK_SelectionEvent* theSelectionEvent,
144                bool theIsHighlight);
145
146   //! To process highlight (called from #SVTK_InteractorStyle)
147   virtual
148   bool
149   Highlight(vtkInteractorStyle* theInteractorStyle,
150             SVTK_SelectionEvent* theSelectionEvent,
151             bool theIsHighlight);
152
153   //! Visibility management
154   virtual
155   void
156   SetVisibility( int );
157
158   //! IsoLines management
159   // theNb[0] - number of U lines
160   // theNb[1] - number of V lines
161   virtual
162   void
163   SetNbIsos(const int theNb[2]);
164
165   virtual
166   void
167   GetNbIsos(int &theNbU,int &theNbV);
168   
169   //! Vector mode management
170   virtual
171   void
172   SetVectorMode(const bool theMode);
173
174   virtual
175   bool
176   GetVectorMode();
177   
178   //! Edges in shading color management
179   void SetEdgesInShadingColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
180
181   void
182   StoreIsoNumbers();
183
184   void
185   RestoreIsoNumbers();
186   
187   void
188   ResetIsoNumbers();
189
190 protected:
191   void SetModified();
192
193   void GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result);
194
195   void StoreBoundaryColors();
196   void RestoreBoundaryColors();
197
198   GEOM_Actor();
199   ~GEOM_Actor();
200
201 private:
202   TopoDS_Shape myShape;
203   int myNbIsos[2];
204   bool isOnlyVertex;
205
206   float myDeflection;
207   bool myIsForced;
208
209   //  EDisplayMode myDisplayMode;
210   bool myIsSelected;
211   bool myVectorMode;
212
213   PDeviceActor myVertexActor;
214   PVertexSource myVertexSource;
215
216   PDeviceActor myIsolatedEdgeActor;
217   PEdgeSource myIsolatedEdgeSource;
218
219   PDeviceActor myOneFaceEdgeActor;
220   PEdgeSource myOneFaceEdgeSource;
221
222   PDeviceActor mySharedEdgeActor;
223   PEdgeSource mySharedEdgeSource;
224
225   PDeviceActor myWireframeFaceActor;
226   PWFaceSource myWireframeFaceSource;
227
228   PDeviceActor myShadingFaceActor;
229   PSFaceSource myShadingFaceSource;
230
231   PDeviceActor myHighlightActor;
232   vtkSmartPointer<vtkProperty>  myHighlightProp;
233   vtkSmartPointer<vtkProperty>  myPreHighlightProp;
234   vtkSmartPointer<vtkProperty>  myShadingFaceProp;
235   vtkSmartPointer<vtkProperty>  myShadingBackFaceProp;
236
237   PAppendFilter myAppendFilter;
238   PPolyGeomPainterDataMapper myPolyDataMapper;
239
240   virtual void SetMapper(vtkMapper*);
241
242   GEOM_Actor(const GEOM_Actor&);
243   void operator=(const GEOM_Actor&);
244
245   vtkFloatingPointType myEdgesInWireframeColor[3];
246   vtkFloatingPointType myEdgesInShadingColor[3];
247 };
248
249 #endif //GEOM_ACTOR_H
250
251