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 #include <Prs3d_ShadingAspect.ixx>
17 //=======================================================================
18 //function : Prs3d_ShadingAspect
20 //=======================================================================
22 Prs3d_ShadingAspect::Prs3d_ShadingAspect () {
25 Graphic3d_MaterialAspect aMat (Graphic3d_NOM_BRASS);
27 // Ceci permet de recuperer la couleur associee
28 // au materiau defini par defaut.
30 Col = aMat.AmbientColor ();
31 // Col = aMat.Color ();
32 myAspect = new Graphic3d_AspectFillArea3d (Aspect_IS_SOLID,
42 //=======================================================================
45 //=======================================================================
47 void Prs3d_ShadingAspect::SetColor(const Quantity_NameOfColor aColor,
48 const Aspect_TypeOfFacingModel aModel) {
50 SetColor(Quantity_Color(aColor),aModel);
53 void Prs3d_ShadingAspect::SetColor(const Quantity_Color &aColor,
54 const Aspect_TypeOfFacingModel aModel) {
55 if( aModel != Aspect_TOFM_BOTH_SIDE ) {
56 myAspect->SetDistinguishOn();
58 if( aModel == Aspect_TOFM_FRONT_SIDE || aModel == Aspect_TOFM_BOTH_SIDE ) {
59 Graphic3d_MaterialAspect front = myAspect->FrontMaterial();
60 front.SetColor(aColor);
61 myAspect->SetFrontMaterial(front);
62 myAspect->SetInteriorColor( aColor );
65 if( aModel == Aspect_TOFM_BACK_SIDE || aModel == Aspect_TOFM_BOTH_SIDE ) {
66 Graphic3d_MaterialAspect back = myAspect->BackMaterial();
67 back.SetColor(aColor);
68 myAspect->SetBackMaterial(back);
69 myAspect->SetBackInteriorColor( aColor );
73 const Quantity_Color& Prs3d_ShadingAspect::Color (const Aspect_TypeOfFacingModel theModel) const
78 case Aspect_TOFM_BOTH_SIDE:
79 case Aspect_TOFM_FRONT_SIDE:
80 return myAspect->FrontMaterial().Color();
81 case Aspect_TOFM_BACK_SIDE:
82 return myAspect->BackMaterial().Color();
86 //=======================================================================
87 //function : SetMaterial
89 //=======================================================================
91 void Prs3d_ShadingAspect::SetMaterial(
92 const Graphic3d_NameOfMaterial aMaterial,
93 const Aspect_TypeOfFacingModel aModel ) {
94 SetMaterial(Graphic3d_MaterialAspect(aMaterial),aModel);
97 //=======================================================================
98 //function : SetMaterial
100 //=======================================================================
102 void Prs3d_ShadingAspect::SetMaterial(
103 const Graphic3d_MaterialAspect& aMaterial,
104 const Aspect_TypeOfFacingModel aModel ) {
106 if( aModel != Aspect_TOFM_BOTH_SIDE ) {
107 myAspect->SetDistinguishOn();
109 if( aModel == Aspect_TOFM_FRONT_SIDE || aModel == Aspect_TOFM_BOTH_SIDE ) {
110 myAspect->SetFrontMaterial(aMaterial);
113 if( aModel == Aspect_TOFM_BACK_SIDE || aModel == Aspect_TOFM_BOTH_SIDE ) {
114 myAspect->SetBackMaterial(aMaterial);
118 const Graphic3d_MaterialAspect& Prs3d_ShadingAspect::Material (const Aspect_TypeOfFacingModel theModel) const
123 case Aspect_TOFM_BOTH_SIDE:
124 case Aspect_TOFM_FRONT_SIDE:
125 return myAspect->FrontMaterial();
126 case Aspect_TOFM_BACK_SIDE:
127 return myAspect->BackMaterial();
131 //=======================================================================
132 //function : SetTransparency
134 //=======================================================================
136 void Prs3d_ShadingAspect::SetTransparency(const Standard_Real aValue,
137 const Aspect_TypeOfFacingModel aModel ) {
139 if( aModel != Aspect_TOFM_BOTH_SIDE ) {
140 myAspect->SetDistinguishOn();
142 if( aModel == Aspect_TOFM_FRONT_SIDE || aModel == Aspect_TOFM_BOTH_SIDE ) {
143 Graphic3d_MaterialAspect front = myAspect->FrontMaterial();
144 front.SetTransparency(aValue);
145 myAspect->SetFrontMaterial(front);
148 if( aModel == Aspect_TOFM_BACK_SIDE || aModel == Aspect_TOFM_BOTH_SIDE ) {
149 Graphic3d_MaterialAspect back = myAspect->BackMaterial();
150 back.SetTransparency(aValue);
151 myAspect->SetBackMaterial(back);
155 Standard_Real Prs3d_ShadingAspect::Transparency(const Aspect_TypeOfFacingModel aModel ) const {
156 Standard_Real aValue(0.);
158 case Aspect_TOFM_BOTH_SIDE:
159 case Aspect_TOFM_FRONT_SIDE:
160 aValue = myAspect->FrontMaterial().Transparency();
162 case Aspect_TOFM_BACK_SIDE:
163 aValue = myAspect->BackMaterial().Transparency();
169 //=======================================================================
170 //function : SetAspect
172 //=======================================================================
174 void Prs3d_ShadingAspect::SetAspect(const Handle(Graphic3d_AspectFillArea3d)& Asp)
179 Handle (Graphic3d_AspectFillArea3d) Prs3d_ShadingAspect::Aspect () const {