1 // Created on: 1997-01-21
2 // Created by: Prestataire Christiane ARMAND
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 //GER61351 //GG_171199 Enable to set an object RGB color instead a restricted object NameOfColor.
19 #include <AIS_Circle.ixx>
20 #include <Aspect_TypeOfLine.hxx>
21 #include <Prs3d_Drawer.hxx>
22 #include <Prs3d_LineAspect.hxx>
23 #include <Graphic3d_AspectLine3d.hxx>
24 #include <Graphic3d_Structure.hxx>
25 #include <TColgp_Array1OfPnt.hxx>
26 #include <SelectMgr_EntityOwner.hxx>
27 #include <Select3D_SensitiveCircle.hxx>
28 #include <StdPrs_DeflectionCurve.hxx>
30 #include <Geom_Circle.hxx>
31 #include <GeomAdaptor_Curve.hxx>
32 #include <AIS_Drawer.hxx>
33 #include <GC_MakeArcOfCircle.hxx>
34 #include <Quantity_Color.hxx>
35 #include <AIS_GraphicTool.hxx>
37 //=======================================================================
38 //function : AIS_Circle
40 //=======================================================================
41 AIS_Circle::AIS_Circle(const Handle(Geom_Circle)& aComponent):
42 AIS_InteractiveObject(PrsMgr_TOP_AllView),
43 myComponent(aComponent),
46 myCircleIsArc(Standard_False),
47 myIsFilledCircleSens (Standard_False)
51 //=======================================================================
52 //function : AIS_Circle
54 //=======================================================================
55 AIS_Circle::AIS_Circle(const Handle(Geom_Circle)& theComponent,
56 const Standard_Real theUStart,
57 const Standard_Real theUEnd,
58 const Standard_Boolean theIsFilledCircleSens)
59 : AIS_InteractiveObject(PrsMgr_TOP_AllView),
60 myComponent (theComponent),
63 myCircleIsArc (Standard_True),
64 myIsFilledCircleSens (theIsFilledCircleSens)
68 //=======================================================================
71 //=======================================================================
72 void AIS_Circle::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
73 const Handle(Prs3d_Presentation)& aPresentation,
74 const Standard_Integer /*aMode*/)
76 aPresentation->Clear();
78 aPresentation->SetDisplayPriority(5);
80 if (myCircleIsArc) ComputeArc(aPresentation);
81 else ComputeCircle(aPresentation);
85 //=======================================================================
88 //=======================================================================
90 void AIS_Circle::Compute(const Handle_Prs3d_Projector& aProjector,
91 const Handle_Geom_Transformation& aTransformation,
92 const Handle_Prs3d_Presentation& aPresentation)
94 // Standard_NotImplemented::Raise("AIS_Circle::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
95 PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ;
98 //=======================================================================
99 //function : ComputeSelection
101 //=======================================================================
103 void AIS_Circle::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
104 const Standard_Integer /*aMode*/)
107 if (myCircleIsArc) ComputeArcSelection(aSelection);
108 else ComputeCircleSelection(aSelection);
113 //=======================================================================
114 //function : SetColor
116 //=======================================================================
118 void AIS_Circle::SetColor(const Quantity_NameOfColor aCol)
120 SetColor(Quantity_Color(aCol));
123 //=======================================================================
124 //function : SetColor
126 //=======================================================================
128 void AIS_Circle::SetColor(const Quantity_Color &aCol)
130 hasOwnColor=Standard_True;
133 Standard_Real WW = HasWidth()? myOwnWidth:
134 AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line);
136 if (!myDrawer->HasLineAspect ())
137 myDrawer->SetLineAspect (new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW));
139 myDrawer->LineAspect()->SetColor(aCol);
144 //=======================================================================
145 //function : SetWidth
147 //=======================================================================
148 void AIS_Circle::SetWidth(const Standard_Real aValue)
152 if (!myDrawer->HasLineAspect ()) {
154 if( HasColor() ) CC = myOwnColor;
155 else AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC);
156 myDrawer->SetLineAspect (new Prs3d_LineAspect(CC,Aspect_TOL_SOLID,aValue));
158 myDrawer->LineAspect()->SetWidth(aValue);
162 //=======================================================================
163 //function : UnsetColor
165 //=======================================================================
166 void AIS_Circle::UnsetColor()
168 hasOwnColor = Standard_False;
170 Handle(Prs3d_LineAspect) NullAsp;
172 if (!HasWidth()) myDrawer->SetLineAspect(NullAsp);
175 if( HasColor() ) CC = myOwnColor;
176 else AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC);
177 myDrawer->LineAspect()->SetColor(CC);
182 //=======================================================================
183 //function : UnsetWidth
185 //=======================================================================
186 void AIS_Circle::UnsetWidth()
188 Handle(Prs3d_LineAspect) NullAsp;
190 if (!HasColor()) myDrawer->SetLineAspect(NullAsp);
192 Standard_Real WW = AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line);
193 myDrawer->LineAspect()->SetWidth(WW);
198 //=======================================================================
199 //function : ComputeCircle
201 //=======================================================================
202 void AIS_Circle::ComputeCircle( const Handle(Prs3d_Presentation)& aPresentation)
205 GeomAdaptor_Curve curv(myComponent);
206 Standard_Real prevdev = myDrawer->DeviationCoefficient();
207 myDrawer->SetDeviationCoefficient(1.e-5);
208 StdPrs_DeflectionCurve::Add(aPresentation,curv,myDrawer);
209 myDrawer->SetDeviationCoefficient(prevdev);
213 //=======================================================================
214 //function : ComputeArc
217 //=======================================================================
218 void AIS_Circle::ComputeArc( const Handle(Prs3d_Presentation)& aPresentation)
220 GeomAdaptor_Curve curv(myComponent,myUStart,myUEnd);
221 Standard_Real prevdev = myDrawer->DeviationCoefficient();
222 myDrawer->SetDeviationCoefficient(1.e-5);
223 StdPrs_DeflectionCurve::Add(aPresentation,curv,myDrawer);
224 myDrawer->SetDeviationCoefficient(prevdev);
227 //=======================================================================
228 //function : ComputeCircleSelection
230 //=======================================================================
232 void AIS_Circle::ComputeCircleSelection(const Handle(SelectMgr_Selection)& aSelection)
234 Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this);
235 Handle(Select3D_SensitiveCircle) seg = new Select3D_SensitiveCircle (eown,
237 myIsFilledCircleSens);
238 aSelection->Add(seg);
240 //=======================================================================
241 //function : ComputeArcSelection
243 //=======================================================================
245 void AIS_Circle::ComputeArcSelection(const Handle(SelectMgr_Selection)& aSelection)
249 Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this);
250 Handle(Select3D_SensitiveCircle) seg = new Select3D_SensitiveCircle (eown,
253 myIsFilledCircleSens);
254 aSelection->Add(seg);
257 //=======================================================================
259 //purpose : to avoid warning
260 //=======================================================================
261 void AIS_Circle::Compute(const Handle(Prs3d_Projector)&,
262 const Handle(Prs3d_Presentation)&)