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