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