1 // Copyright (C) 2007-2013 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
23 // VISU OBJECT : interactive object for VISU entities implementation
24 // File : VISU_ScalarMapAct.h
25 // Author : Laurent CORNABE with help of Nicolas REJNERI
29 #ifndef VISU_GaussPtsAct_HeaderFile
30 #define VISU_GaussPtsAct_HeaderFile
32 #include "VISU_OBJECT.h"
33 #include "VISU_Actor.h"
34 #include "VISU_GaussPtsActorFactory.h"
36 #include <vtkCommand.h>
37 #include <vtkSmartPointer.h>
39 class VISU_GaussPointsPL;
40 class VISU_WidgetCtrl;
41 class VISU_OpenGLPointSpriteMapper;
46 class vtkSphereSource;
47 class vtkPolyDataMapper;
50 class vtkInteractorStyle;
52 class VISU_GaussPtsDeviceActor;
53 class VISU_CursorPyramid;
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.
121 //! Redefined method of getting an actor input.
126 //! Gets memory size used by the instance (bytes).
131 //----------------------------------------------------------------------------
134 SetOpacity(double theValue);
136 //----------------------------------------------------------------------------
139 SetFactory(VISU::TActorFactory* theActorFactory);
141 VISU::TGaussPtsActorFactory*
142 GetGaussPtsFactory();
146 SetPosition(double _arg[3]);
148 //----------------------------------------------------------------------------
149 //! Add actor to the renderer.
152 AddToRender(vtkRenderer* theRenderer);
154 //! Remove actor from the renderer.
157 RemoveFromRender(vtkRenderer* theRenderer);
159 //! Set the Render Window Interactor to the actor.
162 SetInteractor(vtkRenderWindowInteractor* theInteractor);
164 //! Apply the transform on the actor.
167 SetTransform(VTKViewer_Transform* theTransform);
169 //! Redefined method of rendering the Opaque Geometry.
172 RenderOpaqueGeometry(vtkViewport *viewport);
174 //! Redefined method of rendering the Translucent Geometry.
177 RenderTranslucentGeometry(vtkViewport *viewport);
179 //----------------------------------------------------------------------------
180 //! Set actor visibility.
183 SetVisibility(int theMode);
185 //! Get segmentation visibility.
188 IsSegmentationEnabled();
190 //! Set Scalar Bar Control to the actor.
194 //! Set the Scalar Bar Control visibility.
196 SetBarVisibility(bool theMode);
198 //! Get the Scalar Bar Control visibility.
204 SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl);
206 //! Return the information about pipeline magnification changing.
207 /*! True indicates that magnification is increased, false - decreased. */
209 GetChangeMagnification();
211 //! Change the pipeline magnification.
214 ChangeMagnification( bool );
216 //----------------------------------------------------------------------------
217 //! Internal highlight.
220 Highlight(bool theIsHighlight);
222 //! Redefined method of the actor's prehighlighting
225 PreHighlight(vtkInteractorStyle* theInteractorStyle,
226 SVTK_SelectionEvent* theSelectionEvent,
227 bool theIsHighlight);
229 //! Redefined method of the actor's highlighting
232 Highlight(vtkInteractorStyle* theInteractorStyle,
233 SVTK_SelectionEvent* theSelectionEvent,
234 bool theIsHighlight);
236 //----------------------------------------------------------------------------
237 //! Set the picking settings to the actor.
239 SetInsideCursorSettings(VISU_InsideCursorSettings* theInsideCursorSettings);
242 UpdateInsideCursorSettings();
245 UpdateInsideCursorSettings( PDeviceActor );
247 //----------------------------------------------------------------------------
248 //! Apply the picking settings on the actor.
250 UpdatePickingSettings();
260 //----------------------------------------------------------------------------
265 //----------------------------------------------------------------------------
266 virtual void RemoveAllClippingPlanes();
268 virtual vtkIdType GetNumberOfClippingPlanes();
270 virtual bool AddClippingPlane(vtkPlane* thePlane);
272 virtual vtkPlane* GetClippingPlane(vtkIdType theID);
274 virtual vtkImplicitFunctionCollection* GetClippingPlanes();
276 //----------------------------------------------------------------------------
282 //----------------------------------------------------------------------------
288 // Redefined method of setting mapper input.
291 SetMapperInput(vtkDataSet* theDataSet);
297 //! To get current value of the radius of the Point Sprite
300 GetRadius(vtkIdType theObjID,
302 vtkDataArray *theScalarArray);
304 //! To get current value of the magnification
307 GetMagnification(vtkIdType theObjID);
309 //! To get current value of the clamp
312 GetClamp(vtkIdType theObjID);
314 //----------------------------------------------------------------------------
315 vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
317 //! Main process VTK event method
320 ProcessEvents(vtkObject* theObject,
321 unsigned long theEvent,
325 // To process VTK event method
328 OnInteractorEvent(unsigned long theEvent);
331 bool myChangeMagnification;
332 VISU::TGaussPtsActorFactory* myGaussPtsActorFactory;
333 boost::signal1<void,VISU_GaussPtsAct*> myUpdatePrs3dSignal;
335 //----------------------------------------------------------------------------
336 PDeviceActor myDeviceActor;
338 VISU_WidgetCtrl* myWidgetCtrl;
340 VISU_GaussPointsPL* myCurrentPL;
341 vtkSmartPointer<VISU_GaussPointsPL> myGaussPointsPL;
343 vtkSmartPointer<vtkPolyDataMapper> myMapper;
344 vtkSmartPointer<SALOME_ExtractPolyDataGeometry> myPolyDataExtractor;
345 vtkSmartPointer<vtkImplicitBoolean> myFunction;
347 vtkIdType myLastPreHighlightObjID;
349 vtkSmartPointer<VISU_CursorPyramid> myCursorPyramid;
350 vtkSmartPointer<VISU_CursorPyramid> myCursorPyramidSelected;
352 vtkSmartPointer<vtkUnstructuredGrid> myCellSource;
353 vtkSmartPointer<SVTK_Actor> myCellActor;
355 vtkSmartPointer<vtkWarpVector> myWarpVector;
356 vtkSmartPointer<vtkCellDataToPointData> myCellDataToPointData;
358 bool myBarVisibility;
359 vtkSmartPointer<VISU_ScalarBarCtrl> myScalarBarCtrl;
361 VISU_InsideCursorSettings* myInsideCursorSettings;
365 //============================================================================
366 class VISU_GaussPtsAct2;
368 //! Gauss Points Actor, displayed in the Base View.
370 * Contains device actor (VISU_GaussPtsDeviceActor),
371 * which has two representation modes - outside and
372 * inside segmentation cursor.
374 class VISU_OBJECT_EXPORT VISU_GaussPtsAct1 : public VISU_GaussPtsAct
377 vtkTypeMacro(VISU_GaussPtsAct1,VISU_GaussPtsAct);
385 ShallowCopyPL(VISU_PipeLine* thePipeLine);
387 //----------------------------------------------------------------------------
388 //! Set actor visibility.
391 SetVisibility(int theMode);
395 Connect(VISU_GaussPtsAct2* theActor);
397 //----------------------------------------------------------------------------
399 UpdateInsideCursorSettings();
401 //----------------------------------------------------------------------------
402 //! Set the Outside Cursor Gauss Points settings to the actor.
404 SetOutsideCursorSettings(VISU_OutsideCursorSettings* theOutsideCursorSettings);
406 //! Apply the Outside Cursor Gauss Points settings on the actor.
408 UpdateOutsideCursorSettings();
410 //----------------------------------------------------------------------------
411 //! Add actor to the renderer.
414 AddToRender(vtkRenderer* theRenderer);
416 //! Remove actor from the renderer.
419 RemoveFromRender(vtkRenderer* theRenderer);
421 //! Apply the transform on the actor.
424 SetTransform(VTKViewer_Transform* theTransform);
428 SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl);
430 //! Redefined method of rendering the Opaque Geometry.
433 RenderOpaqueGeometry(vtkViewport *viewport);
435 //! Redefined method of rendering the Translucent Geometry.
438 RenderTranslucentGeometry(vtkViewport *viewport);
442 SetPosition(double _arg[3]);
444 //! Gets memory size used by the instance (bytes).
450 //----------------------------------------------------------------------------
454 ~VISU_GaussPtsAct1();
456 // Redefined method of setting mapper input.
459 SetMapperInput(vtkDataSet* theDataSet);
461 //! To get current value of the radius of the Point Sprite
464 GetRadius(vtkIdType theObjID,
466 vtkDataArray *theScalarArray);
468 //! To get current value of the magnification
471 GetMagnification(vtkIdType theObjID);
473 //! To get current value of the clamp
476 GetClamp(vtkIdType theObjID);
478 //----------------------------------------------------------------------------
479 // Main process VTK event method
482 ProcessEvents(vtkObject* theObject,
483 unsigned long theEvent,
487 // To process VTK event method
490 OnInteractorEvent(unsigned long theEvent);
492 boost::signal1<void,int> mySetVisibilitySignal;
493 boost::signal1<void,double*> myUpdatePositionSignal;
494 VISU_OutsideCursorSettings* myOutsideCursorSettings;
496 //----------------------------------------------------------------------------
497 PDeviceActor myInsideDeviceActor;
498 PDeviceActor myOutsideDeviceActor;
502 //! Gauss Points Actor, displayed in the Segmented View.
503 class VISU_OBJECT_EXPORT VISU_GaussPtsAct2 : public VISU_GaussPtsAct
506 vtkTypeMacro(VISU_GaussPtsAct2,VISU_GaussPtsAct);
512 // Redefined method of setting mapper input.
515 SetMapperInput(vtkDataSet* theDataSet);
519 ShallowCopyPL(VISU_PipeLine* thePipeLine);
521 //----------------------------------------------------------------------------
522 //! Set actor visibility.
525 SetVisibility(int theMode);
529 SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl);
531 //! Gets memory size used by the instance (bytes).
538 SetPosition(double _arg[3]);
541 //----------------------------------------------------------------------------
545 ~VISU_GaussPtsAct2();
547 //----------------------------------------------------------------------------
548 // To process VTK event method
551 OnInteractorEvent(unsigned long theEvent);