Warnings on vc14 were eliminated
[occt.git] / src / IVtkDraw / IVtkDraw_HighlightAndSelectionPipeline.hxx
1 // Created on: 2012-04-02 
2
3 // Copyright (c) 2012-2014 OPEN CASCADE SAS 
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _IVtkDraw_HighlightAndSelectionPipeline_HeaderFile
17 #define _IVtkDraw_HighlightAndSelectionPipeline_HeaderFile
18
19 #include <NCollection_DataMap.hxx>
20 #include <NCollection_Shared.hxx>
21 #include <Standard_Transient.hxx>
22 #include <TopoDS_Shape.hxx>
23
24 #include <vtkActor.h>
25 #include <vtkPolyData.h>
26 #include <vtkPolyDataMapper.h>
27 #include <vtkRenderer.h>
28 #include <vtkSmartPointer.h>
29
30 #include <IVtk_Types.hxx>
31 #include <IVtkTools_DisplayModeFilter.hxx>
32 #include <IVtkTools_SubPolyDataFilter.hxx>
33
34 typedef NCollection_DataMap <IVtk_IdType, vtkSmartPointer<IVtkTools_DisplayModeFilter> > DisplayModeFiltersMap;
35 typedef NCollection_DataMap <IVtk_IdType, vtkSmartPointer<IVtkTools_SubPolyDataFilter> > SubShapesFiltersMap;
36
37 class IVtkDraw_HighlightAndSelectionPipeline;
38 DEFINE_STANDARD_HANDLE(IVtkDraw_HighlightAndSelectionPipeline, Standard_Transient)
39
40 class IVtkDraw_HighlightAndSelectionPipeline : public Standard_Transient
41 {
42 public:
43
44   DEFINE_STANDARD_RTTIEXT(IVtkDraw_HighlightAndSelectionPipeline,Standard_Transient)
45
46 public:
47
48   //! Filters comprising the pipeline.
49   enum FilterId
50   {
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.
56   };
57
58 public:
59
60   IVtkDraw_HighlightAndSelectionPipeline (const TopoDS_Shape& theShape,
61                                           const Standard_Integer theShapeID);
62   ~IVtkDraw_HighlightAndSelectionPipeline() {}
63
64 public:
65
66   void AddToRenderer (vtkRenderer* theRenderer);
67   void RemoveFromRenderer (vtkRenderer* theRenderer);
68
69   inline vtkActor* Actor() { return myActor; }
70   inline vtkMapper* Mapper() { return myMapper; }
71
72   void ClearHighlightFilters();
73   void ClearSelectionFilters();
74
75   IVtkTools_DisplayModeFilter* GetDisplayModeFilter();
76   IVtkTools_SubPolyDataFilter* GetHighlightFilter();
77   IVtkTools_SubPolyDataFilter* GetSelectionFilter();
78   IVtkTools_DisplayModeFilter* GetHighlightDMFilter();
79   IVtkTools_DisplayModeFilter* GetSelectionDMFilter();
80
81   void SharedVerticesSelectionOn();
82   void SharedVerticesSelectionOff();
83
84 private:
85
86   //! Auxiliary map of internal filters by their correspondent IDs.
87   typedef NCollection_DataMap <FilterId, vtkSmartPointer<vtkAlgorithm> > FilterMap;
88
89 private:
90
91   //! Actor.
92   vtkSmartPointer<vtkActor> myActor;
93
94   //! Polygonal mapper.
95   vtkSmartPointer<vtkPolyDataMapper> myMapper;
96
97   //! Actor for highlighting.
98   vtkSmartPointer<vtkActor> myHiliActor;
99
100   //! Polygonal mapper for highlighting.
101   vtkSmartPointer<vtkPolyDataMapper> myHiliMapper;
102
103   //! Actor for selection.
104   vtkSmartPointer<vtkActor> mySelActor;
105
106   //! Polygonal mapper for selection.
107   vtkSmartPointer<vtkPolyDataMapper> mySelMapper;
108
109   //! Map of involved VTK filters.
110   FilterMap myFilterMap;
111
112 };
113
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;
117
118 #endif