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;
53 class VISU_FramedTextActor;
55 class vtkUnstructuredGrid;
56 class vtkPolyDataMapper;
59 class vtkCellDataToPointData;
62 class vtkInteractorObserver;
63 class vtkCallbackCommand;
65 class VISU_ScalarBarCtrl;
66 class VISU_InsideCursorSettings;
67 class VISU_OutsideCursorSettings;
69 class SALOME_ExtractPolyDataGeometry;
70 class vtkImplicitBoolean;
72 //============================================================================
73 //! Base class for Gauss Points Actors.
75 The actor is responsible for representation of Gauss Points.
76 It render corresponding presentation by usage of corresponding VISU_GaussPtsDeviceActor.
77 Usage of such technic of rendering gives addititional flexibility to change its behaviour in run-time.
78 Also, the base class implements the following functionality:
79 - implements a highlight and prehighlight functionality;
80 - defining a way to handle VISU_ImplicitFunctionWidget;
81 - global / local scalar bar mamangement.
83 class VISU_OBJECT_EXPORT VISU_GaussPtsAct : public VISU_Actor
86 vtkTypeMacro(VISU_GaussPtsAct,VISU_Actor);
87 typedef vtkSmartPointer<VISU_GaussPtsDeviceActor> PDeviceActor;
93 //----------------------------------------------------------------------------
96 SetPipeLine(VISU_PipeLine* thePipeLine) ;
101 //! Copies all properties from the given actor
104 DeepCopy(VISU_Actor *theActor);
108 ShallowCopyPL(VISU_PipeLine* thePipeLine);
110 //----------------------------------------------------------------------------
111 //! Redefined method of getting a native mapper of the actor.
116 //! Redefined method of getting an actor bounds.
118 vtkFloatingPointType*
121 //! Redefined method of getting an actor input.
126 //! Gets memory size used by the instance (bytes).
131 //----------------------------------------------------------------------------
134 SetFactory(VISU::TActorFactory* theActorFactory);
136 VISU::TGaussPtsActorFactory*
137 GetGaussPtsFactory();
141 SetPosition(double _arg[3]);
143 //----------------------------------------------------------------------------
144 //! Add actor to the renderer.
147 AddToRender(vtkRenderer* theRenderer);
149 //! Remove actor from the renderer.
152 RemoveFromRender(vtkRenderer* theRenderer);
154 //! Set the Render Window Interactor to the actor.
157 SetInteractor(vtkRenderWindowInteractor* theInteractor);
159 //! Apply the transform on the actor.
162 SetTransform(VTKViewer_Transform* theTransform);
164 //! Redefined method of rendering the Opaque Geometry.
167 RenderOpaqueGeometry(vtkViewport *viewport);
169 //! Redefined method of rendering the Translucent Geometry.
172 RenderTranslucentGeometry(vtkViewport *viewport);
174 //----------------------------------------------------------------------------
175 //! Set actor visibility.
178 SetVisibility(int theMode);
180 //! Get segmentation visibility.
183 IsSegmentationEnabled();
185 //! Set Scalar Bar Control to the actor.
189 //! Set the Scalar Bar Control visibility.
191 SetBarVisibility(bool theMode);
193 //! Get the Scalar Bar Control visibility.
199 SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl);
201 //! Return the information about pipeline magnification changing.
202 /*! True indicates that magnification is increased, false - decreased. */
204 GetChangeMagnification();
206 //! Change the pipeline magnification.
209 ChangeMagnification( bool );
211 //----------------------------------------------------------------------------
212 //! Internal highlight.
215 Highlight(bool theIsHighlight);
217 //! Redefined method of the actor's prehighlighting
220 PreHighlight(vtkInteractorStyle* theInteractorStyle,
221 SVTK_SelectionEvent* theSelectionEvent,
222 bool theIsHighlight);
224 //! Redefined method of the actor's highlighting
227 Highlight(vtkInteractorStyle* theInteractorStyle,
228 SVTK_SelectionEvent* theSelectionEvent,
229 bool theIsHighlight);
231 //----------------------------------------------------------------------------
232 //! Set the picking settings to the actor.
234 SetInsideCursorSettings(VISU_InsideCursorSettings* theInsideCursorSettings);
237 UpdateInsideCursorSettings();
240 UpdateInsideCursorSettings( PDeviceActor );
242 //----------------------------------------------------------------------------
243 //! Apply the picking settings on the actor.
245 UpdatePickingSettings();
255 //----------------------------------------------------------------------------
260 //----------------------------------------------------------------------------
261 virtual void RemoveAllClippingPlanes();
263 virtual vtkIdType GetNumberOfClippingPlanes();
265 virtual bool AddClippingPlane(vtkPlane* thePlane);
267 virtual vtkPlane* GetClippingPlane(vtkIdType theID);
269 virtual vtkImplicitFunctionCollection* GetClippingPlanes();
272 //----------------------------------------------------------------------------
278 // Redefined method of setting mapper input.
281 SetMapperInput(vtkDataSet* theDataSet);
287 //! To get current value of the radius of the Point Sprite
290 GetRadius(vtkIdType theObjID,
292 vtkDataArray *theScalarArray);
294 //! To get current value of the magnification
297 GetMagnification(vtkIdType theObjID);
299 //! To get current value of the clamp
302 GetClamp(vtkIdType theObjID);
304 //----------------------------------------------------------------------------
305 vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
307 //! Main process VTK event method
310 ProcessEvents(vtkObject* theObject,
311 unsigned long theEvent,
315 // To process VTK event method
318 OnInteractorEvent(unsigned long theEvent);
320 vtkFloatingPointType myPriority;
321 bool myChangeMagnification;
322 VISU::TGaussPtsActorFactory* myGaussPtsActorFactory;
323 boost::signal1<void,VISU_GaussPtsAct*> myUpdatePrs3dSignal;
325 //----------------------------------------------------------------------------
326 PDeviceActor myDeviceActor;
328 VISU_WidgetCtrl* myWidgetCtrl;
330 VISU_GaussPointsPL* myCurrentPL;
331 vtkSmartPointer<VISU_GaussPointsPL> myGaussPointsPL;
333 vtkSmartPointer<vtkPolyDataMapper> myMapper;
334 vtkSmartPointer<SALOME_ExtractPolyDataGeometry> myPolyDataExtractor;
335 vtkSmartPointer<vtkImplicitBoolean> myFunction;
337 vtkIdType myLastPreHighlightObjID;
339 vtkSmartPointer<VISU_CursorPyramid> myCursorPyramid;
340 vtkSmartPointer<VISU_CursorPyramid> myCursorPyramidSelected;
342 vtkSmartPointer<vtkUnstructuredGrid> myCellSource;
343 vtkSmartPointer<SVTK_Actor> myCellActor;
345 vtkSmartPointer<vtkWarpVector> myWarpVector;
346 vtkSmartPointer<vtkCellDataToPointData> myCellDataToPointData;
348 bool myBarVisibility;
349 vtkSmartPointer<VISU_ScalarBarCtrl> myScalarBarCtrl;
351 VISU_InsideCursorSettings* myInsideCursorSettings;
355 //============================================================================
356 class VISU_GaussPtsAct2;
358 //! Gauss Points Actor, displayed in the Base View.
360 * Contains device actor (VISU_GaussPtsDeviceActor),
361 * which has two representation modes - outside and
362 * inside segmentation cursor.
364 class VISU_OBJECT_EXPORT VISU_GaussPtsAct1 : public VISU_GaussPtsAct
367 vtkTypeMacro(VISU_GaussPtsAct1,VISU_GaussPtsAct);
375 ShallowCopyPL(VISU_PipeLine* thePipeLine);
377 //----------------------------------------------------------------------------
378 //! Set actor visibility.
381 SetVisibility(int theMode);
385 Connect(VISU_GaussPtsAct2* theActor);
387 //----------------------------------------------------------------------------
389 UpdateInsideCursorSettings();
391 //----------------------------------------------------------------------------
392 //! Set the Outside Cursor Gauss Points settings to the actor.
394 SetOutsideCursorSettings(VISU_OutsideCursorSettings* theOutsideCursorSettings);
396 //! Apply the Outside Cursor Gauss Points settings on the actor.
398 UpdateOutsideCursorSettings();
400 //----------------------------------------------------------------------------
401 //! Add actor to the renderer.
404 AddToRender(vtkRenderer* theRenderer);
406 //! Remove actor from the renderer.
409 RemoveFromRender(vtkRenderer* theRenderer);
411 //! Apply the transform on the actor.
414 SetTransform(VTKViewer_Transform* theTransform);
418 SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl);
420 //! Redefined method of rendering the Opaque Geometry.
423 RenderOpaqueGeometry(vtkViewport *viewport);
425 //! Redefined method of rendering the Translucent Geometry.
428 RenderTranslucentGeometry(vtkViewport *viewport);
432 SetPosition(double _arg[3]);
434 //! Gets memory size used by the instance (bytes).
440 //----------------------------------------------------------------------------
444 ~VISU_GaussPtsAct1();
446 // Redefined method of setting mapper input.
449 SetMapperInput(vtkDataSet* theDataSet);
451 //! To get current value of the radius of the Point Sprite
454 GetRadius(vtkIdType theObjID,
456 vtkDataArray *theScalarArray);
458 //! To get current value of the magnification
461 GetMagnification(vtkIdType theObjID);
463 //! To get current value of the clamp
466 GetClamp(vtkIdType theObjID);
468 //----------------------------------------------------------------------------
469 // Main process VTK event method
472 ProcessEvents(vtkObject* theObject,
473 unsigned long theEvent,
477 // To process VTK event method
480 OnInteractorEvent(unsigned long theEvent);
482 boost::signal1<void,int> mySetVisibilitySignal;
483 boost::signal1<void,double*> myUpdatePositionSignal;
484 VISU_OutsideCursorSettings* myOutsideCursorSettings;
486 //----------------------------------------------------------------------------
487 PDeviceActor myInsideDeviceActor;
488 PDeviceActor myOutsideDeviceActor;
492 //! Gauss Points Actor, displayed in the Segmented View.
493 class VISU_OBJECT_EXPORT VISU_GaussPtsAct2 : public VISU_GaussPtsAct
496 vtkTypeMacro(VISU_GaussPtsAct2,VISU_GaussPtsAct);
502 // Redefined method of setting mapper input.
505 SetMapperInput(vtkDataSet* theDataSet);
509 ShallowCopyPL(VISU_PipeLine* thePipeLine);
511 //----------------------------------------------------------------------------
512 //! Set actor visibility.
515 SetVisibility(int theMode);
519 SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl);
521 //! Gets memory size used by the instance (bytes).
528 SetPosition(double _arg[3]);
531 //----------------------------------------------------------------------------
535 ~VISU_GaussPtsAct2();
537 //----------------------------------------------------------------------------
538 // To process VTK event method
541 OnInteractorEvent(unsigned long theEvent);