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