Integration of OCCT 6.5.0 from SVN
[occt.git] / src / Draw / Draw_Box.cxx
1 // File:        Draw_Box.cxx
2 // Created:     Fri Mar 10 14:43:04 1995
3 // Author:      Remi LEQUETTE
4 //              <rle@phobox>
5
6
7 #include <Draw_Box.ixx>
8
9 //=======================================================================
10 //function : Draw_Box
11 //purpose  : 
12 //=======================================================================
13
14 Draw_Box::Draw_Box(const gp_Pnt& p1, const gp_Pnt& p2, const Draw_Color& col) :
15    myFirst(p1), myLast(p2),myColor(col)
16 {
17   Standard_Real t;
18   if (myLast.X() < myFirst.X()) {
19     t = myFirst.X();
20     myFirst.SetX(myLast.X());
21     myLast.SetX(t);
22   }
23   if (myLast.Y() < myFirst.Y()) {
24     t = myFirst.Y();
25     myFirst.SetY(myLast.Y());
26     myLast.SetY(t);
27   }
28   if (myLast.Z() < myFirst.Z()) {
29     t = myFirst.Z();
30     myFirst.SetZ(myLast.Z());
31     myLast.SetZ(t);
32   }
33 }
34
35 //=======================================================================
36 //function : DrawOn
37 //purpose  : 
38 //=======================================================================
39
40 void Draw_Box::DrawOn(Draw_Display& dis) const 
41 {
42   dis.SetColor(myColor);
43   gp_Pnt P = myFirst;
44
45   dis.MoveTo(P);
46   P.SetX(myLast.X());
47   dis.DrawTo(P);
48   P.SetY(myLast.Y());
49   dis.DrawTo(P);
50   P.SetZ(myLast.Z());
51   dis.DrawTo(P);
52   P.SetX(myFirst.X());
53   dis.DrawTo(P);
54   P.SetY(myFirst.Y());
55   dis.DrawTo(P);
56   P.SetZ(myFirst.Z());
57   dis.DrawTo(P);
58
59   P.SetX(myLast.X());
60   dis.MoveTo(P);
61   P.SetZ(myLast.Z());
62   dis.DrawTo(P);
63   P.SetX(myFirst.X());
64   dis.DrawTo(P);
65   
66   P.SetX(myLast.X());
67   dis.MoveTo(P);
68   P.SetY(myLast.Y());
69   dis.DrawTo(P);
70   
71   P.SetX(myFirst.X());
72   dis.MoveTo(P);
73   P.SetZ(myFirst.Z());
74   dis.DrawTo(P);
75   P.SetY(myFirst.Y());
76   dis.DrawTo(P);
77   
78   P.SetY(myLast.Y());
79   dis.MoveTo(P);
80   P.SetX(myLast.X());
81   dis.DrawTo(P);
82 }
83
84 //=======================================================================
85 //function : First
86 //purpose  : 
87 //=======================================================================
88
89 const gp_Pnt& Draw_Box::First() const 
90 {
91   return myFirst;
92 }
93
94 //=======================================================================
95 //function : First
96 //purpose  : 
97 //=======================================================================
98
99 void Draw_Box::First(const gp_Pnt& P)
100 {
101   myFirst = P;
102 }
103
104 //=======================================================================
105 //function : Last
106 //purpose  : 
107 //=======================================================================
108
109 const gp_Pnt& Draw_Box::Last() const 
110 {
111   return myLast;
112 }
113
114 //=======================================================================
115 //function : Last
116 //purpose  : 
117 //=======================================================================
118
119 void Draw_Box::Last(const gp_Pnt& P)
120 {
121   myLast = P;
122 }
123