1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // VISU OBJECT : interactive object for VISU entities implementation
23 // File : VISU_ScalarMapAct.h
24 // Author : Laurent CORNABE with help of Nicolas REJNERI
28 #ifndef VISU_GaussPtsAct_HeaderFile
29 #define VISU_GaussPtsAct_HeaderFile
31 #include "VISU_OBJECT.h"
32 #include "VISU_Actor.h"
33 #include "VISU_GaussPtsActorFactory.h"
35 #include <vtkCommand.h>
36 #include <vtkSmartPointer.h>
38 class VISU_GaussPointsPL;
39 class VISU_WidgetCtrl;
40 class VISU_OpenGLPointSpriteMapper;
45 class vtkSphereSource;
46 class vtkPolyDataMapper;
49 class vtkInteractorStyle;
51 class VISU_GaussPtsDeviceActor;
52 class VISU_CursorPyramid;
54 class vtkUnstructuredGrid;
55 class vtkPolyDataMapper;
58 class vtkCellDataToPointData;
61 class vtkInteractorObserver;
62 class vtkCallbackCommand;
64 class VISU_ScalarBarCtrl;
65 class VISU_InsideCursorSettings;
66 class VISU_OutsideCursorSettings;
68 class SALOME_ExtractPolyDataGeometry;
69 class vtkImplicitBoolean;
71 //============================================================================
72 //! Base class for Gauss Points Actors.
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.
82 class VISU_OBJECT_EXPORT VISU_GaussPtsAct : public VISU_Actor
85 vtkTypeMacro(VISU_GaussPtsAct,VISU_Actor);
86 typedef vtkSmartPointer<VISU_GaussPtsDeviceActor> PDeviceActor;
92 //----------------------------------------------------------------------------
95 SetPipeLine(VISU_PipeLine* thePipeLine) ;
100 //! Copies all properties from the given actor
103 DeepCopy(VISU_Actor *theActor);
107 ShallowCopyPL(VISU_PipeLine* thePipeLine);
109 //----------------------------------------------------------------------------
110 //! Redefined method of getting a native mapper of the actor.
115 //! Redefined method of getting an actor bounds.
117 vtkFloatingPointType*
120 //! Redefined method of getting an actor input.
125 //! Gets memory size used by the instance (bytes).
130 //----------------------------------------------------------------------------
133 SetOpacity(vtkFloatingPointType theValue);
135 //----------------------------------------------------------------------------
138 SetFactory(VISU::TActorFactory* theActorFactory);
140 VISU::TGaussPtsActorFactory*
141 GetGaussPtsFactory();
145 SetPosition(double _arg[3]);
147 //----------------------------------------------------------------------------
148 //! Add actor to the renderer.
151 AddToRender(vtkRenderer* theRenderer);
153 //! Remove actor from the renderer.
156 RemoveFromRender(vtkRenderer* theRenderer);
158 //! Set the Render Window Interactor to the actor.
161 SetInteractor(vtkRenderWindowInteractor* theInteractor);
163 //! Apply the transform on the actor.
166 SetTransform(VTKViewer_Transform* theTransform);
168 //! Redefined method of rendering the Opaque Geometry.
171 RenderOpaqueGeometry(vtkViewport *viewport);
173 //! Redefined method of rendering the Translucent Geometry.
176 RenderTranslucentGeometry(vtkViewport *viewport);
178 //----------------------------------------------------------------------------
179 //! Set actor visibility.
182 SetVisibility(int theMode);
184 //! Get segmentation visibility.
187 IsSegmentationEnabled();
189 //! Set Scalar Bar Control to the actor.
193 //! Set the Scalar Bar Control visibility.
195 SetBarVisibility(bool theMode);
197 //! Get the Scalar Bar Control visibility.
203 SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl);
205 //! Return the information about pipeline magnification changing.
206 /*! True indicates that magnification is increased, false - decreased. */
208 GetChangeMagnification();
210 //! Change the pipeline magnification.
213 ChangeMagnification( bool );
215 //----------------------------------------------------------------------------
216 //! Internal highlight.
219 Highlight(bool theIsHighlight);
221 //! Redefined method of the actor's prehighlighting
224 PreHighlight(vtkInteractorStyle* theInteractorStyle,
225 SVTK_SelectionEvent* theSelectionEvent,
226 bool theIsHighlight);
228 //! Redefined method of the actor's highlighting
231 Highlight(vtkInteractorStyle* theInteractorStyle,
232 SVTK_SelectionEvent* theSelectionEvent,
233 bool theIsHighlight);
235 //----------------------------------------------------------------------------
236 //! Set the picking settings to the actor.
238 SetInsideCursorSettings(VISU_InsideCursorSettings* theInsideCursorSettings);
241 UpdateInsideCursorSettings();
244 UpdateInsideCursorSettings( PDeviceActor );
246 //----------------------------------------------------------------------------
247 //! Apply the picking settings on the actor.
249 UpdatePickingSettings();
259 //----------------------------------------------------------------------------
264 //----------------------------------------------------------------------------
265 virtual void RemoveAllClippingPlanes();
267 virtual vtkIdType GetNumberOfClippingPlanes();
269 virtual bool AddClippingPlane(vtkPlane* thePlane);
271 virtual vtkPlane* GetClippingPlane(vtkIdType theID);
273 virtual vtkImplicitFunctionCollection* GetClippingPlanes();
275 //----------------------------------------------------------------------------
281 //----------------------------------------------------------------------------
287 // Redefined method of setting mapper input.
290 SetMapperInput(vtkDataSet* theDataSet);
296 //! To get current value of the radius of the Point Sprite
299 GetRadius(vtkIdType theObjID,
301 vtkDataArray *theScalarArray);
303 //! To get current value of the magnification
306 GetMagnification(vtkIdType theObjID);
308 //! To get current value of the clamp
311 GetClamp(vtkIdType theObjID);
313 //----------------------------------------------------------------------------
314 vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
316 //! Main process VTK event method
319 ProcessEvents(vtkObject* theObject,
320 unsigned long theEvent,
324 // To process VTK event method
327 OnInteractorEvent(unsigned long theEvent);
329 vtkFloatingPointType myPriority;
330 bool myChangeMagnification;
331 VISU::TGaussPtsActorFactory* myGaussPtsActorFactory;
332 boost::signal1<void,VISU_GaussPtsAct*> myUpdatePrs3dSignal;
334 //----------------------------------------------------------------------------
335 PDeviceActor myDeviceActor;
337 VISU_WidgetCtrl* myWidgetCtrl;
339 VISU_GaussPointsPL* myCurrentPL;
340 vtkSmartPointer<VISU_GaussPointsPL> myGaussPointsPL;
342 vtkSmartPointer<vtkPolyDataMapper> myMapper;
343 vtkSmartPointer<SALOME_ExtractPolyDataGeometry> myPolyDataExtractor;
344 vtkSmartPointer<vtkImplicitBoolean> myFunction;
346 vtkIdType myLastPreHighlightObjID;
348 vtkSmartPointer<VISU_CursorPyramid> myCursorPyramid;
349 vtkSmartPointer<VISU_CursorPyramid> myCursorPyramidSelected;
351 vtkSmartPointer<vtkUnstructuredGrid> myCellSource;
352 vtkSmartPointer<SVTK_Actor> myCellActor;
354 vtkSmartPointer<vtkWarpVector> myWarpVector;
355 vtkSmartPointer<vtkCellDataToPointData> myCellDataToPointData;
357 bool myBarVisibility;
358 vtkSmartPointer<VISU_ScalarBarCtrl> myScalarBarCtrl;
360 VISU_InsideCursorSettings* myInsideCursorSettings;
364 //============================================================================
365 class VISU_GaussPtsAct2;
367 //! Gauss Points Actor, displayed in the Base View.
369 * Contains device actor (VISU_GaussPtsDeviceActor),
370 * which has two representation modes - outside and
371 * inside segmentation cursor.
373 class VISU_OBJECT_EXPORT VISU_GaussPtsAct1 : public VISU_GaussPtsAct
376 vtkTypeMacro(VISU_GaussPtsAct1,VISU_GaussPtsAct);
384 ShallowCopyPL(VISU_PipeLine* thePipeLine);
386 //----------------------------------------------------------------------------
387 //! Set actor visibility.
390 SetVisibility(int theMode);
394 Connect(VISU_GaussPtsAct2* theActor);
396 //----------------------------------------------------------------------------
398 UpdateInsideCursorSettings();
400 //----------------------------------------------------------------------------
401 //! Set the Outside Cursor Gauss Points settings to the actor.
403 SetOutsideCursorSettings(VISU_OutsideCursorSettings* theOutsideCursorSettings);
405 //! Apply the Outside Cursor Gauss Points settings on the actor.
407 UpdateOutsideCursorSettings();
409 //----------------------------------------------------------------------------
410 //! Add actor to the renderer.
413 AddToRender(vtkRenderer* theRenderer);
415 //! Remove actor from the renderer.
418 RemoveFromRender(vtkRenderer* theRenderer);
420 //! Apply the transform on the actor.
423 SetTransform(VTKViewer_Transform* theTransform);
427 SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl);
429 //! Redefined method of rendering the Opaque Geometry.
432 RenderOpaqueGeometry(vtkViewport *viewport);
434 //! Redefined method of rendering the Translucent Geometry.
437 RenderTranslucentGeometry(vtkViewport *viewport);
441 SetPosition(double _arg[3]);
443 //! Gets memory size used by the instance (bytes).
449 //----------------------------------------------------------------------------
453 ~VISU_GaussPtsAct1();
455 // Redefined method of setting mapper input.
458 SetMapperInput(vtkDataSet* theDataSet);
460 //! To get current value of the radius of the Point Sprite
463 GetRadius(vtkIdType theObjID,
465 vtkDataArray *theScalarArray);
467 //! To get current value of the magnification
470 GetMagnification(vtkIdType theObjID);
472 //! To get current value of the clamp
475 GetClamp(vtkIdType theObjID);
477 //----------------------------------------------------------------------------
478 // Main process VTK event method
481 ProcessEvents(vtkObject* theObject,
482 unsigned long theEvent,
486 // To process VTK event method
489 OnInteractorEvent(unsigned long theEvent);
491 boost::signal1<void,int> mySetVisibilitySignal;
492 boost::signal1<void,double*> myUpdatePositionSignal;
493 VISU_OutsideCursorSettings* myOutsideCursorSettings;
495 //----------------------------------------------------------------------------
496 PDeviceActor myInsideDeviceActor;
497 PDeviceActor myOutsideDeviceActor;
501 //! Gauss Points Actor, displayed in the Segmented View.
502 class VISU_OBJECT_EXPORT VISU_GaussPtsAct2 : public VISU_GaussPtsAct
505 vtkTypeMacro(VISU_GaussPtsAct2,VISU_GaussPtsAct);
511 // Redefined method of setting mapper input.
514 SetMapperInput(vtkDataSet* theDataSet);
518 ShallowCopyPL(VISU_PipeLine* thePipeLine);
520 //----------------------------------------------------------------------------
521 //! Set actor visibility.
524 SetVisibility(int theMode);
528 SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl);
530 //! Gets memory size used by the instance (bytes).
537 SetPosition(double _arg[3]);
540 //----------------------------------------------------------------------------
544 ~VISU_GaussPtsAct2();
546 //----------------------------------------------------------------------------
547 // To process VTK event method
550 OnInteractorEvent(unsigned long theEvent);