1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
4 // The content of this file is subject to the Open CASCADE Technology Public
5 // License Version 6.5 (the "License"). You may not use the content of this file
6 // except in compliance with the License. Please obtain a copy of the License
7 // at http://www.opencascade.org and read it completely before using this file.
9 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 // The Original Code and all software distributed under the License is
13 // distributed on an "AS IS" basis, without warranty of any kind, and the
14 // Initial Developer hereby disclaims all such warranties, including without
15 // limitation, any warranties of merchantability, fitness for a particular
16 // purpose or non-infringement. Please see the License for the specific terms
17 // and conditions governing the rights and limitations under the License.
19 #include <DrawTrSurf_BezierCurve2d.ixx>
21 #include <Geom2d_BezierCurve.hxx>
23 #include <TColgp_Array1OfPnt2d.hxx>
24 #include <TColStd_Array1OfReal.hxx>
27 DrawTrSurf_BezierCurve2d::DrawTrSurf_BezierCurve2d (
28 const Handle(Geom2d_BezierCurve)& C) :
29 DrawTrSurf_Curve2d (C, Draw_vert, 50) {
31 drawPoles = Standard_True;
32 polesLook = Draw_rouge;
36 DrawTrSurf_BezierCurve2d::DrawTrSurf_BezierCurve2d (
37 const Handle(Geom2d_BezierCurve)& C, const Draw_Color& CurvColor,
38 const Draw_Color& PolesColor, const Standard_Boolean ShowPoles,
39 const Standard_Integer Discret) : DrawTrSurf_Curve2d (C, CurvColor, Discret) {
41 drawPoles = ShowPoles;
42 polesLook = PolesColor;
46 void DrawTrSurf_BezierCurve2d::DrawOn (Draw_Display& dis) const
49 Handle(Geom2d_BezierCurve) C = Handle(Geom2d_BezierCurve)::DownCast(curv);
52 dis.SetColor(polesLook);
53 TColgp_Array1OfPnt2d CPoles (1, C->NbPoles());
55 dis.MoveTo(CPoles(1));
56 for (Standard_Integer i = 2; i <= C->NbPoles(); i++) {
57 dis.DrawTo(CPoles(i));
61 DrawTrSurf_Curve2d::DrawOn(dis);
67 void DrawTrSurf_BezierCurve2d::ShowPoles ()
69 drawPoles = Standard_True;
73 void DrawTrSurf_BezierCurve2d::ClearPoles ()
75 drawPoles = Standard_False;
79 void DrawTrSurf_BezierCurve2d::FindPole (
80 const Standard_Real X,
81 const Standard_Real Y,
82 const Draw_Display& D,
83 const Standard_Real XPrec,
84 Standard_Integer& Index) const
87 Handle(Geom2d_BezierCurve) bz = Handle(Geom2d_BezierCurve)::DownCast(curv);
88 gp_Pnt2d p1(X/D.Zoom(),Y/D.Zoom());
89 Standard_Real Prec = XPrec / D.Zoom();
91 Standard_Integer NbPoles = bz->NbPoles();
94 while (Index <= NbPoles) {
95 P2d = bz->Pole(Index);
96 P.SetCoord (P2d.X(), P2d.Y(), 0.0);
97 if (D.Project(P).Distance(p1) <= Prec)
104 //=======================================================================
107 //=======================================================================
109 Handle(Draw_Drawable3D) DrawTrSurf_BezierCurve2d::Copy()const
111 Handle(DrawTrSurf_BezierCurve2d) DC = new DrawTrSurf_BezierCurve2d
112 (Handle(Geom2d_BezierCurve)::DownCast(curv->Copy()),
115 GetDiscretisation());