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