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 SetFactory(VISU::TActorFactory* theActorFactory);
135 VISU::TGaussPtsActorFactory*
136 GetGaussPtsFactory();
140 SetPosition(double _arg[3]);
142 //----------------------------------------------------------------------------
143 //! Add actor to the renderer.
146 AddToRender(vtkRenderer* theRenderer);
148 //! Remove actor from the renderer.
151 RemoveFromRender(vtkRenderer* theRenderer);
153 //! Set the Render Window Interactor to the actor.
156 SetInteractor(vtkRenderWindowInteractor* theInteractor);
158 //! Apply the transform on the actor.
161 SetTransform(VTKViewer_Transform* theTransform);
163 //! Redefined method of rendering the Opaque Geometry.
166 RenderOpaqueGeometry(vtkViewport *viewport);
168 //! Redefined method of rendering the Translucent Geometry.
171 RenderTranslucentGeometry(vtkViewport *viewport);
173 //----------------------------------------------------------------------------
174 //! Set actor visibility.
177 SetVisibility(int theMode);
179 //! Get segmentation visibility.
182 IsSegmentationEnabled();
184 //! Set Scalar Bar Control to the actor.
188 //! Set the Scalar Bar Control visibility.
190 SetBarVisibility(bool theMode);
192 //! Get the Scalar Bar Control visibility.
198 SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl);
200 //! Return the information about pipeline magnification changing.
201 /*! True indicates that magnification is increased, false - decreased. */
203 GetChangeMagnification();
205 //! Change the pipeline magnification.
208 ChangeMagnification( bool );
210 //----------------------------------------------------------------------------
211 //! Internal highlight.
214 Highlight(bool theIsHighlight);
216 //! Redefined method of the actor's prehighlighting
219 PreHighlight(vtkInteractorStyle* theInteractorStyle,
220 SVTK_SelectionEvent* theSelectionEvent,
221 bool theIsHighlight);
223 //! Redefined method of the actor's highlighting
226 Highlight(vtkInteractorStyle* theInteractorStyle,
227 SVTK_SelectionEvent* theSelectionEvent,
228 bool theIsHighlight);
230 //----------------------------------------------------------------------------
231 //! Set the picking settings to the actor.
233 SetInsideCursorSettings(VISU_InsideCursorSettings* theInsideCursorSettings);
236 UpdateInsideCursorSettings();
239 UpdateInsideCursorSettings( PDeviceActor );
241 //----------------------------------------------------------------------------
242 //! Apply the picking settings on the actor.
244 UpdatePickingSettings();
254 //----------------------------------------------------------------------------
259 //----------------------------------------------------------------------------
260 virtual void RemoveAllClippingPlanes();
262 virtual vtkIdType GetNumberOfClippingPlanes();
264 virtual bool AddClippingPlane(vtkPlane* thePlane);
266 virtual vtkPlane* GetClippingPlane(vtkIdType theID);
268 virtual vtkImplicitFunctionCollection* GetClippingPlanes();
271 //----------------------------------------------------------------------------
277 // Redefined method of setting mapper input.
280 SetMapperInput(vtkDataSet* theDataSet);
286 //! To get current value of the radius of the Point Sprite
289 GetRadius(vtkIdType theObjID,
291 vtkDataArray *theScalarArray);
293 //! To get current value of the magnification
296 GetMagnification(vtkIdType theObjID);
298 //! To get current value of the clamp
301 GetClamp(vtkIdType theObjID);
303 //----------------------------------------------------------------------------
304 vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
306 //! Main process VTK event method
309 ProcessEvents(vtkObject* theObject,
310 unsigned long theEvent,
314 // To process VTK event method
317 OnInteractorEvent(unsigned long theEvent);
319 vtkFloatingPointType myPriority;
320 bool myChangeMagnification;
321 VISU::TGaussPtsActorFactory* myGaussPtsActorFactory;
322 boost::signal1<void,VISU_GaussPtsAct*> myUpdatePrs3dSignal;
324 //----------------------------------------------------------------------------
325 PDeviceActor myDeviceActor;
327 VISU_WidgetCtrl* myWidgetCtrl;
329 VISU_GaussPointsPL* myCurrentPL;
330 vtkSmartPointer<VISU_GaussPointsPL> myGaussPointsPL;
332 vtkSmartPointer<vtkPolyDataMapper> myMapper;
333 vtkSmartPointer<SALOME_ExtractPolyDataGeometry> myPolyDataExtractor;
334 vtkSmartPointer<vtkImplicitBoolean> myFunction;
336 vtkIdType myLastPreHighlightObjID;
338 vtkSmartPointer<VISU_CursorPyramid> myCursorPyramid;
339 vtkSmartPointer<VISU_CursorPyramid> myCursorPyramidSelected;
341 vtkSmartPointer<vtkUnstructuredGrid> myCellSource;
342 vtkSmartPointer<SVTK_Actor> myCellActor;
344 vtkSmartPointer<vtkWarpVector> myWarpVector;
345 vtkSmartPointer<vtkCellDataToPointData> myCellDataToPointData;
347 bool myBarVisibility;
348 vtkSmartPointer<VISU_ScalarBarCtrl> myScalarBarCtrl;
350 VISU_InsideCursorSettings* myInsideCursorSettings;
354 //============================================================================
355 class VISU_GaussPtsAct2;
357 //! Gauss Points Actor, displayed in the Base View.
359 * Contains device actor (VISU_GaussPtsDeviceActor),
360 * which has two representation modes - outside and
361 * inside segmentation cursor.
363 class VISU_OBJECT_EXPORT VISU_GaussPtsAct1 : public VISU_GaussPtsAct
366 vtkTypeMacro(VISU_GaussPtsAct1,VISU_GaussPtsAct);
374 ShallowCopyPL(VISU_PipeLine* thePipeLine);
376 //----------------------------------------------------------------------------
377 //! Set actor visibility.
380 SetVisibility(int theMode);
384 Connect(VISU_GaussPtsAct2* theActor);
386 //----------------------------------------------------------------------------
388 UpdateInsideCursorSettings();
390 //----------------------------------------------------------------------------
391 //! Set the Outside Cursor Gauss Points settings to the actor.
393 SetOutsideCursorSettings(VISU_OutsideCursorSettings* theOutsideCursorSettings);
395 //! Apply the Outside Cursor Gauss Points settings on the actor.
397 UpdateOutsideCursorSettings();
399 //----------------------------------------------------------------------------
400 //! Add actor to the renderer.
403 AddToRender(vtkRenderer* theRenderer);
405 //! Remove actor from the renderer.
408 RemoveFromRender(vtkRenderer* theRenderer);
410 //! Apply the transform on the actor.
413 SetTransform(VTKViewer_Transform* theTransform);
417 SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl);
419 //! Redefined method of rendering the Opaque Geometry.
422 RenderOpaqueGeometry(vtkViewport *viewport);
424 //! Redefined method of rendering the Translucent Geometry.
427 RenderTranslucentGeometry(vtkViewport *viewport);
431 SetPosition(double _arg[3]);
433 //! Gets memory size used by the instance (bytes).
439 //----------------------------------------------------------------------------
443 ~VISU_GaussPtsAct1();
445 // Redefined method of setting mapper input.
448 SetMapperInput(vtkDataSet* theDataSet);
450 //! To get current value of the radius of the Point Sprite
453 GetRadius(vtkIdType theObjID,
455 vtkDataArray *theScalarArray);
457 //! To get current value of the magnification
460 GetMagnification(vtkIdType theObjID);
462 //! To get current value of the clamp
465 GetClamp(vtkIdType theObjID);
467 //----------------------------------------------------------------------------
468 // Main process VTK event method
471 ProcessEvents(vtkObject* theObject,
472 unsigned long theEvent,
476 // To process VTK event method
479 OnInteractorEvent(unsigned long theEvent);
481 boost::signal1<void,int> mySetVisibilitySignal;
482 boost::signal1<void,double*> myUpdatePositionSignal;
483 VISU_OutsideCursorSettings* myOutsideCursorSettings;
485 //----------------------------------------------------------------------------
486 PDeviceActor myInsideDeviceActor;
487 PDeviceActor myOutsideDeviceActor;
491 //! Gauss Points Actor, displayed in the Segmented View.
492 class VISU_OBJECT_EXPORT VISU_GaussPtsAct2 : public VISU_GaussPtsAct
495 vtkTypeMacro(VISU_GaussPtsAct2,VISU_GaussPtsAct);
501 // Redefined method of setting mapper input.
504 SetMapperInput(vtkDataSet* theDataSet);
508 ShallowCopyPL(VISU_PipeLine* thePipeLine);
510 //----------------------------------------------------------------------------
511 //! Set actor visibility.
514 SetVisibility(int theMode);
518 SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl);
520 //! Gets memory size used by the instance (bytes).
527 SetPosition(double _arg[3]);
530 //----------------------------------------------------------------------------
534 ~VISU_GaussPtsAct2();
536 //----------------------------------------------------------------------------
537 // To process VTK event method
540 OnInteractorEvent(unsigned long theEvent);