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