Mercurial > projects > qtd
comparison qt/d1/qt/core/QLine.d @ 252:37eed70de029
More things broken than fixed. Rolling back to 263
author | maxter |
---|---|
date | Sat, 22 Aug 2009 12:50:58 +0000 |
parents | 7664de4a55e5 |
children | 34a37904ff77 |
comparison
equal
deleted
inserted
replaced
251:739d0ee5bd91 | 252:37eed70de029 |
---|---|
26 QLine ln; | 26 QLine ln; |
27 ln.pt1 = QPoint(x1pos, y1pos); | 27 ln.pt1 = QPoint(x1pos, y1pos); |
28 ln.pt2 = QPoint(x2pos, y2pos); | 28 ln.pt2 = QPoint(x2pos, y2pos); |
29 return ln; | 29 return ln; |
30 } | 30 } |
31 | 31 |
32 bool isNull() // const | 32 bool isNull() // const |
33 { | 33 { |
34 return pt1 == pt2; | 34 return pt1 == pt2; |
35 } | 35 } |
36 | 36 |
37 int x1() // const | 37 int x1() // const |
38 { | 38 { |
39 return pt1.x(); | 39 return pt1.x(); |
40 } | 40 } |
41 | 41 |
42 int y1() // const | 42 int y1() // const |
43 { | 43 { |
44 return pt1.y(); | 44 return pt1.y(); |
45 } | 45 } |
46 | 46 |
47 int x2() // const | 47 int x2() // const |
48 { | 48 { |
49 return pt2.x(); | 49 return pt2.x(); |
50 } | 50 } |
51 | 51 |
52 int y2() // const | 52 int y2() // const |
53 { | 53 { |
54 return pt2.y(); | 54 return pt2.y(); |
55 } | 55 } |
56 | 56 |
57 QPoint p1() // const | 57 QPoint p1() // const |
58 { | 58 { |
59 return pt1; | 59 return pt1; |
60 } | 60 } |
61 | 61 |
62 QPoint p2() // const | 62 QPoint p2() // const |
63 { | 63 { |
64 return pt2; | 64 return pt2; |
65 } | 65 } |
66 | 66 |
67 int dx() // const | 67 int dx() // const |
68 { | 68 { |
69 return pt2.x() - pt1.x(); | 69 return pt2.x() - pt1.x(); |
70 } | 70 } |
71 | 71 |
72 int dy() // const | 72 int dy() // const |
73 { | 73 { |
74 return pt2.y() - pt1.y(); | 74 return pt2.y() - pt1.y(); |
75 } | 75 } |
76 | 76 |
77 void translate(in QPoint point) | 77 void translate(in QPoint point) |
78 { | 78 { |
79 pt1 += point; | 79 pt1 += point; |
80 pt2 += point; | 80 pt2 += point; |
81 } | 81 } |
82 | 82 |
83 void translate(int adx, int ady) | 83 void translate(int adx, int ady) |
84 { | 84 { |
85 translate(QPoint(adx, ady)); | 85 translate(QPoint(adx, ady)); |
86 } | 86 } |
87 | 87 |
88 QLine translated(in QPoint p) // const | 88 QLine translated(in QPoint p) // const |
89 { | 89 { |
90 return QLine(pt1 + p, pt2 + p); | 90 return QLine(pt1 + p, pt2 + p); |
91 } | 91 } |
92 | 92 |
93 QLine translated(int adx, int ady) // const | 93 QLine translated(int adx, int ady) // const |
94 { | 94 { |
95 return translated(QPoint(adx, ady)); | 95 return translated(QPoint(adx, ady)); |
96 } | 96 } |
97 | 97 |
107 | 107 |
108 void setP1(in QPoint aP1) // for convenience | 108 void setP1(in QPoint aP1) // for convenience |
109 { | 109 { |
110 pt1 = aP1; | 110 pt1 = aP1; |
111 } | 111 } |
112 | 112 |
113 void setP2(in QPoint aP2) // for convenience | 113 void setP2(in QPoint aP2) // for convenience |
114 { | 114 { |
115 pt2 = aP2; | 115 pt2 = aP2; |
116 } | 116 } |
117 | 117 |
118 void setPoints(in QPoint aP1, in QPoint aP2) | 118 void setPoints(in QPoint aP1, in QPoint aP2) |
119 { | 119 { |
120 pt1 = aP1; | 120 pt1 = aP1; |
121 pt2 = aP2; | 121 pt2 = aP2; |
122 } | 122 } |
123 | 123 |
124 void setLine(int aX1, int aY1, int aX2, int aY2) | 124 void setLine(int aX1, int aY1, int aX2, int aY2) |
125 { | 125 { |
126 pt1 = QPoint(aX1, aY1); | 126 pt1 = QPoint(aX1, aY1); |
127 pt2 = QPoint(aX2, aY2); | 127 pt2 = QPoint(aX2, aY2); |
128 } | 128 } |
129 | 129 |
130 bool opEquals(in QLine d) // const | 130 bool opEquals(in QLine d) // const |
131 { | 131 { |
132 return pt1 == d.pt1 && pt2 == d.pt2; | 132 return pt1 == d.pt1 && pt2 == d.pt2; |
133 } | 133 } |
134 | 134 |
135 public final void writeTo(QDataStream arg__1) { | 135 public final void writeTo(QDataStream arg__1) { |
136 qtd_QLine_writeTo_QDataStream(this, arg__1 is null ? null : arg__1.__nativeId); | 136 qtd_QLine_writeTo_QDataStream(this, arg__1 is null ? null : arg__1.nativeId); |
137 } | 137 } |
138 | 138 |
139 public final void readFrom(QDataStream arg__1) { | 139 public final void readFrom(QDataStream arg__1) { |
140 qtd_QLine_readFrom_QDataStream(this, arg__1 is null ? null : arg__1.__nativeId); | 140 qtd_QLine_readFrom_QDataStream(this, arg__1 is null ? null : arg__1.nativeId); |
141 } | 141 } |
142 | 142 |
143 private: | 143 private: |
144 QPoint pt1, pt2; | 144 QPoint pt1, pt2; |
145 } | 145 } |
151 UnboundedIntersection = 2 | 151 UnboundedIntersection = 2 |
152 } | 152 } |
153 | 153 |
154 public struct QLineF | 154 public struct QLineF |
155 { | 155 { |
156 | 156 |
157 alias QLineF_IntersectType IntersectType; | 157 alias QLineF_IntersectType IntersectType; |
158 | 158 |
159 alias QLineF_IntersectType.NoIntersection NoIntersection; | 159 alias QLineF_IntersectType.NoIntersection NoIntersection; |
160 alias QLineF_IntersectType.BoundedIntersection BoundedIntersection; | 160 alias QLineF_IntersectType.BoundedIntersection BoundedIntersection; |
161 alias QLineF_IntersectType.UnboundedIntersection UnboundedIntersection; | 161 alias QLineF_IntersectType.UnboundedIntersection UnboundedIntersection; |
162 | 162 |
163 public static QLineF opCall() { | 163 public static QLineF opCall() { |
164 QLineF ln; | 164 QLineF ln; |
165 ln.pt1 = QPointF(); | 165 ln.pt1 = QPointF(); |
166 ln.pt2 = QPointF(); | 166 ln.pt2 = QPointF(); |
167 return ln; | 167 return ln; |
168 } | 168 } |
169 | 169 |
170 public static QLineF opCall(in QPointF apt1, in QPointF apt2) { | 170 public static QLineF opCall(in QPointF apt1, in QPointF apt2) { |
171 QLineF ln; | 171 QLineF ln; |
172 ln.pt1 = apt1; | 172 ln.pt1 = apt1; |
173 ln.pt2 = apt2; | 173 ln.pt2 = apt2; |
174 return ln; | 174 return ln; |
175 } | 175 } |
176 | 176 |
177 public static QLineF opCall(qreal x1pos, qreal y1pos, qreal x2pos, qreal y2pos) { | 177 public static QLineF opCall(qreal x1pos, qreal y1pos, qreal x2pos, qreal y2pos) { |
178 QLineF ln; | 178 QLineF ln; |
179 ln.pt1 = QPointF(x1pos, y1pos); | 179 ln.pt1 = QPointF(x1pos, y1pos); |
180 ln.pt2 = QPointF(x2pos, y2pos); | 180 ln.pt2 = QPointF(x2pos, y2pos); |
181 return ln; | 181 return ln; |
182 } | 182 } |
183 | 183 |
184 public static QLineF opCall(in QLine line){ | 184 public static QLineF opCall(in QLine line){ |
185 QLineF ln; | 185 QLineF ln; |
186 ln.pt1 = QPointF(line.p1()); | 186 ln.pt1 = QPointF(line.p1()); |
187 ln.pt2 = QPointF(line.p2()); | 187 ln.pt2 = QPointF(line.p2()); |
188 return ln; | 188 return ln; |
189 } | 189 } |
190 | 190 |
191 public final bool isNull() // const | 191 public final bool isNull() // const |
192 { | 192 { |
193 return qtd_QLineF_isNull(this); | 193 return qtd_QLineF_isNull(this); |
194 } | 194 } |
195 | 195 |
196 qreal x1() // const | 196 qreal x1() // const |
197 { | 197 { |
198 return pt1.x(); | 198 return pt1.x(); |
199 } | 199 } |
200 | 200 |
201 qreal y1() // const | 201 qreal y1() // const |
202 { | 202 { |
203 return pt1.y(); | 203 return pt1.y(); |
204 } | 204 } |
205 | 205 |
206 qreal x2() // const | 206 qreal x2() // const |
207 { | 207 { |
208 return pt2.x(); | 208 return pt2.x(); |
209 } | 209 } |
210 | 210 |
211 qreal y2() // const | 211 qreal y2() // const |
212 { | 212 { |
213 return pt2.y(); | 213 return pt2.y(); |
214 } | 214 } |
215 | 215 |
216 QPointF p1() // const | 216 QPointF p1() // const |
217 { | 217 { |
218 return pt1; | 218 return pt1; |
219 } | 219 } |
220 | 220 |
221 QPointF p2() // const | 221 QPointF p2() // const |
222 { | 222 { |
223 return pt2; | 223 return pt2; |
224 } | 224 } |
225 | 225 |
226 qreal dx() // const | 226 qreal dx() // const |
227 { | 227 { |
228 return pt2.x() - pt1.x(); | 228 return pt2.x() - pt1.x(); |
229 } | 229 } |
230 | 230 |
231 qreal dy() // const | 231 qreal dy() // const |
232 { | 232 { |
233 return pt2.y() - pt1.y(); | 233 return pt2.y() - pt1.y(); |
234 } | 234 } |
235 | 235 |
236 QLineF normalVector() // const | 236 QLineF normalVector() // const |
237 { | 237 { |
238 return QLineF(p1(), p1() + QPointF(dy(), -dx())); | 238 return QLineF(p1(), p1() + QPointF(dy(), -dx())); |
239 } | 239 } |
240 | 240 |
241 void translate(in QPointF point) | 241 void translate(in QPointF point) |
242 { | 242 { |
243 pt1 += point; | 243 pt1 += point; |
244 pt2 += point; | 244 pt2 += point; |
245 } | 245 } |
246 | 246 |
247 void translate(qreal adx, qreal ady) | 247 void translate(qreal adx, qreal ady) |
248 { | 248 { |
249 this.translate(QPointF(adx, ady)); | 249 this.translate(QPointF(adx, ady)); |
250 } | 250 } |
251 | 251 |
252 QLineF translated(in QPointF p) // const | 252 QLineF translated(in QPointF p) // const |
253 { | 253 { |
254 return QLineF(pt1 + p, pt2 + p); | 254 return QLineF(pt1 + p, pt2 + p); |
255 } | 255 } |
256 | 256 |
257 QLineF translated(qreal adx, qreal ady) // const | 257 QLineF translated(qreal adx, qreal ady) // const |
258 { | 258 { |
259 return translated(QPointF(adx, ady)); | 259 return translated(QPointF(adx, ady)); |
260 } | 260 } |
261 | 261 |
262 void setLength(qreal len) | 262 void setLength(qreal len) |
263 { | 263 { |
264 if (isNull()) | 264 if (isNull()) |
265 return; | 265 return; |
266 QLineF v = unitVector(); | 266 QLineF v = unitVector(); |
267 pt2 = QPointF(pt1.x() + v.dx() * len, pt1.y() + v.dy() * len); | 267 pt2 = QPointF(pt1.x() + v.dx() * len, pt1.y() + v.dy() * len); |
268 } | 268 } |
269 | 269 |
270 void length(qreal len) | 270 void length(qreal len) |
271 { | 271 { |
272 if (isNull()) | 272 if (isNull()) |
273 return; | 273 return; |
274 QLineF v = unitVector(); | 274 QLineF v = unitVector(); |
275 pt2 = QPointF(pt1.x() + v.dx() * len, pt1.y() + v.dy() * len); | 275 pt2 = QPointF(pt1.x() + v.dx() * len, pt1.y() + v.dy() * len); |
276 } | 276 } |
277 | 277 |
278 QPointF pointAt(qreal t) // const | 278 QPointF pointAt(qreal t) // const |
279 { | 279 { |
280 qreal vx = pt2.x() - pt1.x(); | 280 qreal vx = pt2.x() - pt1.x(); |
281 qreal vy = pt2.y() - pt1.y(); | 281 qreal vy = pt2.y() - pt1.y(); |
282 return QPointF(pt1.x() + vx * t, pt1.y() + vy * t); | 282 return QPointF(pt1.x() + vx * t, pt1.y() + vy * t); |
283 } | 283 } |
284 | 284 |
285 QLine toLine() // const | 285 QLine toLine() // const |
286 { | 286 { |
287 return QLine(pt1.toPoint(), pt2.toPoint()); | 287 return QLine(pt1.toPoint(), pt2.toPoint()); |
288 } | 288 } |
289 | 289 |
290 void setP1(in QPointF aP1) | 290 void setP1(in QPointF aP1) |
291 { | 291 { |
292 pt1 = aP1; | 292 pt1 = aP1; |
293 } | 293 } |
294 | 294 |
295 void setP2(in QPointF aP2) | 295 void setP2(in QPointF aP2) |
296 { | 296 { |
297 pt2 = aP2; | 297 pt2 = aP2; |
298 } | 298 } |
299 | 299 |
300 void p1(in QPointF aP1) | 300 void p1(in QPointF aP1) |
301 { | 301 { |
302 pt1 = aP1; | 302 pt1 = aP1; |
303 } | 303 } |
304 | 304 |
305 void p2(in QPointF aP2) | 305 void p2(in QPointF aP2) |
306 { | 306 { |
307 pt2 = aP2; | 307 pt2 = aP2; |
308 } | 308 } |
309 | 309 |
310 void setPoints(in QPointF aP1, in QPointF aP2) | 310 void setPoints(in QPointF aP1, in QPointF aP2) |
311 { | 311 { |
312 pt1 = aP1; | 312 pt1 = aP1; |
313 pt2 = aP2; | 313 pt2 = aP2; |
314 } | 314 } |
315 | 315 |
316 void setLine(qreal aX1, qreal aY1, qreal aX2, qreal aY2) | 316 void setLine(qreal aX1, qreal aY1, qreal aX2, qreal aY2) |
317 { | 317 { |
318 pt1 = QPointF(aX1, aY1); | 318 pt1 = QPointF(aX1, aY1); |
319 pt2 = QPointF(aX2, aY2); | 319 pt2 = QPointF(aX2, aY2); |
320 } | 320 } |
321 | 321 |
322 bool opEquals(in QLineF d) // const | 322 bool opEquals(in QLineF d) // const |
323 { | 323 { |
324 return pt1 == d.pt1 && pt2 == d.pt2; | 324 return pt1 == d.pt1 && pt2 == d.pt2; |
325 } | 325 } |
326 | 326 |
327 public final double angle() { | 327 public final double angle() { |
328 return qtd_QLineF_angle(this); | 328 return qtd_QLineF_angle(this); |
329 } | 329 } |
330 | 330 |
331 public final double angle(in QLineF l) { | 331 public final double angle(in QLineF l) { |
332 return qtd_QLineF_angle_QLineF(this, &l); | 332 return qtd_QLineF_angle_QLineF(this, &l); |
333 } | 333 } |
334 | 334 |
335 public final double angleTo(in QLineF l) { | 335 public final double angleTo(in QLineF l) { |
336 return qtd_QLineF_angleTo_QLineF(this, &l); | 336 return qtd_QLineF_angleTo_QLineF(this, &l); |
337 } | 337 } |
338 | 338 |
339 // ### Qt 5: rename intersects() or intersection() and rename IntersectType IntersectionType | 339 // ### Qt 5: rename intersects() or intersection() and rename IntersectType IntersectionType |
340 private final QLineF_IntersectType intersect(in QLineF l, QPointF* intersectionPoint) { | 340 private final QLineF_IntersectType intersect(in QLineF l, QPointF* intersectionPoint) { |
341 return cast(QLineF_IntersectType) qtd_QLineF_intersect_QLineF_nativepointerQPointF(this, &l, intersectionPoint); | 341 return cast(QLineF_IntersectType) qtd_QLineF_intersect_QLineF_nativepointerQPointF(this, &l, intersectionPoint); |
342 } | 342 } |
343 | 343 |
344 public final double length() { | 344 public final double length() { |
345 return qtd_QLineF_length(this); | 345 return qtd_QLineF_length(this); |
346 } | 346 } |
347 | 347 |
348 public final void writeTo(QDataStream arg__1) { | 348 public final void writeTo(QDataStream arg__1) { |
349 qtd_QLineF_writeTo_QDataStream(this, arg__1 is null ? null : arg__1.__nativeId); | 349 qtd_QLineF_writeTo_QDataStream(this, arg__1 is null ? null : arg__1.nativeId); |
350 } | 350 } |
351 | 351 |
352 public final void readFrom(QDataStream arg__1) { | 352 public final void readFrom(QDataStream arg__1) { |
353 qtd_QLineF_readFrom_QDataStream(this, arg__1 is null ? null : arg__1.__nativeId); | 353 qtd_QLineF_readFrom_QDataStream(this, arg__1 is null ? null : arg__1.nativeId); |
354 } | 354 } |
355 | 355 |
356 public final void setAngle(double angle) { | 356 public final void setAngle(double angle) { |
357 qtd_QLineF_setAngle_double(this, angle); | 357 qtd_QLineF_setAngle_double(this, angle); |
358 } | 358 } |
359 | 359 |
360 public final QLineF unitVector() { | 360 public final QLineF unitVector() { |
361 return qtd_QLineF_unitVector(this); | 361 return qtd_QLineF_unitVector(this); |
362 } | 362 } |
363 | 363 |
364 public static QLineF fromPolar(double length, double angle) { | 364 public static QLineF fromPolar(double length, double angle) { |
365 return qtd_QLineF_fromPolar_double_double(length, angle); | 365 return qtd_QLineF_fromPolar_double_double(length, angle); |
366 } | 366 } |
367 | 367 |
368 private: | 368 private: |
369 QPointF pt1, pt2; | 369 QPointF pt1, pt2; |
370 } | 370 } |
371 | 371 |
372 | 372 |