b311480e |
1 | // Created on: 1997-02-10 |
2 | // Created by: Robert COUBLANC |
3 | // Copyright (c) 1997-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
b8ddfc2f |
22 | //GER61351 //GG_171199 Enable to get an object RGB color instead a restricted object NameOfColor. |
7fd59977 |
23 | |
24 | |
25 | |
26 | #include <AIS_GraphicTool.ixx> |
27 | |
28 | |
29 | #include <Quantity_Color.hxx> |
30 | #include <Prs3d_LineAspect.hxx> |
31 | #include <Aspect_AspectLine.hxx> |
32 | #include <Graphic3d_AspectLine3d.hxx> |
a6eb515f |
33 | #include <Prs3d_DimensionAspect.hxx> |
7fd59977 |
34 | #include <Prs3d_PlaneAspect.hxx> |
35 | #include <Prs3d_DatumAspect.hxx> |
36 | #include <Graphic3d_AspectFillArea3d.hxx> |
37 | #include <Aspect_InteriorStyle.hxx> |
38 | |
39 | #include <Prs3d_ShadingAspect.hxx> |
40 | |
41 | |
42 | static Handle(Prs3d_LineAspect) GetLineAspect(const Handle(Prs3d_Drawer)& Dr, |
43 | const AIS_TypeOfAttribute Att) |
44 | { |
45 | switch(Att){ |
46 | case AIS_TOA_Line: |
47 | return Dr->LineAspect(); |
48 | break; |
a6eb515f |
49 | case AIS_TOA_Dimension: |
50 | return Dr->DimensionAspect()->LineAspect(); |
7fd59977 |
51 | break; |
52 | case AIS_TOA_Wire: |
53 | return Dr->WireAspect(); |
54 | break; |
55 | case AIS_TOA_Plane: |
56 | return Dr->PlaneAspect()->EdgesAspect(); |
57 | break; |
58 | case AIS_TOA_Vector: |
59 | return Dr->VectorAspect(); |
60 | break; |
61 | case AIS_TOA_UIso: |
62 | return Dr->UIsoAspect(); |
63 | break; |
64 | case AIS_TOA_VIso: |
65 | return Dr->VIsoAspect(); |
66 | break; |
67 | case AIS_TOA_Free: |
68 | return Dr->FreeBoundaryAspect(); |
69 | break; |
70 | case AIS_TOA_UnFree: |
71 | return Dr->UnFreeBoundaryAspect(); |
72 | break; |
73 | case AIS_TOA_Section: |
74 | return Dr->SectionAspect(); |
75 | break; |
76 | case AIS_TOA_Hidden: |
77 | return Dr->HiddenLineAspect(); |
78 | break; |
79 | case AIS_TOA_Seen: |
80 | return Dr->SeenLineAspect(); |
81 | break; |
82 | case AIS_TOA_FirstAxis: |
83 | return Dr->DatumAspect()->FirstAxisAspect(); |
84 | case AIS_TOA_SecondAxis: |
85 | return Dr->DatumAspect()->SecondAxisAspect(); |
86 | case AIS_TOA_ThirdAxis: |
87 | return Dr->DatumAspect()->SecondAxisAspect(); |
88 | } |
89 | Handle(Prs3d_LineAspect) bid; |
90 | return bid; |
91 | } |
92 | |
93 | Quantity_NameOfColor AIS_GraphicTool::GetLineColor (const Handle(Prs3d_Drawer)& Dr, const AIS_TypeOfAttribute Att) |
7fd59977 |
94 | { |
95 | Quantity_Color color; |
96 | GetLineColor(Dr,Att,color); |
97 | return color.Name(); |
98 | } |
99 | |
100 | void AIS_GraphicTool::GetLineColor (const Handle(Prs3d_Drawer)& Dr, const AIS_TypeOfAttribute Att, Quantity_Color &aColor) |
7fd59977 |
101 | { |
102 | Standard_Real W; |
103 | Aspect_TypeOfLine TYP; |
b8ddfc2f |
104 | GetLineAspect(Dr,Att)->Aspect()->Values(aColor,TYP,W); |
7fd59977 |
105 | } |
106 | |
107 | Standard_Real AIS_GraphicTool::GetLineWidth (const Handle(Prs3d_Drawer)& Dr, |
108 | const AIS_TypeOfAttribute Att) |
109 | { |
110 | // Quantity_NameOfColor Col; |
111 | Standard_Real W; |
112 | Aspect_TypeOfLine TYP; |
113 | |
114 | Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att); |
115 | |
116 | Quantity_Color QCol; |
117 | LA->Aspect()->Values(QCol,TYP,W); |
118 | return W; |
119 | } |
120 | Aspect_TypeOfLine AIS_GraphicTool::GetLineType (const Handle(Prs3d_Drawer)& Dr, |
121 | const AIS_TypeOfAttribute Att) |
122 | { |
123 | // Quantity_NameOfColor Col; |
124 | Standard_Real W; |
125 | Aspect_TypeOfLine TYP; |
126 | |
127 | Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att); |
128 | |
129 | Quantity_Color QCol; |
130 | LA->Aspect()->Values(QCol,TYP,W); |
131 | return TYP; |
132 | } |
133 | |
134 | |
135 | void AIS_GraphicTool::GetLineAtt(const Handle(Prs3d_Drawer)& Dr, |
136 | const AIS_TypeOfAttribute Att, |
137 | Quantity_NameOfColor& Col, |
138 | Standard_Real& W, |
139 | Aspect_TypeOfLine& TYP) |
140 | { |
141 | |
142 | Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att); |
143 | |
144 | Quantity_Color QCol; |
145 | LA->Aspect()->Values(QCol,TYP,W); |
146 | Col = QCol.Name(); |
147 | } |
148 | |
149 | Quantity_NameOfColor AIS_GraphicTool::GetInteriorColor(const Handle(Prs3d_Drawer)& Dr) |
7fd59977 |
150 | { |
151 | Quantity_Color color; |
152 | GetInteriorColor(Dr,color); |
153 | return color.Name(); |
154 | } |
155 | |
156 | void AIS_GraphicTool::GetInteriorColor(const Handle(Prs3d_Drawer)& Dr, Quantity_Color &aColor) |
7fd59977 |
157 | { |
158 | Handle(Graphic3d_AspectFillArea3d) AFA = Dr->ShadingAspect()->Aspect(); |
159 | Aspect_InteriorStyle IS; |
160 | Aspect_TypeOfLine T; |
161 | Standard_Real W; |
7fd59977 |
162 | Quantity_Color EC; |
163 | AFA->Values(IS,aColor,EC,T,W); |
7fd59977 |
164 | } |
165 | |
166 | Graphic3d_MaterialAspect AIS_GraphicTool::GetMaterial(const Handle(Prs3d_Drawer)& Dr) |
167 | { |
168 | return Dr->ShadingAspect()->Aspect()->BackMaterial(); |
7fd59977 |
169 | } |