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