0023024: Update headers of OCCT files
[occt.git] / src / AIS / AIS_GraphicTool.cxx
CommitLineData
b311480e 1// Created on: 1997-02-10
2// Created by: Robert COUBLANC
3// Copyright (c) 1997-1999 Matra Datavision
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21
22#define GER61351 //GG_171199 Enable to get an object RGB color
23// instead a restricted object NameOfColor.
24
25
26
27#include <AIS_GraphicTool.ixx>
28
29
30#include <Quantity_Color.hxx>
31#include <Prs3d_LineAspect.hxx>
32#include <Aspect_AspectLine.hxx>
33#include <Graphic3d_AspectLine3d.hxx>
34#include <Prs3d_AngleAspect.hxx>
35#include <Prs3d_PlaneAspect.hxx>
36#include <Prs3d_DatumAspect.hxx>
37#include <Graphic3d_AspectFillArea3d.hxx>
38#include <Aspect_InteriorStyle.hxx>
39
40#include <Prs3d_ShadingAspect.hxx>
41
42
43static Handle(Prs3d_LineAspect) GetLineAspect(const Handle(Prs3d_Drawer)& Dr,
44 const AIS_TypeOfAttribute Att)
45{
46 switch(Att){
47 case AIS_TOA_Line:
48 return Dr->LineAspect();
49 break;
50 case AIS_TOA_Angle:
51 return Dr->AngleAspect()->LineAspect();
52 break;
53 case AIS_TOA_Wire:
54 return Dr->WireAspect();
55 break;
56 case AIS_TOA_Plane:
57 return Dr->PlaneAspect()->EdgesAspect();
58 break;
59 case AIS_TOA_Vector:
60 return Dr->VectorAspect();
61 break;
62 case AIS_TOA_UIso:
63 return Dr->UIsoAspect();
64 break;
65 case AIS_TOA_VIso:
66 return Dr->VIsoAspect();
67 break;
68 case AIS_TOA_Free:
69 return Dr->FreeBoundaryAspect();
70 break;
71 case AIS_TOA_UnFree:
72 return Dr->UnFreeBoundaryAspect();
73 break;
74 case AIS_TOA_Section:
75 return Dr->SectionAspect();
76 break;
77 case AIS_TOA_Hidden:
78 return Dr->HiddenLineAspect();
79 break;
80 case AIS_TOA_Seen:
81 return Dr->SeenLineAspect();
82 break;
83 case AIS_TOA_FirstAxis:
84 return Dr->DatumAspect()->FirstAxisAspect();
85 case AIS_TOA_SecondAxis:
86 return Dr->DatumAspect()->SecondAxisAspect();
87 case AIS_TOA_ThirdAxis:
88 return Dr->DatumAspect()->SecondAxisAspect();
89 }
90 Handle(Prs3d_LineAspect) bid;
91 return bid;
92}
93
94Quantity_NameOfColor AIS_GraphicTool::GetLineColor (const Handle(Prs3d_Drawer)& Dr, const AIS_TypeOfAttribute Att)
95#ifdef GER61351
96{
97 Quantity_Color color;
98 GetLineColor(Dr,Att,color);
99 return color.Name();
100}
101
102void AIS_GraphicTool::GetLineColor (const Handle(Prs3d_Drawer)& Dr, const AIS_TypeOfAttribute Att, Quantity_Color &aColor)
103#endif
104{
105 Standard_Real W;
106 Aspect_TypeOfLine TYP;
107
108 Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att);
109
110#ifdef GER61351
111 LA->Aspect()->Values(aColor,TYP,W);
112#else
113 Quantity_Color QCol;
114 LA->Aspect()->Values(QCol,TYP,W);
115 return QCol.Name();
116#endif
117}
118
119Standard_Real AIS_GraphicTool::GetLineWidth (const Handle(Prs3d_Drawer)& Dr,
120 const AIS_TypeOfAttribute Att)
121{
122// Quantity_NameOfColor Col;
123 Standard_Real W;
124 Aspect_TypeOfLine TYP;
125
126 Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att);
127
128 Quantity_Color QCol;
129 LA->Aspect()->Values(QCol,TYP,W);
130 return W;
131}
132Aspect_TypeOfLine AIS_GraphicTool::GetLineType (const Handle(Prs3d_Drawer)& Dr,
133 const AIS_TypeOfAttribute Att)
134{
135// Quantity_NameOfColor Col;
136 Standard_Real W;
137 Aspect_TypeOfLine TYP;
138
139 Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att);
140
141 Quantity_Color QCol;
142 LA->Aspect()->Values(QCol,TYP,W);
143 return TYP;
144}
145
146
147void AIS_GraphicTool::GetLineAtt(const Handle(Prs3d_Drawer)& Dr,
148 const AIS_TypeOfAttribute Att,
149 Quantity_NameOfColor& Col,
150 Standard_Real& W,
151 Aspect_TypeOfLine& TYP)
152{
153
154 Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att);
155
156 Quantity_Color QCol;
157 LA->Aspect()->Values(QCol,TYP,W);
158 Col = QCol.Name();
159}
160
161Quantity_NameOfColor AIS_GraphicTool::GetInteriorColor(const Handle(Prs3d_Drawer)& Dr)
162#ifdef GER61351
163{
164 Quantity_Color color;
165 GetInteriorColor(Dr,color);
166 return color.Name();
167}
168
169void AIS_GraphicTool::GetInteriorColor(const Handle(Prs3d_Drawer)& Dr, Quantity_Color &aColor)
170#endif
171{
172 Handle(Graphic3d_AspectFillArea3d) AFA = Dr->ShadingAspect()->Aspect();
173 Aspect_InteriorStyle IS;
174 Aspect_TypeOfLine T;
175 Standard_Real W;
176#ifdef GER61351
177 Quantity_Color EC;
178 AFA->Values(IS,aColor,EC,T,W);
179#else
180 Quantity_Color IC,EC;
181 AFA->Values(IS,IC,EC,T,W);
182 return IC.Name();
183#endif
184}
185
186Graphic3d_MaterialAspect AIS_GraphicTool::GetMaterial(const Handle(Prs3d_Drawer)& Dr)
187{
188 return Dr->ShadingAspect()->Aspect()->BackMaterial();
189
190}