b311480e |
1 | // Created on: 1992-04-29 |
2 | // Created by: Remi LEQUETTE |
3 | // Copyright (c) 1992-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
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. |
10 | // |
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. |
13 | // |
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. |
20 | |
7fd59977 |
21 | |
22 | #include <Draw_Axis2D.ixx> |
23 | #include <gp_Vec2d.hxx> |
24 | #include <gp.hxx> |
25 | |
26 | extern Standard_Boolean Draw_Bounds; |
27 | |
28 | //======================================================================= |
29 | //function : Draw_Axis2D |
30 | //purpose : |
31 | //======================================================================= |
32 | |
33 | Draw_Axis2D::Draw_Axis2D (const Draw_Color& col, |
34 | const Standard_Integer Size) : |
35 | myAxes(gp_Pnt2d(0,0),gp_Dir2d(1,0)),myColor(col), mySize(Size) |
36 | { |
37 | } |
38 | |
39 | //======================================================================= |
40 | //function : Draw_Axis2D |
41 | //purpose : |
42 | //======================================================================= |
43 | |
44 | Draw_Axis2D::Draw_Axis2D (const gp_Pnt2d& p, |
45 | const Draw_Color& col, |
46 | const Standard_Integer Size) : |
47 | myAxes(p,gp_Dir2d(1,0)), myColor(col), mySize(Size) |
48 | { |
49 | } |
50 | |
51 | //======================================================================= |
52 | //function : Draw_Axis2D |
53 | //purpose : |
54 | //======================================================================= |
55 | |
56 | Draw_Axis2D::Draw_Axis2D (const gp_Ax22d& a, |
57 | const Draw_Color& col, |
58 | const Standard_Integer Size) : |
59 | myAxes(a), myColor(col), mySize(Size) |
60 | { |
61 | } |
62 | |
63 | //======================================================================= |
64 | //function : DrawOn |
65 | //purpose : |
66 | //======================================================================= |
67 | |
68 | void Draw_Axis2D::DrawOn (Draw_Display& dis) const |
69 | { |
70 | Draw_Bounds = Standard_False; |
71 | dis.SetColor(myColor); |
72 | Standard_Real z = dis.Zoom(); |
73 | z = (Standard_Real)mySize / z; |
74 | gp_Pnt2d P,P0 = myAxes.Location(); |
75 | P = P0.Translated(gp_Vec2d(myAxes.XDirection()) * z); |
76 | dis.Draw(P0,P); |
77 | dis.DrawString(P,"X"); |
78 | P = P0.Translated(gp_Vec2d(myAxes.YDirection()) * z); |
79 | dis.Draw(P0,P); |
80 | dis.DrawString(P,"Y"); |
81 | Draw_Bounds = Standard_True; |
82 | } |
83 | |