Mercurial > projects > qtd
annotate d2/qt/core/QLine.d @ 344:96a75b1e5b26
project structure changes
author | Max Samukha <maxter@spambox.com> |
---|---|
date | Fri, 14 May 2010 12:14:37 +0300 |
parents | qt/d2/qt/core/QLine.d@b460cd08041f |
children | a032df77b6ab |
rev | line source |
---|---|
188 | 1 module qt.core.QLine; |
2 | |
3 public import qt.QGlobal; | |
4 public import qt.core.Qt; | |
5 public import qt.core.QPoint; | |
6 public import qt.core.QDataStream; | |
7 | |
8 | |
9 public struct QLine | |
10 { | |
11 public static QLine opCall() { | |
12 QLine ln; | |
13 ln.pt1 = QPoint(); | |
14 ln.pt2 = QPoint(); | |
15 return ln; | |
16 } | |
17 | |
18 public this(QPoint pt1_, QPoint pt2_) { | |
19 pt1 = pt1_; | |
20 pt2 = pt2_; | |
21 } | |
22 | |
23 public this(int x1pos, int y1pos, int x2pos, int y2pos) { | |
24 pt1 = QPoint(x1pos, y1pos); | |
25 pt2 = QPoint(x2pos, y2pos); | |
26 } | |
254 | 27 |
188 | 28 bool isNull() // const |
29 { | |
30 return pt1 == pt2; | |
31 } | |
254 | 32 |
188 | 33 int x1() // const |
34 { | |
35 return pt1.x(); | |
36 } | |
254 | 37 |
188 | 38 int y1() // const |
39 { | |
40 return pt1.y(); | |
41 } | |
254 | 42 |
188 | 43 int x2() // const |
44 { | |
45 return pt2.x(); | |
46 } | |
254 | 47 |
188 | 48 int y2() // const |
49 { | |
50 return pt2.y(); | |
51 } | |
254 | 52 |
188 | 53 QPoint p1() // const |
54 { | |
55 return pt1; | |
56 } | |
254 | 57 |
188 | 58 QPoint p2() // const |
59 { | |
60 return pt2; | |
61 } | |
254 | 62 |
188 | 63 int dx() // const |
64 { | |
65 return pt2.x() - pt1.x(); | |
66 } | |
254 | 67 |
188 | 68 int dy() // const |
69 { | |
70 return pt2.y() - pt1.y(); | |
71 } | |
254 | 72 |
188 | 73 void translate(ref QPoint point) |
74 { | |
75 pt1 += point; | |
76 pt2 += point; | |
77 } | |
254 | 78 |
188 | 79 void translate(int adx, int ady) |
80 { | |
81 translate(QPoint(adx, ady)); | |
82 } | |
254 | 83 |
188 | 84 QLine translated(ref QPoint p) // const |
85 { | |
86 return QLine(pt1 + p, pt2 + p); | |
87 } | |
254 | 88 |
188 | 89 QLine translated(int adx, int ady) // const |
90 { | |
91 return translated(QPoint(adx, ady)); | |
92 } | |
93 | |
94 void p1(ref QPoint aP1) | |
95 { | |
96 pt1 = aP1; | |
97 } | |
98 | |
99 void p2(ref QPoint aP2) | |
100 { | |
101 pt2 = aP2; | |
102 } | |
103 | |
104 void setP1(ref QPoint aP1) // for convenience | |
105 { | |
106 pt1 = aP1; | |
107 } | |
254 | 108 |
188 | 109 void setP2(ref QPoint aP2) // for convenience |
110 { | |
111 pt2 = aP2; | |
112 } | |
254 | 113 |
188 | 114 void setPoints(ref QPoint aP1, ref QPoint aP2) |
115 { | |
116 pt1 = aP1; | |
117 pt2 = aP2; | |
118 } | |
254 | 119 |
188 | 120 void setLine(int aX1, int aY1, int aX2, int aY2) |
121 { | |
122 pt1 = QPoint(aX1, aY1); | |
123 pt2 = QPoint(aX2, aY2); | |
124 } | |
254 | 125 |
325 | 126 bool opEquals(ref const QLine d) const |
188 | 127 { |
128 return pt1 == d.pt1 && pt2 == d.pt2; | |
129 } | |
130 | |
131 public final void writeTo(QDataStream arg__1) { | |
254 | 132 qtd_QLine_writeTo_QDataStream(&this, arg__1 is null ? null : arg__1.__nativeId); |
188 | 133 } |
134 | |
135 public final void readFrom(QDataStream arg__1) { | |
254 | 136 qtd_QLine_readFrom_QDataStream(&this, arg__1 is null ? null : arg__1.__nativeId); |
188 | 137 } |
295
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
138 |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
139 // service stuff |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
140 public alias void __isNativeValueType; |
188 | 141 |
295
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
142 struct QTypeInfo |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
143 { |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
144 enum bool isComplex = true; |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
145 enum bool isStatic = false; |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
146 enum bool isLarge = true; |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
147 enum bool isPointer = false; |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
148 enum bool isDummy = false; |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
149 } |
188 | 150 private: |
151 QPoint pt1, pt2; | |
152 } | |
153 | |
154 | |
155 public enum QLineF_IntersectType { | |
156 NoIntersection = 0, | |
157 BoundedIntersection = 1, | |
158 UnboundedIntersection = 2 | |
159 } | |
160 | |
161 public struct QLineF | |
162 { | |
254 | 163 |
188 | 164 alias QLineF_IntersectType IntersectType; |
254 | 165 |
188 | 166 alias QLineF_IntersectType.NoIntersection NoIntersection; |
167 alias QLineF_IntersectType.BoundedIntersection BoundedIntersection; | |
168 alias QLineF_IntersectType.UnboundedIntersection UnboundedIntersection; | |
254 | 169 |
188 | 170 public static QLineF opCall() { |
171 QLineF ln; | |
172 ln.pt1 = QPointF(); | |
173 ln.pt2 = QPointF(); | |
174 return ln; | |
175 } | |
254 | 176 |
188 | 177 public this(QPointF apt1, QPointF apt2) { |
178 pt1 = apt1; | |
179 pt2 = apt2; | |
180 } | |
254 | 181 |
188 | 182 public this(qreal x1pos, qreal y1pos, qreal x2pos, qreal y2pos) { |
183 pt1 = QPointF(x1pos, y1pos); | |
184 pt2 = QPointF(x2pos, y2pos); | |
185 } | |
254 | 186 |
187 public this(QLine line){ | |
188 | 188 pt1 = QPointF(line.p1()); |
189 pt2 = QPointF(line.p2()); | |
190 } | |
254 | 191 |
188 | 192 public final bool isNull() // const |
193 { | |
194 return qtd_QLineF_isNull(&this); | |
195 } | |
254 | 196 |
188 | 197 qreal x1() // const |
198 { | |
199 return pt1.x(); | |
200 } | |
254 | 201 |
188 | 202 qreal y1() // const |
203 { | |
204 return pt1.y(); | |
205 } | |
254 | 206 |
188 | 207 qreal x2() // const |
208 { | |
209 return pt2.x(); | |
210 } | |
254 | 211 |
188 | 212 qreal y2() // const |
213 { | |
214 return pt2.y(); | |
215 } | |
254 | 216 |
188 | 217 QPointF p1() // const |
218 { | |
219 return pt1; | |
220 } | |
254 | 221 |
188 | 222 QPointF p2() // const |
223 { | |
224 return pt2; | |
225 } | |
254 | 226 |
188 | 227 qreal dx() // const |
228 { | |
229 return pt2.x() - pt1.x(); | |
230 } | |
254 | 231 |
188 | 232 qreal dy() // const |
233 { | |
234 return pt2.y() - pt1.y(); | |
235 } | |
254 | 236 |
188 | 237 QLineF normalVector() // const |
238 { | |
239 return QLineF(p1(), p1() + QPointF(dy(), -dx())); | |
240 } | |
254 | 241 |
188 | 242 void translate(ref QPointF point) |
243 { | |
244 pt1 += point; | |
245 pt2 += point; | |
246 } | |
254 | 247 |
188 | 248 void translate(qreal adx, qreal ady) |
249 { | |
250 this.translate(QPointF(adx, ady)); | |
251 } | |
254 | 252 |
188 | 253 QLineF translated(ref QPointF p) // const |
254 { | |
255 return QLineF(pt1 + p, pt2 + p); | |
256 } | |
254 | 257 |
188 | 258 QLineF translated(qreal adx, qreal ady) // const |
259 { | |
260 return translated(QPointF(adx, ady)); | |
261 } | |
254 | 262 |
188 | 263 void setLength(qreal len) |
264 { | |
265 if (isNull()) | |
266 return; | |
267 QLineF v = unitVector(); | |
268 pt2 = QPointF(pt1.x() + v.dx() * len, pt1.y() + v.dy() * len); | |
269 } | |
254 | 270 |
188 | 271 void length(qreal len) |
272 { | |
273 if (isNull()) | |
274 return; | |
275 QLineF v = unitVector(); | |
276 pt2 = QPointF(pt1.x() + v.dx() * len, pt1.y() + v.dy() * len); | |
277 } | |
254 | 278 |
188 | 279 QPointF pointAt(qreal t) // const |
280 { | |
281 qreal vx = pt2.x() - pt1.x(); | |
282 qreal vy = pt2.y() - pt1.y(); | |
283 return QPointF(pt1.x() + vx * t, pt1.y() + vy * t); | |
284 } | |
254 | 285 |
188 | 286 QLine toLine() // const |
287 { | |
288 return QLine(pt1.toPoint(), pt2.toPoint()); | |
289 } | |
254 | 290 |
188 | 291 void setP1(ref QPointF aP1) |
292 { | |
293 pt1 = aP1; | |
294 } | |
254 | 295 |
188 | 296 void setP2(ref QPointF aP2) |
297 { | |
298 pt2 = aP2; | |
299 } | |
254 | 300 |
188 | 301 void p1(ref QPointF aP1) |
302 { | |
303 pt1 = aP1; | |
304 } | |
254 | 305 |
188 | 306 void p2(ref QPointF aP2) |
307 { | |
308 pt2 = aP2; | |
309 } | |
254 | 310 |
188 | 311 void setPoints(ref QPointF aP1, ref QPointF aP2) |
312 { | |
313 pt1 = aP1; | |
314 pt2 = aP2; | |
315 } | |
254 | 316 |
188 | 317 void setLine(qreal aX1, qreal aY1, qreal aX2, qreal aY2) |
318 { | |
319 pt1 = QPointF(aX1, aY1); | |
320 pt2 = QPointF(aX2, aY2); | |
321 } | |
254 | 322 |
325 | 323 bool opEquals(ref const QLineF d) const |
188 | 324 { |
325 return pt1 == d.pt1 && pt2 == d.pt2; | |
326 } | |
254 | 327 |
188 | 328 public final double angle() { |
329 return qtd_QLineF_angle(&this); | |
330 } | |
254 | 331 |
188 | 332 public final double angle(ref QLineF l) { |
333 return qtd_QLineF_angle_QLineF(&this, &l); | |
334 } | |
254 | 335 |
188 | 336 public final double angleTo(ref QLineF l) { |
337 return qtd_QLineF_angleTo_QLineF(&this, &l); | |
338 } | |
254 | 339 |
188 | 340 // ### Qt 5: rename intersects() or intersection() and rename IntersectType IntersectionType |
341 private final QLineF_IntersectType intersect(ref QLineF l, QPointF* intersectionPoint) { | |
342 return cast(QLineF_IntersectType) qtd_QLineF_intersect_QLineF_nativepointerQPointF(&this, &l, intersectionPoint); | |
343 } | |
254 | 344 |
188 | 345 public final double length() { |
346 return qtd_QLineF_length(&this); | |
347 } | |
254 | 348 |
188 | 349 public final void writeTo(QDataStream arg__1) { |
254 | 350 qtd_QLineF_writeTo_QDataStream(&this, arg__1 is null ? null : arg__1.__nativeId); |
188 | 351 } |
254 | 352 |
188 | 353 public final void readFrom(QDataStream arg__1) { |
254 | 354 qtd_QLineF_readFrom_QDataStream(&this, arg__1 is null ? null : arg__1.__nativeId); |
188 | 355 } |
254 | 356 |
188 | 357 public final void setAngle(double angle) { |
358 qtd_QLineF_setAngle_double(&this, angle); | |
359 } | |
254 | 360 |
188 | 361 public final QLineF unitVector() { |
362 return qtd_QLineF_unitVector(&this); | |
363 } | |
254 | 364 |
188 | 365 public static QLineF fromPolar(double length, double angle) { |
366 return qtd_QLineF_fromPolar_double_double(length, angle); | |
367 } | |
254 | 368 |
295
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
369 // service stuff |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
370 public alias void __isNativeValueType; |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
371 |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
372 struct QTypeInfo |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
373 { |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
374 enum bool isComplex = true; |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
375 enum bool isStatic = false; |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
376 enum bool isLarge = true; |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
377 enum bool isPointer = false; |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
378 enum bool isDummy = false; |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
379 } |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
380 |
188 | 381 private: |
382 QPointF pt1, pt2; | |
383 } | |
384 | |
385 | |
386 // C wrappers | |
387 // QLine | |
388 private extern(C) void qtd_QLine_writeTo_QDataStream(void* __this_nativeId, | |
389 void* arg__1); | |
390 private extern(C) void qtd_QLine_readFrom_QDataStream(void* __this_nativeId, | |
391 void* arg__1); | |
392 | |
393 // QLineF | |
394 private extern(C) bool qtd_QLineF_isNull(void* __this_nativeId); | |
395 private extern(C) double qtd_QLineF_angle(void* __this_nativeId); | |
396 private extern(C) double qtd_QLineF_angle_QLineF(void* __this_nativeId, | |
397 void* l0); | |
398 private extern(C) double qtd_QLineF_angleTo_QLineF(void* __this_nativeId, | |
399 void* l0); | |
400 private extern(C) int qtd_QLineF_intersect_QLineF_nativepointerQPointF(void* __this_nativeId, | |
401 void* l0, | |
402 void* intersectionPoint1); | |
403 private extern(C) double qtd_QLineF_length(void* __this_nativeId); | |
404 private extern(C) void qtd_QLineF_writeTo_QDataStream(void* __this_nativeId, | |
405 void* arg__1); | |
406 private extern(C) void qtd_QLineF_readFrom_QDataStream(void* __this_nativeId, | |
407 void* arg__1); | |
408 private extern(C) void qtd_QLineF_setAngle_double(void* __this_nativeId, | |
409 double angle0); | |
410 | |
411 private extern(C) QLineF qtd_QLineF_unitVector(void* __this_nativeId); | |
412 private extern(C) QLineF qtd_QLineF_fromPolar_double_double(double length0, | |
413 double angle1); |