1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #define BUC60488 //GG_23/09/99 Updates correctly the Material after
18 #define GER61351 //GG_171199 Enable to set an object RGB color
19 // instead a restricted object NameOfColor.
20 // Enable to change separatly the front and back color.
22 #define OCC1174 //SAV_080103 Added back face interior color management
24 #include <Prs3d_ShadingAspect.ixx>
26 //=======================================================================
27 //function : Prs3d_ShadingAspect
29 //=======================================================================
31 Prs3d_ShadingAspect::Prs3d_ShadingAspect () {
34 Graphic3d_MaterialAspect aMat (Graphic3d_NOM_BRASS);
36 // Ceci permet de recuperer la couleur associee
37 // au materiau defini par defaut.
39 Col = aMat.AmbientColor ();
40 // Col = aMat.Color ();
41 myAspect = new Graphic3d_AspectFillArea3d (Aspect_IS_SOLID,
51 //=======================================================================
54 //=======================================================================
57 void Prs3d_ShadingAspect::SetColor(const Quantity_NameOfColor aColor,
58 const Aspect_TypeOfFacingModel aModel) {
60 SetColor(Quantity_Color(aColor),aModel);
63 void Prs3d_ShadingAspect::SetColor(const Quantity_Color &aColor,
64 const Aspect_TypeOfFacingModel aModel) {
66 myAspect->SetInteriorColor(aColor);
69 if( aModel != Aspect_TOFM_BOTH_SIDE ) {
70 myAspect->SetDistinguishOn();
72 if( aModel == Aspect_TOFM_FRONT_SIDE || aModel == Aspect_TOFM_BOTH_SIDE ) {
73 Graphic3d_MaterialAspect front = myAspect->FrontMaterial();
74 front.SetColor(aColor);
75 myAspect->SetFrontMaterial(front);
77 myAspect->SetInteriorColor( aColor );
81 if( aModel == Aspect_TOFM_BACK_SIDE || aModel == Aspect_TOFM_BOTH_SIDE ) {
82 Graphic3d_MaterialAspect back = myAspect->BackMaterial();
83 back.SetColor(aColor);
84 myAspect->SetBackMaterial(back);
86 myAspect->SetBackInteriorColor( aColor );
91 Quantity_Color Prs3d_ShadingAspect::Color( const Aspect_TypeOfFacingModel aModel ) const {
92 Quantity_Color myReturn ;
95 case Aspect_TOFM_BOTH_SIDE:
96 case Aspect_TOFM_FRONT_SIDE:
97 myReturn = myAspect->FrontMaterial().Color();
99 case Aspect_TOFM_BACK_SIDE:
100 myReturn = myAspect->BackMaterial().Color();
106 void Prs3d_ShadingAspect::SetColor(const Quantity_NameOfColor aColor) {
107 myAspect->SetInteriorColor(aColor);
109 myAspect->SetBackInteriorColor( aColor );
111 myAspect->FrontMaterial().SetAmbientColor(Quantity_Color(aColor));
112 myAspect->BackMaterial().SetAmbientColor(Quantity_Color(aColor));
113 // myAspect->FrontMaterial().SetColor(Quantity_Color(aColor));
114 // myAspect->BackMaterial().SetColor(Quantity_Color(aColor));
118 //=======================================================================
119 //function : SetMaterial
121 //=======================================================================
124 void Prs3d_ShadingAspect::SetMaterial(
125 const Graphic3d_NameOfMaterial aMaterial,
126 const Aspect_TypeOfFacingModel aModel ) {
128 SetMaterial(Graphic3d_MaterialAspect(aMaterial),aModel);
131 void Prs3d_ShadingAspect::SetMaterial(
132 // const Graphic3d_NameOfPhysicalMaterial aMaterial) {
133 const Graphic3d_NameOfMaterial aMaterial) {
135 Graphic3d_MaterialAspect TheMaterial(aMaterial);
136 myAspect->SetFrontMaterial (TheMaterial);
137 myAspect->SetBackMaterial (TheMaterial);
141 //=======================================================================
142 //function : SetMaterial
144 //=======================================================================
147 void Prs3d_ShadingAspect::SetMaterial(
148 const Graphic3d_MaterialAspect& aMaterial,
149 const Aspect_TypeOfFacingModel aModel ) {
151 if( aModel != Aspect_TOFM_BOTH_SIDE ) {
152 myAspect->SetDistinguishOn();
154 if( aModel == Aspect_TOFM_FRONT_SIDE || aModel == Aspect_TOFM_BOTH_SIDE ) {
155 myAspect->SetFrontMaterial(aMaterial);
158 if( aModel == Aspect_TOFM_BACK_SIDE || aModel == Aspect_TOFM_BOTH_SIDE ) {
159 myAspect->SetBackMaterial(aMaterial);
163 Graphic3d_MaterialAspect Prs3d_ShadingAspect::Material(
164 const Aspect_TypeOfFacingModel aModel ) const {
165 Graphic3d_MaterialAspect myReturn ;
168 case Aspect_TOFM_BOTH_SIDE:
169 case Aspect_TOFM_FRONT_SIDE:
170 myReturn = myAspect->FrontMaterial();
172 case Aspect_TOFM_BACK_SIDE:
173 myReturn = myAspect->BackMaterial();
179 void Prs3d_ShadingAspect::SetMaterial(
180 const Graphic3d_MaterialAspect& aMaterial)
182 myAspect->SetFrontMaterial (aMaterial);
183 myAspect->SetBackMaterial (aMaterial);
187 //=======================================================================
188 //function : SetTransparency
190 //=======================================================================
193 void Prs3d_ShadingAspect::SetTransparency(const Standard_Real aValue,
194 const Aspect_TypeOfFacingModel aModel ) {
196 if( aModel != Aspect_TOFM_BOTH_SIDE ) {
197 myAspect->SetDistinguishOn();
199 if( aModel == Aspect_TOFM_FRONT_SIDE || aModel == Aspect_TOFM_BOTH_SIDE ) {
200 Graphic3d_MaterialAspect front = myAspect->FrontMaterial();
201 front.SetTransparency(aValue);
202 myAspect->SetFrontMaterial(front);
205 if( aModel == Aspect_TOFM_BACK_SIDE || aModel == Aspect_TOFM_BOTH_SIDE ) {
206 Graphic3d_MaterialAspect back = myAspect->BackMaterial();
207 back.SetTransparency(aValue);
208 myAspect->SetBackMaterial(back);
212 Standard_Real Prs3d_ShadingAspect::Transparency(const Aspect_TypeOfFacingModel aModel ) const {
213 Standard_Real aValue(0.);
215 case Aspect_TOFM_BOTH_SIDE:
216 case Aspect_TOFM_FRONT_SIDE:
217 aValue = myAspect->FrontMaterial().Transparency();
219 case Aspect_TOFM_BACK_SIDE:
220 aValue = myAspect->BackMaterial().Transparency();
227 //=======================================================================
228 //function : SetAspect
230 //=======================================================================
232 void Prs3d_ShadingAspect::SetAspect(const Handle(Graphic3d_AspectFillArea3d)& Asp)
237 Handle (Graphic3d_AspectFillArea3d) Prs3d_ShadingAspect::Aspect () const {