1 // Created on: 1991-07-15
2 // Created by: Arnaud BOUZY
3 // Copyright (c) 1991-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
23 #include <Draw_Display.ixx>
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