0024023: Revamp the OCCT Handle - gcc and clang
[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
42cf5bc1 18#include <AIS_GraphicTool.hxx>
7fd59977 19#include <Aspect_AspectLine.hxx>
42cf5bc1 20#include <Aspect_InteriorStyle.hxx>
21#include <Graphic3d_AspectFillArea3d.hxx>
7fd59977 22#include <Graphic3d_AspectLine3d.hxx>
42cf5bc1 23#include <Graphic3d_MaterialAspect.hxx>
24#include <Prs3d_DatumAspect.hxx>
a6eb515f 25#include <Prs3d_DimensionAspect.hxx>
42cf5bc1 26#include <Prs3d_IsoAspect.hxx>
27#include <Prs3d_LineAspect.hxx>
7fd59977 28#include <Prs3d_PlaneAspect.hxx>
7fd59977 29#include <Prs3d_ShadingAspect.hxx>
42cf5bc1 30#include <Quantity_Color.hxx>
7fd59977 31
32static Handle(Prs3d_LineAspect) GetLineAspect(const Handle(Prs3d_Drawer)& Dr,
33 const AIS_TypeOfAttribute Att)
34{
35 switch(Att){
36 case AIS_TOA_Line:
37 return Dr->LineAspect();
38 break;
a6eb515f 39 case AIS_TOA_Dimension:
40 return Dr->DimensionAspect()->LineAspect();
7fd59977 41 break;
42 case AIS_TOA_Wire:
43 return Dr->WireAspect();
44 break;
45 case AIS_TOA_Plane:
46 return Dr->PlaneAspect()->EdgesAspect();
47 break;
48 case AIS_TOA_Vector:
49 return Dr->VectorAspect();
50 break;
51 case AIS_TOA_UIso:
5b111128 52 return Handle(Prs3d_LineAspect) (Dr->UIsoAspect());
7fd59977 53 break;
54 case AIS_TOA_VIso:
5b111128 55 return Handle(Prs3d_LineAspect) (Dr->VIsoAspect());
7fd59977 56 break;
57 case AIS_TOA_Free:
58 return Dr->FreeBoundaryAspect();
59 break;
60 case AIS_TOA_UnFree:
61 return Dr->UnFreeBoundaryAspect();
62 break;
63 case AIS_TOA_Section:
64 return Dr->SectionAspect();
65 break;
66 case AIS_TOA_Hidden:
67 return Dr->HiddenLineAspect();
68 break;
69 case AIS_TOA_Seen:
70 return Dr->SeenLineAspect();
71 break;
72 case AIS_TOA_FirstAxis:
73 return Dr->DatumAspect()->FirstAxisAspect();
74 case AIS_TOA_SecondAxis:
75 return Dr->DatumAspect()->SecondAxisAspect();
76 case AIS_TOA_ThirdAxis:
77 return Dr->DatumAspect()->SecondAxisAspect();
78 }
79 Handle(Prs3d_LineAspect) bid;
80 return bid;
81}
82
83Quantity_NameOfColor AIS_GraphicTool::GetLineColor (const Handle(Prs3d_Drawer)& Dr, const AIS_TypeOfAttribute Att)
7fd59977 84{
85 Quantity_Color color;
86 GetLineColor(Dr,Att,color);
87 return color.Name();
88}
89
90void AIS_GraphicTool::GetLineColor (const Handle(Prs3d_Drawer)& Dr, const AIS_TypeOfAttribute Att, Quantity_Color &aColor)
7fd59977 91{
92 Standard_Real W;
93 Aspect_TypeOfLine TYP;
b8ddfc2f 94 GetLineAspect(Dr,Att)->Aspect()->Values(aColor,TYP,W);
7fd59977 95}
96
97Standard_Real AIS_GraphicTool::GetLineWidth (const Handle(Prs3d_Drawer)& Dr,
98 const AIS_TypeOfAttribute Att)
99{
100// Quantity_NameOfColor Col;
101 Standard_Real W;
102 Aspect_TypeOfLine TYP;
103
104 Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att);
105
106 Quantity_Color QCol;
107 LA->Aspect()->Values(QCol,TYP,W);
108 return W;
109}
110Aspect_TypeOfLine AIS_GraphicTool::GetLineType (const Handle(Prs3d_Drawer)& Dr,
111 const AIS_TypeOfAttribute Att)
112{
113// Quantity_NameOfColor Col;
114 Standard_Real W;
115 Aspect_TypeOfLine TYP;
116
117 Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att);
118
119 Quantity_Color QCol;
120 LA->Aspect()->Values(QCol,TYP,W);
121 return TYP;
122}
123
124
125void AIS_GraphicTool::GetLineAtt(const Handle(Prs3d_Drawer)& Dr,
126 const AIS_TypeOfAttribute Att,
127 Quantity_NameOfColor& Col,
128 Standard_Real& W,
129 Aspect_TypeOfLine& TYP)
130{
131
132 Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att);
133
134 Quantity_Color QCol;
135 LA->Aspect()->Values(QCol,TYP,W);
136 Col = QCol.Name();
137}
138
139Quantity_NameOfColor AIS_GraphicTool::GetInteriorColor(const Handle(Prs3d_Drawer)& Dr)
7fd59977 140{
141 Quantity_Color color;
142 GetInteriorColor(Dr,color);
143 return color.Name();
144}
145
146void AIS_GraphicTool::GetInteriorColor(const Handle(Prs3d_Drawer)& Dr, Quantity_Color &aColor)
7fd59977 147{
148 Handle(Graphic3d_AspectFillArea3d) AFA = Dr->ShadingAspect()->Aspect();
149 Aspect_InteriorStyle IS;
150 Aspect_TypeOfLine T;
151 Standard_Real W;
7fd59977 152 Quantity_Color EC;
153 AFA->Values(IS,aColor,EC,T,W);
7fd59977 154}
155
156Graphic3d_MaterialAspect AIS_GraphicTool::GetMaterial(const Handle(Prs3d_Drawer)& Dr)
157{
158 return Dr->ShadingAspect()->Aspect()->BackMaterial();
7fd59977 159}