1 // Copyright (C) 2007-2010 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
31 #include "VISU_OBJECT.h"
33 #include "SALOME_Actor.h"
34 #include "VISU_ActorBase.h"
35 #include "VISU_BoostSignals.h"
36 #include "SVTK_DeviceActor.h"
39 #include <vtkTimeStamp.h>
40 #include <vtkSmartPointer.h>
46 class vtkInteractorStyle;
47 class vtkCallbackCommand;
48 class VTKViewer_ShrinkFilter;
51 class vtkImplicitFunctionCollection;
52 class vtkFeatureEdges;
53 class vtkTextProperty;
55 class vtkLabeledDataMapper;
59 class VTKViewer_FramedTextActor;
61 class VISU_SelectVisiblePoints;
63 #if !defined(VTK_XVERSION)
64 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
69 namespace Representation
71 const Type Surfaceframe = Insideframe + 1;
72 const Type FeatureEdges = Insideframe + 2;
81 //----------------------------------------------------------------------------
82 class VISU_OBJECT_EXPORT VISU_Actor : public VISU_ActorBase
85 vtkTypeMacro(VISU_Actor, VISU_ActorBase);
91 //! Copies all properties from the given actor
94 DeepCopy(VISU_Actor *theActor);
98 ShallowCopyPL(VISU_PipeLine* thePipeLine);
100 //----------------------------------------------------------------------------
103 setIO(const Handle(SALOME_InteractiveObject)& theIO);
105 //----------------------------------------------------------------------------
111 SetPrs3d(VISU::Prs3d_i* thePrs3d);
115 SetVisibility(int theMode);
122 SetPosition( double thePosition[3] );
126 SetPosition( double theX, double theY, double theZ );
128 //----------------------------------------------------------------------------
135 SetPipeLine(VISU_PipeLine* thePipeLine);
137 //----------------------------------------------------------------------------
140 SetRepresentation(int theMode);
142 //----------------------------------------------------------------------------
161 SetShrinkable(bool theIsShrinkable);
165 SetShrinkFactor(vtkFloatingPointType theFactor = 0.8);
171 //----------------------------------------------------------------------------
174 IsFeatureEdgesAllowed();
178 SetFeatureEdgesAllowed(bool theIsFeatureEdgesAllowed);
182 IsFeatureEdgesEnabled();
186 SetFeatureEdgesEnabled(bool theIsFeatureEdgesEnabled);
190 GetFeatureEdgesAngle();
194 SetFeatureEdgesAngle(vtkFloatingPointType theAngle = 30.0);
198 GetFeatureEdgesFlags(bool& theIsFeatureEdges,
199 bool& theIsBoundaryEdges,
200 bool& theIsManifoldEdges,
201 bool& theIsNonManifoldEdges);
205 SetFeatureEdgesFlags(bool theIsFeatureEdges,
206 bool theIsBoundaryEdges,
207 bool theIsManifoldEdges,
208 bool theIsNonManifoldEdges);
212 GetFeatureEdgesColoring();
216 SetFeatureEdgesColoring(bool theIsColoring);
218 //----------------------------------------------------------------------------
221 SetOpacity(vtkFloatingPointType theValue);
229 SetLineWidth(vtkFloatingPointType theLineWidth);
235 //----------------------------------------------------------------------------
238 AddToRender( vtkRenderer* );
242 RemoveFromRender( vtkRenderer* );
244 //----------------------------------------------------------------------------
245 //! Just to update visibility of the highlight devices
248 highlight(bool theHighlight);
250 //! To process prehighlight (called from #SVTK_InteractorStyle)
253 PreHighlight(vtkInteractorStyle* theInteractorStyle,
254 SVTK_SelectionEvent* theSelectionEvent,
255 bool theIsHighlight);
257 //! To process highlight (called from #SVTK_InteractorStyle)
260 Highlight(vtkInteractorStyle* theInteractorStyle,
261 SVTK_SelectionEvent* theSelectionEvent,
262 bool theIsHighlight);
264 //! Internal highlight.
267 Highlight(bool theIsHighlight);
271 SetVTKMapping(bool theIsVTKMapping);
275 IsVTKMapping() const;
281 //! Gets memory size used by the instance (bytes).
286 //----------------------------------------------------------------------------
289 GetNodeObjId(vtkIdType theID);
293 GetNodeVTKID(vtkIdType theID);
296 vtkFloatingPointType*
297 GetNodeCoord(vtkIdType theObjID);
301 GetElemObjId(vtkIdType theID);
305 GetElemVTKID(vtkIdType theID);
309 GetElemCell(vtkIdType theObjID);
311 //----------------------------------------------------------------------------
312 virtual void RemoveAllClippingPlanes();
314 virtual vtkIdType GetNumberOfClippingPlanes();
316 virtual bool AddClippingPlane(vtkPlane* thePlane);
318 virtual vtkPlane* GetClippingPlane(vtkIdType theID);
320 virtual vtkImplicitFunctionCollection* GetClippingPlanes();
322 //----------------------------------------------------------------------------
323 //! Apply the picking settings on the actor.
325 UpdatePickingSettings();
327 //----------------------------------------------------------------------------
328 //! Methods for values labeling
331 SetValuesLabeled( const bool theIsValLabeled );
335 GetValuesLabeled() const;
342 GetsValLabelsProps() const;
344 enum EQuadratic2DRepresentation { eLines = 0, eArcs };
347 EQuadratic2DRepresentation GetQuadratic2DRepresentation() const;
350 SetQuadratic2DRepresentation( EQuadratic2DRepresentation theMode );
361 SetMapperInput(vtkDataSet* theDataSet) = 0;
367 //----------------------------------------------------------------------------
369 isSubElementsHighlighted();
371 //----------------------------------------------------------------------------
372 vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
374 //! Main process VTK event method
377 ProcessEvents(vtkObject* theObject,
378 unsigned long theEvent,
382 //----------------------------------------------------------------------------
387 //----------------------------------------------------------------------------
389 vtkFloatingPointType myPriority;
391 VISU::Prs3d_i* myPrs3d;
392 vtkSmartPointer<VISU_PipeLine> myPipeLine;
394 vtkSmartPointer<VTKViewer_ShrinkFilter> myShrinkFilter;
398 vtkSmartPointer<vtkTextMapper> myAnnotationMapper;
399 #if (VTK_XVERSION < 0x050100)
400 vtkSmartPointer<vtkTextActor> myAnnotationActor;
402 vtkSmartPointer<vtkActor2D> myAnnotationActor;
405 vtkSmartPointer<VTKViewer_FramedTextActor> myTextActor;
407 vtkSmartPointer<vtkFeatureEdges> myFeatureEdges;
408 bool myIsFeatureEdgesAllowed;
409 bool myIsFeatureEdgesEnabled;
411 Selection_Mode myLastSelectionMode;
412 bool myIsSubElementsHighlighted;
414 // fields for values labeling
416 vtkDataSet* myValLblDataSet;
417 vtkActor2D* myValLabels;
418 vtkMaskPoints* myValMaskPoints;
419 vtkCellCenters* myValCellCenters;
420 vtkLabeledDataMapper* myValLabeledDataMapper;
421 VISU_SelectVisiblePoints* myValSelectVisiblePoints;
424 #endif //VISU_ACTOR_H