Salome HOME
Update GUI documentation for bugs 16559
[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
34 #include "SALOME_Actor.h"
35  
36 #include <TopoDS_Shape.hxx>
37  
38 #include "GEOM_SmartPtr.h"
39 #include <vtkSmartPointer.h>
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 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx> 
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 theIsRelative); 
68  
69   void SetDeflection(float theDeflection, bool theIsRelative); 
70   float GetDeflection() const{ return myDeflection;} 
71   bool GetIsRelative() const{ return myIsRelative;} 
72  
73   void AddToRender(vtkRenderer* theRenderer); 
74   void RemoveFromRender(vtkRenderer* theRenderer);
75
76   enum EDisplayMode{ eWireframe, eShading};
77   
78 /*   void SetDisplayMode(EDisplayMode theMode);  */
79 /*   EDisplayMode GetDisplayMode() const { return myDisplayMode;}  */
80  
81   void SetSelected(bool theIsSelected); 
82   bool IsSelected() const { return myIsSelected;} 
83
84   // OLD METHODS
85   // Properties
86   void SetHighlightProperty(vtkProperty* Prop);
87   void SetWireframeProperty(vtkProperty* Prop);
88   void SetShadingProperty(vtkProperty* Prop);
89
90   void setDeflection(double adef);
91   virtual void setDisplayMode(int thenewmode);
92
93   // Description:
94   // This causes the actor to be rendered. It, in turn, will render the actor's
95   // property and then mapper.
96   virtual void Render(vtkRenderer *, vtkMapper *);
97   // Description:
98   // Release any graphics resources that are being consumed by this actor.
99   // The parameter window could be used to determine which graphic
100   // resources to release.
101   void ReleaseGraphicsResources(vtkWindow *);
102   const TopoDS_Shape& getTopo();
103   void setInputShape(const TopoDS_Shape& ashape, double adef1,
104                      int imode, bool isVector = false);
105   double getDeflection();
106   double isVector();
107
108   // SubShape
109   void SubShapeOn();
110   void SubShapeOff();
111   
112   // Highlight
113   virtual void highlight(bool theHighlight);
114   virtual bool hasHighlight() { return true; }
115
116   void ShallowCopy(vtkProp *prop);
117
118   // Opacity
119   void SetOpacity(vtkFloatingPointType opa);
120   vtkFloatingPointType GetOpacity();
121
122   // Color
123   void SetColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
124   void GetColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
125
126   virtual bool IsInfinite();
127
128   // overloaded functions
129   //! To map current selection to VTK representation
130   virtual
131   void
132   Highlight(bool theHighlight);
133   
134   //----------------------------------------------------------------------------
135   //! To process prehighlight (called from #SVTK_InteractorStyle)
136   virtual
137   bool
138   PreHighlight(vtkInteractorStyle* theInteractorStyle, 
139                SVTK_SelectionEvent* theSelectionEvent,
140                bool theIsHighlight);
141
142   //! To process highlight (called from #SVTK_InteractorStyle)
143   virtual 
144   bool
145   Highlight(vtkInteractorStyle* theInteractorStyle, 
146             SVTK_SelectionEvent* theSelectionEvent,
147             bool theIsHighlight);
148
149   //! Visibility management
150   virtual
151   void
152   SetVisibility( int );
153
154   //! IsoLines management
155   // theNb[0] - number of U lines
156   // theNb[1] - number of V lines
157   virtual
158   void
159   SetNbIsos(const int theNb[2]);
160   
161   virtual
162   void
163   GetNbIsos(int &theNbU,int &theNbV);
164   
165 protected: 
166   void SetShape(const TopoDS_Shape& theShape, 
167                 const TopTools_IndexedDataMapOfShapeListOfShape& theEdgeMap); 
168  
169   void SetModified(); 
170
171   void GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result);
172  
173   GEOM_Actor(); 
174   ~GEOM_Actor(); 
175  
176 private: 
177   TopoDS_Shape myShape;
178   int myNbIsos[2];
179   
180   float myDeflection; 
181   bool myIsRelative; 
182   bool myIsForced; 
183  
184   //  EDisplayMode myDisplayMode; 
185   bool myIsSelected; 
186  
187   PDeviceActor myVertexActor; 
188   PVertexSource myVertexSource; 
189  
190   PDeviceActor myIsolatedEdgeActor; 
191   PEdgeSource myIsolatedEdgeSource; 
192  
193   PDeviceActor myOneFaceEdgeActor; 
194   PEdgeSource myOneFaceEdgeSource; 
195  
196   PDeviceActor mySharedEdgeActor; 
197   PEdgeSource mySharedEdgeSource; 
198  
199   PDeviceActor myWireframeFaceActor; 
200   PWFaceSource myWireframeFaceSource; 
201  
202   PDeviceActor myShadingFaceActor; 
203   PSFaceSource myShadingFaceSource; 
204  
205   PDeviceActor myHighlightActor;
206   vtkSmartPointer<vtkProperty>  myHighlightProp;
207   vtkSmartPointer<vtkProperty>  myPreHighlightProp;
208   vtkSmartPointer<vtkProperty>  myShadingFaceProp;
209  
210   PAppendFilter myAppendFilter; 
211   PPolyDataMapper myPolyDataMapper; 
212  
213   virtual void SetMapper(vtkMapper*); 
214  
215   GEOM_Actor(const GEOM_Actor&); 
216   void operator=(const GEOM_Actor&); 
217 }; 
218  
219 #endif //GEOM_ACTOR_H