b311480e |
1 | // Created on: 1997-01-21 |
2 | // Created by: Prestataire Christiane ARMAND |
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_Circle.ixx> |
18 | #include <Aspect_TypeOfLine.hxx> |
19 | #include <Prs3d_Drawer.hxx> |
20 | #include <Prs3d_LineAspect.hxx> |
7fd59977 |
21 | #include <Graphic3d_AspectLine3d.hxx> |
22 | #include <Graphic3d_Structure.hxx> |
23 | #include <TColgp_Array1OfPnt.hxx> |
24 | #include <SelectMgr_EntityOwner.hxx> |
f751596e |
25 | #include <SelectMgr_Selection.hxx> |
7fd59977 |
26 | #include <Select3D_SensitiveCircle.hxx> |
27 | #include <StdPrs_DeflectionCurve.hxx> |
28 | #include <TopoDS.hxx> |
29 | #include <Geom_Circle.hxx> |
30 | #include <GeomAdaptor_Curve.hxx> |
7fd59977 |
31 | #include <GC_MakeArcOfCircle.hxx> |
32 | #include <Quantity_Color.hxx> |
33 | #include <AIS_GraphicTool.hxx> |
34 | |
35 | //======================================================================= |
36 | //function : AIS_Circle |
37 | //purpose : |
38 | //======================================================================= |
39 | AIS_Circle::AIS_Circle(const Handle(Geom_Circle)& aComponent): |
40 | AIS_InteractiveObject(PrsMgr_TOP_AllView), |
41 | myComponent(aComponent), |
42 | myUStart(0.), |
c6541a0c |
43 | myUEnd(2*M_PI), |
9e8804b6 |
44 | myCircleIsArc(Standard_False), |
45 | myIsFilledCircleSens (Standard_False) |
7fd59977 |
46 | { |
47 | } |
48 | |
49 | //======================================================================= |
50 | //function : AIS_Circle |
51 | //purpose : |
52 | //======================================================================= |
9e8804b6 |
53 | AIS_Circle::AIS_Circle(const Handle(Geom_Circle)& theComponent, |
54 | const Standard_Real theUStart, |
55 | const Standard_Real theUEnd, |
56 | const Standard_Boolean theIsFilledCircleSens) |
57 | : AIS_InteractiveObject(PrsMgr_TOP_AllView), |
58 | myComponent (theComponent), |
59 | myUStart (theUStart), |
60 | myUEnd (theUEnd), |
61 | myCircleIsArc (Standard_True), |
62 | myIsFilledCircleSens (theIsFilledCircleSens) |
7fd59977 |
63 | { |
7fd59977 |
64 | } |
65 | |
66 | //======================================================================= |
67 | //function : Compute |
68 | //purpose : |
69 | //======================================================================= |
70 | void AIS_Circle::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/, |
71 | const Handle(Prs3d_Presentation)& aPresentation, |
72 | const Standard_Integer /*aMode*/) |
73 | { |
74 | aPresentation->Clear(); |
75 | |
76 | aPresentation->SetDisplayPriority(5); |
77 | |
78 | if (myCircleIsArc) ComputeArc(aPresentation); |
79 | else ComputeCircle(aPresentation); |
80 | |
81 | } |
82 | |
83 | //======================================================================= |
84 | //function : Compute |
85 | //purpose : |
86 | //======================================================================= |
87 | |
857ffd5e |
88 | void AIS_Circle::Compute(const Handle(Prs3d_Projector)& aProjector, |
89 | const Handle(Geom_Transformation)& aTransformation, |
90 | const Handle(Prs3d_Presentation)& aPresentation) |
7fd59977 |
91 | { |
857ffd5e |
92 | // Standard_NotImplemented::Raise("AIS_Circle::Compute(const Handle(Prs3d_Projector)&, const Handle(Geom_Transformation)&, const Handle(Prs3d_Presentation)&)"); |
7fd59977 |
93 | PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ; |
94 | } |
95 | |
96 | //======================================================================= |
97 | //function : ComputeSelection |
98 | //purpose : |
99 | //======================================================================= |
100 | |
101 | void AIS_Circle::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, |
102 | const Standard_Integer /*aMode*/) |
103 | { |
104 | |
105 | if (myCircleIsArc) ComputeArcSelection(aSelection); |
106 | else ComputeCircleSelection(aSelection); |
107 | |
108 | } |
109 | |
110 | |
111 | //======================================================================= |
112 | //function : SetColor |
113 | //purpose : |
114 | //======================================================================= |
115 | |
116 | void AIS_Circle::SetColor(const Quantity_NameOfColor aCol) |
7fd59977 |
117 | { |
118 | SetColor(Quantity_Color(aCol)); |
119 | } |
120 | |
121 | //======================================================================= |
122 | //function : SetColor |
123 | //purpose : |
124 | //======================================================================= |
125 | |
126 | void AIS_Circle::SetColor(const Quantity_Color &aCol) |
7fd59977 |
127 | { |
128 | hasOwnColor=Standard_True; |
129 | myOwnColor=aCol; |
130 | |
6262338c |
131 | Standard_Real WW = HasWidth() ? myOwnWidth : |
132 | myDrawer->HasLink() ? |
133 | AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line) : |
134 | 1.; |
7fd59977 |
135 | |
6262338c |
136 | if (!myDrawer->HasOwnLineAspect ()) |
7fd59977 |
137 | myDrawer->SetLineAspect (new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW)); |
138 | else |
139 | myDrawer->LineAspect()->SetColor(aCol); |
140 | } |
141 | |
142 | |
143 | |
144 | //======================================================================= |
145 | //function : SetWidth |
146 | //purpose : |
147 | //======================================================================= |
148 | void AIS_Circle::SetWidth(const Standard_Real aValue) |
149 | { |
150 | myOwnWidth=aValue; |
151 | |
6262338c |
152 | if (!myDrawer->HasOwnLineAspect ()) { |
153 | Quantity_Color CC = Quantity_NOC_YELLOW; |
7fd59977 |
154 | if( HasColor() ) CC = myOwnColor; |
6262338c |
155 | else if(myDrawer->HasLink()) AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Line, CC); |
7fd59977 |
156 | myDrawer->SetLineAspect (new Prs3d_LineAspect(CC,Aspect_TOL_SOLID,aValue)); |
157 | } else |
158 | myDrawer->LineAspect()->SetWidth(aValue); |
159 | } |
160 | |
161 | |
162 | //======================================================================= |
163 | //function : UnsetColor |
164 | //purpose : |
165 | //======================================================================= |
166 | void AIS_Circle::UnsetColor() |
167 | { |
168 | hasOwnColor = Standard_False; |
169 | |
170 | Handle(Prs3d_LineAspect) NullAsp; |
171 | |
172 | if (!HasWidth()) myDrawer->SetLineAspect(NullAsp); |
173 | else{ |
6262338c |
174 | Quantity_Color CC = Quantity_NOC_YELLOW;; |
b8ddfc2f |
175 | if( HasColor() ) CC = myOwnColor; |
6262338c |
176 | else if (myDrawer->HasLink()) AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC); |
7fd59977 |
177 | myDrawer->LineAspect()->SetColor(CC); |
178 | myOwnColor = CC; |
b8ddfc2f |
179 | } |
7fd59977 |
180 | } |
181 | |
182 | //======================================================================= |
183 | //function : UnsetWidth |
184 | //purpose : |
185 | //======================================================================= |
186 | void AIS_Circle::UnsetWidth() |
187 | { |
188 | Handle(Prs3d_LineAspect) NullAsp; |
189 | |
190 | if (!HasColor()) myDrawer->SetLineAspect(NullAsp); |
191 | else{ |
6262338c |
192 | Standard_Real WW = myDrawer->HasLink() ? AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line) : 1.; |
7fd59977 |
193 | myDrawer->LineAspect()->SetWidth(WW); |
194 | myOwnWidth = WW; |
195 | } |
196 | } |
197 | |
198 | //======================================================================= |
199 | //function : ComputeCircle |
200 | //purpose : |
201 | //======================================================================= |
202 | void AIS_Circle::ComputeCircle( const Handle(Prs3d_Presentation)& aPresentation) |
203 | { |
204 | |
205 | GeomAdaptor_Curve curv(myComponent); |
206 | Standard_Real prevdev = myDrawer->DeviationCoefficient(); |
207 | myDrawer->SetDeviationCoefficient(1.e-5); |
7fd59977 |
208 | StdPrs_DeflectionCurve::Add(aPresentation,curv,myDrawer); |
7fd59977 |
209 | myDrawer->SetDeviationCoefficient(prevdev); |
210 | |
211 | } |
212 | |
213 | //======================================================================= |
214 | //function : ComputeArc |
215 | |
216 | //purpose : |
217 | //======================================================================= |
218 | void AIS_Circle::ComputeArc( const Handle(Prs3d_Presentation)& aPresentation) |
219 | { |
7fd59977 |
220 | GeomAdaptor_Curve curv(myComponent,myUStart,myUEnd); |
221 | Standard_Real prevdev = myDrawer->DeviationCoefficient(); |
222 | myDrawer->SetDeviationCoefficient(1.e-5); |
7fd59977 |
223 | StdPrs_DeflectionCurve::Add(aPresentation,curv,myDrawer); |
7fd59977 |
224 | myDrawer->SetDeviationCoefficient(prevdev); |
7fd59977 |
225 | } |
226 | |
227 | //======================================================================= |
228 | //function : ComputeCircleSelection |
229 | //purpose : |
230 | //======================================================================= |
231 | |
232 | void AIS_Circle::ComputeCircleSelection(const Handle(SelectMgr_Selection)& aSelection) |
233 | { |
234 | Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this); |
9e8804b6 |
235 | Handle(Select3D_SensitiveCircle) seg = new Select3D_SensitiveCircle (eown, |
236 | myComponent, |
237 | myIsFilledCircleSens); |
7fd59977 |
238 | aSelection->Add(seg); |
239 | } |
240 | //======================================================================= |
241 | //function : ComputeArcSelection |
242 | //purpose : |
243 | //======================================================================= |
244 | |
245 | void AIS_Circle::ComputeArcSelection(const Handle(SelectMgr_Selection)& aSelection) |
246 | { |
247 | |
248 | |
249 | Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this); |
9e8804b6 |
250 | Handle(Select3D_SensitiveCircle) seg = new Select3D_SensitiveCircle (eown, |
251 | myComponent, |
252 | myUStart, myUEnd, |
253 | myIsFilledCircleSens); |
7fd59977 |
254 | aSelection->Add(seg); |
255 | } |
7fd59977 |
256 | |
257 | //======================================================================= |
258 | //function : Compute |
259 | //purpose : to avoid warning |
260 | //======================================================================= |
261 | void AIS_Circle::Compute(const Handle(Prs3d_Projector)&, |
262 | const Handle(Prs3d_Presentation)&) |
263 | { |
264 | } |