| Line | Source Code | Coverage |
|---|
| 1 | /**************************************************************************** | - |
| 2 | ** | - |
| 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
| 4 | ** Contact: http://www.qt-project.org/legal | - |
| 5 | ** | - |
| 6 | ** This file is part of the QtCore module of the Qt Toolkit. | - |
| 7 | ** | - |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
| 9 | ** Commercial License Usage | - |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
| 11 | ** accordance with the commercial license agreement provided with the | - |
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - |
| 13 | ** a written agreement between you and Digia. For licensing terms and | - |
| 14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
| 15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
| 16 | ** | - |
| 17 | ** GNU Lesser General Public License Usage | - |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
| 19 | ** General Public License version 2.1 as published by the Free Software | - |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
| 21 | ** packaging of this file. Please review the following information to | - |
| 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
| 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
| 24 | ** | - |
| 25 | ** In addition, as a special exception, Digia gives you certain additional | - |
| 26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
| 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
| 28 | ** | - |
| 29 | ** GNU General Public License Usage | - |
| 30 | ** Alternatively, this file may be used under the terms of the GNU | - |
| 31 | ** General Public License version 3.0 as published by the Free Software | - |
| 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
| 33 | ** packaging of this file. Please review the following information to | - |
| 34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
| 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
| 36 | ** | - |
| 37 | ** | - |
| 38 | ** $QT_END_LICENSE$ | - |
| 39 | ** | - |
| 40 | ****************************************************************************/ | - |
| 41 | | - |
| 42 | #include "qpoint.h" | - |
| 43 | #include "qdatastream.h" | - |
| 44 | #include "qdebug.h" | - |
| 45 | | - |
| 46 | QT_BEGIN_NAMESPACE | - |
| 47 | | - |
| 48 | /*! | - |
| 49 | \class QPoint | - |
| 50 | \inmodule QtCore | - |
| 51 | \ingroup painting | - |
| 52 | | - |
| 53 | \brief The QPoint class defines a point in the plane using integer | - |
| 54 | precision. | - |
| 55 | | - |
| 56 | A point is specified by a x coordinate and an y coordinate which | - |
| 57 | can be accessed using the x() and y() functions. The isNull() | - |
| 58 | function returns true if both x and y are set to 0. The | - |
| 59 | coordinates can be set (or altered) using the setX() and setY() | - |
| 60 | functions, or alternatively the rx() and ry() functions which | - |
| 61 | return references to the coordinates (allowing direct | - |
| 62 | manipulation). | - |
| 63 | | - |
| 64 | Given a point \e p, the following statements are all equivalent: | - |
| 65 | | - |
| 66 | \snippet code/src_corelib_tools_qpoint.cpp 0 | - |
| 67 | | - |
| 68 | A QPoint object can also be used as a vector: Addition and | - |
| 69 | subtraction are defined as for vectors (each component is added | - |
| 70 | separately). A QPoint object can also be divided or multiplied by | - |
| 71 | an \c int or a \c qreal. | - |
| 72 | | - |
| 73 | In addition, the QPoint class provides the manhattanLength() | - |
| 74 | function which gives an inexpensive approximation of the length of | - |
| 75 | the QPoint object interpreted as a vector. Finally, QPoint objects | - |
| 76 | can be streamed as well as compared. | - |
| 77 | | - |
| 78 | \sa QPointF, QPolygon | - |
| 79 | */ | - |
| 80 | | - |
| 81 | | - |
| 82 | /***************************************************************************** | - |
| 83 | QPoint member functions | - |
| 84 | *****************************************************************************/ | - |
| 85 | | - |
| 86 | /*! | - |
| 87 | \fn QPoint::QPoint() | - |
| 88 | | - |
| 89 | Constructs a null point, i.e. with coordinates (0, 0) | - |
| 90 | | - |
| 91 | \sa isNull() | - |
| 92 | */ | - |
| 93 | | - |
| 94 | /*! | - |
| 95 | \fn QPoint::QPoint(int xpos, int ypos) | - |
| 96 | | - |
| 97 | Constructs a point with the given coordinates (\a xpos, \a ypos). | - |
| 98 | | - |
| 99 | \sa setX(), setY() | - |
| 100 | */ | - |
| 101 | | - |
| 102 | /*! | - |
| 103 | \fn bool QPoint::isNull() const | - |
| 104 | | - |
| 105 | Returns true if both the x and y coordinates are set to 0, | - |
| 106 | otherwise returns false. | - |
| 107 | */ | - |
| 108 | | - |
| 109 | /*! | - |
| 110 | \fn int QPoint::x() const | - |
| 111 | | - |
| 112 | Returns the x coordinate of this point. | - |
| 113 | | - |
| 114 | \sa setX(), rx() | - |
| 115 | */ | - |
| 116 | | - |
| 117 | /*! | - |
| 118 | \fn int QPoint::y() const | - |
| 119 | | - |
| 120 | Returns the y coordinate of this point. | - |
| 121 | | - |
| 122 | \sa setY(), ry() | - |
| 123 | */ | - |
| 124 | | - |
| 125 | /*! | - |
| 126 | \fn void QPoint::setX(int x) | - |
| 127 | | - |
| 128 | Sets the x coordinate of this point to the given \a x coordinate. | - |
| 129 | | - |
| 130 | \sa x(), setY() | - |
| 131 | */ | - |
| 132 | | - |
| 133 | /*! | - |
| 134 | \fn void QPoint::setY(int y) | - |
| 135 | | - |
| 136 | Sets the y coordinate of this point to the given \a y coordinate. | - |
| 137 | | - |
| 138 | \sa y(), setX() | - |
| 139 | */ | - |
| 140 | | - |
| 141 | | - |
| 142 | /*! | - |
| 143 | \fn int &QPoint::rx() | - |
| 144 | | - |
| 145 | Returns a reference to the x coordinate of this point. | - |
| 146 | | - |
| 147 | Using a reference makes it possible to directly manipulate x. For example: | - |
| 148 | | - |
| 149 | \snippet code/src_corelib_tools_qpoint.cpp 1 | - |
| 150 | | - |
| 151 | \sa x(), setX() | - |
| 152 | */ | - |
| 153 | | - |
| 154 | /*! | - |
| 155 | \fn int &QPoint::ry() | - |
| 156 | | - |
| 157 | Returns a reference to the y coordinate of this point. | - |
| 158 | | - |
| 159 | Using a reference makes it possible to directly manipulate y. For | - |
| 160 | example: | - |
| 161 | | - |
| 162 | \snippet code/src_corelib_tools_qpoint.cpp 2 | - |
| 163 | | - |
| 164 | \sa y(), setY() | - |
| 165 | */ | - |
| 166 | | - |
| 167 | | - |
| 168 | /*! | - |
| 169 | \fn QPoint &QPoint::operator+=(const QPoint &point) | - |
| 170 | | - |
| 171 | Adds the given \a point to this point and returns a reference to | - |
| 172 | this point. For example: | - |
| 173 | | - |
| 174 | \snippet code/src_corelib_tools_qpoint.cpp 3 | - |
| 175 | | - |
| 176 | \sa operator-=() | - |
| 177 | */ | - |
| 178 | | - |
| 179 | /*! | - |
| 180 | \fn QPoint &QPoint::operator-=(const QPoint &point) | - |
| 181 | | - |
| 182 | Subtracts the given \a point from this point and returns a | - |
| 183 | reference to this point. For example: | - |
| 184 | | - |
| 185 | \snippet code/src_corelib_tools_qpoint.cpp 4 | - |
| 186 | | - |
| 187 | \sa operator+=() | - |
| 188 | */ | - |
| 189 | | - |
| 190 | /*! | - |
| 191 | \fn QPoint &QPoint::operator*=(float factor) | - |
| 192 | | - |
| 193 | Multiplies this point's coordinates by the given \a factor, and | - |
| 194 | returns a reference to this point. | - |
| 195 | | - |
| 196 | Note that the result is rounded to the nearest integer as points are held as | - |
| 197 | integers. Use QPointF for floating point accuracy. | - |
| 198 | | - |
| 199 | \sa operator/=() | - |
| 200 | */ | - |
| 201 | | - |
| 202 | /*! | - |
| 203 | \fn QPoint &QPoint::operator*=(double factor) | - |
| 204 | | - |
| 205 | Multiplies this point's coordinates by the given \a factor, and | - |
| 206 | returns a reference to this point. For example: | - |
| 207 | | - |
| 208 | \snippet code/src_corelib_tools_qpoint.cpp 5 | - |
| 209 | | - |
| 210 | Note that the result is rounded to the nearest integer as points are held as | - |
| 211 | integers. Use QPointF for floating point accuracy. | - |
| 212 | | - |
| 213 | \sa operator/=() | - |
| 214 | */ | - |
| 215 | | - |
| 216 | /*! | - |
| 217 | \fn QPoint &QPoint::operator*=(int factor) | - |
| 218 | | - |
| 219 | Multiplies this point's coordinates by the given \a factor, and | - |
| 220 | returns a reference to this point. | - |
| 221 | | - |
| 222 | \sa operator/=() | - |
| 223 | */ | - |
| 224 | | - |
| 225 | /*! | - |
| 226 | \fn bool operator==(const QPoint &p1, const QPoint &p2) | - |
| 227 | \relates QPoint | - |
| 228 | | - |
| 229 | Returns true if \a p1 and \a p2 are equal; otherwise returns | - |
| 230 | false. | - |
| 231 | */ | - |
| 232 | | - |
| 233 | /*! | - |
| 234 | \fn bool operator!=(const QPoint &p1, const QPoint &p2) | - |
| 235 | \relates QPoint | - |
| 236 | | - |
| 237 | Returns true if \a p1 and \a p2 are not equal; otherwise returns false. | - |
| 238 | */ | - |
| 239 | | - |
| 240 | /*! | - |
| 241 | \fn const QPoint operator+(const QPoint &p1, const QPoint &p2) | - |
| 242 | \relates QPoint | - |
| 243 | | - |
| 244 | Returns a QPoint object that is the sum of the given points, \a p1 | - |
| 245 | and \a p2; each component is added separately. | - |
| 246 | | - |
| 247 | \sa QPoint::operator+=() | - |
| 248 | */ | - |
| 249 | | - |
| 250 | /*! | - |
| 251 | \fn const QPoint operator-(const QPoint &p1, const QPoint &p2) | - |
| 252 | \relates QPoint | - |
| 253 | | - |
| 254 | Returns a QPoint object that is formed by subtracting \a p2 from | - |
| 255 | \a p1; each component is subtracted separately. | - |
| 256 | | - |
| 257 | \sa QPoint::operator-=() | - |
| 258 | */ | - |
| 259 | | - |
| 260 | /*! | - |
| 261 | \fn const QPoint operator*(const QPoint &point, float factor) | - |
| 262 | \relates QPoint | - |
| 263 | | - |
| 264 | Returns a copy of the given \a point multiplied by the given \a factor. | - |
| 265 | | - |
| 266 | Note that the result is rounded to the nearest integer as points | - |
| 267 | are held as integers. Use QPointF for floating point accuracy. | - |
| 268 | | - |
| 269 | \sa QPoint::operator*=() | - |
| 270 | */ | - |
| 271 | | - |
| 272 | /*! | - |
| 273 | \fn const QPoint operator*(const QPoint &point, double factor) | - |
| 274 | \relates QPoint | - |
| 275 | | - |
| 276 | Returns a copy of the given \a point multiplied by the given \a factor. | - |
| 277 | | - |
| 278 | Note that the result is rounded to the nearest integer as points | - |
| 279 | are held as integers. Use QPointF for floating point accuracy. | - |
| 280 | | - |
| 281 | \sa QPoint::operator*=() | - |
| 282 | */ | - |
| 283 | | - |
| 284 | /*! | - |
| 285 | \fn const QPoint operator*(const QPoint &point, int factor) | - |
| 286 | \relates QPoint | - |
| 287 | | - |
| 288 | Returns a copy of the given \a point multiplied by the given \a factor. | - |
| 289 | | - |
| 290 | \sa QPoint::operator*=() | - |
| 291 | */ | - |
| 292 | | - |
| 293 | /*! | - |
| 294 | \fn const QPoint operator*(float factor, const QPoint &point) | - |
| 295 | \overload | - |
| 296 | \relates QPoint | - |
| 297 | | - |
| 298 | Returns a copy of the given \a point multiplied by the given \a factor. | - |
| 299 | | - |
| 300 | Note that the result is rounded to the nearest integer as points | - |
| 301 | are held as integers. Use QPointF for floating point accuracy. | - |
| 302 | | - |
| 303 | \sa QPoint::operator*=() | - |
| 304 | */ | - |
| 305 | | - |
| 306 | /*! | - |
| 307 | \fn const QPoint operator*(double factor, const QPoint &point) | - |
| 308 | \overload | - |
| 309 | \relates QPoint | - |
| 310 | | - |
| 311 | Returns a copy of the given \a point multiplied by the given \a factor. | - |
| 312 | | - |
| 313 | Note that the result is rounded to the nearest integer as points | - |
| 314 | are held as integers. Use QPointF for floating point accuracy. | - |
| 315 | | - |
| 316 | \sa QPoint::operator*=() | - |
| 317 | */ | - |
| 318 | | - |
| 319 | /*! | - |
| 320 | \fn const QPoint operator*(int factor, const QPoint &point) | - |
| 321 | \overload | - |
| 322 | \relates QPoint | - |
| 323 | | - |
| 324 | Returns a copy of the given \a point multiplied by the given \a factor. | - |
| 325 | | - |
| 326 | \sa QPoint::operator*=() | - |
| 327 | */ | - |
| 328 | | - |
| 329 | /*! | - |
| 330 | \fn const QPoint operator+(const QPoint &point) | - |
| 331 | \relates QPoint | - |
| 332 | \since 5.0 | - |
| 333 | | - |
| 334 | Returns \a point unmodified. | - |
| 335 | */ | - |
| 336 | | - |
| 337 | /*! | - |
| 338 | \fn const QPoint operator-(const QPoint &point) | - |
| 339 | \overload | - |
| 340 | \relates QPoint | - |
| 341 | | - |
| 342 | Returns a QPoint object that is formed by changing the sign of | - |
| 343 | both components of the given \a point. | - |
| 344 | | - |
| 345 | Equivalent to \c{QPoint(0,0) - point}. | - |
| 346 | */ | - |
| 347 | | - |
| 348 | /*! | - |
| 349 | \fn QPoint &QPoint::operator/=(qreal divisor) | - |
| 350 | \overload | - |
| 351 | | - |
| 352 | Divides both x and y by the given \a divisor, and returns a reference to this | - |
| 353 | point. For example: | - |
| 354 | | - |
| 355 | \snippet code/src_corelib_tools_qpoint.cpp 6 | - |
| 356 | | - |
| 357 | Note that the result is rounded to the nearest integer as points are held as | - |
| 358 | integers. Use QPointF for floating point accuracy. | - |
| 359 | | - |
| 360 | \sa operator*=() | - |
| 361 | */ | - |
| 362 | | - |
| 363 | /*! | - |
| 364 | \fn const QPoint operator/(const QPoint &point, qreal divisor) | - |
| 365 | \relates QPoint | - |
| 366 | | - |
| 367 | Returns the QPoint formed by dividing both components of the given \a point | - |
| 368 | by the given \a divisor. | - |
| 369 | | - |
| 370 | Note that the result is rounded to the nearest integer as points are held as | - |
| 371 | integers. Use QPointF for floating point accuracy. | - |
| 372 | | - |
| 373 | \sa QPoint::operator/=() | - |
| 374 | */ | - |
| 375 | | - |
| 376 | /***************************************************************************** | - |
| 377 | QPoint stream functions | - |
| 378 | *****************************************************************************/ | - |
| 379 | #ifndef QT_NO_DATASTREAM | - |
| 380 | /*! | - |
| 381 | \fn QDataStream &operator<<(QDataStream &stream, const QPoint &point) | - |
| 382 | \relates QPoint | - |
| 383 | | - |
| 384 | Writes the given \a point to the given \a stream and returns a | - |
| 385 | reference to the stream. | - |
| 386 | | - |
| 387 | \sa {Serializing Qt Data Types} | - |
| 388 | */ | - |
| 389 | | - |
| 390 | QDataStream &operator<<(QDataStream &s, const QPoint &p) | - |
| 391 | { | - |
| 392 | if (s.version() == 1) partially evaluated: s.version() == 1| no Evaluation Count:0 | yes Evaluation Count:109 |
| 0-109 |
| 393 | s << (qint16)p.x() << (qint16)p.y(); never executed: s << (qint16)p.x() << (qint16)p.y(); | 0 |
| 394 | else | - |
| 395 | s << (qint32)p.x() << (qint32)p.y(); executed: s << (qint32)p.x() << (qint32)p.y();Execution Count:109 | 109 |
| 396 | return s; executed: return s;Execution Count:109 | 109 |
| 397 | } | - |
| 398 | | - |
| 399 | /*! | - |
| 400 | \fn QDataStream &operator>>(QDataStream &stream, QPoint &point) | - |
| 401 | \relates QPoint | - |
| 402 | | - |
| 403 | Reads a point from the given \a stream into the given \a point | - |
| 404 | and returns a reference to the stream. | - |
| 405 | | - |
| 406 | \sa {Serializing Qt Data Types} | - |
| 407 | */ | - |
| 408 | | - |
| 409 | QDataStream &operator>>(QDataStream &s, QPoint &p) | - |
| 410 | { | - |
| 411 | if (s.version() == 1) { partially evaluated: s.version() == 1| no Evaluation Count:0 | yes Evaluation Count:121 |
| 0-121 |
| 412 | qint16 x, y; never executed (the execution status of this line is deduced): qint16 x, y; | - |
| 413 | s >> x; p.rx() = x; never executed (the execution status of this line is deduced): s >> x; p.rx() = x; | - |
| 414 | s >> y; p.ry() = y; never executed (the execution status of this line is deduced): s >> y; p.ry() = y; | - |
| 415 | } | 0 |
| 416 | else { | - |
| 417 | qint32 x, y; executed (the execution status of this line is deduced): qint32 x, y; | - |
| 418 | s >> x; p.rx() = x; executed (the execution status of this line is deduced): s >> x; p.rx() = x; | - |
| 419 | s >> y; p.ry() = y; executed (the execution status of this line is deduced): s >> y; p.ry() = y; | - |
| 420 | } executed: }Execution Count:121 | 121 |
| 421 | return s; executed: return s;Execution Count:121 | 121 |
| 422 | } | - |
| 423 | | - |
| 424 | #endif // QT_NO_DATASTREAM | - |
| 425 | /*! | - |
| 426 | \fn int QPoint::manhattanLength() const | - |
| 427 | | - |
| 428 | Returns the sum of the absolute values of x() and y(), | - |
| 429 | traditionally known as the "Manhattan length" of the vector from | - |
| 430 | the origin to the point. For example: | - |
| 431 | | - |
| 432 | \snippet code/src_corelib_tools_qpoint.cpp 7 | - |
| 433 | | - |
| 434 | This is a useful, and quick to calculate, approximation to the | - |
| 435 | true length: | - |
| 436 | | - |
| 437 | \snippet code/src_corelib_tools_qpoint.cpp 8 | - |
| 438 | | - |
| 439 | The tradition of "Manhattan length" arises because such distances | - |
| 440 | apply to travelers who can only travel on a rectangular grid, like | - |
| 441 | the streets of Manhattan. | - |
| 442 | */ | - |
| 443 | | - |
| 444 | #ifndef QT_NO_DEBUG_STREAM | - |
| 445 | QDebug operator<<(QDebug dbg, const QPoint &p) { | - |
| 446 | dbg.nospace() << "QPoint(" << p.x() << ',' << p.y() << ')'; executed (the execution status of this line is deduced): dbg.nospace() << "QPoint(" << p.x() << ',' << p.y() << ')'; | - |
| 447 | return dbg.space(); executed: return dbg.space();Execution Count:23 | 23 |
| 448 | } | - |
| 449 | | - |
| 450 | QDebug operator<<(QDebug d, const QPointF &p) | - |
| 451 | { | - |
| 452 | d.nospace() << "QPointF(" << p.x() << ", " << p.y() << ')'; executed (the execution status of this line is deduced): d.nospace() << "QPointF(" << p.x() << ", " << p.y() << ')'; | - |
| 453 | return d.space(); executed: return d.space();Execution Count:3 | 3 |
| 454 | } | - |
| 455 | #endif | - |
| 456 | | - |
| 457 | /*! | - |
| 458 | \class QPointF | - |
| 459 | \inmodule QtCore | - |
| 460 | \ingroup painting | - |
| 461 | | - |
| 462 | \brief The QPointF class defines a point in the plane using | - |
| 463 | floating point precision. | - |
| 464 | | - |
| 465 | A point is specified by a x coordinate and an y coordinate which | - |
| 466 | can be accessed using the x() and y() functions. The coordinates | - |
| 467 | of the point are specified using floating point numbers for | - |
| 468 | accuracy. The isNull() function returns true if both x and y are | - |
| 469 | set to 0.0. The coordinates can be set (or altered) using the setX() | - |
| 470 | and setY() functions, or alternatively the rx() and ry() functions which | - |
| 471 | return references to the coordinates (allowing direct | - |
| 472 | manipulation). | - |
| 473 | | - |
| 474 | Given a point \e p, the following statements are all equivalent: | - |
| 475 | | - |
| 476 | \snippet code/src_corelib_tools_qpoint.cpp 9 | - |
| 477 | | - |
| 478 | A QPointF object can also be used as a vector: Addition and | - |
| 479 | subtraction are defined as for vectors (each component is added | - |
| 480 | separately). A QPointF object can also be divided or multiplied by | - |
| 481 | an \c int or a \c qreal. | - |
| 482 | | - |
| 483 | In addition, the QPointF class provides a constructor converting a | - |
| 484 | QPoint object into a QPointF object, and a corresponding toPoint() | - |
| 485 | function which returns a QPoint copy of \e this point. Finally, | - |
| 486 | QPointF objects can be streamed as well as compared. | - |
| 487 | | - |
| 488 | \sa QPoint, QPolygonF | - |
| 489 | */ | - |
| 490 | | - |
| 491 | /*! | - |
| 492 | \fn QPointF::QPointF() | - |
| 493 | | - |
| 494 | Constructs a null point, i.e. with coordinates (0.0, 0.0) | - |
| 495 | | - |
| 496 | \sa isNull() | - |
| 497 | */ | - |
| 498 | | - |
| 499 | /*! | - |
| 500 | \fn QPointF::QPointF(const QPoint &point) | - |
| 501 | | - |
| 502 | Constructs a copy of the given \a point. | - |
| 503 | | - |
| 504 | \sa toPoint() | - |
| 505 | */ | - |
| 506 | | - |
| 507 | /*! | - |
| 508 | \fn QPointF::QPointF(qreal xpos, qreal ypos) | - |
| 509 | | - |
| 510 | Constructs a point with the given coordinates (\a xpos, \a ypos). | - |
| 511 | | - |
| 512 | \sa setX(), setY() | - |
| 513 | */ | - |
| 514 | | - |
| 515 | /*! | - |
| 516 | \fn bool QPointF::isNull() const | - |
| 517 | | - |
| 518 | Returns true if both the x and y coordinates are set to +0.0; | - |
| 519 | otherwise returns false. | - |
| 520 | | - |
| 521 | \note Since this function treats +0.0 and -0.0 differently, points | - |
| 522 | with zero-valued coordinates where either or both values have a | - |
| 523 | negative sign are not defined to be null points. | - |
| 524 | */ | - |
| 525 | | - |
| 526 | | - |
| 527 | /*! | - |
| 528 | \fn qreal QPointF::manhattanLength() const | - |
| 529 | \since 4.6 | - |
| 530 | | - |
| 531 | Returns the sum of the absolute values of x() and y(), | - |
| 532 | traditionally known as the "Manhattan length" of the vector from | - |
| 533 | the origin to the point. | - |
| 534 | | - |
| 535 | \sa QPoint::manhattanLength() | - |
| 536 | */ | - |
| 537 | | - |
| 538 | /*! | - |
| 539 | \fn qreal QPointF::x() const | - |
| 540 | | - |
| 541 | Returns the x coordinate of this point. | - |
| 542 | | - |
| 543 | \sa setX(), rx() | - |
| 544 | */ | - |
| 545 | | - |
| 546 | /*! | - |
| 547 | \fn qreal QPointF::y() const | - |
| 548 | | - |
| 549 | Returns the y coordinate of this point. | - |
| 550 | | - |
| 551 | \sa setY(), ry() | - |
| 552 | */ | - |
| 553 | | - |
| 554 | /*! | - |
| 555 | \fn void QPointF::setX(qreal x) | - |
| 556 | | - |
| 557 | Sets the x coordinate of this point to the given \a x coordinate. | - |
| 558 | | - |
| 559 | \sa x(), setY() | - |
| 560 | */ | - |
| 561 | | - |
| 562 | /*! | - |
| 563 | \fn void QPointF::setY(qreal y) | - |
| 564 | | - |
| 565 | Sets the y coordinate of this point to the given \a y coordinate. | - |
| 566 | | - |
| 567 | \sa y(), setX() | - |
| 568 | */ | - |
| 569 | | - |
| 570 | /*! | - |
| 571 | \fn qreal& QPointF::rx() | - |
| 572 | | - |
| 573 | Returns a reference to the x coordinate of this point. | - |
| 574 | | - |
| 575 | Using a reference makes it possible to directly manipulate x. For example: | - |
| 576 | | - |
| 577 | \snippet code/src_corelib_tools_qpoint.cpp 10 | - |
| 578 | | - |
| 579 | \sa x(), setX() | - |
| 580 | */ | - |
| 581 | | - |
| 582 | /*! | - |
| 583 | \fn qreal& QPointF::ry() | - |
| 584 | | - |
| 585 | Returns a reference to the y coordinate of this point. | - |
| 586 | | - |
| 587 | Using a reference makes it possible to directly manipulate y. For example: | - |
| 588 | | - |
| 589 | \snippet code/src_corelib_tools_qpoint.cpp 11 | - |
| 590 | | - |
| 591 | \sa y(), setY() | - |
| 592 | */ | - |
| 593 | | - |
| 594 | /*! | - |
| 595 | \fn QPointF& QPointF::operator+=(const QPointF &point) | - |
| 596 | | - |
| 597 | Adds the given \a point to this point and returns a reference to | - |
| 598 | this point. For example: | - |
| 599 | | - |
| 600 | \snippet code/src_corelib_tools_qpoint.cpp 12 | - |
| 601 | | - |
| 602 | \sa operator-=() | - |
| 603 | */ | - |
| 604 | | - |
| 605 | /*! | - |
| 606 | \fn QPointF& QPointF::operator-=(const QPointF &point) | - |
| 607 | | - |
| 608 | Subtracts the given \a point from this point and returns a reference | - |
| 609 | to this point. For example: | - |
| 610 | | - |
| 611 | \snippet code/src_corelib_tools_qpoint.cpp 13 | - |
| 612 | | - |
| 613 | \sa operator+=() | - |
| 614 | */ | - |
| 615 | | - |
| 616 | /*! | - |
| 617 | \fn QPointF& QPointF::operator*=(qreal factor) | - |
| 618 | | - |
| 619 | Multiplies this point's coordinates by the given \a factor, and | - |
| 620 | returns a reference to this point. For example: | - |
| 621 | | - |
| 622 | \snippet code/src_corelib_tools_qpoint.cpp 14 | - |
| 623 | | - |
| 624 | \sa operator/=() | - |
| 625 | */ | - |
| 626 | | - |
| 627 | /*! | - |
| 628 | \fn QPointF& QPointF::operator/=(qreal divisor) | - |
| 629 | | - |
| 630 | Divides both x and y by the given \a divisor, and returns a reference | - |
| 631 | to this point. For example: | - |
| 632 | | - |
| 633 | \snippet code/src_corelib_tools_qpoint.cpp 15 | - |
| 634 | | - |
| 635 | \sa operator*=() | - |
| 636 | */ | - |
| 637 | | - |
| 638 | /*! | - |
| 639 | \fn const QPointF operator+(const QPointF &p1, const QPointF &p2) | - |
| 640 | \relates QPointF | - |
| 641 | | - |
| 642 | Returns a QPointF object that is the sum of the given points, \a p1 | - |
| 643 | and \a p2; each component is added separately. | - |
| 644 | | - |
| 645 | \sa QPointF::operator+=() | - |
| 646 | */ | - |
| 647 | | - |
| 648 | /*! | - |
| 649 | \fn const QPointF operator-(const QPointF &p1, const QPointF &p2) | - |
| 650 | \relates QPointF | - |
| 651 | | - |
| 652 | Returns a QPointF object that is formed by subtracting \a p2 from \a p1; | - |
| 653 | each component is subtracted separately. | - |
| 654 | | - |
| 655 | \sa QPointF::operator-=() | - |
| 656 | */ | - |
| 657 | | - |
| 658 | /*! | - |
| 659 | \fn const QPointF operator*(const QPointF &point, qreal factor) | - |
| 660 | \relates QPointF | - |
| 661 | | - |
| 662 | Returns a copy of the given \a point, multiplied by the given \a factor. | - |
| 663 | | - |
| 664 | \sa QPointF::operator*=() | - |
| 665 | */ | - |
| 666 | | - |
| 667 | /*! | - |
| 668 | \fn const QPointF operator*(qreal factor, const QPointF &point) | - |
| 669 | \relates QPointF | - |
| 670 | | - |
| 671 | \overload | - |
| 672 | | - |
| 673 | Returns a copy of the given \a point, multiplied by the given \a factor. | - |
| 674 | */ | - |
| 675 | | - |
| 676 | /*! | - |
| 677 | \fn const QPointF operator+(const QPointF &point) | - |
| 678 | \relates QPointF | - |
| 679 | \since 5.0 | - |
| 680 | | - |
| 681 | Returns \a point unmodified. | - |
| 682 | */ | - |
| 683 | | - |
| 684 | /*! | - |
| 685 | \fn const QPointF operator-(const QPointF &point) | - |
| 686 | \relates QPointF | - |
| 687 | \overload | - |
| 688 | | - |
| 689 | Returns a QPointF object that is formed by changing the sign of | - |
| 690 | both components of the given \a point. | - |
| 691 | | - |
| 692 | Equivalent to \c {QPointF(0,0) - point}. | - |
| 693 | */ | - |
| 694 | | - |
| 695 | /*! | - |
| 696 | \fn const QPointF operator/(const QPointF &point, qreal divisor) | - |
| 697 | \relates QPointF | - |
| 698 | | - |
| 699 | Returns the QPointF object formed by dividing both components of | - |
| 700 | the given \a point by the given \a divisor. | - |
| 701 | | - |
| 702 | \sa QPointF::operator/=() | - |
| 703 | */ | - |
| 704 | | - |
| 705 | /*! | - |
| 706 | \fn QPoint QPointF::toPoint() const | - |
| 707 | | - |
| 708 | Rounds the coordinates of this point to the nearest integer, and | - |
| 709 | returns a QPoint object with the rounded coordinates. | - |
| 710 | | - |
| 711 | \sa QPointF() | - |
| 712 | */ | - |
| 713 | | - |
| 714 | /*! | - |
| 715 | \fn bool operator==(const QPointF &p1, const QPointF &p2) | - |
| 716 | \relates QPointF | - |
| 717 | | - |
| 718 | Returns true if \a p1 is equal to \a p2; otherwise returns false. | - |
| 719 | */ | - |
| 720 | | - |
| 721 | /*! | - |
| 722 | \fn bool operator!=(const QPointF &p1, const QPointF &p2); | - |
| 723 | \relates QPointF | - |
| 724 | | - |
| 725 | Returns true if \a p1 is not equal to \a p2; otherwise returns false. | - |
| 726 | */ | - |
| 727 | | - |
| 728 | #ifndef QT_NO_DATASTREAM | - |
| 729 | /*! | - |
| 730 | \fn QDataStream &operator<<(QDataStream &stream, const QPointF &point) | - |
| 731 | \relates QPointF | - |
| 732 | | - |
| 733 | Writes the given \a point to the given \a stream and returns a | - |
| 734 | reference to the stream. | - |
| 735 | | - |
| 736 | \sa {Serializing Qt Data Types} | - |
| 737 | */ | - |
| 738 | | - |
| 739 | QDataStream &operator<<(QDataStream &s, const QPointF &p) | - |
| 740 | { | - |
| 741 | s << double(p.x()) << double(p.y()); executed (the execution status of this line is deduced): s << double(p.x()) << double(p.y()); | - |
| 742 | return s; executed: return s;Execution Count:116 | 116 |
| 743 | } | - |
| 744 | | - |
| 745 | /*! | - |
| 746 | \fn QDataStream &operator>>(QDataStream &stream, QPointF &point) | - |
| 747 | \relates QPointF | - |
| 748 | | - |
| 749 | Reads a point from the given \a stream into the given \a point | - |
| 750 | and returns a reference to the stream. | - |
| 751 | | - |
| 752 | \sa {Serializing Qt Data Types} | - |
| 753 | */ | - |
| 754 | | - |
| 755 | QDataStream &operator>>(QDataStream &s, QPointF &p) | - |
| 756 | { | - |
| 757 | double x, y; executed (the execution status of this line is deduced): double x, y; | - |
| 758 | s >> x; executed (the execution status of this line is deduced): s >> x; | - |
| 759 | s >> y; executed (the execution status of this line is deduced): s >> y; | - |
| 760 | p.setX(qreal(x)); executed (the execution status of this line is deduced): p.setX(qreal(x)); | - |
| 761 | p.setY(qreal(y)); executed (the execution status of this line is deduced): p.setY(qreal(y)); | - |
| 762 | return s; executed: return s;Execution Count:122 | 122 |
| 763 | } | - |
| 764 | #endif // QT_NO_DATASTREAM | - |
| 765 | | - |
| 766 | QT_END_NAMESPACE | - |
| 767 | | - |
| | |