0027772: Foundation Classes - define Standard_Boolean using C++ type "bool" instead...
[occt.git] / src / Draw / Draw_Axis2D.cxx
CommitLineData
b311480e 1// Created on: 1992-04-29
2// Created by: Remi LEQUETTE
3// Copyright (c) 1992-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
42cf5bc1 17
18#include <Draw_Axis2D.hxx>
19#include <Draw_Color.hxx>
20#include <Draw_Display.hxx>
7fd59977 21#include <gp.hxx>
42cf5bc1 22#include <gp_Ax22d.hxx>
23#include <gp_Pnt2d.hxx>
24#include <gp_Vec2d.hxx>
25#include <Standard_Type.hxx>
7fd59977 26
92efcf78 27IMPLEMENT_STANDARD_RTTIEXT(Draw_Axis2D,Draw_Drawable2D)
28
7fd59977 29extern Standard_Boolean Draw_Bounds;
30
31//=======================================================================
32//function : Draw_Axis2D
33//purpose :
34//=======================================================================
35
36Draw_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)
39{
40}
41
42//=======================================================================
43//function : Draw_Axis2D
44//purpose :
45//=======================================================================
46
47Draw_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)
51{
52}
53
54//=======================================================================
55//function : Draw_Axis2D
56//purpose :
57//=======================================================================
58
59Draw_Axis2D::Draw_Axis2D (const gp_Ax22d& a,
60 const Draw_Color& col,
61 const Standard_Integer Size) :
62 myAxes(a), myColor(col), mySize(Size)
63{
64}
65
66//=======================================================================
67//function : DrawOn
68//purpose :
69//=======================================================================
70
71void Draw_Axis2D::DrawOn (Draw_Display& dis) const
72{
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);
79 dis.Draw(P0,P);
80 dis.DrawString(P,"X");
81 P = P0.Translated(gp_Vec2d(myAxes.YDirection()) * z);
82 dis.Draw(P0,P);
83 dis.DrawString(P,"Y");
84 Draw_Bounds = Standard_True;
85}
86