0025747: Bad IGES file after import and export with different units
[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
19#include <AIS_Drawer.hxx>
20#include <AIS_Shape.hxx>
21
22#include <NCollection_DataMap.hxx>
23#include <NCollection_IndexedDataMap.hxx>
24#include <TopTools_ShapeMapHasher.hxx>
25#include <TopoDS_Compound.hxx>
26
27//! Customizable properties.
28class AIS_ColoredDrawer : public AIS_Drawer
29{
30public:
31
32 AIS_ColoredDrawer (const Handle(AIS_Drawer)& theLink)
86766b0e 33 : myIsHidden (Standard_False),
34 myHasOwnColor (Standard_False),
ad3217cd 35 myHasOwnWidth (Standard_False)
36 {
37 Link (theLink);
38 }
39
86766b0e 40 Standard_Boolean IsHidden() const { return myIsHidden; }
41 void SetHidden (const Standard_Boolean theToHide) { myIsHidden = theToHide; }
ad3217cd 42 Standard_Boolean HasOwnColor() const { return myHasOwnColor; }
43 void UnsetOwnColor() { myHasOwnColor = Standard_False; }
44 void SetOwnColor (const Quantity_Color& /*theColor*/) { myHasOwnColor = Standard_True; }
45 Standard_Boolean HasOwnWidth() const { return myHasOwnWidth; }
46 void UnsetOwnWidth() { myHasOwnWidth = Standard_False; }
47 void SetOwnWidth (const Standard_Real /*theWidth*/) { myHasOwnWidth = Standard_True; }
48
49public: //! @name list of overridden properties
50
86766b0e 51 Standard_Boolean myIsHidden;
ad3217cd 52 Standard_Boolean myHasOwnColor;
53 Standard_Boolean myHasOwnWidth;
54
55public:
56 DEFINE_STANDARD_RTTI(AIS_ColoredDrawer);
57
58};
59
60DEFINE_STANDARD_HANDLE(AIS_ColoredDrawer, AIS_Drawer)
61
62//! Presentation of the shape with customizable sub-shapes properties.
63class AIS_ColoredShape : public AIS_Shape
64{
65public:
66
67 //! Default constructor
68 Standard_EXPORT AIS_ColoredShape (const TopoDS_Shape& theShape);
69
70 //! Copy constructor
71 Standard_EXPORT AIS_ColoredShape (const Handle(AIS_Shape)& theShape);
72
73public: //! @name sub-shape aspects
74
75 //! Customize properties of specified sub-shape.
76 //! The shape will be stored in the map but ignored, if it is not sub-shape of main Shape!
77 //! This method can be used to mark sub-shapes with customizable properties.
78 Standard_EXPORT Handle(AIS_ColoredDrawer) CustomAspects (const TopoDS_Shape& theShape);
79
80 //! Reset the map of custom sub-shape aspects.
81 Standard_EXPORT void ClearCustomAspects();
82
83 //! Reset custom properties of specified sub-shape.
84 //! @param theToUnregister unregister or not sub-shape from the map
85 Standard_EXPORT void UnsetCustomAspects (const TopoDS_Shape& theShape,
86 const Standard_Boolean theToUnregister = Standard_False);
87
88 //! Customize color of specified sub-shape
89 Standard_EXPORT void SetCustomColor (const TopoDS_Shape& theShape,
90 const Quantity_Color& theColor);
91
92 //! Customize line width of specified sub-shape
93 Standard_EXPORT void SetCustomWidth (const TopoDS_Shape& theShape,
94 const Standard_Real theLineWidth);
95
96public: //! @name global aspects
97
98 //! Setup color of entire shape.
a3157439 99 Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;
ad3217cd 100
101 //! Setup line width of entire shape.
a3157439 102 Standard_EXPORT virtual void SetWidth (const Standard_Real theLineWidth) Standard_OVERRIDE;
ad3217cd 103
104 //! Sets transparency value.
a3157439 105 Standard_EXPORT virtual void SetTransparency (const Standard_Real theValue) Standard_OVERRIDE;
ad3217cd 106
e0608a8d 107 //! Sets the material aspect.
108 Standard_EXPORT virtual void SetMaterial (const Graphic3d_MaterialAspect& theAspect) Standard_OVERRIDE;
109
ad3217cd 110protected: //! @name override presentation computation
111
112 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
113 const Handle(Prs3d_Presentation)& thePrs,
a3157439 114 const Standard_Integer theMode) Standard_OVERRIDE;
ad3217cd 115
116protected:
117
118 typedef NCollection_DataMap<TopoDS_Shape, Handle(AIS_ColoredDrawer), TopTools_ShapeMapHasher> DataMapOfShapeColor;
119 typedef NCollection_DataMap<TopoDS_Shape, TopoDS_Shape, TopTools_ShapeMapHasher> DataMapOfShapeShape;
120 typedef NCollection_IndexedDataMap<TopoDS_Shape, TopoDS_Compound, TopTools_ShapeMapHasher> DataMapOfShapeCompd;
121
122protected:
123
124 //! Recursive function to map shapes.
125 //! @param theBaseKey the key to be used for undetailed shapes (default colors)
126 //! @param theSubshapeToParse the subshape to be parsed
127 //! @param theSubshapeKeyshapeMap shapes map Subshape (in the base shape) -> Keyshape (detailed shape)
128 //! @param theParentType the parent subshape type
129 //! @param theTypeKeyshapeDrawshapeArray the array of shape types to fill
130 Standard_EXPORT static Standard_Boolean dispatchColors (const TopoDS_Shape& theBaseKey,
131 const TopoDS_Shape& theSubshapeToParse,
132 const DataMapOfShapeShape& theSubshapeKeyshapeMap,
133 const TopAbs_ShapeEnum theParentType,
134 DataMapOfShapeCompd* theTypeKeyshapeDrawshapeArray);
135
136 Standard_EXPORT static void dispatchColors (const TopoDS_Shape& theBaseShape,
137 const DataMapOfShapeColor& theKeyshapeColorMap,
138 DataMapOfShapeCompd* theTypeKeyshapeDrawshapeArray);
139
140protected:
141
142 DataMapOfShapeColor myShapeColors;
143
144public:
145
146 DEFINE_STANDARD_RTTI(AIS_ColoredShape);
147
148};
149
150DEFINE_STANDARD_HANDLE(AIS_ColoredShape, AIS_Shape)
151
152#endif // _AIS_ColoredShape_HeaderFile