1
|
1 module qt.core.QPoint;
|
|
2
|
|
3 public import qt.QGlobal;
|
|
4 public import qt.core.Qt;
|
|
5 public import qt.core.QDataStream;
|
|
6
|
|
7 public struct QPoint
|
|
8 {
|
|
9
|
|
10 // Functions
|
|
11 public static QPoint opCall() {
|
|
12 QPoint pt;
|
|
13 pt.xp = pt.yp = 0;
|
|
14 return pt;
|
|
15 }
|
|
16
|
|
17 public static QPoint opCall(int xpos, int ypos) {
|
|
18 QPoint pt;
|
|
19 pt.xp = xpos;
|
|
20 pt.yp = ypos;
|
|
21 return pt;
|
|
22 }
|
|
23
|
|
24 bool isNull() // const
|
|
25 { return xp == 0 && yp == 0; }
|
|
26
|
|
27 int x() // const
|
|
28 { return xp; }
|
|
29
|
|
30 int y() // const
|
|
31 { return yp; }
|
|
32
|
|
33 void x(int xpos)
|
|
34 { xp = xpos; }
|
|
35
|
|
36 void y(int ypos)
|
|
37 { yp = ypos; }
|
|
38
|
|
39 public final int manhattanLength() {
|
|
40 return qtd_QPoint_manhattanLength(this);
|
|
41 }
|
|
42 /*
|
|
43 inline int &rx()
|
|
44 { return xp; }
|
|
45
|
|
46 inline int &ry()
|
|
47 { return yp; }
|
|
48 */
|
|
49
|
|
50 QPoint opAddAssign(ref QPoint p)
|
|
51 { xp+=p.xp; yp+=p.yp; return *this; }
|
|
52
|
|
53 QPoint opSubAssign(ref QPoint p)
|
|
54 { xp-=p.xp; yp-=p.yp; return *this; }
|
|
55
|
|
56 QPoint opMulAssign(qreal c)
|
|
57 { xp = qRound(xp*c); yp = qRound(yp*c); return *this; }
|
|
58
|
|
59 bool opEquals(ref QPoint p1, ref QPoint p2)
|
|
60 { return p1.xp == p2.xp && p1.yp == p2.yp; }
|
|
61
|
|
62 QPoint opAdd(ref QPoint p)
|
|
63 { return QPoint(this.xp+p.xp, this.yp+p.yp); }
|
|
64
|
|
65 QPoint opSub(ref QPoint p)
|
|
66 { return QPoint(this.xp-p.xp, this.yp-p.yp); }
|
|
67
|
|
68 QPoint opMul(qreal c)
|
|
69 { return QPoint(qRound(this.xp*c), qRound(this.yp*c)); }
|
|
70
|
|
71 QPoint opDivAssign(qreal c)
|
|
72 {
|
|
73 xp = qRound(xp/c);
|
|
74 yp = qRound(yp/c);
|
|
75 return *this;
|
|
76 }
|
|
77
|
|
78 QPoint opDiv(qreal c)
|
|
79 {
|
|
80 return QPoint(qRound(this.xp/c), qRound(this.yp/c));
|
|
81 }
|
|
82
|
|
83 public final void writeTo(QDataStream arg__1) {
|
|
84 qtd_QPoint_writeTo_QDataStream(this, arg__1 is null ? null : arg__1.nativeId);
|
|
85 }
|
|
86
|
|
87 public final void readFrom(QDataStream arg__1) {
|
|
88 qtd_QPoint_readFrom_QDataStream(this, arg__1 is null ? null : arg__1.nativeId);
|
|
89 }
|
|
90
|
|
91 private:
|
|
92 // ### Qt 5; remove the ifdef and just have the same order on all platforms.
|
|
93 version(OSX)
|
|
94 {
|
|
95 int yp;
|
|
96 int xp;
|
|
97 }
|
|
98 else
|
|
99 {
|
|
100 int xp;
|
|
101 int yp;
|
|
102 }
|
|
103 }
|
|
104
|
|
105
|
|
106 public struct QPointF
|
|
107 {
|
|
108 public static QPointF opCall() {
|
|
109 QPointF pt;
|
|
110 pt.xp = pt.yp = 0;
|
|
111 return pt;
|
|
112 }
|
|
113
|
|
114 public static QPointF opCall(qreal xpos, qreal ypos) {
|
|
115 QPointF pt;
|
|
116 pt.xp = xpos;
|
|
117 pt.yp = ypos;
|
|
118 return pt;
|
|
119 }
|
|
120
|
|
121 public static QPointF opCall(ref QPoint p) {
|
|
122 QPointF pt;
|
|
123 pt.xp = p.x();
|
|
124 pt.yp = p.y();
|
|
125 return pt;
|
|
126 }
|
|
127
|
|
128 bool isNull() //const
|
|
129 {
|
|
130 return qIsNull(xp) && qIsNull(yp);
|
|
131 }
|
|
132
|
|
133 qreal x() //const
|
|
134 {
|
|
135 return xp;
|
|
136 }
|
|
137
|
|
138 qreal y() //const
|
|
139 {
|
|
140 return yp;
|
|
141 }
|
|
142
|
|
143 void x(qreal xpos)
|
|
144 {
|
|
145 xp = xpos;
|
|
146 }
|
|
147
|
|
148 void y(qreal ypos)
|
|
149 {
|
|
150 yp = ypos;
|
|
151 }
|
|
152 /*
|
|
153 inline qreal &QPointF::rx()
|
|
154 {
|
|
155 return xp;
|
|
156 }
|
|
157
|
|
158 inline qreal &QPointF::ry()
|
|
159 {
|
|
160 return yp;
|
|
161 }
|
|
162 */
|
|
163
|
|
164 QPointF opAddAssign(ref QPointF p)
|
|
165 { xp+=p.xp; yp+=p.yp; return *this; }
|
|
166
|
|
167 QPointF opSubAssign(ref QPointF p)
|
|
168 { xp-=p.xp; yp-=p.yp; return *this; }
|
|
169
|
|
170 QPointF opMulAssign(qreal c)
|
|
171 { xp*=c; yp*=c; return *this; }
|
|
172
|
|
173 bool opEquals(ref QPointF p1, ref QPointF p2)
|
|
174 { return qFuzzyCompare(p1.xp, p2.xp) && qFuzzyCompare(p1.yp, p2.yp); }
|
|
175
|
|
176 QPointF opAdd(ref QPointF p)
|
|
177 { return QPointF(this.xp+p.xp, this.yp+p.yp); }
|
|
178
|
|
179 QPointF opSub(ref QPointF p)
|
|
180 { return QPointF(this.xp-p.xp, this.yp-p.yp); }
|
|
181
|
|
182 QPointF opMul(qreal c)
|
|
183 { return QPointF(this.xp*c, this.yp*c); }
|
|
184
|
|
185 QPointF opDivAssign(qreal c)
|
|
186 {
|
|
187 xp/=c;
|
|
188 yp/=c;
|
|
189 return *this;
|
|
190 }
|
|
191
|
|
192 QPointF opDiv(qreal c)
|
|
193 {
|
|
194 return QPointF(xp/c, yp/c);
|
|
195 }
|
|
196
|
|
197 QPoint toPoint() //const
|
|
198 {
|
|
199 return QPoint(qRound(xp), qRound(yp));
|
|
200 }
|
|
201
|
|
202 public final void writeTo(QDataStream arg__1) {
|
|
203 qtd_QPointF_writeTo_QDataStream(this, arg__1 is null ? null : arg__1.nativeId);
|
|
204 }
|
|
205
|
|
206 public final void readFrom(QDataStream arg__1) {
|
|
207 qtd_QPointF_readFrom_QDataStream(this, arg__1 is null ? null : arg__1.nativeId);
|
|
208 }
|
|
209
|
|
210 private:
|
|
211 qreal xp;
|
|
212 qreal yp;
|
|
213 }
|
|
214
|
|
215
|
|
216 // C wrappers
|
|
217 // QPoint
|
|
218 private extern(C) int qtd_QPoint_manhattanLength(void* __this_nativeId);
|
|
219 private extern(C) void qtd_QPoint_writeTo_QDataStream(void* __this_nativeId,
|
|
220 void* arg__1);
|
|
221 private extern(C) void qtd_QPoint_readFrom_QDataStream(void* __this_nativeId,
|
|
222 void* arg__1);
|
|
223
|
|
224 // QPointF
|
|
225 private extern(C) void qtd_QPointF_writeTo_QDataStream(void* __this_nativeId,
|
|
226 void* arg__1);
|
|
227 private extern(C) void qtd_QPointF_readFrom_QDataStream(void* __this_nativeId,
|
|
228 void* arg__1); |