]>
Commit | Line | Data |
---|---|---|
5f91c9e8 | 1 | // $Id$ |
2 | // Category: basic | |
3 | // | |
4 | // Class AliMpArea | |
5 | // ---------------- | |
6 | // Class that defines a rectangle area positioned in plane.. | |
7 | // | |
8 | // Authors: David Guez, Ivana Hrivnacova; IPN Orsay | |
9 | ||
10 | #include <Riostream.h> | |
11 | ||
12 | #include "AliMpArea.h" | |
13 | ||
14 | ClassImp(AliMpArea) | |
15 | ||
16 | ||
17 | //_____________________________________________________________________________ | |
18 | AliMpArea::AliMpArea(const TVector2& position, const TVector2& dimensions) | |
19 | : TObject(), | |
20 | fPosition(position), | |
21 | fDimensions(dimensions), | |
22 | fValidity(true) { | |
23 | // | |
24 | // Check dimensions | |
25 | if (fDimensions.X() <= 0. || fDimensions.Y() <=0.) { | |
26 | fDimensions = TVector2(); | |
27 | fValidity = false; | |
28 | } | |
29 | } | |
30 | ||
31 | //_____________________________________________________________________________ | |
32 | AliMpArea::AliMpArea() | |
33 | : TObject(), | |
34 | fPosition(TVector2()), | |
35 | fDimensions(TVector2()), | |
36 | fValidity(false) { | |
37 | // | |
38 | } | |
39 | ||
40 | //_____________________________________________________________________________ | |
41 | AliMpArea::AliMpArea(const AliMpArea& rhs): | |
42 | TObject(rhs), | |
43 | fPosition(rhs.fPosition), | |
44 | fDimensions(rhs.fDimensions) { | |
45 | // | |
46 | } | |
47 | ||
48 | //_____________________________________________________________________________ | |
49 | AliMpArea::~AliMpArea() { | |
50 | // | |
51 | } | |
52 | ||
53 | // | |
54 | // operators | |
55 | // | |
56 | ||
57 | //______________________________________________________________________________ | |
58 | AliMpArea& AliMpArea::operator = (const AliMpArea& right) | |
59 | { | |
60 | // Assignement operator | |
61 | ||
62 | // check assignement to self | |
63 | if (this == &right) return *this; | |
64 | ||
65 | // base class assignement | |
66 | TObject::operator=(right); | |
67 | ||
68 | fPosition = right.fPosition; | |
69 | fDimensions = right.fDimensions; | |
70 | fValidity = right.fValidity; | |
71 | ||
72 | return *this; | |
73 | } | |
74 | ||
75 | // | |
76 | // public methods | |
77 | // | |
78 | ||
79 | //_____________________________________________________________________________ | |
80 | Double_t AliMpArea::LeftBorder() const | |
81 | { | |
82 | // Returns the position of the left edge. | |
83 | // -- | |
84 | ||
85 | return fPosition.X() - fDimensions.X(); | |
86 | } | |
87 | ||
88 | //_____________________________________________________________________________ | |
89 | Double_t AliMpArea::RightBorder() const | |
90 | { | |
91 | // Returns the position of right edge. | |
92 | // -- | |
93 | ||
94 | return fPosition.X() + fDimensions.X(); | |
95 | } | |
96 | ||
97 | //_____________________________________________________________________________ | |
98 | Double_t AliMpArea::UpBorder() const | |
99 | { | |
100 | // Returns the position of the up edge. | |
101 | // -- | |
102 | ||
103 | return fPosition.Y() + fDimensions.Y(); | |
104 | } | |
105 | ||
106 | //_____________________________________________________________________________ | |
107 | Double_t AliMpArea::DownBorder() const | |
108 | { | |
109 | // Returns the position of the down edge. | |
110 | // -- | |
111 | ||
112 | return fPosition.Y() - fDimensions.Y(); | |
113 | } | |
114 | ||
115 | //_____________________________________________________________________________ | |
116 | TVector2 AliMpArea::LeftDownCorner() const | |
117 | { | |
118 | // Returns position of the left down corner. | |
119 | // -- | |
120 | ||
121 | return TVector2(LeftBorder(), DownBorder()); | |
122 | } | |
123 | ||
124 | //_____________________________________________________________________________ | |
125 | TVector2 AliMpArea::LeftUpCorner() const | |
126 | { | |
127 | // Returns position of the left up corner. | |
128 | // -- | |
129 | ||
130 | return TVector2(LeftBorder(), UpBorder()); | |
131 | } | |
132 | ||
133 | //_____________________________________________________________________________ | |
134 | TVector2 AliMpArea::RightDownCorner() const | |
135 | { | |
136 | // Returns position of the right down corner. | |
137 | // -- | |
138 | ||
139 | return TVector2(RightBorder(), DownBorder()); | |
140 | } | |
141 | ||
142 | ||
143 | //_____________________________________________________________________________ | |
144 | TVector2 AliMpArea::RightUpCorner() const | |
145 | { | |
146 | // Returns position of the right up corner. | |
147 | // -- | |
148 | ||
149 | return TVector2(RightBorder(), UpBorder()); | |
150 | } | |
151 | ||
152 | //_____________________________________________________________________________ | |
153 | ostream& operator<< (ostream &stream,const AliMpArea& area) | |
154 | { | |
155 | stream << "Area: position: (" | |
156 | << area.Position().X() << ", " << area.Position().Y() << ") " | |
157 | << " dimensions: (" | |
158 | << area.Dimensions().X() << ", " << area.Dimensions().Y() << ") " | |
159 | << endl; | |
160 | return stream; | |
161 | } | |
162 |