]>
Commit | Line | Data |
---|---|---|
dee1d5f1 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
5f91c9e8 | 16 | // $Id$ |
2c605e66 | 17 | // $MpId: AliMpArea.cxx,v 1.7 2006/03/17 11:34:46 ivana Exp $ |
5f91c9e8 | 18 | // Category: basic |
19 | // | |
20 | // Class AliMpArea | |
21 | // ---------------- | |
22 | // Class that defines a rectangle area positioned in plane.. | |
3ffe1a93 | 23 | // Included in AliRoot: 2003/05/02 |
5f91c9e8 | 24 | // Authors: David Guez, Ivana Hrivnacova; IPN Orsay |
25 | ||
5f91c9e8 | 26 | #include "AliMpArea.h" |
27 | ||
2c605e66 | 28 | #include <Riostream.h> |
29 | ||
5f91c9e8 | 30 | ClassImp(AliMpArea) |
31 | ||
32 | ||
33 | //_____________________________________________________________________________ | |
34 | AliMpArea::AliMpArea(const TVector2& position, const TVector2& dimensions) | |
35 | : TObject(), | |
36 | fPosition(position), | |
37 | fDimensions(dimensions), | |
dee1d5f1 | 38 | fValidity(true) |
39 | { | |
40 | /// Standard constructor | |
41 | ||
5f91c9e8 | 42 | // Check dimensions |
dee1d5f1 | 43 | if ( fDimensions.X() < 0. || fDimensions.Y() < 0. || |
44 | ( fDimensions.X() == 0 && fDimensions.Y() == 0.0 ) ) { | |
5f91c9e8 | 45 | fDimensions = TVector2(); |
46 | fValidity = false; | |
47 | } | |
48 | } | |
49 | ||
50 | //_____________________________________________________________________________ | |
51 | AliMpArea::AliMpArea() | |
52 | : TObject(), | |
53 | fPosition(TVector2()), | |
54 | fDimensions(TVector2()), | |
dee1d5f1 | 55 | fValidity(false) |
56 | { | |
57 | /// Default constructor | |
5f91c9e8 | 58 | } |
59 | ||
60 | //_____________________________________________________________________________ | |
61 | AliMpArea::AliMpArea(const AliMpArea& rhs): | |
62 | TObject(rhs), | |
63 | fPosition(rhs.fPosition), | |
dee1d5f1 | 64 | fDimensions(rhs.fDimensions) |
65 | { | |
66 | /// Copy constructor | |
5f91c9e8 | 67 | } |
68 | ||
69 | //_____________________________________________________________________________ | |
dee1d5f1 | 70 | AliMpArea::~AliMpArea() |
71 | { | |
72 | /// Destructor | |
5f91c9e8 | 73 | } |
74 | ||
75 | // | |
76 | // operators | |
77 | // | |
78 | ||
79 | //______________________________________________________________________________ | |
80 | AliMpArea& AliMpArea::operator = (const AliMpArea& right) | |
81 | { | |
dee1d5f1 | 82 | /// Assignment operator |
5f91c9e8 | 83 | |
dee1d5f1 | 84 | // check assignment to self |
5f91c9e8 | 85 | if (this == &right) return *this; |
86 | ||
dee1d5f1 | 87 | // base class assignment |
5f91c9e8 | 88 | TObject::operator=(right); |
89 | ||
90 | fPosition = right.fPosition; | |
91 | fDimensions = right.fDimensions; | |
92 | fValidity = right.fValidity; | |
93 | ||
94 | return *this; | |
95 | } | |
96 | ||
97 | // | |
98 | // public methods | |
99 | // | |
100 | ||
101 | //_____________________________________________________________________________ | |
102 | Double_t AliMpArea::LeftBorder() const | |
103 | { | |
dee1d5f1 | 104 | /// Return the position of the left edge. |
5f91c9e8 | 105 | |
106 | return fPosition.X() - fDimensions.X(); | |
107 | } | |
108 | ||
109 | //_____________________________________________________________________________ | |
110 | Double_t AliMpArea::RightBorder() const | |
111 | { | |
dee1d5f1 | 112 | /// Return the position of right edge. |
5f91c9e8 | 113 | |
114 | return fPosition.X() + fDimensions.X(); | |
115 | } | |
116 | ||
117 | //_____________________________________________________________________________ | |
118 | Double_t AliMpArea::UpBorder() const | |
119 | { | |
dee1d5f1 | 120 | /// Return the position of the up edge. |
5f91c9e8 | 121 | |
122 | return fPosition.Y() + fDimensions.Y(); | |
123 | } | |
124 | ||
125 | //_____________________________________________________________________________ | |
126 | Double_t AliMpArea::DownBorder() const | |
127 | { | |
dee1d5f1 | 128 | /// Return the position of the down edge. |
5f91c9e8 | 129 | |
130 | return fPosition.Y() - fDimensions.Y(); | |
131 | } | |
132 | ||
133 | //_____________________________________________________________________________ | |
134 | TVector2 AliMpArea::LeftDownCorner() const | |
135 | { | |
dee1d5f1 | 136 | /// Return position of the left down corner. |
5f91c9e8 | 137 | |
138 | return TVector2(LeftBorder(), DownBorder()); | |
139 | } | |
140 | ||
141 | //_____________________________________________________________________________ | |
142 | TVector2 AliMpArea::LeftUpCorner() const | |
143 | { | |
dee1d5f1 | 144 | /// Return position of the left up corner. |
5f91c9e8 | 145 | |
146 | return TVector2(LeftBorder(), UpBorder()); | |
147 | } | |
148 | ||
149 | //_____________________________________________________________________________ | |
150 | TVector2 AliMpArea::RightDownCorner() const | |
151 | { | |
dee1d5f1 | 152 | /// Return position of the right down corner. |
5f91c9e8 | 153 | |
154 | return TVector2(RightBorder(), DownBorder()); | |
155 | } | |
156 | ||
157 | ||
158 | //_____________________________________________________________________________ | |
159 | TVector2 AliMpArea::RightUpCorner() const | |
160 | { | |
dee1d5f1 | 161 | /// Return position of the right up corner. |
5f91c9e8 | 162 | |
163 | return TVector2(RightBorder(), UpBorder()); | |
164 | } | |
165 | ||
166 | //_____________________________________________________________________________ | |
167 | ostream& operator<< (ostream &stream,const AliMpArea& area) | |
168 | { | |
dee1d5f1 | 169 | /// Output streaming |
170 | ||
5f91c9e8 | 171 | stream << "Area: position: (" |
172 | << area.Position().X() << ", " << area.Position().Y() << ") " | |
173 | << " dimensions: (" | |
174 | << area.Dimensions().X() << ", " << area.Dimensions().Y() << ") " | |
175 | << endl; | |
176 | return stream; | |
177 | } | |
178 |