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