1 // Created on: 1991-07-15
2 // Created by: Arnaud BOUZY
3 // Copyright (c) 1991-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.
18 #include <Draw_Color.hxx>
19 #include <Draw_Display.hxx>
21 #include <gp_Circ.hxx>
22 #include <gp_Circ2d.hxx>
24 #include <gp_Pnt2d.hxx>
26 extern Standard_Boolean Draw_Bounds;
29 //=======================================================================
30 //function : DrawMarker
32 //=======================================================================
34 void Draw_Display::DrawMarker (const gp_Pnt& pt,
35 const Draw_MarkerShape S,
36 const Standard_Integer Size)
43 //=======================================================================
44 //function : DrawMarker
46 //=======================================================================
48 void Draw_Display::DrawMarker (const gp_Pnt2d& pt,
49 const Draw_MarkerShape S,
50 const Standard_Integer ISize)
52 Draw_Bounds = Standard_False;
57 Standard_Real Size = ((Standard_Real) ISize) / Zoom();
62 p1.Translate(gp_Vec2d(-Size,-Size));
63 p2.Translate(gp_Vec2d( Size,-Size));
65 p1.Translate(gp_Vec2d(2*Size,2*Size));
67 p2.Translate(gp_Vec2d(-2*Size,2*Size));
69 p1.Translate(gp_Vec2d(-2*Size,-2*Size));
74 p1.Translate(gp_Vec2d(-Size,0));
75 p2.Translate(gp_Vec2d( 0,Size));
77 p1.Translate(gp_Vec2d(2*Size,0));
79 p2.Translate(gp_Vec2d(0,-2*Size));
81 p1.Translate(gp_Vec2d(-2*Size,0));
86 p1.Translate(gp_Vec2d(-Size,-Size));
87 p2.Translate(gp_Vec2d( Size,Size));
89 p1.Translate(gp_Vec2d(2*Size,0));
90 p2.Translate(gp_Vec2d(-2*Size,0));
95 p1.Translate(gp_Vec2d(-Size,0));
96 p2.Translate(gp_Vec2d( Size,0));
98 p1.Translate(gp_Vec2d(Size,Size));
99 p2.Translate(gp_Vec2d(-Size,-Size));
107 Draw(C, 0, 2*M_PI, Standard_False);
113 Draw_Bounds = Standard_True;
117 //=======================================================================
118 //function : DrawMarker
120 //=======================================================================
122 void Draw_Display::DrawMarker (const gp_Pnt& pt,
123 const Draw_MarkerShape S,
124 const Standard_Real Size)
128 DrawMarker(p,S,Size);
131 //=======================================================================
132 //function : DrawMarker
134 //=======================================================================
136 void Draw_Display::DrawMarker (const gp_Pnt2d& pt,
137 const Draw_MarkerShape S,
138 const Standard_Real R)
147 Standard_Integer I = (Standard_Integer ) R;
149 DrawMarker(pt, S, I);
152 case Draw_CircleZoom :
157 // if the circus is too small, a "plus" is drawn to mark the point
158 Standard_Boolean b = (R * Zoom()) > 2;
162 DrawMarker(pt, Draw_Plus);
164 Draw_Bounds = Standard_True;
171 //=======================================================================
174 //=======================================================================
176 void Draw_Display::Draw(const gp_Circ& C, const Standard_Real A1,const Standard_Real A3,
177 const Standard_Boolean ModifyWithZoom)
179 Standard_Real A2 = A3;
180 while (A2 < A1) A2 += 2*M_PI;
182 Standard_Real angle = DEFLECTION / (C.Radius() * Zoom());
183 Standard_Integer n = (Standard_Integer )( (A2 - A1) / angle);
185 angle = (A2 - A1) / MAXPNT;
189 angle = (A2 - A1) / 6;
192 Standard_Real c = 2*Cos(angle);
195 if(!ModifyWithZoom) {
196 Standard_Integer ISize = (Standard_Integer )( Cloc.Radius() / Zoom());
197 Cloc.SetRadius(ISize);
200 gp_Pnt PC = Cloc.Location();
201 gp_Pnt P = ElCLib::Value(A1,Cloc);
204 P = ElCLib::Value(A1+angle,Cloc);
209 for (Standard_Integer i = 2; i < n; i++) {
213 DrawTo(PC.Translated(V));
216 P = ElCLib::Value(A2,Cloc);
220 //=======================================================================
223 //=======================================================================
225 void Draw_Display::Draw(const gp_Circ2d& C, const Standard_Real A1, const Standard_Real A3,
226 const Standard_Boolean ModifyWithZoom)
228 Standard_Real A2 = A3;
229 while (A2 < A1) A2 += 2*M_PI;
231 Standard_Real angle = DEFLECTION / (C.Radius() * Zoom());
232 Standard_Integer n = (Standard_Integer )( (A2 - A1) / angle);
234 angle = (A2 - A1) / MAXPNT;
238 angle = (A2 - A1) / 6;
241 Standard_Real c = 2*Cos(angle);
244 if(!ModifyWithZoom) {// the effet of zoom is cancelled to follow
245 Standard_Real Size = Cloc.Radius() / Zoom();
246 Cloc.SetRadius(Size);
249 gp_Pnt2d PC = Cloc.Location();
250 gp_Pnt2d P = ElCLib::Value(A1,Cloc);
253 P = ElCLib::Value(A1+angle,Cloc);
258 for (Standard_Integer i = 2; i < n; i++) {
262 DrawTo(PC.Translated(V));
265 P = ElCLib::Value(A2,Cloc);
270 //=======================================================================
273 //=======================================================================
275 gp_Pnt2d Draw_Display::Project(const gp_Pnt& p) const