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 VISU_FramedTextActor;
63 namespace Representation
65 const Type Surfaceframe = Insideframe + 1;
66 const Type FeatureEdges = Insideframe + 2;
75 //----------------------------------------------------------------------------
76 class VISU_OBJECT_EXPORT VISU_Actor : public VISU_ActorBase
79 vtkTypeMacro(VISU_Actor, VISU_ActorBase);
85 //! Copies all properties from the given actor
88 DeepCopy(VISU_Actor *theActor);
92 ShallowCopyPL(VISU_PipeLine* thePipeLine);
94 //----------------------------------------------------------------------------
97 setIO(const Handle(SALOME_InteractiveObject)& theIO);
99 //----------------------------------------------------------------------------
105 SetPrs3d(VISU::Prs3d_i* thePrs3d);
109 SetVisibility(int theMode);
114 //----------------------------------------------------------------------------
121 SetPipeLine(VISU_PipeLine* thePipeLine);
123 //----------------------------------------------------------------------------
126 SetRepresentation(int theMode);
128 //----------------------------------------------------------------------------
147 SetShrinkable(bool theIsShrinkable);
151 SetShrinkFactor(vtkFloatingPointType theFactor = 0.8);
157 //----------------------------------------------------------------------------
160 IsFeatureEdgesAllowed();
164 SetFeatureEdgesAllowed(bool theIsFeatureEdgesAllowed);
168 IsFeatureEdgesEnabled();
172 SetFeatureEdgesEnabled(bool theIsFeatureEdgesEnabled);
176 GetFeatureEdgesAngle();
180 SetFeatureEdgesAngle(vtkFloatingPointType theAngle = 30.0);
184 GetFeatureEdgesFlags(bool& theIsFeatureEdges,
185 bool& theIsBoundaryEdges,
186 bool& theIsManifoldEdges,
187 bool& theIsNonManifoldEdges);
191 SetFeatureEdgesFlags(bool theIsFeatureEdges,
192 bool theIsBoundaryEdges,
193 bool theIsManifoldEdges,
194 bool theIsNonManifoldEdges);
198 GetFeatureEdgesColoring();
202 SetFeatureEdgesColoring(bool theIsColoring);
204 //----------------------------------------------------------------------------
207 SetOpacity(vtkFloatingPointType theValue);
215 SetLineWidth(vtkFloatingPointType theLineWidth);
221 //----------------------------------------------------------------------------
224 AddToRender( vtkRenderer* );
228 RemoveFromRender( vtkRenderer* );
230 //----------------------------------------------------------------------------
231 //! Just to update visibility of the highlight devices
234 highlight(bool theHighlight);
236 //! To process prehighlight (called from #SVTK_InteractorStyle)
239 PreHighlight(vtkInteractorStyle* theInteractorStyle,
240 SVTK_SelectionEvent* theSelectionEvent,
241 bool theIsHighlight);
243 //! To process highlight (called from #SVTK_InteractorStyle)
246 Highlight(vtkInteractorStyle* theInteractorStyle,
247 SVTK_SelectionEvent* theSelectionEvent,
248 bool theIsHighlight);
250 //! Internal highlight.
253 Highlight(bool theIsHighlight);
257 SetVTKMapping(bool theIsVTKMapping);
261 IsVTKMapping() const;
267 //! Gets memory size used by the instance (bytes).
272 //----------------------------------------------------------------------------
275 GetNodeObjId(vtkIdType theID);
279 GetNodeVTKID(vtkIdType theID);
282 vtkFloatingPointType*
283 GetNodeCoord(vtkIdType theObjID);
287 GetElemObjId(vtkIdType theID);
291 GetElemVTKID(vtkIdType theID);
295 GetElemCell(vtkIdType theObjID);
297 //----------------------------------------------------------------------------
298 virtual void RemoveAllClippingPlanes();
300 virtual vtkIdType GetNumberOfClippingPlanes();
302 virtual bool AddClippingPlane(vtkPlane* thePlane);
304 virtual vtkPlane* GetClippingPlane(vtkIdType theID);
306 virtual vtkImplicitFunctionCollection* GetClippingPlanes();
308 //----------------------------------------------------------------------------
309 //! Apply the picking settings on the actor.
311 UpdatePickingSettings();
313 //----------------------------------------------------------------------------
314 //! Methods for values labeling
317 SetValuesLabeled( const bool theIsValLabeled );
321 GetValuesLabeled() const;
328 GetsValLabelsProps() const;
338 SetMapperInput(vtkDataSet* theDataSet) = 0;
344 //----------------------------------------------------------------------------
346 isSubElementsHighlighted();
348 //----------------------------------------------------------------------------
349 vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
351 //! Main process VTK event method
354 ProcessEvents(vtkObject* theObject,
355 unsigned long theEvent,
359 //----------------------------------------------------------------------------
364 //----------------------------------------------------------------------------
366 vtkFloatingPointType myPriority;
368 VISU::Prs3d_i* myPrs3d;
369 vtkSmartPointer<VISU_PipeLine> myPipeLine;
371 vtkSmartPointer<VTKViewer_ShrinkFilter> myShrinkFilter;
375 vtkSmartPointer<vtkTextMapper> myAnnotationMapper;
376 vtkSmartPointer<vtkTextActor> myAnnotationActor;
378 vtkSmartPointer<VISU_FramedTextActor> myTextActor;
380 vtkSmartPointer<vtkFeatureEdges> myFeatureEdges;
381 bool myIsFeatureEdgesAllowed;
382 bool myIsFeatureEdgesEnabled;
384 Selection_Mode myLastSelectionMode;
385 bool myIsSubElementsHighlighted;
387 // fields for values labeling
389 vtkDataSet* myValLblDataSet;
390 vtkActor2D* myValLabels;
391 vtkMaskPoints* myValMaskPoints;
392 vtkCellCenters* myValCellCenters;
393 vtkLabeledDataMapper* myValLabeledDataMapper;
394 vtkSelectVisiblePoints* myValSelectVisiblePoints;
397 #endif //VISU_ACTOR_H