1 // Created on: 2012-04-02
3 // Copyright (c) 2012-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _IVtkDraw_HighlightAndSelectionPipeline_HeaderFile
17 #define _IVtkDraw_HighlightAndSelectionPipeline_HeaderFile
19 #include <NCollection_DataMap.hxx>
20 #include <NCollection_Shared.hxx>
21 #include <Standard_Transient.hxx>
22 #include <TopoDS_Shape.hxx>
25 #include <vtkPolyData.h>
26 #include <vtkPolyDataMapper.h>
27 #include <vtkRenderer.h>
28 #include <vtkSmartPointer.h>
30 #include <IVtk_Types.hxx>
31 #include <IVtkTools_DisplayModeFilter.hxx>
32 #include <IVtkTools_SubPolyDataFilter.hxx>
34 typedef NCollection_DataMap <IVtk_IdType, vtkSmartPointer<IVtkTools_DisplayModeFilter> > DisplayModeFiltersMap;
35 typedef NCollection_DataMap <IVtk_IdType, vtkSmartPointer<IVtkTools_SubPolyDataFilter> > SubShapesFiltersMap;
37 class IVtkDraw_HighlightAndSelectionPipeline;
38 DEFINE_STANDARD_HANDLE(IVtkDraw_HighlightAndSelectionPipeline, Standard_Transient)
40 class IVtkDraw_HighlightAndSelectionPipeline : public Standard_Transient
44 DEFINE_STANDARD_RTTIEXT(IVtkDraw_HighlightAndSelectionPipeline,Standard_Transient)
48 //! Filters comprising the pipeline.
51 Filter_DM_Shape = 1, //!< Display Mode filter for shape.
52 Filter_DM_Hili, //!< Display Mode filter for highlighting.
53 Filter_DM_Sel, //!< Display Mode filter for selection.
54 Filter_SUB_Hili, //!< Sub-shapes filter for highlighting.
55 Filter_SUB_Sel //!< Sub-shapes filter for selection.
60 IVtkDraw_HighlightAndSelectionPipeline (const TopoDS_Shape& theShape,
61 const Standard_Integer theShapeID);
62 ~IVtkDraw_HighlightAndSelectionPipeline() {}
66 void AddToRenderer (vtkRenderer* theRenderer);
67 void RemoveFromRenderer (vtkRenderer* theRenderer);
69 inline vtkActor* Actor() { return myActor; }
70 inline vtkMapper* Mapper() { return myMapper; }
72 void ClearHighlightFilters();
73 void ClearSelectionFilters();
75 IVtkTools_DisplayModeFilter* GetDisplayModeFilter();
76 IVtkTools_SubPolyDataFilter* GetHighlightFilter();
77 IVtkTools_SubPolyDataFilter* GetSelectionFilter();
78 IVtkTools_DisplayModeFilter* GetHighlightDMFilter();
79 IVtkTools_DisplayModeFilter* GetSelectionDMFilter();
81 void SharedVerticesSelectionOn();
82 void SharedVerticesSelectionOff();
86 //! Auxiliary map of internal filters by their correspondent IDs.
87 typedef NCollection_DataMap <FilterId, vtkSmartPointer<vtkAlgorithm> > FilterMap;
92 vtkSmartPointer<vtkActor> myActor;
95 vtkSmartPointer<vtkPolyDataMapper> myMapper;
97 //! Actor for highlighting.
98 vtkSmartPointer<vtkActor> myHiliActor;
100 //! Polygonal mapper for highlighting.
101 vtkSmartPointer<vtkPolyDataMapper> myHiliMapper;
103 //! Actor for selection.
104 vtkSmartPointer<vtkActor> mySelActor;
106 //! Polygonal mapper for selection.
107 vtkSmartPointer<vtkPolyDataMapper> mySelMapper;
109 //! Map of involved VTK filters.
110 FilterMap myFilterMap;
114 //! Mapping between OCCT topological shape IDs and their correspondent
115 //! visualization pipelines.
116 typedef NCollection_Shared< NCollection_DataMap<IVtk_IdType, Handle(IVtkDraw_HighlightAndSelectionPipeline)> > ShapePipelineMap;