0024624: Lost word in license statement in source files
[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
b8ddfc2f 17//GER61351 //GG_171199 Enable to set an object RGB color instead a restricted object NameOfColor.
7fd59977 18
19#include <AIS_Circle.ixx>
20#include <Aspect_TypeOfLine.hxx>
21#include <Prs3d_Drawer.hxx>
22#include <Prs3d_LineAspect.hxx>
7fd59977 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>
29#include <TopoDS.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>
36
37//=======================================================================
38//function : AIS_Circle
39//purpose :
40//=======================================================================
41AIS_Circle::AIS_Circle(const Handle(Geom_Circle)& aComponent):
42AIS_InteractiveObject(PrsMgr_TOP_AllView),
43myComponent(aComponent),
44myUStart(0.),
c6541a0c 45myUEnd(2*M_PI),
9e8804b6 46myCircleIsArc(Standard_False),
47myIsFilledCircleSens (Standard_False)
7fd59977 48{
49}
50
51//=======================================================================
52//function : AIS_Circle
53//purpose :
54//=======================================================================
9e8804b6 55AIS_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),
61 myUStart (theUStart),
62 myUEnd (theUEnd),
63 myCircleIsArc (Standard_True),
64 myIsFilledCircleSens (theIsFilledCircleSens)
7fd59977 65{
7fd59977 66}
67
68//=======================================================================
69//function : Compute
70//purpose :
71//=======================================================================
72void AIS_Circle::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
73 const Handle(Prs3d_Presentation)& aPresentation,
74 const Standard_Integer /*aMode*/)
75{
76 aPresentation->Clear();
77
78 aPresentation->SetDisplayPriority(5);
79
80 if (myCircleIsArc) ComputeArc(aPresentation);
81 else ComputeCircle(aPresentation);
82
83}
84
85//=======================================================================
86//function : Compute
87//purpose :
88//=======================================================================
89
90void AIS_Circle::Compute(const Handle_Prs3d_Projector& aProjector,
91 const Handle_Geom_Transformation& aTransformation,
92 const Handle_Prs3d_Presentation& aPresentation)
93{
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 ) ;
96}
97
98//=======================================================================
99//function : ComputeSelection
100//purpose :
101//=======================================================================
102
103void AIS_Circle::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
104 const Standard_Integer /*aMode*/)
105{
106
107 if (myCircleIsArc) ComputeArcSelection(aSelection);
108 else ComputeCircleSelection(aSelection);
109
110}
111
112
113//=======================================================================
114//function : SetColor
115//purpose :
116//=======================================================================
117
118void AIS_Circle::SetColor(const Quantity_NameOfColor aCol)
7fd59977 119{
120 SetColor(Quantity_Color(aCol));
121}
122
123//=======================================================================
124//function : SetColor
125//purpose :
126//=======================================================================
127
128void AIS_Circle::SetColor(const Quantity_Color &aCol)
7fd59977 129{
130 hasOwnColor=Standard_True;
131 myOwnColor=aCol;
132
133 Standard_Real WW = HasWidth()? myOwnWidth:
134 AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line);
135
136 if (!myDrawer->HasLineAspect ())
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//=======================================================================
148void AIS_Circle::SetWidth(const Standard_Real aValue)
149{
150 myOwnWidth=aValue;
151
7fd59977 152 if (!myDrawer->HasLineAspect ()) {
7fd59977 153 Quantity_Color CC;
154 if( HasColor() ) CC = myOwnColor;
155 else 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//=======================================================================
166void AIS_Circle::UnsetColor()
167{
168 hasOwnColor = Standard_False;
169
170 Handle(Prs3d_LineAspect) NullAsp;
171
172 if (!HasWidth()) myDrawer->SetLineAspect(NullAsp);
173 else{
b8ddfc2f 174 Quantity_Color CC;
175 if( HasColor() ) CC = myOwnColor;
176 else 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//=======================================================================
186void AIS_Circle::UnsetWidth()
187{
188 Handle(Prs3d_LineAspect) NullAsp;
189
190 if (!HasColor()) myDrawer->SetLineAspect(NullAsp);
191 else{
192 Standard_Real WW = AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line);
193 myDrawer->LineAspect()->SetWidth(WW);
194 myOwnWidth = WW;
195 }
196}
197
198//=======================================================================
199//function : ComputeCircle
200//purpose :
201//=======================================================================
202void 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//=======================================================================
218void 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
232void 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
245void 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//=======================================================================
261void AIS_Circle::Compute(const Handle(Prs3d_Projector)&,
262 const Handle(Prs3d_Presentation)&)
263{
264}