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