0029517: Visualization - introduce AlphaMode property defining alpha value handling...
[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 #include <Graphic3d_AspectFillArea3d.hxx>
17
18 IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectFillArea3d, Standard_Transient)
19
20 // =======================================================================
21 // function : Graphic3d_AspectFillArea3d
22 // purpose  :
23 // =======================================================================
24 Graphic3d_AspectFillArea3d::Graphic3d_AspectFillArea3d()
25 : myInteriorColor       (Quantity_NOC_CYAN1),
26   myBackInteriorColor   (Quantity_NOC_CYAN1),
27   myEdgeColor           (Quantity_NOC_WHITE),
28   myInteriorStyle       (Aspect_IS_EMPTY),
29   myShadingModel        (Graphic3d_TOSM_DEFAULT),
30   myAlphaMode           (Graphic3d_AlphaMode_BlendAuto),
31   myAlphaCutoff         (0.5f),
32   myEdgeType            (Aspect_TOL_SOLID),
33   myEdgeWidth           (1.0f),
34   myHatchStyle          (Handle(Graphic3d_HatchStyle)()),
35   myToDistinguishMaterials (false),
36   myToDrawEdges         (false),
37   myToSuppressBackFaces (true),
38   myToMapTexture        (false)
39 {
40   //
41 }
42
43 // =======================================================================
44 // function : Graphic3d_AspectFillArea3d
45 // purpose  :
46 // =======================================================================
47 Graphic3d_AspectFillArea3d::Graphic3d_AspectFillArea3d (const Aspect_InteriorStyle theInteriorStyle,
48                                                         const Quantity_Color&      theInteriorColor,
49                                                         const Quantity_Color&      theEdgeColor,
50                                                         const Aspect_TypeOfLine    theEdgeLineType,
51                                                         const Standard_Real        theEdgeLineWidth,
52                                                         const Graphic3d_MaterialAspect& theFrontMaterial,
53                                                         const Graphic3d_MaterialAspect& theBackMaterial)
54 : myFrontMaterial       (theFrontMaterial),
55   myBackMaterial        (theBackMaterial),
56   myInteriorColor       (theInteriorColor),
57   myBackInteriorColor   (theInteriorColor),
58   myEdgeColor           (theEdgeColor),
59   myInteriorStyle       (theInteriorStyle),
60   myShadingModel        (Graphic3d_TOSM_DEFAULT),
61   myAlphaMode           (Graphic3d_AlphaMode_BlendAuto),
62   myAlphaCutoff         (0.5f),
63   myEdgeType            (theEdgeLineType),
64   myEdgeWidth           ((float )theEdgeLineWidth),
65   myHatchStyle          (Handle(Graphic3d_HatchStyle)()),
66   myToDistinguishMaterials (false),
67   myToDrawEdges         (false),
68   myToSuppressBackFaces (true),
69   myToMapTexture        (false)
70 {
71   if (theEdgeLineWidth <= 0.0)
72   {
73     throw Aspect_AspectFillAreaDefinitionError("Bad value for EdgeLineWidth");
74   }
75 }
76
77 // =======================================================================
78 // function : Graphic3d_AspectFillArea3d
79 // purpose  :
80 // =======================================================================
81 void Graphic3d_AspectFillArea3d::SetTextureMap (const Handle(Graphic3d_TextureMap)& theTexture)
82 {
83   if (theTexture.IsNull())
84   {
85     myTextureSet.Nullify();
86     return;
87   }
88
89   myTextureSet = new Graphic3d_TextureSet (theTexture);
90 }