1 // Created on: 1992-04-29
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1992-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_Axis2D.hxx>
19 #include <Draw_Color.hxx>
20 #include <Draw_Display.hxx>
22 #include <gp_Ax22d.hxx>
23 #include <gp_Pnt2d.hxx>
24 #include <gp_Vec2d.hxx>
25 #include <Standard_Type.hxx>
27 IMPLEMENT_STANDARD_RTTIEXT(Draw_Axis2D,Draw_Drawable2D)
29 extern Standard_Boolean Draw_Bounds;
31 //=======================================================================
32 //function : Draw_Axis2D
34 //=======================================================================
36 Draw_Axis2D::Draw_Axis2D (const Draw_Color& col,
37 const Standard_Integer Size) :
38 myAxes(gp_Pnt2d(0,0),gp_Dir2d(1,0)),myColor(col), mySize(Size)
42 //=======================================================================
43 //function : Draw_Axis2D
45 //=======================================================================
47 Draw_Axis2D::Draw_Axis2D (const gp_Pnt2d& p,
48 const Draw_Color& col,
49 const Standard_Integer Size) :
50 myAxes(p,gp_Dir2d(1,0)), myColor(col), mySize(Size)
54 //=======================================================================
55 //function : Draw_Axis2D
57 //=======================================================================
59 Draw_Axis2D::Draw_Axis2D (const gp_Ax22d& a,
60 const Draw_Color& col,
61 const Standard_Integer Size) :
62 myAxes(a), myColor(col), mySize(Size)
66 //=======================================================================
69 //=======================================================================
71 void Draw_Axis2D::DrawOn (Draw_Display& dis) const
73 Draw_Bounds = Standard_False;
74 dis.SetColor(myColor);
75 Standard_Real z = dis.Zoom();
76 z = (Standard_Real)mySize / z;
77 gp_Pnt2d P,P0 = myAxes.Location();
78 P = P0.Translated(gp_Vec2d(myAxes.XDirection()) * z);
80 dis.DrawString(P,"X");
81 P = P0.Translated(gp_Vec2d(myAxes.YDirection()) * z);
83 dis.DrawString(P,"Y");
84 Draw_Bounds = Standard_True;