]> SALOME platform Git repositories - modules/visu.git/blob - src/OBJECT/VISU_GaussPtsAct.h
Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[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   vtkFloatingPointType* 
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   virtual
235   int
236   GetPickable();
237
238  protected:
239   //----------------------------------------------------------------------------
240   VISU_GaussPtsAct();
241
242   virtual 
243   ~VISU_GaussPtsAct();
244
245   // Redefined method of setting mapper input.
246   virtual 
247   void
248   SetMapperInput(vtkDataSet* theDataSet);
249
250   virtual
251   VISU_PipeLine* 
252   GetCurrentPL();
253
254   //! To get current value of the radius of the Point Sprite
255   virtual
256   vtkFloatingPointType
257   GetRadius(vtkIdType theObjID,
258             vtkIdType theVTKID,
259             vtkDataArray *theScalarArray);
260
261   //! To get current value of the magnification
262   virtual
263   vtkFloatingPointType
264   GetMagnification(vtkIdType theObjID);
265
266   //! To get current value of the clamp
267   virtual
268   vtkFloatingPointType
269   GetClamp(vtkIdType theObjID);
270
271   //----------------------------------------------------------------------------
272   vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
273
274   //! Main process VTK event method
275   static
276   void
277   ProcessEvents(vtkObject* theObject, 
278                 unsigned long theEvent,
279                 void* theClientData, 
280                 void* theCallData);
281
282   // To process VTK event method
283   virtual
284   void
285   OnInteractorEvent(unsigned long theEvent);
286
287   vtkFloatingPointType myPriority;
288   bool myChangeMagnification;
289   VISU::TGaussPtsActorFactory* myGaussPtsActorFactory;
290   boost::signal1<void,VISU_GaussPtsAct*> myUpdatePrs3dSignal;
291
292   //----------------------------------------------------------------------------
293   PDeviceActor myDeviceActor;
294
295   VISU_WidgetCtrl* myWidgetCtrl;
296
297   VISU_GaussPointsPL* myCurrentPL;
298   vtkSmartPointer<VISU_GaussPointsPL> myGaussPointsPL;
299
300   vtkIdType myLastObjPointID;
301
302   vtkSmartPointer<VISU_FramedTextActor> myTextActor;
303
304   vtkSmartPointer<VISU_CursorPyramid> myCursorPyramid;
305   vtkSmartPointer<VISU_CursorPyramid> myCursorPyramidSelected;
306   
307   vtkSmartPointer<vtkUnstructuredGrid> myCellSource;
308   vtkSmartPointer<SVTK_Actor> myCellActor;
309
310   bool myBarVisibility;
311   vtkSmartPointer<VISU_ScalarBarCtrl> myScalarBarCtrl;
312
313   VISU_InsideCursorSettings* myInsideCursorSettings;
314   VISU_PickingSettings* myPickingSettings;
315 };
316
317
318 //============================================================================
319 class VISU_GaussPtsAct2;
320
321 //! Gauss Points Actor, displayed in the Base View.
322 /*!
323  * Contains device actor (VISU_GaussPtsDeviceActor),
324  * which has two representation modes - outside and
325  * inside segmentation cursor.
326  */
327 class VTKOCC_EXPORT VISU_GaussPtsAct1 : public VISU_GaussPtsAct
328 {
329  public:
330   vtkTypeMacro(VISU_GaussPtsAct1,VISU_GaussPtsAct);
331
332   static
333   VISU_GaussPtsAct1* 
334   New();
335
336   virtual
337   void
338   ShallowCopyPL(VISU_PipeLine* thePipeLine);
339
340   //----------------------------------------------------------------------------
341   //! Set actor visibility.
342   virtual
343   void
344   SetVisibility(int theMode);
345
346   virtual 
347   void
348   Connect(VISU_GaussPtsAct2* theActor);
349
350   //----------------------------------------------------------------------------
351   virtual void
352   UpdateInsideCursorSettings();
353
354   //----------------------------------------------------------------------------
355   //! Set the Outside Cursor Gauss Points settings to the actor.
356   void
357   SetOutsideCursorSettings(VISU_OutsideCursorSettings* theOutsideCursorSettings);
358
359   //! Apply the Outside Cursor Gauss Points settings on the actor.
360   void
361   UpdateOutsideCursorSettings();
362
363   //----------------------------------------------------------------------------
364   //! Add actor to the renderer.
365   virtual
366   void
367   AddToRender(vtkRenderer* theRenderer); 
368
369   //! Remove actor from the renderer.
370   virtual
371   void
372   RemoveFromRender(vtkRenderer* theRenderer);
373
374   //! Apply the transform on the actor.
375   virtual
376   void
377   SetTransform(VTKViewer_Transform* theTransform);
378
379   virtual void SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl);
380
381  protected:
382   //----------------------------------------------------------------------------
383   VISU_GaussPtsAct1();
384
385   virtual 
386   ~VISU_GaussPtsAct1();
387
388   // Redefined method of setting mapper input.
389   virtual 
390   void
391   SetMapperInput(vtkDataSet* theDataSet);
392
393   //! To get current value of the radius of the Point Sprite
394   virtual
395   vtkFloatingPointType
396   GetRadius(vtkIdType theObjID,
397             vtkIdType theVTKID,
398             vtkDataArray *theScalarArray);
399
400   //! To get current value of the magnification
401   virtual
402   vtkFloatingPointType
403   GetMagnification(vtkIdType theObjID);
404
405   //! To get current value of the clamp
406   virtual
407   vtkFloatingPointType
408   GetClamp(vtkIdType theObjID);
409
410   //----------------------------------------------------------------------------
411   // Main process VTK event method
412   static
413   void
414   ProcessEvents(vtkObject* theObject, 
415                 unsigned long theEvent,
416                 void* theClientData, 
417                 void* theCallData);
418
419   // To process VTK event method
420   virtual 
421   void
422   OnInteractorEvent(unsigned long theEvent);
423
424   boost::signal1<void,int> mySetVisibilitySignal;
425   VISU_OutsideCursorSettings* myOutsideCursorSettings;
426
427   //----------------------------------------------------------------------------
428   PDeviceActor myInsideDeviceActor;
429   PDeviceActor myOutsideDeviceActor;
430 };
431
432
433 //! Gauss Points Actor, displayed in the Segmented View.
434 class VTKOCC_EXPORT VISU_GaussPtsAct2 : public VISU_GaussPtsAct
435 {
436  public:
437   vtkTypeMacro(VISU_GaussPtsAct2,VISU_GaussPtsAct);
438
439   static
440   VISU_GaussPtsAct2* 
441   New();
442
443   // Redefined method of setting mapper input.
444   virtual 
445   void
446   SetMapperInput(vtkDataSet* theDataSet);
447
448   virtual
449   void
450   ShallowCopyPL(VISU_PipeLine* thePipeLine);
451
452   //----------------------------------------------------------------------------
453   //! Set actor visibility.
454   virtual
455   void
456   SetVisibility(int theMode);
457
458   virtual void SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl);
459
460  protected:
461   //----------------------------------------------------------------------------
462   VISU_GaussPtsAct2();
463
464   virtual 
465   ~VISU_GaussPtsAct2();
466
467   //----------------------------------------------------------------------------
468   // To process VTK event method
469   virtual 
470   void
471   OnInteractorEvent(unsigned long theEvent);
472 };
473
474
475 #endif