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>
24 // prevent disabling some MSVC warning messages by VTK headers
25 #include <Standard_WarningsDisable.hxx>
27 #include <vtkPolyData.h>
28 #include <vtkPolyDataMapper.h>
29 #include <vtkRenderer.h>
30 #include <vtkSmartPointer.h>
31 #include <Standard_WarningsRestore.hxx>
33 #include <IVtk_Types.hxx>
34 #include <IVtkTools_DisplayModeFilter.hxx>
35 #include <IVtkTools_SubPolyDataFilter.hxx>
37 typedef NCollection_DataMap <IVtk_IdType, vtkSmartPointer<IVtkTools_DisplayModeFilter> > DisplayModeFiltersMap;
38 typedef NCollection_DataMap <IVtk_IdType, vtkSmartPointer<IVtkTools_SubPolyDataFilter> > SubShapesFiltersMap;
40 class IVtkDraw_HighlightAndSelectionPipeline;
41 DEFINE_STANDARD_HANDLE(IVtkDraw_HighlightAndSelectionPipeline, Standard_Transient)
43 class IVtkDraw_HighlightAndSelectionPipeline : public Standard_Transient
47 DEFINE_STANDARD_RTTIEXT(IVtkDraw_HighlightAndSelectionPipeline,Standard_Transient)
51 //! Filters comprising the pipeline.
54 Filter_DM_Shape = 1, //!< Display Mode filter for shape.
55 Filter_DM_Hili, //!< Display Mode filter for highlighting.
56 Filter_DM_Sel, //!< Display Mode filter for selection.
57 Filter_SUB_Hili, //!< Sub-shapes filter for highlighting.
58 Filter_SUB_Sel //!< Sub-shapes filter for selection.
63 IVtkDraw_HighlightAndSelectionPipeline (const TopoDS_Shape& theShape,
64 const Standard_Integer theShapeID);
65 ~IVtkDraw_HighlightAndSelectionPipeline() {}
69 void AddToRenderer (vtkRenderer* theRenderer);
70 void RemoveFromRenderer (vtkRenderer* theRenderer);
72 inline vtkActor* Actor() { return myActor; }
73 inline vtkMapper* Mapper() { return myMapper; }
75 void ClearHighlightFilters();
76 void ClearSelectionFilters();
78 IVtkTools_DisplayModeFilter* GetDisplayModeFilter();
79 IVtkTools_SubPolyDataFilter* GetHighlightFilter();
80 IVtkTools_SubPolyDataFilter* GetSelectionFilter();
81 IVtkTools_DisplayModeFilter* GetHighlightDMFilter();
82 IVtkTools_DisplayModeFilter* GetSelectionDMFilter();
84 void SharedVerticesSelectionOn();
85 void SharedVerticesSelectionOff();
89 //! Auxiliary map of internal filters by their correspondent IDs.
90 typedef NCollection_DataMap <FilterId, vtkSmartPointer<vtkAlgorithm> > FilterMap;
95 vtkSmartPointer<vtkActor> myActor;
98 vtkSmartPointer<vtkPolyDataMapper> myMapper;
100 //! Actor for highlighting.
101 vtkSmartPointer<vtkActor> myHiliActor;
103 //! Polygonal mapper for highlighting.
104 vtkSmartPointer<vtkPolyDataMapper> myHiliMapper;
106 //! Actor for selection.
107 vtkSmartPointer<vtkActor> mySelActor;
109 //! Polygonal mapper for selection.
110 vtkSmartPointer<vtkPolyDataMapper> mySelMapper;
112 //! Map of involved VTK filters.
113 FilterMap myFilterMap;
117 //! Mapping between OCCT topological shape IDs and their correspondent
118 //! visualization pipelines.
119 typedef NCollection_Shared< NCollection_DataMap<IVtk_IdType, Handle(IVtkDraw_HighlightAndSelectionPipeline)> > ShapePipelineMap;