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