0029056: Configuration - It is not possible to install VTK products
[occt.git] / src / AIS / AIS_ColoredShape.hxx
CommitLineData
ad3217cd 1// Created on: 2014-04-24
2// Created by: Kirill Gavrilov
3// Copyright (c) 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 _AIS_ColoredShape_HeaderFile
17#define _AIS_ColoredShape_HeaderFile
18
fb66bb28 19#include <AIS_DataMapOfShapeDrawer.hxx>
ad3217cd 20#include <AIS_Shape.hxx>
ad3217cd 21#include <NCollection_IndexedDataMap.hxx>
5bffb882 22#include <StdPrs_Volume.hxx>
fb66bb28 23#include <TopoDS_Compound.hxx>
9c86076b 24#include <TopTools_MapOfShape.hxx>
25#include <TColStd_MapTransientHasher.hxx>
ad3217cd 26
27//! Presentation of the shape with customizable sub-shapes properties.
28class AIS_ColoredShape : public AIS_Shape
29{
30public:
31
32 //! Default constructor
33 Standard_EXPORT AIS_ColoredShape (const TopoDS_Shape& theShape);
34
35 //! Copy constructor
36 Standard_EXPORT AIS_ColoredShape (const Handle(AIS_Shape)& theShape);
37
38public: //! @name sub-shape aspects
39
40 //! Customize properties of specified sub-shape.
41 //! The shape will be stored in the map but ignored, if it is not sub-shape of main Shape!
42 //! This method can be used to mark sub-shapes with customizable properties.
e5b8456d 43 Standard_EXPORT virtual Handle(AIS_ColoredDrawer) CustomAspects (const TopoDS_Shape& theShape);
ad3217cd 44
45 //! Reset the map of custom sub-shape aspects.
e5b8456d 46 Standard_EXPORT virtual void ClearCustomAspects();
ad3217cd 47
48 //! Reset custom properties of specified sub-shape.
49 //! @param theToUnregister unregister or not sub-shape from the map
50 Standard_EXPORT void UnsetCustomAspects (const TopoDS_Shape& theShape,
51 const Standard_Boolean theToUnregister = Standard_False);
52
53 //! Customize color of specified sub-shape
54 Standard_EXPORT void SetCustomColor (const TopoDS_Shape& theShape,
55 const Quantity_Color& theColor);
56
57 //! Customize line width of specified sub-shape
58 Standard_EXPORT void SetCustomWidth (const TopoDS_Shape& theShape,
59 const Standard_Real theLineWidth);
60
fb66bb28 61 //! Return the map of custom aspects.
62 const AIS_DataMapOfShapeDrawer& CustomAspectsMap() const { return myShapeColors; }
63
64 //! Return the map of custom aspects.
65 AIS_DataMapOfShapeDrawer& ChangeCustomAspectsMap() { return myShapeColors; }
66
ad3217cd 67public: //! @name global aspects
68
69 //! Setup color of entire shape.
a3157439 70 Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;
ad3217cd 71
72 //! Setup line width of entire shape.
a3157439 73 Standard_EXPORT virtual void SetWidth (const Standard_Real theLineWidth) Standard_OVERRIDE;
ad3217cd 74
75 //! Sets transparency value.
a3157439 76 Standard_EXPORT virtual void SetTransparency (const Standard_Real theValue) Standard_OVERRIDE;
ad3217cd 77
f6d4c5cf 78 //! Removes the setting for transparency in the reconstructed compound shape.
79 Standard_EXPORT virtual void UnsetTransparency() Standard_OVERRIDE;
80
e0608a8d 81 //! Sets the material aspect.
82 Standard_EXPORT virtual void SetMaterial (const Graphic3d_MaterialAspect& theAspect) Standard_OVERRIDE;
83
ad3217cd 84protected: //! @name override presentation computation
85
86 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
87 const Handle(Prs3d_Presentation)& thePrs,
a3157439 88 const Standard_Integer theMode) Standard_OVERRIDE;
ad3217cd 89
90protected:
91
9c86076b 92 typedef NCollection_IndexedDataMap<Handle(AIS_ColoredDrawer), TopoDS_Compound, TColStd_MapTransientHasher> DataMapOfDrawerCompd;
ad3217cd 93
94protected:
95
96 //! Recursive function to map shapes.
9c86076b 97 //! @param theParentDrawer the drawer to be used for undetailed shapes (default colors)
98 //! @param theShapeToParse the subshape to be recursively parsed
99 //! @param theShapeDrawerMap shapes map Subshape (in the base shape) -> Drawer
100 //! @param theParentType the parent subshape type
101 //! @param theIsParentClosed flag indicating that specified shape is part of closed Solid
102 //! @param theDrawerOpenedShapePerType the array of shape types to fill
103 //! @param theDrawerClosedFaces the map for closed faces
104 Standard_EXPORT static Standard_Boolean dispatchColors (const Handle(AIS_ColoredDrawer)& theParentDrawer,
105 const TopoDS_Shape& theShapeToParse,
106 const AIS_DataMapOfShapeDrawer& theShapeDrawerMap,
107 const TopAbs_ShapeEnum theParentType,
108 const Standard_Boolean theIsParentClosed,
109 DataMapOfDrawerCompd* theDrawerOpenedShapePerType,
110 DataMapOfDrawerCompd& theDrawerClosedFaces);
ad3217cd 111protected:
112
5bffb882 113 //! Add shape to presentation
9c86076b 114 //! @param thePrs the presentation
115 //! @param theDrawerOpenedShapePerType the shapes map with unique attributes
116 //! @param theDrawerClosedFaces the map of attributes for closed faces
117 //! @param theMode display mode
5bffb882 118 Standard_EXPORT void addShapesWithCustomProps (const Handle(Prs3d_Presentation)& thePrs,
9c86076b 119 const DataMapOfDrawerCompd* theDrawerOpenedShapePerType,
120 const DataMapOfDrawerCompd& theDrawerClosedFaces,
121 const Standard_Integer theMode);
5bffb882 122
123 //! Check all shapes from myShapeColorsfor visibility
124 Standard_EXPORT Standard_Boolean isShapeEntirelyVisible() const;
125
5bffb882 126 //! Resolve (parse) theKeyShape into subshapes, search in they for theBaseShape,
9c86076b 127 //! bind all resolved subshapes with theOriginKeyShape and store all binds in theShapeDrawerMap
128 //! @param theShapeDrawerMap shapes map: resolved and found theBaseShape subshape -> theOriginKeyShape
129 //! @param theKeyShape a shape to be resolved (parse) into smaller (in topological sense)
130 //! subshapes for new bind cycle
131 //! @param theDrawer assigned drawer
132 Standard_EXPORT void bindSubShapes (AIS_DataMapOfShapeDrawer& theShapeDrawerMap,
133 const TopoDS_Shape& theKeyShape,
134 const Handle(AIS_ColoredDrawer)& theDrawer);
5bffb882 135
136protected:
137
fb66bb28 138 AIS_DataMapOfShapeDrawer myShapeColors;
ad3217cd 139
140public:
141
a3f6f591 142 DEFINE_STANDARD_RTTIEXT(AIS_ColoredShape,AIS_Shape)
ad3217cd 143
144};
145
146DEFINE_STANDARD_HANDLE(AIS_ColoredShape, AIS_Shape)
147
148#endif // _AIS_ColoredShape_HeaderFile