b311480e |
1 | // Created by: NW,JPB,CAL |
2 | // Copyright (c) 1991-1999 Matra Datavision |
973c2be1 |
3 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
b311480e |
6 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
b311480e |
15 | |
81bba717 |
16 | //-Design Declaration of variables specific to the context |
17 | // of tracing of facets 3D |
7fd59977 |
18 | |
81bba717 |
19 | //-Warning Ccontext of tracing of facets 3d inherits the context |
20 | // defined by : |
21 | // - the style of the interior of the facet |
22 | // - the style of the facet border |
23 | // - the color |
24 | // Additionally, it has more than one definition of material |
25 | // for internal and external faces. |
7fd59977 |
26 | |
7fd59977 |
27 | // for the class |
28 | #include <Graphic3d_AspectFillArea3d.ixx> |
29 | |
7fd59977 |
30 | #include <Aspect_PolygonOffsetMode.hxx> |
7fd59977 |
31 | #include <Standard_Boolean.hxx> |
32 | |
7fd59977 |
33 | Graphic3d_AspectFillArea3d::Graphic3d_AspectFillArea3d (): |
de75ed09 |
34 | DistinguishModeActive (Standard_False), EdgeModeActive (Standard_False), BackFaceRemovalActive (Standard_False), MyTextureMapState(Standard_False), MyFrontMaterial (), MyBackMaterial () |
35 | { |
7fd59977 |
36 | // By default, aspect do not change current polygon offset parameters |
60761105 |
37 | MyPolygonOffsetMode = Aspect_POM_Fill; |
7fd59977 |
38 | MyPolygonOffsetFactor = 1.; |
39 | MyPolygonOffsetUnits = 0.; |
7fd59977 |
40 | } |
41 | |
81bba717 |
42 | // (InteriorStyle, InteriorColor, EdgeColor, EdgeLineType, EdgeLineWidth) |
43 | // because AspectFillArea3d inherits AspectFillArea and it is necessary to call |
44 | // initialisation of AspectFillArea with InteriorStyle, InteriorColor, |
45 | // EdgeColor, EdgeLineType and EdgeLineWidth. |
7fd59977 |
46 | |
47 | Graphic3d_AspectFillArea3d::Graphic3d_AspectFillArea3d (const Aspect_InteriorStyle InteriorStyle, const Quantity_Color& InteriorColor, const Quantity_Color& EdgeColor, const Aspect_TypeOfLine EdgeLineType, const Standard_Real EdgeLineWidth, const Graphic3d_MaterialAspect& FrontMaterial, const Graphic3d_MaterialAspect& BackMaterial): |
48 | Aspect_AspectFillArea (InteriorStyle, InteriorColor, EdgeColor, EdgeLineType, EdgeLineWidth), DistinguishModeActive (Standard_False), EdgeModeActive (Standard_False), BackFaceRemovalActive (Standard_False), MyTextureMap(), MyTextureMapState(Standard_False), MyFrontMaterial (FrontMaterial), MyBackMaterial (BackMaterial) { |
7fd59977 |
49 | // By default, aspect do not change current polygon offset parameters |
60761105 |
50 | MyPolygonOffsetMode = Aspect_POM_Fill; |
7fd59977 |
51 | MyPolygonOffsetFactor = 1.; |
52 | MyPolygonOffsetUnits = 0.; |
7fd59977 |
53 | } |
54 | |
55 | void Graphic3d_AspectFillArea3d::SetBackMaterial (const Graphic3d_MaterialAspect& AMaterial) { |
56 | |
57 | MyBackMaterial = AMaterial; |
58 | |
59 | } |
60 | |
61 | void Graphic3d_AspectFillArea3d::SetFrontMaterial (const Graphic3d_MaterialAspect& AMaterial) { |
62 | |
63 | MyFrontMaterial = AMaterial; |
64 | |
65 | } |
66 | |
63bcc448 |
67 | const Graphic3d_MaterialAspect& Graphic3d_AspectFillArea3d::BackMaterial() const |
68 | { |
69 | return MyBackMaterial; |
7fd59977 |
70 | } |
71 | |
63bcc448 |
72 | const Graphic3d_MaterialAspect& Graphic3d_AspectFillArea3d::FrontMaterial() const |
73 | { |
74 | return MyFrontMaterial; |
7fd59977 |
75 | } |
76 | |
77 | void Graphic3d_AspectFillArea3d::AllowBackFace () { |
78 | |
79 | BackFaceRemovalActive = Standard_False; |
80 | |
81 | } |
82 | |
83 | void Graphic3d_AspectFillArea3d::SuppressBackFace () { |
84 | |
85 | BackFaceRemovalActive = Standard_True; |
86 | |
87 | } |
88 | |
89 | Standard_Boolean Graphic3d_AspectFillArea3d::BackFace () const { |
90 | |
91 | return (BackFaceRemovalActive); |
92 | |
93 | } |
94 | |
95 | void Graphic3d_AspectFillArea3d::SetDistinguishOn () { |
96 | |
97 | DistinguishModeActive = Standard_True; |
98 | |
99 | } |
100 | |
101 | void Graphic3d_AspectFillArea3d::SetDistinguishOff () { |
102 | |
103 | DistinguishModeActive = Standard_False; |
104 | |
105 | } |
106 | |
107 | Standard_Boolean Graphic3d_AspectFillArea3d::Distinguish () const { |
108 | |
109 | return (DistinguishModeActive); |
110 | |
111 | } |
112 | |
113 | void Graphic3d_AspectFillArea3d::SetEdgeOn () { |
114 | |
115 | EdgeModeActive = Standard_True; |
116 | |
117 | } |
118 | |
119 | void Graphic3d_AspectFillArea3d::SetEdgeOff () { |
120 | |
121 | EdgeModeActive = Standard_False; |
122 | |
123 | } |
124 | |
125 | |
126 | void Graphic3d_AspectFillArea3d::SetTextureMap(const Handle(Graphic3d_TextureMap)& ATexture) |
127 | { |
128 | MyTextureMap = ATexture; |
129 | } |
130 | |
131 | |
132 | void Graphic3d_AspectFillArea3d::SetTextureMapOn() |
133 | { |
134 | MyTextureMapState = Standard_True; |
135 | } |
136 | |
137 | |
138 | void Graphic3d_AspectFillArea3d::SetTextureMapOff() |
139 | { |
140 | MyTextureMapState = Standard_False; |
141 | } |
142 | |
143 | |
144 | Standard_Boolean Graphic3d_AspectFillArea3d::Edge () const { |
145 | |
146 | return (EdgeModeActive); |
147 | |
148 | } |
149 | |
150 | |
151 | Handle(Graphic3d_TextureMap) Graphic3d_AspectFillArea3d::TextureMap() const |
152 | { |
153 | return MyTextureMap; |
154 | } |
155 | |
156 | |
157 | Standard_Boolean Graphic3d_AspectFillArea3d::TextureMapState() const |
158 | { |
159 | return MyTextureMapState; |
160 | } |
161 | |
60be1f9b |
162 | void Graphic3d_AspectFillArea3d::SetPolygonOffsets(const Standard_Integer aMode, |
163 | const Standard_ShortReal aFactor, |
164 | const Standard_ShortReal aUnits) { |
7fd59977 |
165 | MyPolygonOffsetMode = ( aMode & Aspect_POM_Mask ); |
166 | MyPolygonOffsetFactor = aFactor; |
167 | MyPolygonOffsetUnits = aUnits; |
168 | } |
169 | |
60be1f9b |
170 | void Graphic3d_AspectFillArea3d::PolygonOffsets(Standard_Integer& aMode, |
171 | Standard_ShortReal& aFactor, |
172 | Standard_ShortReal& aUnits) const { |
7fd59977 |
173 | aMode = MyPolygonOffsetMode; |
174 | aFactor = MyPolygonOffsetFactor; |
175 | aUnits = MyPolygonOffsetUnits; |
176 | } |
30f0ad28 |
177 | |
178 | void Graphic3d_AspectFillArea3d::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram) |
179 | { |
180 | MyShaderProgram = theProgram; |
181 | } |
182 | |
183 | const Handle(Graphic3d_ShaderProgram)& Graphic3d_AspectFillArea3d::ShaderProgram() const |
184 | { |
185 | return MyShaderProgram; |
186 | } |