]> SALOME platform Git repositories - modules/visu.git/blob - src/OBJECT/VISU_Actor.h
Salome HOME
Patch for VTK 5.1 and newer (merge from BR_PARAVIS_DEV)
[modules/visu.git] / src / OBJECT / VISU_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 //  VISU OBJECT : interactive object for VISU entities implementation
23 //  File   : 
24 //  Author : 
25 //  Module : VISU
26
27 #ifndef VISU_ACTOR_H
28 #define VISU_ACTOR_H
29
30 #include "VISU_OBJECT.h"
31
32 #include "SALOME_Actor.h"
33 #include "VISU_ActorBase.h"
34 #include "VISU_BoostSignals.h"
35 #include "SVTK_DeviceActor.h"
36
37 #include <string>
38 #include <vtkTimeStamp.h>
39 #include <vtkSmartPointer.h>
40
41 class vtkProp;
42 class vtkProperty;
43 class vtkTextMapper;
44 class vtkTextActor;
45 class vtkInteractorStyle;
46 class vtkCallbackCommand;
47 class VTKViewer_ShrinkFilter;
48 class VISU_PipeLine;
49 class vtkPlane;
50 class vtkImplicitFunctionCollection;
51 class vtkFeatureEdges;
52 class vtkTextProperty;
53 class vtkCellCenters;
54 class vtkSelectVisiblePoints;
55 class vtkLabeledDataMapper;
56 class vtkMaskPoints;
57 class vtkActor2D;
58
59 class VTKViewer_FramedTextActor;
60
61 #if !defined(VTK_XVERSION)
62 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
63 #endif
64
65 namespace SVTK
66 {
67   namespace Representation
68   {
69     const Type Surfaceframe = Insideframe + 1;
70     const Type FeatureEdges = Insideframe + 2;
71   }
72 }
73
74 namespace VISU 
75 {
76   class Prs3d_i;
77 }
78
79 //----------------------------------------------------------------------------
80 class VISU_OBJECT_EXPORT VISU_Actor : public VISU_ActorBase
81 {
82  public:
83   vtkTypeMacro(VISU_Actor, VISU_ActorBase);
84
85   //static 
86   //VISU_Actor* 
87   //New();
88
89   //! Copies all properties from the given actor
90   virtual
91   void
92   DeepCopy(VISU_Actor *theActor);
93
94   virtual
95   void
96   ShallowCopyPL(VISU_PipeLine* thePipeLine);
97
98   //----------------------------------------------------------------------------
99   virtual
100   void
101   setIO(const Handle(SALOME_InteractiveObject)& theIO);
102
103   //----------------------------------------------------------------------------
104   VISU::Prs3d_i* 
105   GetPrs3d();
106
107   virtual
108   void
109   SetPrs3d(VISU::Prs3d_i* thePrs3d);
110
111   virtual
112   void
113   SetVisibility(int theMode);
114
115   bool
116   ShouldBeDisplayed();
117
118   //----------------------------------------------------------------------------
119   virtual
120   VISU_PipeLine* 
121   GetPipeLine();
122
123   virtual 
124   void
125   SetPipeLine(VISU_PipeLine* thePipeLine);
126
127   //----------------------------------------------------------------------------
128   virtual
129   void
130   SetRepresentation(int theMode);
131
132   //----------------------------------------------------------------------------
133   virtual
134   bool
135   IsShrunkable();
136
137   virtual
138   bool
139   IsShrunk();
140
141   virtual
142   void
143   SetShrink();
144
145   virtual
146   void
147   UnShrink(); 
148
149   virtual
150   void
151   SetShrinkable(bool theIsShrinkable);
152
153   virtual
154   void
155   SetShrinkFactor(vtkFloatingPointType theFactor = 0.8); 
156
157   virtual
158   vtkFloatingPointType
159   GetShrinkFactor();
160
161   //----------------------------------------------------------------------------
162   virtual
163   bool
164   IsFeatureEdgesAllowed();
165
166   virtual
167   void
168   SetFeatureEdgesAllowed(bool theIsFeatureEdgesAllowed);
169
170   virtual
171   bool
172   IsFeatureEdgesEnabled();
173
174   virtual
175   void
176   SetFeatureEdgesEnabled(bool theIsFeatureEdgesEnabled);
177
178   virtual
179   vtkFloatingPointType
180   GetFeatureEdgesAngle();
181
182   virtual
183   void
184   SetFeatureEdgesAngle(vtkFloatingPointType theAngle = 30.0); 
185
186   virtual
187   void
188   GetFeatureEdgesFlags(bool& theIsFeatureEdges,
189                        bool& theIsBoundaryEdges,
190                        bool& theIsManifoldEdges,
191                        bool& theIsNonManifoldEdges);
192
193   virtual
194   void
195   SetFeatureEdgesFlags(bool theIsFeatureEdges,
196                        bool theIsBoundaryEdges,
197                        bool theIsManifoldEdges,
198                        bool theIsNonManifoldEdges);
199
200   virtual
201   bool
202   GetFeatureEdgesColoring();
203
204   virtual
205   void
206   SetFeatureEdgesColoring(bool theIsColoring);
207
208   //----------------------------------------------------------------------------
209   virtual
210   void
211   SetOpacity(vtkFloatingPointType theValue);
212
213   virtual
214   vtkFloatingPointType
215   GetOpacity();
216
217   virtual
218   void
219   SetLineWidth(vtkFloatingPointType theLineWidth);
220
221   virtual
222   vtkFloatingPointType
223   GetLineWidth();
224  
225   //----------------------------------------------------------------------------
226   virtual
227   void
228   AddToRender( vtkRenderer* ); 
229
230   virtual
231   void
232   RemoveFromRender( vtkRenderer* );
233
234   //----------------------------------------------------------------------------
235   //! Just to update visibility of the highlight devices
236   virtual
237   void
238   highlight(bool theHighlight);  
239
240   //! To process prehighlight (called from #SVTK_InteractorStyle)
241   virtual
242   bool
243   PreHighlight(vtkInteractorStyle* theInteractorStyle, 
244                SVTK_SelectionEvent* theSelectionEvent,
245                bool theIsHighlight);
246
247   //! To process highlight (called from #SVTK_InteractorStyle)
248   virtual
249   bool
250   Highlight(vtkInteractorStyle* theInteractorStyle, 
251             SVTK_SelectionEvent* theSelectionEvent,
252             bool theIsHighlight);
253
254   //! Internal highlight.
255   virtual
256   void
257   Highlight(bool theIsHighlight);
258
259   virtual
260   void 
261   SetVTKMapping(bool theIsVTKMapping); 
262
263   virtual
264   bool 
265   IsVTKMapping() const;
266
267   virtual
268   vtkDataSet* 
269   GetInput(); 
270
271   //! Gets memory size used by the instance (bytes).
272   virtual
273   unsigned long int
274   GetMemorySize();
275  
276   //----------------------------------------------------------------------------
277   virtual
278   vtkIdType
279   GetNodeObjId(vtkIdType theID);
280
281   virtual
282   vtkIdType
283   GetNodeVTKID(vtkIdType theID);
284
285   virtual
286   vtkFloatingPointType* 
287   GetNodeCoord(vtkIdType theObjID);
288
289   virtual
290   vtkIdType
291   GetElemObjId(vtkIdType theID);
292
293   virtual
294   vtkIdType
295   GetElemVTKID(vtkIdType theID);
296
297   virtual
298   vtkCell* 
299   GetElemCell(vtkIdType theObjID);
300
301   //----------------------------------------------------------------------------
302   virtual void RemoveAllClippingPlanes();
303
304   virtual vtkIdType GetNumberOfClippingPlanes();
305
306   virtual bool AddClippingPlane(vtkPlane* thePlane);
307
308   virtual vtkPlane* GetClippingPlane(vtkIdType theID);
309
310   virtual vtkImplicitFunctionCollection* GetClippingPlanes();
311
312   //----------------------------------------------------------------------------
313   //! Apply the picking settings on the actor.
314   void
315   UpdatePickingSettings();
316
317   //----------------------------------------------------------------------------
318   //! Methods for values labeling
319   virtual 
320   void 
321   SetValuesLabeled( const bool theIsValLabeled );
322
323   virtual 
324   bool 
325   GetValuesLabeled() const;
326
327   virtual
328   vtkDataSet*
329   GetValLabelsInput();
330
331   vtkTextProperty* 
332   GetsValLabelsProps() const;
333
334   enum EQuadratic2DRepresentation { eLines = 0, eArcs };
335
336   virtual
337     EQuadratic2DRepresentation GetQuadratic2DRepresentation() const;
338   
339   virtual void 
340     SetQuadratic2DRepresentation( EQuadratic2DRepresentation theMode );
341   
342   
343  protected:
344   VISU_Actor();
345
346   virtual
347   ~VISU_Actor();
348  
349   virtual 
350   void
351   SetMapperInput(vtkDataSet* theDataSet) = 0;
352
353   virtual
354   VISU_PipeLine* 
355   GetCurrentPL();
356
357   //----------------------------------------------------------------------------
358   bool
359   isSubElementsHighlighted();
360
361   //----------------------------------------------------------------------------
362   vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
363
364   //! Main process VTK event method
365   static
366   void
367   ProcessEvents(vtkObject* theObject, 
368                 unsigned long theEvent,
369                 void* theClientData, 
370                 void* theCallData);
371
372   //----------------------------------------------------------------------------
373  private:
374   void
375   ResetTextActor();
376
377   //----------------------------------------------------------------------------
378  protected:
379   vtkFloatingPointType myPriority;
380   bool myIsVTKMapping;
381   VISU::Prs3d_i* myPrs3d;
382   vtkSmartPointer<VISU_PipeLine> myPipeLine;
383
384   vtkSmartPointer<VTKViewer_ShrinkFilter> myShrinkFilter;
385   bool myIsShrinkable;
386   bool myIsShrunk;
387
388   vtkSmartPointer<vtkTextMapper> myAnnotationMapper;
389 #if (VTK_XVERSION < 0x050100)
390   vtkSmartPointer<vtkTextActor>  myAnnotationActor;
391 #else
392   vtkSmartPointer<vtkActor2D>  myAnnotationActor;
393 #endif
394
395   vtkSmartPointer<VTKViewer_FramedTextActor> myTextActor;
396
397   vtkSmartPointer<vtkFeatureEdges> myFeatureEdges;
398   bool myIsFeatureEdgesAllowed;
399   bool myIsFeatureEdgesEnabled;
400
401   Selection_Mode myLastSelectionMode;
402   bool myIsSubElementsHighlighted;
403   
404   // fields for values labeling
405   bool                    myIsValLabeled;
406   vtkDataSet*             myValLblDataSet;
407   vtkActor2D*             myValLabels;
408   vtkMaskPoints*          myValMaskPoints;
409   vtkCellCenters*         myValCellCenters;
410   vtkLabeledDataMapper*   myValLabeledDataMapper;
411   vtkSelectVisiblePoints* myValSelectVisiblePoints;
412 };
413
414 #endif //VISU_ACTOR_H