comparison 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
comparison
equal deleted inserted replaced
343:552647ec0f82 344:96a75b1e5b26
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 }
27
28 bool isNull() // const
29 {
30 return pt1 == pt2;
31 }
32
33 int x1() // const
34 {
35 return pt1.x();
36 }
37
38 int y1() // const
39 {
40 return pt1.y();
41 }
42
43 int x2() // const
44 {
45 return pt2.x();
46 }
47
48 int y2() // const
49 {
50 return pt2.y();
51 }
52
53 QPoint p1() // const
54 {
55 return pt1;
56 }
57
58 QPoint p2() // const
59 {
60 return pt2;
61 }
62
63 int dx() // const
64 {
65 return pt2.x() - pt1.x();
66 }
67
68 int dy() // const
69 {
70 return pt2.y() - pt1.y();
71 }
72
73 void translate(ref QPoint point)
74 {
75 pt1 += point;
76 pt2 += point;
77 }
78
79 void translate(int adx, int ady)
80 {
81 translate(QPoint(adx, ady));
82 }
83
84 QLine translated(ref QPoint p) // const
85 {
86 return QLine(pt1 + p, pt2 + p);
87 }
88
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 }
108
109 void setP2(ref QPoint aP2) // for convenience
110 {
111 pt2 = aP2;
112 }
113
114 void setPoints(ref QPoint aP1, ref QPoint aP2)
115 {
116 pt1 = aP1;
117 pt2 = aP2;
118 }
119
120 void setLine(int aX1, int aY1, int aX2, int aY2)
121 {
122 pt1 = QPoint(aX1, aY1);
123 pt2 = QPoint(aX2, aY2);
124 }
125
126 bool opEquals(ref const QLine d) const
127 {
128 return pt1 == d.pt1 && pt2 == d.pt2;
129 }
130
131 public final void writeTo(QDataStream arg__1) {
132 qtd_QLine_writeTo_QDataStream(&this, arg__1 is null ? null : arg__1.__nativeId);
133 }
134
135 public final void readFrom(QDataStream arg__1) {
136 qtd_QLine_readFrom_QDataStream(&this, arg__1 is null ? null : arg__1.__nativeId);
137 }
138
139 // service stuff
140 public alias void __isNativeValueType;
141
142 struct QTypeInfo
143 {
144 enum bool isComplex = true;
145 enum bool isStatic = false;
146 enum bool isLarge = true;
147 enum bool isPointer = false;
148 enum bool isDummy = false;
149 }
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 {
163
164 alias QLineF_IntersectType IntersectType;
165
166 alias QLineF_IntersectType.NoIntersection NoIntersection;
167 alias QLineF_IntersectType.BoundedIntersection BoundedIntersection;
168 alias QLineF_IntersectType.UnboundedIntersection UnboundedIntersection;
169
170 public static QLineF opCall() {
171 QLineF ln;
172 ln.pt1 = QPointF();
173 ln.pt2 = QPointF();
174 return ln;
175 }
176
177 public this(QPointF apt1, QPointF apt2) {
178 pt1 = apt1;
179 pt2 = apt2;
180 }
181
182 public this(qreal x1pos, qreal y1pos, qreal x2pos, qreal y2pos) {
183 pt1 = QPointF(x1pos, y1pos);
184 pt2 = QPointF(x2pos, y2pos);
185 }
186
187 public this(QLine line){
188 pt1 = QPointF(line.p1());
189 pt2 = QPointF(line.p2());
190 }
191
192 public final bool isNull() // const
193 {
194 return qtd_QLineF_isNull(&this);
195 }
196
197 qreal x1() // const
198 {
199 return pt1.x();
200 }
201
202 qreal y1() // const
203 {
204 return pt1.y();
205 }
206
207 qreal x2() // const
208 {
209 return pt2.x();
210 }
211
212 qreal y2() // const
213 {
214 return pt2.y();
215 }
216
217 QPointF p1() // const
218 {
219 return pt1;
220 }
221
222 QPointF p2() // const
223 {
224 return pt2;
225 }
226
227 qreal dx() // const
228 {
229 return pt2.x() - pt1.x();
230 }
231
232 qreal dy() // const
233 {
234 return pt2.y() - pt1.y();
235 }
236
237 QLineF normalVector() // const
238 {
239 return QLineF(p1(), p1() + QPointF(dy(), -dx()));
240 }
241
242 void translate(ref QPointF point)
243 {
244 pt1 += point;
245 pt2 += point;
246 }
247
248 void translate(qreal adx, qreal ady)
249 {
250 this.translate(QPointF(adx, ady));
251 }
252
253 QLineF translated(ref QPointF p) // const
254 {
255 return QLineF(pt1 + p, pt2 + p);
256 }
257
258 QLineF translated(qreal adx, qreal ady) // const
259 {
260 return translated(QPointF(adx, ady));
261 }
262
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 }
270
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 }
278
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 }
285
286 QLine toLine() // const
287 {
288 return QLine(pt1.toPoint(), pt2.toPoint());
289 }
290
291 void setP1(ref QPointF aP1)
292 {
293 pt1 = aP1;
294 }
295
296 void setP2(ref QPointF aP2)
297 {
298 pt2 = aP2;
299 }
300
301 void p1(ref QPointF aP1)
302 {
303 pt1 = aP1;
304 }
305
306 void p2(ref QPointF aP2)
307 {
308 pt2 = aP2;
309 }
310
311 void setPoints(ref QPointF aP1, ref QPointF aP2)
312 {
313 pt1 = aP1;
314 pt2 = aP2;
315 }
316
317 void setLine(qreal aX1, qreal aY1, qreal aX2, qreal aY2)
318 {
319 pt1 = QPointF(aX1, aY1);
320 pt2 = QPointF(aX2, aY2);
321 }
322
323 bool opEquals(ref const QLineF d) const
324 {
325 return pt1 == d.pt1 && pt2 == d.pt2;
326 }
327
328 public final double angle() {
329 return qtd_QLineF_angle(&this);
330 }
331
332 public final double angle(ref QLineF l) {
333 return qtd_QLineF_angle_QLineF(&this, &l);
334 }
335
336 public final double angleTo(ref QLineF l) {
337 return qtd_QLineF_angleTo_QLineF(&this, &l);
338 }
339
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 }
344
345 public final double length() {
346 return qtd_QLineF_length(&this);
347 }
348
349 public final void writeTo(QDataStream arg__1) {
350 qtd_QLineF_writeTo_QDataStream(&this, arg__1 is null ? null : arg__1.__nativeId);
351 }
352
353 public final void readFrom(QDataStream arg__1) {
354 qtd_QLineF_readFrom_QDataStream(&this, arg__1 is null ? null : arg__1.__nativeId);
355 }
356
357 public final void setAngle(double angle) {
358 qtd_QLineF_setAngle_double(&this, angle);
359 }
360
361 public final QLineF unitVector() {
362 return qtd_QLineF_unitVector(&this);
363 }
364
365 public static QLineF fromPolar(double length, double angle) {
366 return qtd_QLineF_fromPolar_double_double(length, angle);
367 }
368
369 // service stuff
370 public alias void __isNativeValueType;
371
372 struct QTypeInfo
373 {
374 enum bool isComplex = true;
375 enum bool isStatic = false;
376 enum bool isLarge = true;
377 enum bool isPointer = false;
378 enum bool isDummy = false;
379 }
380
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);