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