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