0025765: Coding rules - clean up code from obsolete macro checks
[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
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
7fd59977 17#include <AIS_GraphicTool.ixx>
18
19
20#include <Quantity_Color.hxx>
21#include <Prs3d_LineAspect.hxx>
22#include <Aspect_AspectLine.hxx>
23#include <Graphic3d_AspectLine3d.hxx>
a6eb515f 24#include <Prs3d_DimensionAspect.hxx>
7fd59977 25#include <Prs3d_PlaneAspect.hxx>
26#include <Prs3d_DatumAspect.hxx>
27#include <Graphic3d_AspectFillArea3d.hxx>
28#include <Aspect_InteriorStyle.hxx>
29
30#include <Prs3d_ShadingAspect.hxx>
31
32
33static Handle(Prs3d_LineAspect) GetLineAspect(const Handle(Prs3d_Drawer)& Dr,
34 const AIS_TypeOfAttribute Att)
35{
36 switch(Att){
37 case AIS_TOA_Line:
38 return Dr->LineAspect();
39 break;
a6eb515f 40 case AIS_TOA_Dimension:
41 return Dr->DimensionAspect()->LineAspect();
7fd59977 42 break;
43 case AIS_TOA_Wire:
44 return Dr->WireAspect();
45 break;
46 case AIS_TOA_Plane:
47 return Dr->PlaneAspect()->EdgesAspect();
48 break;
49 case AIS_TOA_Vector:
50 return Dr->VectorAspect();
51 break;
52 case AIS_TOA_UIso:
53 return Dr->UIsoAspect();
54 break;
55 case AIS_TOA_VIso:
56 return Dr->VIsoAspect();
57 break;
58 case AIS_TOA_Free:
59 return Dr->FreeBoundaryAspect();
60 break;
61 case AIS_TOA_UnFree:
62 return Dr->UnFreeBoundaryAspect();
63 break;
64 case AIS_TOA_Section:
65 return Dr->SectionAspect();
66 break;
67 case AIS_TOA_Hidden:
68 return Dr->HiddenLineAspect();
69 break;
70 case AIS_TOA_Seen:
71 return Dr->SeenLineAspect();
72 break;
73 case AIS_TOA_FirstAxis:
74 return Dr->DatumAspect()->FirstAxisAspect();
75 case AIS_TOA_SecondAxis:
76 return Dr->DatumAspect()->SecondAxisAspect();
77 case AIS_TOA_ThirdAxis:
78 return Dr->DatumAspect()->SecondAxisAspect();
79 }
80 Handle(Prs3d_LineAspect) bid;
81 return bid;
82}
83
84Quantity_NameOfColor AIS_GraphicTool::GetLineColor (const Handle(Prs3d_Drawer)& Dr, const AIS_TypeOfAttribute Att)
7fd59977 85{
86 Quantity_Color color;
87 GetLineColor(Dr,Att,color);
88 return color.Name();
89}
90
91void AIS_GraphicTool::GetLineColor (const Handle(Prs3d_Drawer)& Dr, const AIS_TypeOfAttribute Att, Quantity_Color &aColor)
7fd59977 92{
93 Standard_Real W;
94 Aspect_TypeOfLine TYP;
b8ddfc2f 95 GetLineAspect(Dr,Att)->Aspect()->Values(aColor,TYP,W);
7fd59977 96}
97
98Standard_Real AIS_GraphicTool::GetLineWidth (const Handle(Prs3d_Drawer)& Dr,
99 const AIS_TypeOfAttribute Att)
100{
101// Quantity_NameOfColor Col;
102 Standard_Real W;
103 Aspect_TypeOfLine TYP;
104
105 Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att);
106
107 Quantity_Color QCol;
108 LA->Aspect()->Values(QCol,TYP,W);
109 return W;
110}
111Aspect_TypeOfLine AIS_GraphicTool::GetLineType (const Handle(Prs3d_Drawer)& Dr,
112 const AIS_TypeOfAttribute Att)
113{
114// Quantity_NameOfColor Col;
115 Standard_Real W;
116 Aspect_TypeOfLine TYP;
117
118 Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att);
119
120 Quantity_Color QCol;
121 LA->Aspect()->Values(QCol,TYP,W);
122 return TYP;
123}
124
125
126void AIS_GraphicTool::GetLineAtt(const Handle(Prs3d_Drawer)& Dr,
127 const AIS_TypeOfAttribute Att,
128 Quantity_NameOfColor& Col,
129 Standard_Real& W,
130 Aspect_TypeOfLine& TYP)
131{
132
133 Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att);
134
135 Quantity_Color QCol;
136 LA->Aspect()->Values(QCol,TYP,W);
137 Col = QCol.Name();
138}
139
140Quantity_NameOfColor AIS_GraphicTool::GetInteriorColor(const Handle(Prs3d_Drawer)& Dr)
7fd59977 141{
142 Quantity_Color color;
143 GetInteriorColor(Dr,color);
144 return color.Name();
145}
146
147void AIS_GraphicTool::GetInteriorColor(const Handle(Prs3d_Drawer)& Dr, Quantity_Color &aColor)
7fd59977 148{
149 Handle(Graphic3d_AspectFillArea3d) AFA = Dr->ShadingAspect()->Aspect();
150 Aspect_InteriorStyle IS;
151 Aspect_TypeOfLine T;
152 Standard_Real W;
7fd59977 153 Quantity_Color EC;
154 AFA->Values(IS,aColor,EC,T,W);
7fd59977 155}
156
157Graphic3d_MaterialAspect AIS_GraphicTool::GetMaterial(const Handle(Prs3d_Drawer)& Dr)
158{
159 return Dr->ShadingAspect()->Aspect()->BackMaterial();
7fd59977 160}