1 // File: AIS_Circle.cxx
2 // Created: Tue Jan 21 11:45:01 1997
3 // Author: Prestataire Christiane ARMAND
4 // <car@chamalox.paris1.matra-dtv.fr>
5 // Copyright: Matra Datavision 1997
7 #define GER61351 //GG_171199 Enable to set an object RGB color
8 // instead a restricted object NameOfColor.
10 #include <AIS_Circle.ixx>
11 #include <Aspect_TypeOfLine.hxx>
12 #include <Prs3d_Drawer.hxx>
13 #include <Prs3d_LineAspect.hxx>
14 #include <Graphic3d_ArrayOfPrimitives.hxx>
15 #include <Graphic3d_AspectLine3d.hxx>
16 #include <Graphic3d_Structure.hxx>
17 #include <TColgp_Array1OfPnt.hxx>
18 #include <SelectMgr_EntityOwner.hxx>
19 #include <Select3D_SensitiveCircle.hxx>
20 #include <StdPrs_DeflectionCurve.hxx>
22 #include <Geom_Circle.hxx>
23 #include <GeomAdaptor_Curve.hxx>
24 #include <AIS_Drawer.hxx>
25 #include <GC_MakeArcOfCircle.hxx>
26 #include <Quantity_Color.hxx>
27 #include <AIS_GraphicTool.hxx>
29 //=======================================================================
30 //function : AIS_Circle
32 //=======================================================================
33 AIS_Circle::AIS_Circle(const Handle(Geom_Circle)& aComponent):
34 AIS_InteractiveObject(PrsMgr_TOP_AllView),
35 myComponent(aComponent),
38 myCircleIsArc(Standard_False)
42 //=======================================================================
43 //function : AIS_Circle
45 //=======================================================================
46 AIS_Circle::AIS_Circle(const Handle(Geom_Circle)& aComponent,
47 const Standard_Real aUStart,
48 const Standard_Real aUEnd,
49 const Standard_Boolean aSens):
50 AIS_InteractiveObject(PrsMgr_TOP_AllView)
52 myComponent = aComponent;
56 myCircleIsArc = Standard_True;
59 //=======================================================================
62 //=======================================================================
63 void AIS_Circle::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
64 const Handle(Prs3d_Presentation)& aPresentation,
65 const Standard_Integer /*aMode*/)
67 aPresentation->Clear();
69 aPresentation->SetDisplayPriority(5);
71 if (myCircleIsArc) ComputeArc(aPresentation);
72 else ComputeCircle(aPresentation);
76 //=======================================================================
79 //=======================================================================
81 void AIS_Circle::Compute(const Handle_Prs3d_Projector& aProjector,
82 const Handle_Geom_Transformation& aTransformation,
83 const Handle_Prs3d_Presentation& aPresentation)
85 // Standard_NotImplemented::Raise("AIS_Circle::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
86 PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ;
89 //=======================================================================
90 //function : ComputeSelection
92 //=======================================================================
94 void AIS_Circle::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
95 const Standard_Integer /*aMode*/)
98 if (myCircleIsArc) ComputeArcSelection(aSelection);
99 else ComputeCircleSelection(aSelection);
104 //=======================================================================
105 //function : SetColor
107 //=======================================================================
109 void AIS_Circle::SetColor(const Quantity_NameOfColor aCol)
112 SetColor(Quantity_Color(aCol));
115 //=======================================================================
116 //function : SetColor
118 //=======================================================================
120 void AIS_Circle::SetColor(const Quantity_Color &aCol)
123 hasOwnColor=Standard_True;
126 Standard_Real WW = HasWidth()? myOwnWidth:
127 AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line);
129 if (!myDrawer->HasLineAspect ())
130 myDrawer->SetLineAspect (new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW));
132 myDrawer->LineAspect()->SetColor(aCol);
137 //=======================================================================
138 //function : SetWidth
140 //=======================================================================
141 void AIS_Circle::SetWidth(const Standard_Real aValue)
146 Quantity_NameOfColor CC =
147 HasColor() ? myOwnColor : AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line);
150 if (!myDrawer->HasLineAspect ()) {
153 if( HasColor() ) CC = myOwnColor;
154 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);
176 if( HasColor() ) CC = myOwnColor;
177 else AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC);
179 Quantity_NameOfColor CC =
181 AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line);
182 myDrawer->LineAspect()->SetColor(CC);
187 //=======================================================================
188 //function : UnsetWidth
190 //=======================================================================
191 void AIS_Circle::UnsetWidth()
193 Handle(Prs3d_LineAspect) NullAsp;
195 if (!HasColor()) myDrawer->SetLineAspect(NullAsp);
197 Standard_Real WW = AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line);
198 myDrawer->LineAspect()->SetWidth(WW);
203 //=======================================================================
204 //function : ComputeCircle
206 //=======================================================================
207 void AIS_Circle::ComputeCircle( const Handle(Prs3d_Presentation)& aPresentation)
210 GeomAdaptor_Curve curv(myComponent);
211 Standard_Real prevdev = myDrawer->DeviationCoefficient();
212 myDrawer->SetDeviationCoefficient(1.e-5);
213 Standard_Boolean isPrimitiveArraysEnabled = Graphic3d_ArrayOfPrimitives::IsEnable();
214 if(isPrimitiveArraysEnabled) Graphic3d_ArrayOfPrimitives::Disable();
215 StdPrs_DeflectionCurve::Add(aPresentation,curv,myDrawer);
216 if(isPrimitiveArraysEnabled) Graphic3d_ArrayOfPrimitives::Enable();
217 myDrawer->SetDeviationCoefficient(prevdev);
221 //=======================================================================
222 //function : ComputeArc
225 //=======================================================================
226 void AIS_Circle::ComputeArc( const Handle(Prs3d_Presentation)& aPresentation)
229 GeomAdaptor_Curve curv(myComponent,myUStart,myUEnd);
230 Standard_Real prevdev = myDrawer->DeviationCoefficient();
231 myDrawer->SetDeviationCoefficient(1.e-5);
232 Standard_Boolean isPrimitiveArraysEnabled = Graphic3d_ArrayOfPrimitives::IsEnable();
233 if(isPrimitiveArraysEnabled) Graphic3d_ArrayOfPrimitives::Disable();
234 StdPrs_DeflectionCurve::Add(aPresentation,curv,myDrawer);
235 if(isPrimitiveArraysEnabled) Graphic3d_ArrayOfPrimitives::Enable();
236 myDrawer->SetDeviationCoefficient(prevdev);
240 //=======================================================================
241 //function : ComputeCircleSelection
243 //=======================================================================
245 void AIS_Circle::ComputeCircleSelection(const Handle(SelectMgr_Selection)& aSelection)
247 Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this);
248 Handle(Select3D_SensitiveCircle) seg = new Select3D_SensitiveCircle(eown,
250 aSelection->Add(seg);
252 //=======================================================================
253 //function : ComputeArcSelection
255 //=======================================================================
257 void AIS_Circle::ComputeArcSelection(const Handle(SelectMgr_Selection)& aSelection)
261 Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this);
262 Handle(Select3D_SensitiveCircle) seg = new Select3D_SensitiveCircle(eown,
263 myComponent,myUStart,myUEnd);
264 aSelection->Add(seg);
266 //=======================================================================
268 //purpose : to avoid warning
269 //=======================================================================
270 void AIS_Circle::Compute(const Handle(PrsMgr_PresentationManager2d)&,
271 const Handle(Graphic2d_GraphicObject)&,
272 const Standard_Integer)
276 //=======================================================================
278 //purpose : to avoid warning
279 //=======================================================================
280 void AIS_Circle::Compute(const Handle(Prs3d_Projector)&,
281 const Handle(Prs3d_Presentation)&)