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