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