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
30 #include "VISU_OBJECT.h"
32 #include "SALOME_Actor.h"
33 #include "VISU_ActorBase.h"
34 #include "VISU_BoostSignals.h"
35 #include "SVTK_DeviceActor.h"
38 #include <vtkTimeStamp.h>
39 #include <vtkSmartPointer.h>
45 class vtkInteractorStyle;
46 class vtkCallbackCommand;
47 class VTKViewer_ShrinkFilter;
50 class vtkImplicitFunctionCollection;
51 class vtkFeatureEdges;
52 class vtkTextProperty;
54 class vtkLabeledDataMapper;
58 class VTKViewer_FramedTextActor;
60 class VISU_SelectVisiblePoints;
62 #if !defined(VTK_XVERSION)
63 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
68 namespace Representation
70 const Type Surfaceframe = Insideframe + 1;
71 const Type FeatureEdges = Insideframe + 2;
80 //----------------------------------------------------------------------------
81 class VISU_OBJECT_EXPORT VISU_Actor : public VISU_ActorBase
84 vtkTypeMacro(VISU_Actor, VISU_ActorBase);
90 //! Copies all properties from the given actor
93 DeepCopy(VISU_Actor *theActor);
97 ShallowCopyPL(VISU_PipeLine* thePipeLine);
99 //----------------------------------------------------------------------------
102 setIO(const Handle(SALOME_InteractiveObject)& theIO);
104 //----------------------------------------------------------------------------
110 SetPrs3d(VISU::Prs3d_i* thePrs3d);
114 SetVisibility(int theMode);
121 SetPosition( double thePosition[3] );
125 SetPosition( double theX, double theY, double theZ );
127 //----------------------------------------------------------------------------
134 SetPipeLine(VISU_PipeLine* thePipeLine);
136 //----------------------------------------------------------------------------
139 SetRepresentation(int theMode);
141 //----------------------------------------------------------------------------
160 SetShrinkable(bool theIsShrinkable);
164 SetShrinkFactor(vtkFloatingPointType theFactor = 0.8);
170 //----------------------------------------------------------------------------
173 IsFeatureEdgesAllowed();
177 SetFeatureEdgesAllowed(bool theIsFeatureEdgesAllowed);
181 IsFeatureEdgesEnabled();
185 SetFeatureEdgesEnabled(bool theIsFeatureEdgesEnabled);
189 GetFeatureEdgesAngle();
193 SetFeatureEdgesAngle(vtkFloatingPointType theAngle = 30.0);
197 GetFeatureEdgesFlags(bool& theIsFeatureEdges,
198 bool& theIsBoundaryEdges,
199 bool& theIsManifoldEdges,
200 bool& theIsNonManifoldEdges);
204 SetFeatureEdgesFlags(bool theIsFeatureEdges,
205 bool theIsBoundaryEdges,
206 bool theIsManifoldEdges,
207 bool theIsNonManifoldEdges);
211 GetFeatureEdgesColoring();
215 SetFeatureEdgesColoring(bool theIsColoring);
217 //----------------------------------------------------------------------------
220 SetOpacity(vtkFloatingPointType theValue);
228 SetLineWidth(vtkFloatingPointType theLineWidth);
234 //----------------------------------------------------------------------------
237 AddToRender( vtkRenderer* );
241 RemoveFromRender( vtkRenderer* );
243 //----------------------------------------------------------------------------
244 //! Just to update visibility of the highlight devices
247 highlight(bool theHighlight);
249 //! To process prehighlight (called from #SVTK_InteractorStyle)
252 PreHighlight(vtkInteractorStyle* theInteractorStyle,
253 SVTK_SelectionEvent* theSelectionEvent,
254 bool theIsHighlight);
256 //! To process highlight (called from #SVTK_InteractorStyle)
259 Highlight(vtkInteractorStyle* theInteractorStyle,
260 SVTK_SelectionEvent* theSelectionEvent,
261 bool theIsHighlight);
263 //! Internal highlight.
266 Highlight(bool theIsHighlight);
270 SetVTKMapping(bool theIsVTKMapping);
274 IsVTKMapping() const;
280 //! Gets memory size used by the instance (bytes).
285 //----------------------------------------------------------------------------
288 GetNodeObjId(vtkIdType theID);
292 GetNodeVTKID(vtkIdType theID);
295 vtkFloatingPointType*
296 GetNodeCoord(vtkIdType theObjID);
300 GetElemObjId(vtkIdType theID);
304 GetElemVTKID(vtkIdType theID);
308 GetElemCell(vtkIdType theObjID);
310 //----------------------------------------------------------------------------
311 virtual void RemoveAllClippingPlanes();
313 virtual vtkIdType GetNumberOfClippingPlanes();
315 virtual bool AddClippingPlane(vtkPlane* thePlane);
317 virtual vtkPlane* GetClippingPlane(vtkIdType theID);
319 virtual vtkImplicitFunctionCollection* GetClippingPlanes();
321 //----------------------------------------------------------------------------
322 //! Apply the picking settings on the actor.
324 UpdatePickingSettings();
326 //----------------------------------------------------------------------------
327 //! Methods for values labeling
330 SetValuesLabeled( const bool theIsValLabeled );
334 GetValuesLabeled() const;
341 GetsValLabelsProps() const;
343 enum EQuadratic2DRepresentation { eLines = 0, eArcs };
346 EQuadratic2DRepresentation GetQuadratic2DRepresentation() const;
349 SetQuadratic2DRepresentation( EQuadratic2DRepresentation theMode );
360 SetMapperInput(vtkDataSet* theDataSet) = 0;
366 //----------------------------------------------------------------------------
368 isSubElementsHighlighted();
370 //----------------------------------------------------------------------------
371 vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
373 //! Main process VTK event method
376 ProcessEvents(vtkObject* theObject,
377 unsigned long theEvent,
381 //----------------------------------------------------------------------------
386 //----------------------------------------------------------------------------
388 vtkFloatingPointType myPriority;
390 VISU::Prs3d_i* myPrs3d;
391 vtkSmartPointer<VISU_PipeLine> myPipeLine;
393 vtkSmartPointer<VTKViewer_ShrinkFilter> myShrinkFilter;
397 vtkSmartPointer<vtkTextMapper> myAnnotationMapper;
398 #if (VTK_XVERSION < 0x050100)
399 vtkSmartPointer<vtkTextActor> myAnnotationActor;
401 vtkSmartPointer<vtkActor2D> myAnnotationActor;
404 vtkSmartPointer<VTKViewer_FramedTextActor> myTextActor;
406 vtkSmartPointer<vtkFeatureEdges> myFeatureEdges;
407 bool myIsFeatureEdgesAllowed;
408 bool myIsFeatureEdgesEnabled;
410 Selection_Mode myLastSelectionMode;
411 bool myIsSubElementsHighlighted;
413 // fields for values labeling
415 vtkDataSet* myValLblDataSet;
416 vtkActor2D* myValLabels;
417 vtkMaskPoints* myValMaskPoints;
418 vtkCellCenters* myValCellCenters;
419 vtkLabeledDataMapper* myValLabeledDataMapper;
420 VISU_SelectVisiblePoints* myValSelectVisiblePoints;
423 #endif //VISU_ACTOR_H