|
1 /* |
|
2 * Copyright (c) 2003-2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: trpoint implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "trpoint.h" |
|
22 |
|
23 // EXTERNAL DATA STRUCTURES |
|
24 |
|
25 // EXTERNAL FUNCTION PROTOTYPES |
|
26 |
|
27 // CONSTANTS |
|
28 |
|
29 // MACROS |
|
30 |
|
31 // LOCAL CONSTANTS AND MACROS |
|
32 |
|
33 // MODULE DATA STRUCTURES |
|
34 |
|
35 // LOCAL FUNCTION PROTOTYPES |
|
36 |
|
37 // FORWARD DECLARATIONS |
|
38 |
|
39 // ============================= LOCAL FUNCTIONS =============================== |
|
40 |
|
41 |
|
42 // ============================ MEMBER FUNCTIONS =============================== |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // TRPoint::TRPoint |
|
46 // C++ default constructor can NOT contain any code, that |
|
47 // might leave. |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 TRPoint::TRPoint() : |
|
51 iX( 0.0 ), |
|
52 iY( 0.0 ) |
|
53 { |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // TRPoint::TRPoint |
|
58 // C++ default constructor can NOT contain any code, that |
|
59 // might leave. |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 TRPoint::TRPoint( TReal aX, TReal aY ) : |
|
63 iX( aX ), |
|
64 iY( aY ) |
|
65 { |
|
66 } |
|
67 // ----------------------------------------------------------------------------- |
|
68 // TRPoint::operator== |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 TInt TRPoint::operator==( const TRPoint& aPoint ) const |
|
72 { |
|
73 if ( iX == aPoint.iX && iY == aPoint.iY ) |
|
74 { |
|
75 return 0; |
|
76 } |
|
77 |
|
78 return -1; |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // TRPoint::operator!= |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 TInt TRPoint::operator!=( const TRPoint& aPoint ) const |
|
86 { |
|
87 if ( iX != aPoint.iX || iY != aPoint.iY ) |
|
88 { |
|
89 return 0; |
|
90 } |
|
91 |
|
92 return -1; |
|
93 } |
|
94 |
|
95 // ----------------------------------------------------------------------------- |
|
96 // TRPoint::operator-= |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 TRPoint& TRPoint::operator-=( const TRPoint& aPoint ) |
|
100 { |
|
101 iX -= aPoint.iX; |
|
102 iY -= aPoint.iY; |
|
103 |
|
104 return *this; |
|
105 } |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // TRPoint::operator+= |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 TRPoint& TRPoint::operator+=( const TRPoint& aPoint ) |
|
112 { |
|
113 iX += aPoint.iX; |
|
114 iY += aPoint.iY; |
|
115 |
|
116 return *this; |
|
117 } |
|
118 |
|
119 // ----------------------------------------------------------------------------- |
|
120 // TRPoint::operator- |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 TRPoint TRPoint::operator-( const TRPoint& aPoint ) const |
|
124 { |
|
125 return TRPoint( iX - aPoint.iX, iY - aPoint.iY ); |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // TRPoint::operator+ |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 TRPoint TRPoint::operator+( const TRPoint& aPoint ) const |
|
133 { |
|
134 return TRPoint( iX + aPoint.iX, iY + aPoint.iY ); |
|
135 } |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // TRPoint::operator- |
|
139 // ----------------------------------------------------------------------------- |
|
140 // |
|
141 TRPoint TRPoint::operator-() const |
|
142 { |
|
143 return TRPoint( -iX, -iY ); |
|
144 } |
|
145 |
|
146 // ----------------------------------------------------------------------------- |
|
147 // TRPoint::SetXY |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 void TRPoint::SetXY( TInt aX, TInt aY ) |
|
151 { |
|
152 iX = aX; |
|
153 iY = aY; |
|
154 } |
|
155 |
|
156 // ----------------------------------------------------------------------------- |
|
157 // TRPoint::operator*= |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 TRPoint& TRPoint::operator*=( const TReal aVal ) |
|
161 { |
|
162 iX *= aVal; |
|
163 iY *= aVal; |
|
164 return *this; |
|
165 } |
|
166 |
|
167 // ----------------------------------------------------------------------------- |
|
168 // TRPoint::operator/= |
|
169 // ----------------------------------------------------------------------------- |
|
170 // |
|
171 TRPoint& TRPoint::operator/=( const TReal aVal ) |
|
172 { |
|
173 iX /= aVal; |
|
174 iY /= aVal; |
|
175 return *this; |
|
176 } |
|
177 |
|
178 // ----------------------------------------------------------------------------- |
|
179 // TRPoint::operator* |
|
180 // ----------------------------------------------------------------------------- |
|
181 // |
|
182 TRPoint TRPoint::operator*( const TReal aVal ) const |
|
183 { |
|
184 return TRPoint( iX * aVal, iY * aVal ); |
|
185 } |
|
186 |
|
187 // ----------------------------------------------------------------------------- |
|
188 // TRPoint::operator/ |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 TRPoint TRPoint::operator/( const TReal aVal ) const |
|
192 { |
|
193 return TRPoint( iX / aVal, iY / aVal ); |
|
194 } |
|
195 |
|
196 // ----------------------------------------------------------------------------- |
|
197 // TRPoint::operator+= |
|
198 // ----------------------------------------------------------------------------- |
|
199 // |
|
200 TRPoint& TRPoint::operator+=( const TReal aVal ) |
|
201 { |
|
202 iX += aVal; |
|
203 iY += aVal; |
|
204 return *this; |
|
205 } |
|
206 |
|
207 // ----------------------------------------------------------------------------- |
|
208 // TRPoint::operator-= |
|
209 // ----------------------------------------------------------------------------- |
|
210 // |
|
211 TRPoint& TRPoint::operator-=( const TReal aVal ) |
|
212 { |
|
213 iX -= aVal; |
|
214 iY -= aVal; |
|
215 return *this; |
|
216 } |
|
217 |
|
218 // ----------------------------------------------------------------------------- |
|
219 // TRPoint::operator+ |
|
220 // ----------------------------------------------------------------------------- |
|
221 // |
|
222 TRPoint TRPoint::operator+( const TReal aVal ) const |
|
223 { |
|
224 return TRPoint( iX + aVal, iY + aVal ); |
|
225 } |
|
226 |
|
227 // ----------------------------------------------------------------------------- |
|
228 // TRPoint::operator- |
|
229 // ----------------------------------------------------------------------------- |
|
230 // |
|
231 TRPoint TRPoint::operator-( const TReal aVal ) const |
|
232 { |
|
233 return TRPoint( iX - aVal, iY - aVal ); |
|
234 } |
|
235 |
|
236 // End of File |