1 // Created on: 1997-01-21
2 // Created by: Prestataire Christiane ARMAND
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
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.
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.
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.
22 //GER61351 //GG_171199 Enable to set an object RGB color instead a restricted object NameOfColor.
24 #include <AIS_Circle.ixx>
25 #include <Aspect_TypeOfLine.hxx>
26 #include <Prs3d_Drawer.hxx>
27 #include <Prs3d_LineAspect.hxx>
28 #include <Graphic3d_AspectLine3d.hxx>
29 #include <Graphic3d_Structure.hxx>
30 #include <TColgp_Array1OfPnt.hxx>
31 #include <SelectMgr_EntityOwner.hxx>
32 #include <Select3D_SensitiveCircle.hxx>
33 #include <StdPrs_DeflectionCurve.hxx>
35 #include <Geom_Circle.hxx>
36 #include <GeomAdaptor_Curve.hxx>
37 #include <AIS_Drawer.hxx>
38 #include <GC_MakeArcOfCircle.hxx>
39 #include <Quantity_Color.hxx>
40 #include <AIS_GraphicTool.hxx>
42 //=======================================================================
43 //function : AIS_Circle
45 //=======================================================================
46 AIS_Circle::AIS_Circle(const Handle(Geom_Circle)& aComponent):
47 AIS_InteractiveObject(PrsMgr_TOP_AllView),
48 myComponent(aComponent),
51 myCircleIsArc(Standard_False)
55 //=======================================================================
56 //function : AIS_Circle
58 //=======================================================================
59 AIS_Circle::AIS_Circle(const Handle(Geom_Circle)& aComponent,
60 const Standard_Real aUStart,
61 const Standard_Real aUEnd,
62 const Standard_Boolean aSens):
63 AIS_InteractiveObject(PrsMgr_TOP_AllView)
65 myComponent = aComponent;
69 myCircleIsArc = Standard_True;
72 //=======================================================================
75 //=======================================================================
76 void AIS_Circle::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
77 const Handle(Prs3d_Presentation)& aPresentation,
78 const Standard_Integer /*aMode*/)
80 aPresentation->Clear();
82 aPresentation->SetDisplayPriority(5);
84 if (myCircleIsArc) ComputeArc(aPresentation);
85 else ComputeCircle(aPresentation);
89 //=======================================================================
92 //=======================================================================
94 void AIS_Circle::Compute(const Handle_Prs3d_Projector& aProjector,
95 const Handle_Geom_Transformation& aTransformation,
96 const Handle_Prs3d_Presentation& aPresentation)
98 // Standard_NotImplemented::Raise("AIS_Circle::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
99 PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ;
102 //=======================================================================
103 //function : ComputeSelection
105 //=======================================================================
107 void AIS_Circle::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
108 const Standard_Integer /*aMode*/)
111 if (myCircleIsArc) ComputeArcSelection(aSelection);
112 else ComputeCircleSelection(aSelection);
117 //=======================================================================
118 //function : SetColor
120 //=======================================================================
122 void AIS_Circle::SetColor(const Quantity_NameOfColor aCol)
124 SetColor(Quantity_Color(aCol));
127 //=======================================================================
128 //function : SetColor
130 //=======================================================================
132 void AIS_Circle::SetColor(const Quantity_Color &aCol)
134 hasOwnColor=Standard_True;
137 Standard_Real WW = HasWidth()? myOwnWidth:
138 AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line);
140 if (!myDrawer->HasLineAspect ())
141 myDrawer->SetLineAspect (new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW));
143 myDrawer->LineAspect()->SetColor(aCol);
148 //=======================================================================
149 //function : SetWidth
151 //=======================================================================
152 void AIS_Circle::SetWidth(const Standard_Real aValue)
156 if (!myDrawer->HasLineAspect ()) {
158 if( HasColor() ) CC = myOwnColor;
159 else AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC);
160 myDrawer->SetLineAspect (new Prs3d_LineAspect(CC,Aspect_TOL_SOLID,aValue));
162 myDrawer->LineAspect()->SetWidth(aValue);
166 //=======================================================================
167 //function : UnsetColor
169 //=======================================================================
170 void AIS_Circle::UnsetColor()
172 hasOwnColor = Standard_False;
174 Handle(Prs3d_LineAspect) NullAsp;
176 if (!HasWidth()) myDrawer->SetLineAspect(NullAsp);
179 if( HasColor() ) CC = myOwnColor;
180 else AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC);
181 myDrawer->LineAspect()->SetColor(CC);
186 //=======================================================================
187 //function : UnsetWidth
189 //=======================================================================
190 void AIS_Circle::UnsetWidth()
192 Handle(Prs3d_LineAspect) NullAsp;
194 if (!HasColor()) myDrawer->SetLineAspect(NullAsp);
196 Standard_Real WW = AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line);
197 myDrawer->LineAspect()->SetWidth(WW);
202 //=======================================================================
203 //function : ComputeCircle
205 //=======================================================================
206 void AIS_Circle::ComputeCircle( const Handle(Prs3d_Presentation)& aPresentation)
209 GeomAdaptor_Curve curv(myComponent);
210 Standard_Real prevdev = myDrawer->DeviationCoefficient();
211 myDrawer->SetDeviationCoefficient(1.e-5);
212 StdPrs_DeflectionCurve::Add(aPresentation,curv,myDrawer);
213 myDrawer->SetDeviationCoefficient(prevdev);
217 //=======================================================================
218 //function : ComputeArc
221 //=======================================================================
222 void AIS_Circle::ComputeArc( const Handle(Prs3d_Presentation)& aPresentation)
224 GeomAdaptor_Curve curv(myComponent,myUStart,myUEnd);
225 Standard_Real prevdev = myDrawer->DeviationCoefficient();
226 myDrawer->SetDeviationCoefficient(1.e-5);
227 StdPrs_DeflectionCurve::Add(aPresentation,curv,myDrawer);
228 myDrawer->SetDeviationCoefficient(prevdev);
231 //=======================================================================
232 //function : ComputeCircleSelection
234 //=======================================================================
236 void AIS_Circle::ComputeCircleSelection(const Handle(SelectMgr_Selection)& aSelection)
238 Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this);
239 Handle(Select3D_SensitiveCircle) seg = new Select3D_SensitiveCircle(eown,
241 aSelection->Add(seg);
243 //=======================================================================
244 //function : ComputeArcSelection
246 //=======================================================================
248 void AIS_Circle::ComputeArcSelection(const Handle(SelectMgr_Selection)& aSelection)
252 Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this);
253 Handle(Select3D_SensitiveCircle) seg = new Select3D_SensitiveCircle(eown,
254 myComponent,myUStart,myUEnd);
255 aSelection->Add(seg);
258 //=======================================================================
260 //purpose : to avoid warning
261 //=======================================================================
262 void AIS_Circle::Compute(const Handle(Prs3d_Projector)&,
263 const Handle(Prs3d_Presentation)&)