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