Salome HOME
Fix for Bug IPAL8945
[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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
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 vtkDataSetMapper;
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   virtual
98   void
99   ShallowCopyPL(VISU_PipeLine* thePipeLine);
100
101   //----------------------------------------------------------------------------
102   //! Redefined method of getting a native mapper of the actor.
103   virtual
104   vtkMapper* 
105   GetMapper();
106
107   //! Redefined method of getting an actor bounds.
108   virtual
109   float* 
110   GetBounds();
111
112   //! Redefined method of getting an actor input.
113   virtual
114   vtkDataSet* 
115   GetInput(); 
116
117   //----------------------------------------------------------------------------
118   virtual
119   void
120   SetFactory(VISU::TActorFactory* theActorFactory);
121   
122   VISU::TGaussPtsActorFactory*
123   GetGaussPtsFactory();    
124
125   //----------------------------------------------------------------------------
126   //! Add actor to the renderer.
127   virtual
128   void
129   AddToRender(vtkRenderer* theRenderer); 
130
131   //! Remove actor from the renderer.
132   virtual
133   void
134   RemoveFromRender(vtkRenderer* theRenderer);
135
136   //! Set the Render Window Interactor to the actor.
137   virtual
138   void
139   SetInteractor(vtkRenderWindowInteractor* theInteractor);
140
141   //! Apply the transform on the actor.
142   virtual
143   void
144   SetTransform(VTKViewer_Transform* theTransform);
145
146   //! Redefined method of rendering the Opaque Geometry.
147   virtual
148   int
149   RenderOpaqueGeometry(vtkViewport *viewport);
150
151   //! Redefined method of rendering the Translucent Geometry.
152   virtual
153   int
154   RenderTranslucentGeometry(vtkViewport *viewport);
155
156   //----------------------------------------------------------------------------
157   //! Set actor visibility.
158   virtual
159   void
160   SetVisibility(int theMode);
161
162   //! Get segmentation visibility.
163   virtual
164   int
165   IsSegmentationEnabled();
166
167   //! Set Scalar Bar Control to the actor.
168   VISU_ScalarBarCtrl* 
169   GetScalarBarCtrl();
170
171   //! Set the Scalar Bar Control visibility.
172   void
173   SetBarVisibility(bool theMode);
174
175   //! Get the Scalar Bar Control visibility.
176   bool
177   GetBarVisibility();
178
179   virtual void SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl);
180
181   //! Return the information about pipeline magnification changing.
182   /*! True indicates that magnification is increased, false - decreased. */
183   bool
184   GetChangeMagnification();
185
186   //! Change the pipeline magnification.
187   virtual
188   void
189   ChangeMagnification( bool );
190
191   //----------------------------------------------------------------------------
192   //! Internal highlight.
193   virtual
194   void
195   Highlight(bool theIsHighlight);
196  
197   //! Redefined method of the actor's prehighlighting 
198   virtual
199   bool
200   PreHighlight(vtkInteractorStyle* theInteractorStyle, 
201                SVTK_SelectionEvent* theSelectionEvent,
202                bool theIsHighlight);
203
204   //! Redefined method of the actor's highlighting 
205   virtual
206   bool
207   Highlight(vtkInteractorStyle* theInteractorStyle, 
208             SVTK_SelectionEvent* theSelectionEvent,
209             bool theIsHighlight);
210
211   //----------------------------------------------------------------------------
212   //! Set the picking settings to the actor.
213   void
214   SetInsideCursorSettings(VISU_InsideCursorSettings* theInsideCursorSettings);
215
216   virtual void
217   UpdateInsideCursorSettings();
218
219   virtual void
220   UpdateInsideCursorSettings( PDeviceActor );
221
222   //----------------------------------------------------------------------------
223   void
224   SetPickingSettings(VISU_PickingSettings* thePickingSettings);
225
226   //! Apply the picking settings on the actor.
227   void
228   UpdatePickingSettings();
229
230   virtual
231   bool
232   IsInfinitive();
233
234  protected:
235   //----------------------------------------------------------------------------
236   VISU_GaussPtsAct();
237
238   virtual 
239   ~VISU_GaussPtsAct();
240
241   // Redefined method of setting mapper input.
242   virtual 
243   void
244   SetMapperInput(vtkDataSet* theDataSet);
245
246   virtual
247   VISU_PipeLine* 
248   GetCurrentPL();
249
250   //! To get current value of the radius of the Point Sprite
251   virtual
252   float
253   GetRadius(vtkIdType theObjID,
254             vtkIdType theVTKID,
255             vtkDataArray *theScalarArray);
256
257   //! To get current value of the magnification
258   virtual
259   float
260   GetMagnification(vtkIdType theObjID);
261
262   //! To get current value of the clamp
263   virtual
264   float
265   GetClamp(vtkIdType theObjID);
266
267   //----------------------------------------------------------------------------
268   vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
269
270   //! Main process VTK event method
271   static
272   void
273   ProcessEvents(vtkObject* theObject, 
274                 unsigned long theEvent,
275                 void* theClientData, 
276                 void* theCallData);
277
278   // To process VTK event method
279   virtual
280   void
281   OnInteractorEvent(unsigned long theEvent);
282
283   float myPriority;
284   bool myChangeMagnification;
285   VISU::TGaussPtsActorFactory* myGaussPtsActorFactory;
286   boost::signal1<void,VISU_GaussPtsAct*> myUpdatePrs3dSignal;
287
288   //----------------------------------------------------------------------------
289   PDeviceActor myDeviceActor;
290
291   VISU_WidgetCtrl* myWidgetCtrl;
292
293   VISU_GaussPointsPL* myCurrentPL;
294   vtkSmartPointer<VISU_GaussPointsPL> myGaussPointsPL;
295
296   vtkIdType myLastObjPointID;
297
298   vtkSmartPointer<VISU_FramedTextActor> myTextActor;
299
300   vtkSmartPointer<VISU_CursorPyramid> myCursorPyramid;
301   vtkSmartPointer<VISU_CursorPyramid> myCursorPyramidSelected;
302   
303   vtkSmartPointer<vtkUnstructuredGrid> myCellSource;
304   vtkSmartPointer<SVTK_Actor> myCellActor;
305
306   bool myBarVisibility;
307   vtkSmartPointer<VISU_ScalarBarCtrl> myScalarBarCtrl;
308
309   VISU_InsideCursorSettings* myInsideCursorSettings;
310   VISU_PickingSettings* myPickingSettings;
311 };
312
313
314 //============================================================================
315 class VISU_GaussPtsAct2;
316
317 //! Gauss Points Actor, displayed in the Base View.
318 /*!
319  * Contains device actor (VISU_GaussPtsDeviceActor),
320  * which has two representation modes - outside and
321  * inside segmentation cursor.
322  */
323 class VTKOCC_EXPORT VISU_GaussPtsAct1 : public VISU_GaussPtsAct
324 {
325  public:
326   vtkTypeMacro(VISU_GaussPtsAct1,VISU_GaussPtsAct);
327
328   static
329   VISU_GaussPtsAct1* 
330   New();
331
332   virtual
333   void
334   ShallowCopyPL(VISU_PipeLine* thePipeLine);
335
336   //----------------------------------------------------------------------------
337   //! Set actor visibility.
338   virtual
339   void
340   SetVisibility(int theMode);
341
342   virtual 
343   void
344   Connect(VISU_GaussPtsAct2* theActor);
345
346   //----------------------------------------------------------------------------
347   virtual void
348   UpdateInsideCursorSettings();
349
350   //----------------------------------------------------------------------------
351   //! Set the Outside Cursor Gauss Points settings to the actor.
352   void
353   SetOutsideCursorSettings(VISU_OutsideCursorSettings* theOutsideCursorSettings);
354
355   //! Apply the Outside Cursor Gauss Points settings on the actor.
356   void
357   UpdateOutsideCursorSettings();
358
359   //----------------------------------------------------------------------------
360   //! Add actor to the renderer.
361   virtual
362   void
363   AddToRender(vtkRenderer* theRenderer); 
364
365   //! Remove actor from the renderer.
366   virtual
367   void
368   RemoveFromRender(vtkRenderer* theRenderer);
369
370   //! Apply the transform on the actor.
371   virtual
372   void
373   SetTransform(VTKViewer_Transform* theTransform);
374
375   virtual void SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl);
376
377  protected:
378   //----------------------------------------------------------------------------
379   VISU_GaussPtsAct1();
380
381   virtual 
382   ~VISU_GaussPtsAct1();
383
384   // Redefined method of setting mapper input.
385   virtual 
386   void
387   SetMapperInput(vtkDataSet* theDataSet);
388
389   //! To get current value of the radius of the Point Sprite
390   virtual
391   float
392   GetRadius(vtkIdType theObjID,
393             vtkIdType theVTKID,
394             vtkDataArray *theScalarArray);
395
396   //! To get current value of the magnification
397   virtual
398   float
399   GetMagnification(vtkIdType theObjID);
400
401   //! To get current value of the clamp
402   virtual
403   float
404   GetClamp(vtkIdType theObjID);
405
406   //----------------------------------------------------------------------------
407   // Main process VTK event method
408   static
409   void
410   ProcessEvents(vtkObject* theObject, 
411                 unsigned long theEvent,
412                 void* theClientData, 
413                 void* theCallData);
414
415   // To process VTK event method
416   virtual 
417   void
418   OnInteractorEvent(unsigned long theEvent);
419
420   boost::signal1<void,int> mySetVisibilitySignal;
421   VISU_OutsideCursorSettings* myOutsideCursorSettings;
422
423   //----------------------------------------------------------------------------
424   PDeviceActor myInsideDeviceActor;
425   PDeviceActor myOutsideDeviceActor;
426 };
427
428
429 //! Gauss Points Actor, displayed in the Segmented View.
430 class VTKOCC_EXPORT VISU_GaussPtsAct2 : public VISU_GaussPtsAct
431 {
432  public:
433   vtkTypeMacro(VISU_GaussPtsAct2,VISU_GaussPtsAct);
434
435   static
436   VISU_GaussPtsAct2* 
437   New();
438
439   // Redefined method of setting mapper input.
440   virtual 
441   void
442   SetMapperInput(vtkDataSet* theDataSet);
443
444   virtual
445   void
446   ShallowCopyPL(VISU_PipeLine* thePipeLine);
447
448   //----------------------------------------------------------------------------
449   //! Set actor visibility.
450   virtual
451   void
452   SetVisibility(int theMode);
453
454   virtual void SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl);
455
456  protected:
457   //----------------------------------------------------------------------------
458   VISU_GaussPtsAct2();
459
460   virtual 
461   ~VISU_GaussPtsAct2();
462
463   //----------------------------------------------------------------------------
464   // To process VTK event method
465   virtual 
466   void
467   OnInteractorEvent(unsigned long theEvent);
468 };
469
470
471 #endif