1 // Copyright (C) 2007-2012 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 "VTKViewer_Actor.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;
54 class vtkLabeledDataMapper;
58 class VTKViewer_CellCenters;
59 class VTKViewer_FramedTextActor;
61 class VISU_SelectVisiblePoints;
62 class VISU_UsedPointsFilter;
64 #if !defined(VTK_XVERSION)
65 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
70 namespace Representation
72 const Type Surfaceframe = Insideframe + 1;
73 const Type FeatureEdges = Insideframe + 2;
82 //----------------------------------------------------------------------------
83 class VISU_OBJECT_EXPORT VISU_Actor : public VISU_ActorBase
86 vtkTypeMacro(VISU_Actor, VISU_ActorBase);
92 //! Copies all properties from the given actor
95 DeepCopy(VISU_Actor *theActor);
99 ShallowCopyPL(VISU_PipeLine* thePipeLine);
101 //----------------------------------------------------------------------------
104 setIO(const Handle(SALOME_InteractiveObject)& theIO);
106 //----------------------------------------------------------------------------
112 SetPrs3d(VISU::Prs3d_i* thePrs3d);
116 SetVisibility(int theMode);
123 SetPosition( double thePosition[3] );
127 SetPosition( double theX, double theY, double theZ );
129 //----------------------------------------------------------------------------
136 SetPipeLine(VISU_PipeLine* thePipeLine);
138 //----------------------------------------------------------------------------
141 SetRepresentation(int theMode);
143 //----------------------------------------------------------------------------
162 SetShrinkable(bool theIsShrinkable);
166 SetShrinkFactor(double theFactor = 0.8);
172 //----------------------------------------------------------------------------
175 IsFeatureEdgesAllowed();
179 SetFeatureEdgesAllowed(bool theIsFeatureEdgesAllowed);
183 IsFeatureEdgesEnabled();
187 SetFeatureEdgesEnabled(bool theIsFeatureEdgesEnabled);
191 GetFeatureEdgesAngle();
195 SetFeatureEdgesAngle(double theAngle = 30.0);
199 GetFeatureEdgesFlags(bool& theIsFeatureEdges,
200 bool& theIsBoundaryEdges,
201 bool& theIsManifoldEdges,
202 bool& theIsNonManifoldEdges);
206 SetFeatureEdgesFlags(bool theIsFeatureEdges,
207 bool theIsBoundaryEdges,
208 bool theIsManifoldEdges,
209 bool theIsNonManifoldEdges);
213 GetFeatureEdgesColoring();
217 SetFeatureEdgesColoring(bool theIsColoring);
219 //----------------------------------------------------------------------------
222 SetOpacity(double theValue);
230 SetLineWidth(double theLineWidth);
236 //----------------------------------------------------------------------------
239 AddToRender( vtkRenderer* );
243 RemoveFromRender( vtkRenderer* );
245 //----------------------------------------------------------------------------
246 //! Just to update visibility of the highlight devices
249 highlight(bool theHighlight);
251 //! To process prehighlight (called from #SVTK_InteractorStyle)
254 PreHighlight(vtkInteractorStyle* theInteractorStyle,
255 SVTK_SelectionEvent* theSelectionEvent,
256 bool theIsHighlight);
258 //! To process highlight (called from #SVTK_InteractorStyle)
261 Highlight(vtkInteractorStyle* theInteractorStyle,
262 SVTK_SelectionEvent* theSelectionEvent,
263 bool theIsHighlight);
265 //! Internal highlight.
268 Highlight(bool theIsHighlight);
272 SetVTKMapping(bool theIsVTKMapping);
276 IsVTKMapping() const;
282 //! Gets memory size used by the instance (bytes).
287 //----------------------------------------------------------------------------
290 GetNodeObjId(vtkIdType theID);
294 GetNodeVTKID(vtkIdType theID);
298 GetNodeCoord(vtkIdType theObjID);
302 GetElemObjId(vtkIdType theID);
306 GetElemVTKID(vtkIdType theID);
310 GetElemCell(vtkIdType theObjID);
312 //----------------------------------------------------------------------------
313 virtual void RemoveAllClippingPlanes();
315 virtual vtkIdType GetNumberOfClippingPlanes();
317 virtual bool AddClippingPlane(vtkPlane* thePlane);
319 virtual vtkPlane* GetClippingPlane(vtkIdType theID);
321 virtual vtkImplicitFunctionCollection* GetClippingPlanes();
323 //----------------------------------------------------------------------------
324 //! Apply the picking settings on the actor.
326 UpdatePickingSettings();
328 //----------------------------------------------------------------------------
329 //! Methods for values labeling
332 SetValuesLabeled( const bool theIsValLabeled );
336 GetValuesLabeled() const;
343 GetsValLabelsProps() const;
345 enum EQuadratic2DRepresentation { eLines = 0, eArcs };
348 EQuadratic2DRepresentation GetQuadratic2DRepresentation() const;
351 SetQuadratic2DRepresentation( EQuadratic2DRepresentation theMode );
362 SetMapperInput(vtkDataSet* theDataSet) = 0;
368 //----------------------------------------------------------------------------
370 isSubElementsHighlighted();
372 //----------------------------------------------------------------------------
373 vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
375 //! Main process VTK event method
378 ProcessEvents(vtkObject* theObject,
379 unsigned long theEvent,
383 //----------------------------------------------------------------------------
388 //----------------------------------------------------------------------------
392 VISU::Prs3d_i* myPrs3d;
393 vtkSmartPointer<VISU_PipeLine> myPipeLine;
395 vtkSmartPointer<VTKViewer_ShrinkFilter> myShrinkFilter;
399 vtkSmartPointer<vtkTextMapper> myAnnotationMapper;
400 #if (VTK_XVERSION < 0x050100)
401 vtkSmartPointer<vtkTextActor> myAnnotationActor;
403 vtkSmartPointer<vtkActor2D> myAnnotationActor;
406 vtkSmartPointer<VTKViewer_FramedTextActor> myTextActor;
408 vtkSmartPointer<vtkFeatureEdges> myFeatureEdges;
409 bool myIsFeatureEdgesAllowed;
410 bool myIsFeatureEdgesEnabled;
412 Selection_Mode myLastSelectionMode;
413 bool myIsSubElementsHighlighted;
415 // fields for values labeling
417 vtkDataSet* myValLblDataSet;
418 vtkActor2D* myValLabels;
419 vtkMaskPoints* myValMaskPoints;
420 VTKViewer_CellCenters* myValCellCenters;
421 VISU_UsedPointsFilter* myValUsedPoints;
422 vtkLabeledDataMapper* myValLabeledDataMapper;
423 VISU_SelectVisiblePoints* myValSelectVisiblePoints;
426 #endif //VISU_ACTOR_H