0027772: Foundation Classes - define Standard_Boolean using C++ type "bool" instead...
[occt.git] / src / Draw / Draw_Box.cxx
CommitLineData
b311480e 1// Created on: 1995-03-10
2// Created by: Remi LEQUETTE
3// Copyright (c) 1995-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_Box.hxx>
19#include <Draw_Color.hxx>
20#include <Draw_Display.hxx>
21#include <gp_Pnt.hxx>
22#include <Standard_Type.hxx>
7fd59977 23
92efcf78 24IMPLEMENT_STANDARD_RTTIEXT(Draw_Box,Draw_Drawable3D)
25
7fd59977 26//=======================================================================
27//function : Draw_Box
28//purpose :
29//=======================================================================
7fd59977 30Draw_Box::Draw_Box(const gp_Pnt& p1, const gp_Pnt& p2, const Draw_Color& col) :
31 myFirst(p1), myLast(p2),myColor(col)
32{
33 Standard_Real t;
34 if (myLast.X() < myFirst.X()) {
35 t = myFirst.X();
36 myFirst.SetX(myLast.X());
37 myLast.SetX(t);
38 }
39 if (myLast.Y() < myFirst.Y()) {
40 t = myFirst.Y();
41 myFirst.SetY(myLast.Y());
42 myLast.SetY(t);
43 }
44 if (myLast.Z() < myFirst.Z()) {
45 t = myFirst.Z();
46 myFirst.SetZ(myLast.Z());
47 myLast.SetZ(t);
48 }
49}
50
51//=======================================================================
52//function : DrawOn
53//purpose :
54//=======================================================================
55
56void Draw_Box::DrawOn(Draw_Display& dis) const
57{
58 dis.SetColor(myColor);
59 gp_Pnt P = myFirst;
60
61 dis.MoveTo(P);
62 P.SetX(myLast.X());
63 dis.DrawTo(P);
64 P.SetY(myLast.Y());
65 dis.DrawTo(P);
66 P.SetZ(myLast.Z());
67 dis.DrawTo(P);
68 P.SetX(myFirst.X());
69 dis.DrawTo(P);
70 P.SetY(myFirst.Y());
71 dis.DrawTo(P);
72 P.SetZ(myFirst.Z());
73 dis.DrawTo(P);
74
75 P.SetX(myLast.X());
76 dis.MoveTo(P);
77 P.SetZ(myLast.Z());
78 dis.DrawTo(P);
79 P.SetX(myFirst.X());
80 dis.DrawTo(P);
81
82 P.SetX(myLast.X());
83 dis.MoveTo(P);
84 P.SetY(myLast.Y());
85 dis.DrawTo(P);
86
87 P.SetX(myFirst.X());
88 dis.MoveTo(P);
89 P.SetZ(myFirst.Z());
90 dis.DrawTo(P);
91 P.SetY(myFirst.Y());
92 dis.DrawTo(P);
93
94 P.SetY(myLast.Y());
95 dis.MoveTo(P);
96 P.SetX(myLast.X());
97 dis.DrawTo(P);
98}
99
100//=======================================================================
101//function : First
102//purpose :
103//=======================================================================
104
105const gp_Pnt& Draw_Box::First() const
106{
107 return myFirst;
108}
109
110//=======================================================================
111//function : First
112//purpose :
113//=======================================================================
114
115void Draw_Box::First(const gp_Pnt& P)
116{
117 myFirst = P;
118}
119
120//=======================================================================
121//function : Last
122//purpose :
123//=======================================================================
124
125const gp_Pnt& Draw_Box::Last() const
126{
127 return myLast;
128}
129
130//=======================================================================
131//function : Last
132//purpose :
133//=======================================================================
134
135void Draw_Box::Last(const gp_Pnt& P)
136{
137 myLast = P;
138}
139