Salome HOME
IMP 0016175: EDF455: Save GUIState don't redisplay the objects.
[modules/geom.git] / src / OBJECT / GEOM_Actor.h
1 //  GEOM OBJECT : interactive object for Geometry entities visualization
2 //
3 //  Copyright (C) 2003  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 //
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 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
55 class vtkRenderer;
56
57 class vtkAppendPolyData;
58 typedef GEOM_SmartPtr<vtkAppendPolyData> PAppendFilter;
59
60 class GEOM_OBJECT_EXPORT GEOM_Actor: public SALOME_Actor
61 {
62 public:
63   vtkTypeMacro(GEOM_Actor,SALOME_Actor);
64   static GEOM_Actor* New();
65
66   void SetShape(const TopoDS_Shape& theShape,
67                 float theDeflection,
68                 bool theIsRelative,
69                 bool theIsVector = false);
70
71   void SetDeflection(float theDeflection, bool theIsRelative);
72   float GetDeflection() const{ return myDeflection;}
73   bool GetIsRelative() const{ return myIsRelative;}
74
75   void AddToRender(vtkRenderer* theRenderer);
76   void RemoveFromRender(vtkRenderer* theRenderer);
77
78   enum EDisplayMode{ eWireframe, eShading};
79
80 /*   void SetDisplayMode(EDisplayMode theMode);  */
81 /*   EDisplayMode GetDisplayMode() const { return myDisplayMode;}  */
82
83   void SetSelected(bool theIsSelected);
84   bool IsSelected() const { return myIsSelected;}
85
86   // OLD METHODS
87   // Properties
88   void SetHighlightProperty(vtkProperty* Prop);
89   void SetWireframeProperty(vtkProperty* Prop);
90   void SetShadingProperty(vtkProperty* Prop);
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   virtual bool IsInfinitive();
129
130   // overloaded functions
131   //! To map current selection to VTK representation
132   virtual
133   void
134   Highlight(bool theHighlight);
135
136   //----------------------------------------------------------------------------
137   //! To process prehighlight (called from #SVTK_InteractorStyle)
138   virtual
139   bool
140   PreHighlight(vtkInteractorStyle* theInteractorStyle,
141                SVTK_SelectionEvent* theSelectionEvent,
142                bool theIsHighlight);
143
144   //! To process highlight (called from #SVTK_InteractorStyle)
145   virtual
146   bool
147   Highlight(vtkInteractorStyle* theInteractorStyle,
148             SVTK_SelectionEvent* theSelectionEvent,
149             bool theIsHighlight);
150
151   //! Visibility management
152   virtual
153   void
154   SetVisibility( int );
155
156   //! IsoLines management
157   // theNb[0] - number of U lines
158   // theNb[1] - number of V lines
159   virtual
160   void
161   SetNbIsos(const int theNb[2]);
162
163   virtual
164   void
165   GetNbIsos(int &theNbU,int &theNbV);
166
167 protected:
168   void SetShape(const TopoDS_Shape& theShape,
169                 const TopTools_IndexedDataMapOfShapeListOfShape& theEdgeMap,
170                 bool theIsVector = false);
171
172   void SetModified();
173
174   void GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result);
175
176   GEOM_Actor();
177   ~GEOM_Actor();
178
179 private:
180   TopoDS_Shape myShape;
181   int myNbIsos[2];
182
183   float myDeflection;
184   bool myIsRelative;
185   bool myIsForced;
186
187   //  EDisplayMode myDisplayMode;
188   bool myIsSelected;
189
190   PDeviceActor myVertexActor;
191   PVertexSource myVertexSource;
192
193   PDeviceActor myIsolatedEdgeActor;
194   PEdgeSource myIsolatedEdgeSource;
195
196   PDeviceActor myOneFaceEdgeActor;
197   PEdgeSource myOneFaceEdgeSource;
198
199   PDeviceActor mySharedEdgeActor;
200   PEdgeSource mySharedEdgeSource;
201
202   PDeviceActor myWireframeFaceActor;
203   PWFaceSource myWireframeFaceSource;
204
205   PDeviceActor myShadingFaceActor;
206   PSFaceSource myShadingFaceSource;
207
208   PDeviceActor myHighlightActor;
209   vtkSmartPointer<vtkProperty>  myHighlightProp;
210   vtkSmartPointer<vtkProperty>  myPreHighlightProp;
211   vtkSmartPointer<vtkProperty>  myShadingFaceProp;
212
213   PAppendFilter myAppendFilter;
214   PPolyDataMapper myPolyDataMapper;
215
216   virtual void SetMapper(vtkMapper*);
217
218   GEOM_Actor(const GEOM_Actor&);
219   void operator=(const GEOM_Actor&);
220 };
221
222 #endif //GEOM_ACTOR_H