Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/visu.git] / src / OBJECT / VISU_GaussPtsAct.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   : VISU_ScalarMapAct.h
24 //  Author : Laurent CORNABE with help of Nicolas REJNERI
25 //  Module : VISU
26 //  $Header$
27 //
28 #ifndef VISU_GaussPtsAct_HeaderFile
29 #define VISU_GaussPtsAct_HeaderFile
30
31 #include "VISU_OBJECT.h"
32 #include "VISU_Actor.h"
33 #include "VISU_GaussPtsActorFactory.h"
34
35 #include <vtkCommand.h>
36 #include <vtkSmartPointer.h>
37
38 class VISU_GaussPointsPL;
39 class VISU_WidgetCtrl;
40 class VISU_OpenGLPointSpriteMapper;
41
42 class vtkTextMapper;
43 class vtkTextActor;
44
45 class vtkSphereSource;
46 class vtkPolyDataMapper;
47 class vtkActor;
48 class vtkImageData;
49 class vtkInteractorStyle;
50
51 class VISU_GaussPtsDeviceActor;
52 class VISU_CursorPyramid;
53 class VISU_FramedTextActor;
54
55 class vtkUnstructuredGrid;
56 class vtkPolyDataMapper;
57 class vtkDataArray;
58
59 class vtkCellDataToPointData;
60 class vtkWarpVector;
61
62 class vtkInteractorObserver;
63 class vtkCallbackCommand;
64
65 class VISU_ScalarBarCtrl;
66 class VISU_InsideCursorSettings;
67 class VISU_OutsideCursorSettings;
68
69 class SALOME_ExtractPolyDataGeometry;
70 class vtkImplicitBoolean;
71
72 //============================================================================
73 //! Base class for Gauss Points Actors.
74 /*!
75   The actor is responsible for representation of Gauss Points.
76   It render corresponding presentation by usage of corresponding VISU_GaussPtsDeviceActor.
77   Usage of such technic of rendering gives addititional flexibility to change its behaviour in run-time.
78   Also, the base class implements the following functionality:
79   - implements a highlight and prehighlight functionality;
80   - defining a way to handle VISU_ImplicitFunctionWidget;
81   - global / local scalar bar mamangement.
82 */
83 class VISU_OBJECT_EXPORT VISU_GaussPtsAct : public VISU_Actor
84 {
85  public:
86   vtkTypeMacro(VISU_GaussPtsAct,VISU_Actor);
87   typedef vtkSmartPointer<VISU_GaussPtsDeviceActor> PDeviceActor;
88
89   static
90   VISU_GaussPtsAct* 
91   New();
92
93   //----------------------------------------------------------------------------
94   virtual
95   void
96   SetPipeLine(VISU_PipeLine* thePipeLine) ;
97   
98   VISU_GaussPointsPL*
99   GetGaussPointsPL();
100
101   //! Copies all properties from the given actor
102   virtual
103   void
104   DeepCopy(VISU_Actor *theActor);
105
106   virtual
107   void
108   ShallowCopyPL(VISU_PipeLine* thePipeLine);
109
110   //----------------------------------------------------------------------------
111   //! Redefined method of getting a native mapper of the actor.
112   virtual
113   vtkMapper* 
114   GetMapper();
115
116   //! Redefined method of getting an actor bounds.
117   virtual
118   vtkFloatingPointType* 
119   GetBounds();
120
121   //! Redefined method of getting an actor input.
122   virtual
123   vtkDataSet* 
124   GetInput(); 
125
126   //! Gets memory size used by the instance (bytes).
127   virtual
128   unsigned long int
129   GetMemorySize();
130  
131   //----------------------------------------------------------------------------
132   virtual
133   void
134   SetFactory(VISU::TActorFactory* theActorFactory);
135   
136   VISU::TGaussPtsActorFactory*
137   GetGaussPtsFactory();    
138
139   virtual
140   void 
141   SetPosition(double _arg[3]);
142
143   //----------------------------------------------------------------------------
144   //! Add actor to the renderer.
145   virtual
146   void
147   AddToRender(vtkRenderer* theRenderer); 
148
149   //! Remove actor from the renderer.
150   virtual
151   void
152   RemoveFromRender(vtkRenderer* theRenderer);
153
154   //! Set the Render Window Interactor to the actor.
155   virtual
156   void
157   SetInteractor(vtkRenderWindowInteractor* theInteractor);
158
159   //! Apply the transform on the actor.
160   virtual
161   void
162   SetTransform(VTKViewer_Transform* theTransform);
163
164   //! Redefined method of rendering the Opaque Geometry.
165   virtual
166   int
167   RenderOpaqueGeometry(vtkViewport *viewport);
168
169   //! Redefined method of rendering the Translucent Geometry.
170   virtual
171   int
172   RenderTranslucentGeometry(vtkViewport *viewport);
173
174   //----------------------------------------------------------------------------
175   //! Set actor visibility.
176   virtual
177   void
178   SetVisibility(int theMode);
179
180   //! Get segmentation visibility.
181   virtual
182   int
183   IsSegmentationEnabled();
184
185   //! Set Scalar Bar Control to the actor.
186   VISU_ScalarBarCtrl* 
187   GetScalarBarCtrl();
188
189   //! Set the Scalar Bar Control visibility.
190   void
191   SetBarVisibility(bool theMode);
192
193   //! Get the Scalar Bar Control visibility.
194   bool
195   GetBarVisibility();
196
197   virtual 
198   void
199   SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl);
200
201   //! Return the information about pipeline magnification changing.
202   /*! True indicates that magnification is increased, false - decreased. */
203   bool
204   GetChangeMagnification();
205
206   //! Change the pipeline magnification.
207   virtual
208   void
209   ChangeMagnification( bool );
210
211   //----------------------------------------------------------------------------
212   //! Internal highlight.
213   virtual
214   void
215   Highlight(bool theIsHighlight);
216  
217   //! Redefined method of the actor's prehighlighting 
218   virtual
219   bool
220   PreHighlight(vtkInteractorStyle* theInteractorStyle, 
221                SVTK_SelectionEvent* theSelectionEvent,
222                bool theIsHighlight);
223
224   //! Redefined method of the actor's highlighting 
225   virtual
226   bool
227   Highlight(vtkInteractorStyle* theInteractorStyle, 
228             SVTK_SelectionEvent* theSelectionEvent,
229             bool theIsHighlight);
230
231   //----------------------------------------------------------------------------
232   //! Set the picking settings to the actor.
233   void
234   SetInsideCursorSettings(VISU_InsideCursorSettings* theInsideCursorSettings);
235
236   virtual void
237   UpdateInsideCursorSettings();
238
239   virtual void
240   UpdateInsideCursorSettings( PDeviceActor );
241
242   //----------------------------------------------------------------------------
243   //! Apply the picking settings on the actor.
244   void
245   UpdatePickingSettings();
246
247   virtual
248   bool
249   IsInfinitive();
250
251   virtual
252   int
253   GetPickable();
254
255   //----------------------------------------------------------------------------
256   virtual
257   unsigned long int 
258   GetMTime();
259
260   //----------------------------------------------------------------------------
261   virtual void RemoveAllClippingPlanes();
262
263   virtual vtkIdType GetNumberOfClippingPlanes();
264
265   virtual bool AddClippingPlane(vtkPlane* thePlane);
266
267   virtual vtkPlane* GetClippingPlane(vtkIdType theID);
268
269   virtual vtkImplicitFunctionCollection* GetClippingPlanes();
270
271  protected:
272   //----------------------------------------------------------------------------
273   VISU_GaussPtsAct();
274
275   virtual 
276   ~VISU_GaussPtsAct();
277
278   // Redefined method of setting mapper input.
279   virtual 
280   void
281   SetMapperInput(vtkDataSet* theDataSet);
282
283   virtual
284   VISU_PipeLine* 
285   GetCurrentPL();
286
287   //! To get current value of the radius of the Point Sprite
288   virtual
289   vtkFloatingPointType
290   GetRadius(vtkIdType theObjID,
291             vtkIdType theVTKID,
292             vtkDataArray *theScalarArray);
293
294   //! To get current value of the magnification
295   virtual
296   vtkFloatingPointType
297   GetMagnification(vtkIdType theObjID);
298
299   //! To get current value of the clamp
300   virtual
301   vtkFloatingPointType
302   GetClamp(vtkIdType theObjID);
303
304   //----------------------------------------------------------------------------
305   vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
306
307   //! Main process VTK event method
308   static
309   void
310   ProcessEvents(vtkObject* theObject, 
311                 unsigned long theEvent,
312                 void* theClientData, 
313                 void* theCallData);
314
315   // To process VTK event method
316   virtual
317   void
318   OnInteractorEvent(unsigned long theEvent);
319
320   vtkFloatingPointType myPriority;
321   bool myChangeMagnification;
322   VISU::TGaussPtsActorFactory* myGaussPtsActorFactory;
323   boost::signal1<void,VISU_GaussPtsAct*> myUpdatePrs3dSignal;
324
325   //----------------------------------------------------------------------------
326   PDeviceActor myDeviceActor;
327
328   VISU_WidgetCtrl* myWidgetCtrl;
329
330   VISU_GaussPointsPL* myCurrentPL;
331   vtkSmartPointer<VISU_GaussPointsPL> myGaussPointsPL;
332
333   vtkSmartPointer<vtkPolyDataMapper> myMapper;
334   vtkSmartPointer<SALOME_ExtractPolyDataGeometry> myPolyDataExtractor;
335   vtkSmartPointer<vtkImplicitBoolean> myFunction;
336
337   vtkIdType myLastPreHighlightObjID;
338
339   vtkSmartPointer<VISU_CursorPyramid> myCursorPyramid;
340   vtkSmartPointer<VISU_CursorPyramid> myCursorPyramidSelected;
341   
342   vtkSmartPointer<vtkUnstructuredGrid> myCellSource;
343   vtkSmartPointer<SVTK_Actor> myCellActor;
344
345   vtkSmartPointer<vtkWarpVector> myWarpVector;
346   vtkSmartPointer<vtkCellDataToPointData> myCellDataToPointData;
347
348   bool myBarVisibility;
349   vtkSmartPointer<VISU_ScalarBarCtrl> myScalarBarCtrl;
350
351   VISU_InsideCursorSettings* myInsideCursorSettings;
352 };
353
354
355 //============================================================================
356 class VISU_GaussPtsAct2;
357
358 //! Gauss Points Actor, displayed in the Base View.
359 /*!
360  * Contains device actor (VISU_GaussPtsDeviceActor),
361  * which has two representation modes - outside and
362  * inside segmentation cursor.
363  */
364 class VISU_OBJECT_EXPORT VISU_GaussPtsAct1 : public VISU_GaussPtsAct
365 {
366  public:
367   vtkTypeMacro(VISU_GaussPtsAct1,VISU_GaussPtsAct);
368
369   static
370   VISU_GaussPtsAct1* 
371   New();
372
373   virtual
374   void
375   ShallowCopyPL(VISU_PipeLine* thePipeLine);
376
377   //----------------------------------------------------------------------------
378   //! Set actor visibility.
379   virtual
380   void
381   SetVisibility(int theMode);
382
383   virtual 
384   void
385   Connect(VISU_GaussPtsAct2* theActor);
386
387   //----------------------------------------------------------------------------
388   virtual void
389   UpdateInsideCursorSettings();
390
391   //----------------------------------------------------------------------------
392   //! Set the Outside Cursor Gauss Points settings to the actor.
393   void
394   SetOutsideCursorSettings(VISU_OutsideCursorSettings* theOutsideCursorSettings);
395
396   //! Apply the Outside Cursor Gauss Points settings on the actor.
397   void
398   UpdateOutsideCursorSettings();
399
400   //----------------------------------------------------------------------------
401   //! Add actor to the renderer.
402   virtual
403   void
404   AddToRender(vtkRenderer* theRenderer); 
405
406   //! Remove actor from the renderer.
407   virtual
408   void
409   RemoveFromRender(vtkRenderer* theRenderer);
410
411   //! Apply the transform on the actor.
412   virtual
413   void
414   SetTransform(VTKViewer_Transform* theTransform);
415
416   virtual 
417   void
418   SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl);
419
420   //! Redefined method of rendering the Opaque Geometry.
421   virtual
422   int
423   RenderOpaqueGeometry(vtkViewport *viewport);
424
425   //! Redefined method of rendering the Translucent Geometry.
426   virtual
427   int
428   RenderTranslucentGeometry(vtkViewport *viewport);
429                       
430   virtual
431   void 
432   SetPosition(double _arg[3]);
433
434   //! Gets memory size used by the instance (bytes).
435   virtual
436   unsigned long int
437   GetMemorySize();
438  
439  protected:
440   //----------------------------------------------------------------------------
441   VISU_GaussPtsAct1();
442
443   virtual 
444   ~VISU_GaussPtsAct1();
445
446   // Redefined method of setting mapper input.
447   virtual 
448   void
449   SetMapperInput(vtkDataSet* theDataSet);
450
451   //! To get current value of the radius of the Point Sprite
452   virtual
453   vtkFloatingPointType
454   GetRadius(vtkIdType theObjID,
455             vtkIdType theVTKID,
456             vtkDataArray *theScalarArray);
457
458   //! To get current value of the magnification
459   virtual
460   vtkFloatingPointType
461   GetMagnification(vtkIdType theObjID);
462
463   //! To get current value of the clamp
464   virtual
465   vtkFloatingPointType
466   GetClamp(vtkIdType theObjID);
467
468   //----------------------------------------------------------------------------
469   // Main process VTK event method
470   static
471   void
472   ProcessEvents(vtkObject* theObject, 
473                 unsigned long theEvent,
474                 void* theClientData, 
475                 void* theCallData);
476
477   // To process VTK event method
478   virtual 
479   void
480   OnInteractorEvent(unsigned long theEvent);
481
482   boost::signal1<void,int> mySetVisibilitySignal;
483   boost::signal1<void,double*> myUpdatePositionSignal;
484   VISU_OutsideCursorSettings* myOutsideCursorSettings;
485
486   //----------------------------------------------------------------------------
487   PDeviceActor myInsideDeviceActor;
488   PDeviceActor myOutsideDeviceActor;
489 };
490
491
492 //! Gauss Points Actor, displayed in the Segmented View.
493 class VISU_OBJECT_EXPORT VISU_GaussPtsAct2 : public VISU_GaussPtsAct
494 {
495  public:
496   vtkTypeMacro(VISU_GaussPtsAct2,VISU_GaussPtsAct);
497
498   static
499   VISU_GaussPtsAct2* 
500   New();
501
502   // Redefined method of setting mapper input.
503   virtual 
504   void
505   SetMapperInput(vtkDataSet* theDataSet);
506
507   virtual
508   void
509   ShallowCopyPL(VISU_PipeLine* thePipeLine);
510
511   //----------------------------------------------------------------------------
512   //! Set actor visibility.
513   virtual
514   void
515   SetVisibility(int theMode);
516
517   virtual 
518   void
519   SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl);
520
521   //! Gets memory size used by the instance (bytes).
522   virtual
523   unsigned long int
524   GetMemorySize();
525                       
526   virtual
527   void 
528   SetPosition(double _arg[3]);
529   
530  protected:
531   //----------------------------------------------------------------------------
532   VISU_GaussPtsAct2();
533
534   virtual 
535   ~VISU_GaussPtsAct2();
536
537   //----------------------------------------------------------------------------
538   // To process VTK event method
539   virtual 
540   void
541   OnInteractorEvent(unsigned long theEvent);
542 };
543
544
545 #endif