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 vtkSelectVisiblePoints;
55 class vtkLabeledDataMapper;
59 class VTKViewer_FramedTextActor;
61 #if !defined(VTK_XVERSION)
62 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
67 namespace Representation
69 const Type Surfaceframe = Insideframe + 1;
70 const Type FeatureEdges = Insideframe + 2;
79 //----------------------------------------------------------------------------
80 class VISU_OBJECT_EXPORT VISU_Actor : public VISU_ActorBase
83 vtkTypeMacro(VISU_Actor, VISU_ActorBase);
89 //! Copies all properties from the given actor
92 DeepCopy(VISU_Actor *theActor);
96 ShallowCopyPL(VISU_PipeLine* thePipeLine);
98 //----------------------------------------------------------------------------
101 setIO(const Handle(SALOME_InteractiveObject)& theIO);
103 //----------------------------------------------------------------------------
109 SetPrs3d(VISU::Prs3d_i* thePrs3d);
113 SetVisibility(int theMode);
118 //----------------------------------------------------------------------------
125 SetPipeLine(VISU_PipeLine* thePipeLine);
127 //----------------------------------------------------------------------------
130 SetRepresentation(int theMode);
132 //----------------------------------------------------------------------------
151 SetShrinkable(bool theIsShrinkable);
155 SetShrinkFactor(vtkFloatingPointType theFactor = 0.8);
161 //----------------------------------------------------------------------------
164 IsFeatureEdgesAllowed();
168 SetFeatureEdgesAllowed(bool theIsFeatureEdgesAllowed);
172 IsFeatureEdgesEnabled();
176 SetFeatureEdgesEnabled(bool theIsFeatureEdgesEnabled);
180 GetFeatureEdgesAngle();
184 SetFeatureEdgesAngle(vtkFloatingPointType theAngle = 30.0);
188 GetFeatureEdgesFlags(bool& theIsFeatureEdges,
189 bool& theIsBoundaryEdges,
190 bool& theIsManifoldEdges,
191 bool& theIsNonManifoldEdges);
195 SetFeatureEdgesFlags(bool theIsFeatureEdges,
196 bool theIsBoundaryEdges,
197 bool theIsManifoldEdges,
198 bool theIsNonManifoldEdges);
202 GetFeatureEdgesColoring();
206 SetFeatureEdgesColoring(bool theIsColoring);
208 //----------------------------------------------------------------------------
211 SetOpacity(vtkFloatingPointType theValue);
219 SetLineWidth(vtkFloatingPointType theLineWidth);
225 //----------------------------------------------------------------------------
228 AddToRender( vtkRenderer* );
232 RemoveFromRender( vtkRenderer* );
234 //----------------------------------------------------------------------------
235 //! Just to update visibility of the highlight devices
238 highlight(bool theHighlight);
240 //! To process prehighlight (called from #SVTK_InteractorStyle)
243 PreHighlight(vtkInteractorStyle* theInteractorStyle,
244 SVTK_SelectionEvent* theSelectionEvent,
245 bool theIsHighlight);
247 //! To process highlight (called from #SVTK_InteractorStyle)
250 Highlight(vtkInteractorStyle* theInteractorStyle,
251 SVTK_SelectionEvent* theSelectionEvent,
252 bool theIsHighlight);
254 //! Internal highlight.
257 Highlight(bool theIsHighlight);
261 SetVTKMapping(bool theIsVTKMapping);
265 IsVTKMapping() const;
271 //! Gets memory size used by the instance (bytes).
276 //----------------------------------------------------------------------------
279 GetNodeObjId(vtkIdType theID);
283 GetNodeVTKID(vtkIdType theID);
286 vtkFloatingPointType*
287 GetNodeCoord(vtkIdType theObjID);
291 GetElemObjId(vtkIdType theID);
295 GetElemVTKID(vtkIdType theID);
299 GetElemCell(vtkIdType theObjID);
301 //----------------------------------------------------------------------------
302 virtual void RemoveAllClippingPlanes();
304 virtual vtkIdType GetNumberOfClippingPlanes();
306 virtual bool AddClippingPlane(vtkPlane* thePlane);
308 virtual vtkPlane* GetClippingPlane(vtkIdType theID);
310 virtual vtkImplicitFunctionCollection* GetClippingPlanes();
312 //----------------------------------------------------------------------------
313 //! Apply the picking settings on the actor.
315 UpdatePickingSettings();
317 //----------------------------------------------------------------------------
318 //! Methods for values labeling
321 SetValuesLabeled( const bool theIsValLabeled );
325 GetValuesLabeled() const;
332 GetsValLabelsProps() const;
334 enum EQuadratic2DRepresentation { eLines = 0, eArcs };
337 EQuadratic2DRepresentation GetQuadratic2DRepresentation() const;
340 SetQuadratic2DRepresentation( EQuadratic2DRepresentation theMode );
351 SetMapperInput(vtkDataSet* theDataSet) = 0;
357 //----------------------------------------------------------------------------
359 isSubElementsHighlighted();
361 //----------------------------------------------------------------------------
362 vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
364 //! Main process VTK event method
367 ProcessEvents(vtkObject* theObject,
368 unsigned long theEvent,
372 //----------------------------------------------------------------------------
377 //----------------------------------------------------------------------------
379 vtkFloatingPointType myPriority;
381 VISU::Prs3d_i* myPrs3d;
382 vtkSmartPointer<VISU_PipeLine> myPipeLine;
384 vtkSmartPointer<VTKViewer_ShrinkFilter> myShrinkFilter;
388 vtkSmartPointer<vtkTextMapper> myAnnotationMapper;
389 #if (VTK_XVERSION < 0x050100)
390 vtkSmartPointer<vtkTextActor> myAnnotationActor;
392 vtkSmartPointer<vtkActor2D> myAnnotationActor;
395 vtkSmartPointer<VTKViewer_FramedTextActor> myTextActor;
397 vtkSmartPointer<vtkFeatureEdges> myFeatureEdges;
398 bool myIsFeatureEdgesAllowed;
399 bool myIsFeatureEdgesEnabled;
401 Selection_Mode myLastSelectionMode;
402 bool myIsSubElementsHighlighted;
404 // fields for values labeling
406 vtkDataSet* myValLblDataSet;
407 vtkActor2D* myValLabels;
408 vtkMaskPoints* myValMaskPoints;
409 vtkCellCenters* myValCellCenters;
410 vtkLabeledDataMapper* myValLabeledDataMapper;
411 vtkSelectVisiblePoints* myValSelectVisiblePoints;
414 #endif //VISU_ACTOR_H