]> SALOME platform Git repositories - modules/geom.git/blob - src/OBJECT/GEOM_Actor.h
Salome HOME
Implementation of the "21046: EDF 1610 GUI: To be able to change the width of the...
[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   vtkProperty* GetWireframeProperty();
90   vtkProperty* GetShadingProperty();
91
92   void setDeflection(double adef);
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 getDeflection();
108   double isVector();
109
110   // SubShape
111   void SubShapeOn();
112   void SubShapeOff();
113
114   // Highlight
115   virtual void highlight(bool theHighlight);
116   virtual bool hasHighlight() { return true; }
117
118   void ShallowCopy(vtkProp *prop);
119
120   // Opacity
121   void SetOpacity(vtkFloatingPointType opa);
122   vtkFloatingPointType GetOpacity();
123
124   // Color
125   void SetColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
126   void GetColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
127
128   // Material
129   void SetMaterial(std::vector<vtkProperty*> theProps);
130   vtkProperty* GetFrontMaterial();
131   vtkProperty* GetBackMaterial();
132
133   virtual bool IsInfinitive();
134
135   // overloaded functions
136   //! To map current selection to VTK representation
137   virtual
138   void
139   Highlight(bool theHighlight);
140
141   //----------------------------------------------------------------------------
142   //! To process prehighlight (called from #SVTK_InteractorStyle)
143   virtual
144   bool
145   PreHighlight(vtkInteractorStyle* theInteractorStyle,
146                SVTK_SelectionEvent* theSelectionEvent,
147                bool theIsHighlight);
148
149   //! To process highlight (called from #SVTK_InteractorStyle)
150   virtual
151   bool
152   Highlight(vtkInteractorStyle* theInteractorStyle,
153             SVTK_SelectionEvent* theSelectionEvent,
154             bool theIsHighlight);
155
156   //! Visibility management
157   virtual
158   void
159   SetVisibility( int );
160
161   //! IsoLines management
162   // theNb[0] - number of U lines
163   // theNb[1] - number of V lines
164   virtual
165   void
166   SetNbIsos(const int theNb[2]);
167
168   virtual
169   void
170   GetNbIsos(int &theNbU,int &theNbV);
171   
172   virtual 
173   void SetIsosWidth(const int width);
174
175   int GetIsosWidth() const;
176
177   virtual void SetWidth(const int width);
178
179   int GetWidth() const;
180   
181   //! Vector mode management
182   virtual
183   void
184   SetVectorMode(const bool theMode);
185
186   virtual
187   bool
188   GetVectorMode();
189   
190   //! Edges in shading color management
191   void SetEdgesInShadingColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
192
193   void
194   StoreIsoNumbers();
195
196   void
197   RestoreIsoNumbers();
198   
199   void
200   ResetIsoNumbers();
201
202 protected:
203   void SetModified();
204
205   void GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result);
206
207   void StoreBoundaryColors();
208   void RestoreBoundaryColors();
209
210   GEOM_Actor();
211   ~GEOM_Actor();
212
213 private:
214   TopoDS_Shape myShape;
215   int myNbIsos[2];
216   bool isOnlyVertex;
217
218   float myDeflection;
219   bool myIsForced;
220
221   //  EDisplayMode myDisplayMode;
222   bool myIsSelected;
223   bool myVectorMode;
224
225   PDeviceActor myVertexActor;
226   PVertexSource myVertexSource;
227
228   PDeviceActor myIsolatedEdgeActor;
229   PEdgeSource myIsolatedEdgeSource;
230
231   PDeviceActor myOneFaceEdgeActor;
232   PEdgeSource myOneFaceEdgeSource;
233
234   PDeviceActor mySharedEdgeActor;
235   PEdgeSource mySharedEdgeSource;
236
237   PDeviceActor myWireframeFaceActor;
238   PWFaceSource myWireframeFaceSource;
239
240   PDeviceActor myShadingFaceActor;
241   PSFaceSource myShadingFaceSource;
242
243   PDeviceActor myHighlightActor;
244   vtkSmartPointer<vtkProperty>  myHighlightProp;
245   vtkSmartPointer<vtkProperty>  myPreHighlightProp;
246   vtkSmartPointer<vtkProperty>  myShadingFaceProp;
247   vtkSmartPointer<vtkProperty>  myShadingBackFaceProp;
248
249   PAppendFilter myAppendFilter;
250   PPolyGeomPainterDataMapper myPolyDataMapper;
251
252   virtual void SetMapper(vtkMapper*);
253
254   GEOM_Actor(const GEOM_Actor&);
255   void operator=(const GEOM_Actor&);
256
257   vtkFloatingPointType myEdgesInWireframeColor[3];
258   vtkFloatingPointType myEdgesInShadingColor[3];
259 };
260
261 #endif //GEOM_ACTOR_H
262
263