0022627: Change OCCT memory management defaults
[occt.git] / src / AIS / AIS_GraphicTool.cxx
CommitLineData
7fd59977 1// File: AIS_GraphicTool.cxx
2// Created: Mon Feb 10 16:39:03 1997
3// Author: Robert COUBLANC
4// <rob@robox.paris1.matra-dtv.fr>
5
6#define GER61351 //GG_171199 Enable to get an object RGB color
7// instead a restricted object NameOfColor.
8
9
10
11#include <AIS_GraphicTool.ixx>
12
13
14#include <Quantity_Color.hxx>
15#include <Prs3d_LineAspect.hxx>
16#include <Aspect_AspectLine.hxx>
17#include <Graphic3d_AspectLine3d.hxx>
18#include <Prs3d_AngleAspect.hxx>
19#include <Prs3d_PlaneAspect.hxx>
20#include <Prs3d_DatumAspect.hxx>
21#include <Graphic3d_AspectFillArea3d.hxx>
22#include <Aspect_InteriorStyle.hxx>
23
24#include <Prs3d_ShadingAspect.hxx>
25
26
27static Handle(Prs3d_LineAspect) GetLineAspect(const Handle(Prs3d_Drawer)& Dr,
28 const AIS_TypeOfAttribute Att)
29{
30 switch(Att){
31 case AIS_TOA_Line:
32 return Dr->LineAspect();
33 break;
34 case AIS_TOA_Angle:
35 return Dr->AngleAspect()->LineAspect();
36 break;
37 case AIS_TOA_Wire:
38 return Dr->WireAspect();
39 break;
40 case AIS_TOA_Plane:
41 return Dr->PlaneAspect()->EdgesAspect();
42 break;
43 case AIS_TOA_Vector:
44 return Dr->VectorAspect();
45 break;
46 case AIS_TOA_UIso:
47 return Dr->UIsoAspect();
48 break;
49 case AIS_TOA_VIso:
50 return Dr->VIsoAspect();
51 break;
52 case AIS_TOA_Free:
53 return Dr->FreeBoundaryAspect();
54 break;
55 case AIS_TOA_UnFree:
56 return Dr->UnFreeBoundaryAspect();
57 break;
58 case AIS_TOA_Section:
59 return Dr->SectionAspect();
60 break;
61 case AIS_TOA_Hidden:
62 return Dr->HiddenLineAspect();
63 break;
64 case AIS_TOA_Seen:
65 return Dr->SeenLineAspect();
66 break;
67 case AIS_TOA_FirstAxis:
68 return Dr->DatumAspect()->FirstAxisAspect();
69 case AIS_TOA_SecondAxis:
70 return Dr->DatumAspect()->SecondAxisAspect();
71 case AIS_TOA_ThirdAxis:
72 return Dr->DatumAspect()->SecondAxisAspect();
73 }
74 Handle(Prs3d_LineAspect) bid;
75 return bid;
76}
77
78Quantity_NameOfColor AIS_GraphicTool::GetLineColor (const Handle(Prs3d_Drawer)& Dr, const AIS_TypeOfAttribute Att)
79#ifdef GER61351
80{
81 Quantity_Color color;
82 GetLineColor(Dr,Att,color);
83 return color.Name();
84}
85
86void AIS_GraphicTool::GetLineColor (const Handle(Prs3d_Drawer)& Dr, const AIS_TypeOfAttribute Att, Quantity_Color &aColor)
87#endif
88{
89 Standard_Real W;
90 Aspect_TypeOfLine TYP;
91
92 Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att);
93
94#ifdef GER61351
95 LA->Aspect()->Values(aColor,TYP,W);
96#else
97 Quantity_Color QCol;
98 LA->Aspect()->Values(QCol,TYP,W);
99 return QCol.Name();
100#endif
101}
102
103Standard_Real AIS_GraphicTool::GetLineWidth (const Handle(Prs3d_Drawer)& Dr,
104 const AIS_TypeOfAttribute Att)
105{
106// Quantity_NameOfColor Col;
107 Standard_Real W;
108 Aspect_TypeOfLine TYP;
109
110 Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att);
111
112 Quantity_Color QCol;
113 LA->Aspect()->Values(QCol,TYP,W);
114 return W;
115}
116Aspect_TypeOfLine AIS_GraphicTool::GetLineType (const Handle(Prs3d_Drawer)& Dr,
117 const AIS_TypeOfAttribute Att)
118{
119// Quantity_NameOfColor Col;
120 Standard_Real W;
121 Aspect_TypeOfLine TYP;
122
123 Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att);
124
125 Quantity_Color QCol;
126 LA->Aspect()->Values(QCol,TYP,W);
127 return TYP;
128}
129
130
131void AIS_GraphicTool::GetLineAtt(const Handle(Prs3d_Drawer)& Dr,
132 const AIS_TypeOfAttribute Att,
133 Quantity_NameOfColor& Col,
134 Standard_Real& W,
135 Aspect_TypeOfLine& TYP)
136{
137
138 Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att);
139
140 Quantity_Color QCol;
141 LA->Aspect()->Values(QCol,TYP,W);
142 Col = QCol.Name();
143}
144
145Quantity_NameOfColor AIS_GraphicTool::GetInteriorColor(const Handle(Prs3d_Drawer)& Dr)
146#ifdef GER61351
147{
148 Quantity_Color color;
149 GetInteriorColor(Dr,color);
150 return color.Name();
151}
152
153void AIS_GraphicTool::GetInteriorColor(const Handle(Prs3d_Drawer)& Dr, Quantity_Color &aColor)
154#endif
155{
156 Handle(Graphic3d_AspectFillArea3d) AFA = Dr->ShadingAspect()->Aspect();
157 Aspect_InteriorStyle IS;
158 Aspect_TypeOfLine T;
159 Standard_Real W;
160#ifdef GER61351
161 Quantity_Color EC;
162 AFA->Values(IS,aColor,EC,T,W);
163#else
164 Quantity_Color IC,EC;
165 AFA->Values(IS,IC,EC,T,W);
166 return IC.Name();
167#endif
168}
169
170Graphic3d_MaterialAspect AIS_GraphicTool::GetMaterial(const Handle(Prs3d_Drawer)& Dr)
171{
172 return Dr->ShadingAspect()->Aspect()->BackMaterial();
173
174}