Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[modules/gui.git] / src / VTKViewer / VTKViewer_Actor.h
1 //  SALOME OBJECT : implementation of interactive object visualization for OCC and VTK viewers
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   : SALOME_Actor.h
25 //  Author : Nicolas REJNERI
26 //  Module : SALOME
27 //  $Header$
28
29 #ifndef VTKVIEVER_ACTOR_H
30 #define VTKVIEVER_ACTOR_H
31
32 #include "VTKViewer.h"
33
34 #include <string>
35 #include <vector>
36
37 #include <vtkLODActor.h>
38
39 class vtkCell;
40 class vtkPointPicker;
41 class vtkCellPicker;
42 class vtkDataSet;
43 class vtkCamera;
44 class vtkProperty;
45 class vtkRenderer;
46
47 class VTKViewer_Transform;
48 class VTKViewer_GeometryFilter;
49 class VTKViewer_TransformFilter;
50 class VTKViewer_PassThroughFilter;
51
52 extern int VTKViewer_POINT_SIZE;
53 extern int VTKViewer_LINE_WIDTH;
54
55 /*! \class vtkLODActor
56  * \brief For more information see <a href="http://www.vtk.org/">VTK documentation</a>
57  */
58 class VTKVIEWER_EXPORT VTKViewer_Actor : public vtkLODActor 
59 {
60  public:
61   static VTKViewer_Actor* New();
62   
63   vtkTypeMacro(VTKViewer_Actor,vtkLODActor);
64
65   //----------------------------------------------------------------------------
66   //! Get its name
67   virtual 
68   const char* 
69   getName();
70
71   //! Name the #VTKViewer_Actor
72   virtual
73   void
74   setName(const char* theName);
75
76   //----------------------------------------------------------------------------
77   //! Change opacity
78   virtual
79   void
80   SetOpacity(vtkFloatingPointType theOpacity);
81
82   //! Get current opacity
83   virtual
84   vtkFloatingPointType 
85   GetOpacity();
86
87   //! Change color
88   virtual
89   void
90   SetColor(vtkFloatingPointType r,
91            vtkFloatingPointType g,
92            vtkFloatingPointType b);
93
94   //! Get current color
95   virtual
96   void
97   GetColor(vtkFloatingPointType& r,
98            vtkFloatingPointType& g,
99            vtkFloatingPointType& b);
100
101   //! Change color
102   virtual
103   void
104   SetColor(const vtkFloatingPointType theRGB[3]);
105
106   //----------------------------------------------------------------------------
107   // For selection mapping purpose
108   //! Maps VTK index of a node to corresponding object index
109   virtual
110   int 
111   GetNodeObjId(int theVtkID);
112
113   //! Get coordinates of a node for given object index
114   virtual
115   vtkFloatingPointType*
116   GetNodeCoord(int theObjID);
117
118   //! Maps VTK index of a cell to corresponding object index
119   virtual 
120   int
121   GetElemObjId(int theVtkID);
122
123   //! Get corresponding #vtkCell for given object index
124   virtual
125   vtkCell* 
126   GetElemCell(int theObjID);
127
128   //----------------------------------------------------------------------------
129   //! Get dimension of corresponding mesh element
130   virtual
131   int
132   GetObjDimension( const int theObjId );
133
134   //! To insert some additional filters and then sets the given #vtkMapper
135   virtual
136   void
137   SetMapper(vtkMapper* theMapper); 
138
139   //! Allows to get initial #vtkDataSet
140   virtual
141   vtkDataSet* 
142   GetInput(); 
143
144   //! Apply view transformation
145   virtual
146   void
147   SetTransform(VTKViewer_Transform* theTransform); 
148
149   //! To calculatate last modified time
150   virtual
151   unsigned long int
152   GetMTime();
153
154   //----------------------------------------------------------------------------
155   //! Set representation (VTK_SURFACE, VTK_POINTS, VTK_WIREFRAME and so on)
156   virtual
157   void
158   SetRepresentation(int theMode);
159
160   //! Get current representation mode
161   virtual
162   int
163   GetRepresentation();
164
165   //! Get current display mode (obsolete)
166   virtual
167   int
168   getDisplayMode();
169
170   //! Set display mode (obsolete)
171   virtual
172   void
173   setDisplayMode(int theMode);
174
175   //----------------------------------------------------------------------------
176   //! Set infinive flag
177   /*!
178     Infinitive means actor without size (point for example),
179     which is not taken into account in calculation of boundaries of the scene
180   */
181   void
182   SetInfinitive(bool theIsInfinite);
183
184   //! Get infinive flag
185   virtual
186   bool
187   IsInfinitive();
188     
189   //! To calcualte current bounding box
190   virtual
191   vtkFloatingPointType* 
192   GetBounds();
193
194   //! To calcualte current bounding box
195   void
196   GetBounds(vtkFloatingPointType bounds[6]);
197
198   //----------------------------------------------------------------------------
199   virtual
200   bool
201   IsSetCamera() const;
202
203   virtual
204   bool
205   IsResizable() const;
206
207   virtual
208   void
209   SetSize( const vtkFloatingPointType );
210
211   virtual
212   void 
213   SetCamera( vtkCamera* );
214
215   //----------------------------------------------------------------------------
216   //! Set ResolveCoincidentTopology flag
217   void
218   SetResolveCoincidentTopology(bool theIsResolve);
219
220   //! Set ResolveCoincidentTopology parameters
221   void
222   SetPolygonOffsetParameters(vtkFloatingPointType factor, 
223                              vtkFloatingPointType units);
224
225   //! Get current ResolveCoincidentTopology parameters
226   void
227   GetPolygonOffsetParameters(vtkFloatingPointType& factor, 
228                              vtkFloatingPointType& units);
229
230   virtual
231   void
232   Render(vtkRenderer *, vtkMapper *);
233
234   //----------------------------------------------------------------------------
235   //! Get current shrink factor
236   virtual
237   vtkFloatingPointType
238   GetShrinkFactor();
239
240   //! Is the actor is shrunkable
241   virtual
242   bool
243   IsShrunkable();
244
245   //! Is the actor is shrunk
246   virtual
247   bool
248   IsShrunk();
249
250   //! Insert shrink filter into pipeline
251   virtual
252   void
253   SetShrink();
254
255   //! Remove shrink filter from pipeline
256   virtual
257   void
258   UnShrink();
259
260   //----------------------------------------------------------------------------
261   //! To publish the actor an all its internal devices
262   virtual
263   void
264   AddToRender(vtkRenderer* theRendere); 
265
266   //! To remove the actor an all its internal devices
267   virtual
268   void
269   RemoveFromRender(vtkRenderer* theRendere);
270
271   //! Used to obtain all dependent actors
272   virtual
273   void
274   GetChildActors(vtkActorCollection*);
275
276   //----------------------------------------------------------------------------
277   //! Ask, if the descendant of the VTKViewer_Actor will implement its own highlight or not
278   virtual
279   bool
280   hasHighlight(); 
281
282   //! Ask, if the VTKViewer_Actor is already highlighted
283   virtual
284   bool
285   isHighlighted();
286
287   //! Set preselection mode
288   virtual
289   void
290   SetPreSelected(bool thePreselect = false);
291
292   //----------------------------------------------------------------------------
293   //! Just to update visibility of the highlight devices
294   virtual
295   void
296   highlight(bool theHighlight);  
297
298   void
299   SetPreviewProperty(vtkProperty* theProperty);
300
301  protected:
302   //----------------------------------------------------------------------------
303   bool myIsResolveCoincidentTopology;
304   vtkFloatingPointType myPolygonOffsetFactor;
305   vtkFloatingPointType myPolygonOffsetUnits;
306
307   std::string myName;
308
309   vtkFloatingPointType myOpacity;
310   int myDisplayMode;
311   bool myIsInfinite;
312
313   bool myStoreMapping;
314   VTKViewer_GeometryFilter *myGeomFilter;
315   VTKViewer_TransformFilter *myTransformFilter;
316   std::vector<VTKViewer_PassThroughFilter*> myPassFilter;
317
318   int myRepresentation;
319   vtkProperty *myProperty;
320
321   void
322   InitPipeLine(vtkMapper* theMapper); 
323
324   VTKViewer_Actor();
325   ~VTKViewer_Actor();
326
327  protected:
328   vtkProperty *PreviewProperty;
329   bool myIsPreselected;
330   bool myIsHighlighted;
331 };
332
333 #endif // VTKVIEVER_ACTOR_H