0024192: Adding support for shaders to OCCT visualization toolkit
[occt.git] / src / Graphic3d / Graphic3d_AspectFillArea3d.cxx
CommitLineData
b311480e 1// Created by: NW,JPB,CAL
2// Copyright (c) 1991-1999 Matra Datavision
3// Copyright (c) 1999-2012 OPEN CASCADE SAS
4//
5// The content of this file is subject to the Open CASCADE Technology Public
6// License Version 6.5 (the "License"). You may not use the content of this file
7// except in compliance with the License. Please obtain a copy of the License
8// at http://www.opencascade.org and read it completely before using this file.
9//
10// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12//
13// The Original Code and all software distributed under the License is
14// distributed on an "AS IS" basis, without warranty of any kind, and the
15// Initial Developer hereby disclaims all such warranties, including without
16// limitation, any warranties of merchantability, fitness for a particular
17// purpose or non-infringement. Please see the License for the specific terms
18// and conditions governing the rights and limitations under the License.
19
81bba717 20//-Design Declaration of variables specific to the context
21// of tracing of facets 3D
7fd59977 22
81bba717 23//-Warning Ccontext of tracing of facets 3d inherits the context
24// defined by :
25// - the style of the interior of the facet
26// - the style of the facet border
27// - the color
28// Additionally, it has more than one definition of material
29// for internal and external faces.
7fd59977 30
7fd59977 31// for the class
32#include <Graphic3d_AspectFillArea3d.ixx>
33
7fd59977 34#include <Aspect_PolygonOffsetMode.hxx>
7fd59977 35#include <Standard_Boolean.hxx>
36
7fd59977 37Graphic3d_AspectFillArea3d::Graphic3d_AspectFillArea3d ():
de75ed09 38DistinguishModeActive (Standard_False), EdgeModeActive (Standard_False), BackFaceRemovalActive (Standard_False), MyTextureMapState(Standard_False), MyFrontMaterial (), MyBackMaterial ()
39{
7fd59977 40 // By default, aspect do not change current polygon offset parameters
60761105 41 MyPolygonOffsetMode = Aspect_POM_Fill;
7fd59977 42 MyPolygonOffsetFactor = 1.;
43 MyPolygonOffsetUnits = 0.;
7fd59977 44}
45
81bba717 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.
7fd59977 50
51Graphic3d_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):
52Aspect_AspectFillArea (InteriorStyle, InteriorColor, EdgeColor, EdgeLineType, EdgeLineWidth), DistinguishModeActive (Standard_False), EdgeModeActive (Standard_False), BackFaceRemovalActive (Standard_False), MyTextureMap(), MyTextureMapState(Standard_False), MyFrontMaterial (FrontMaterial), MyBackMaterial (BackMaterial) {
7fd59977 53 // By default, aspect do not change current polygon offset parameters
60761105 54 MyPolygonOffsetMode = Aspect_POM_Fill;
7fd59977 55 MyPolygonOffsetFactor = 1.;
56 MyPolygonOffsetUnits = 0.;
7fd59977 57}
58
59void Graphic3d_AspectFillArea3d::SetBackMaterial (const Graphic3d_MaterialAspect& AMaterial) {
60
61 MyBackMaterial = AMaterial;
62
63}
64
65void Graphic3d_AspectFillArea3d::SetFrontMaterial (const Graphic3d_MaterialAspect& AMaterial) {
66
67 MyFrontMaterial = AMaterial;
68
69}
70
71Graphic3d_MaterialAspect Graphic3d_AspectFillArea3d::BackMaterial () const {
72
73 return (MyBackMaterial);
74
75}
76
77Graphic3d_MaterialAspect Graphic3d_AspectFillArea3d::FrontMaterial () const {
78
79 return (MyFrontMaterial);
80
81}
82
83void Graphic3d_AspectFillArea3d::AllowBackFace () {
84
85 BackFaceRemovalActive = Standard_False;
86
87}
88
89void Graphic3d_AspectFillArea3d::SuppressBackFace () {
90
91 BackFaceRemovalActive = Standard_True;
92
93}
94
95Standard_Boolean Graphic3d_AspectFillArea3d::BackFace () const {
96
97 return (BackFaceRemovalActive);
98
99}
100
101void Graphic3d_AspectFillArea3d::SetDistinguishOn () {
102
103 DistinguishModeActive = Standard_True;
104
105}
106
107void Graphic3d_AspectFillArea3d::SetDistinguishOff () {
108
109 DistinguishModeActive = Standard_False;
110
111}
112
113Standard_Boolean Graphic3d_AspectFillArea3d::Distinguish () const {
114
115 return (DistinguishModeActive);
116
117}
118
119void Graphic3d_AspectFillArea3d::SetEdgeOn () {
120
121 EdgeModeActive = Standard_True;
122
123}
124
125void Graphic3d_AspectFillArea3d::SetEdgeOff () {
126
127 EdgeModeActive = Standard_False;
128
129}
130
131
132void Graphic3d_AspectFillArea3d::SetTextureMap(const Handle(Graphic3d_TextureMap)& ATexture)
133{
134 MyTextureMap = ATexture;
135}
136
137
138void Graphic3d_AspectFillArea3d::SetTextureMapOn()
139{
140 MyTextureMapState = Standard_True;
141}
142
143
144void Graphic3d_AspectFillArea3d::SetTextureMapOff()
145{
146 MyTextureMapState = Standard_False;
147}
148
149
150Standard_Boolean Graphic3d_AspectFillArea3d::Edge () const {
151
152 return (EdgeModeActive);
153
154}
155
156
157Handle(Graphic3d_TextureMap) Graphic3d_AspectFillArea3d::TextureMap() const
158{
159 return MyTextureMap;
160}
161
162
163Standard_Boolean Graphic3d_AspectFillArea3d::TextureMapState() const
164{
165 return MyTextureMapState;
166}
167
60be1f9b 168void Graphic3d_AspectFillArea3d::SetPolygonOffsets(const Standard_Integer aMode,
169 const Standard_ShortReal aFactor,
170 const Standard_ShortReal aUnits) {
7fd59977 171 MyPolygonOffsetMode = ( aMode & Aspect_POM_Mask );
172 MyPolygonOffsetFactor = aFactor;
173 MyPolygonOffsetUnits = aUnits;
174}
175
60be1f9b 176void Graphic3d_AspectFillArea3d::PolygonOffsets(Standard_Integer& aMode,
177 Standard_ShortReal& aFactor,
178 Standard_ShortReal& aUnits) const {
7fd59977 179 aMode = MyPolygonOffsetMode;
180 aFactor = MyPolygonOffsetFactor;
181 aUnits = MyPolygonOffsetUnits;
182}
30f0ad28 183
184void Graphic3d_AspectFillArea3d::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram)
185{
186 MyShaderProgram = theProgram;
187}
188
189const Handle(Graphic3d_ShaderProgram)& Graphic3d_AspectFillArea3d::ShaderProgram() const
190{
191 return MyShaderProgram;
192}