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