0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / IVtkDraw / IVtkDraw_HighlightAndSelectionPipeline.hxx
CommitLineData
52f99d93 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
52f99d93 19#include <NCollection_DataMap.hxx>
c04c30b3 20#include <NCollection_Shared.hxx>
52f99d93 21#include <Standard_Transient.hxx>
22#include <TopoDS_Shape.hxx>
23
a9660929 24// prevent disabling some MSVC warning messages by VTK headers
25#ifdef _MSC_VER
26#pragma warning(push)
27#endif
52f99d93 28#include <vtkActor.h>
29#include <vtkPolyData.h>
30#include <vtkPolyDataMapper.h>
31#include <vtkRenderer.h>
32#include <vtkSmartPointer.h>
a9660929 33#ifdef _MSC_VER
34#pragma warning(pop)
35#endif
52f99d93 36
37#include <IVtk_Types.hxx>
38#include <IVtkTools_DisplayModeFilter.hxx>
39#include <IVtkTools_SubPolyDataFilter.hxx>
40
41typedef NCollection_DataMap <IVtk_IdType, vtkSmartPointer<IVtkTools_DisplayModeFilter> > DisplayModeFiltersMap;
42typedef NCollection_DataMap <IVtk_IdType, vtkSmartPointer<IVtkTools_SubPolyDataFilter> > SubShapesFiltersMap;
43
c04c30b3 44class IVtkDraw_HighlightAndSelectionPipeline;
52f99d93 45DEFINE_STANDARD_HANDLE(IVtkDraw_HighlightAndSelectionPipeline, Standard_Transient)
46
47class IVtkDraw_HighlightAndSelectionPipeline : public Standard_Transient
48{
49public:
50
92efcf78 51 DEFINE_STANDARD_RTTIEXT(IVtkDraw_HighlightAndSelectionPipeline,Standard_Transient)
52f99d93 52
53public:
54
55 //! Filters comprising the pipeline.
56 enum FilterId
57 {
58 Filter_DM_Shape = 1, //!< Display Mode filter for shape.
59 Filter_DM_Hili, //!< Display Mode filter for highlighting.
60 Filter_DM_Sel, //!< Display Mode filter for selection.
61 Filter_SUB_Hili, //!< Sub-shapes filter for highlighting.
62 Filter_SUB_Sel //!< Sub-shapes filter for selection.
63 };
64
65public:
66
67 IVtkDraw_HighlightAndSelectionPipeline (const TopoDS_Shape& theShape,
68 const Standard_Integer theShapeID);
69 ~IVtkDraw_HighlightAndSelectionPipeline() {}
70
71public:
72
73 void AddToRenderer (vtkRenderer* theRenderer);
74 void RemoveFromRenderer (vtkRenderer* theRenderer);
75
76 inline vtkActor* Actor() { return myActor; }
77 inline vtkMapper* Mapper() { return myMapper; }
78
79 void ClearHighlightFilters();
80 void ClearSelectionFilters();
81
82 IVtkTools_DisplayModeFilter* GetDisplayModeFilter();
83 IVtkTools_SubPolyDataFilter* GetHighlightFilter();
84 IVtkTools_SubPolyDataFilter* GetSelectionFilter();
85 IVtkTools_DisplayModeFilter* GetHighlightDMFilter();
86 IVtkTools_DisplayModeFilter* GetSelectionDMFilter();
87
88 void SharedVerticesSelectionOn();
89 void SharedVerticesSelectionOff();
90
91private:
92
93 //! Auxiliary map of internal filters by their correspondent IDs.
94 typedef NCollection_DataMap <FilterId, vtkSmartPointer<vtkAlgorithm> > FilterMap;
95
96private:
97
98 //! Actor.
99 vtkSmartPointer<vtkActor> myActor;
100
101 //! Polygonal mapper.
102 vtkSmartPointer<vtkPolyDataMapper> myMapper;
103
104 //! Actor for highlighting.
105 vtkSmartPointer<vtkActor> myHiliActor;
106
107 //! Polygonal mapper for highlighting.
108 vtkSmartPointer<vtkPolyDataMapper> myHiliMapper;
109
110 //! Actor for selection.
111 vtkSmartPointer<vtkActor> mySelActor;
112
113 //! Polygonal mapper for selection.
114 vtkSmartPointer<vtkPolyDataMapper> mySelMapper;
115
116 //! Map of involved VTK filters.
117 FilterMap myFilterMap;
118
119};
120
121//! Mapping between OCCT topological shape IDs and their correspondent
122//! visualization pipelines.
c04c30b3 123typedef NCollection_Shared< NCollection_DataMap<IVtk_IdType, Handle(IVtkDraw_HighlightAndSelectionPipeline)> > ShapePipelineMap;
52f99d93 124
125#endif