| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/tools/qline.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||
| 2 | ** | - | ||||||||||||
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||
| 4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||
| 5 | ** | - | ||||||||||||
| 6 | ** This file is part of the QtCore module of the Qt Toolkit. | - | ||||||||||||
| 7 | ** | - | ||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||
| 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 The Qt Company. For licensing terms | - | ||||||||||||
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||
| 15 | ** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free | - | ||||||||||||
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||
| 22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||
| 25 | ** | - | ||||||||||||
| 26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||
| 29 | ** | - | ||||||||||||
| 30 | ** $QT_END_LICENSE$ | - | ||||||||||||
| 31 | ** | - | ||||||||||||
| 32 | ****************************************************************************/ | - | ||||||||||||
| 33 | - | |||||||||||||
| 34 | #include "qline.h" | - | ||||||||||||
| 35 | #include "qdebug.h" | - | ||||||||||||
| 36 | #include "qdatastream.h" | - | ||||||||||||
| 37 | #include "qmath.h" | - | ||||||||||||
| 38 | #include <private/qnumeric_p.h> | - | ||||||||||||
| 39 | - | |||||||||||||
| 40 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 41 | - | |||||||||||||
| 42 | /*! | - | ||||||||||||
| 43 | \class QLine | - | ||||||||||||
| 44 | \inmodule QtCore | - | ||||||||||||
| 45 | \ingroup painting | - | ||||||||||||
| 46 | - | |||||||||||||
| 47 | \brief The QLine class provides a two-dimensional vector using | - | ||||||||||||
| 48 | integer precision. | - | ||||||||||||
| 49 | - | |||||||||||||
| 50 | A QLine describes a finite length line (or a line segment) on a | - | ||||||||||||
| 51 | two-dimensional surface. The start and end points of the line are | - | ||||||||||||
| 52 | specified using integer point accuracy for coordinates. Use the | - | ||||||||||||
| 53 | QLineF constructor to retrieve a floating point copy. | - | ||||||||||||
| 54 | - | |||||||||||||
| 55 | \table | - | ||||||||||||
| 56 | \row | - | ||||||||||||
| 57 | \li \inlineimage qline-point.png | - | ||||||||||||
| 58 | \li \inlineimage qline-coordinates.png | - | ||||||||||||
| 59 | \endtable | - | ||||||||||||
| 60 | - | |||||||||||||
| 61 | The positions of the line's start and end points can be retrieved | - | ||||||||||||
| 62 | using the p1(), x1(), y1(), p2(), x2(), and y2() functions. The | - | ||||||||||||
| 63 | dx() and dy() functions return the horizontal and vertical | - | ||||||||||||
| 64 | components of the line. Use isNull() to determine whether the | - | ||||||||||||
| 65 | QLine represents a valid line or a null line. | - | ||||||||||||
| 66 | - | |||||||||||||
| 67 | Finally, the line can be translated a given offset using the | - | ||||||||||||
| 68 | translate() function. | - | ||||||||||||
| 69 | - | |||||||||||||
| 70 | \sa QLineF, QPolygon, QRect | - | ||||||||||||
| 71 | */ | - | ||||||||||||
| 72 | - | |||||||||||||
| 73 | /*! | - | ||||||||||||
| 74 | \fn QLine::QLine() | - | ||||||||||||
| 75 | - | |||||||||||||
| 76 | Constructs a null line. | - | ||||||||||||
| 77 | */ | - | ||||||||||||
| 78 | - | |||||||||||||
| 79 | /*! | - | ||||||||||||
| 80 | \fn QLine::QLine(const QPoint &p1, const QPoint &p2) | - | ||||||||||||
| 81 | - | |||||||||||||
| 82 | Constructs a line object that represents the line between \a p1 and | - | ||||||||||||
| 83 | \a p2. | - | ||||||||||||
| 84 | */ | - | ||||||||||||
| 85 | - | |||||||||||||
| 86 | /*! | - | ||||||||||||
| 87 | \fn QLine::QLine(int x1, int y1, int x2, int y2) | - | ||||||||||||
| 88 | - | |||||||||||||
| 89 | Constructs a line object that represents the line between (\a x1, \a y1) and | - | ||||||||||||
| 90 | (\a x2, \a y2). | - | ||||||||||||
| 91 | */ | - | ||||||||||||
| 92 | - | |||||||||||||
| 93 | /*! | - | ||||||||||||
| 94 | \fn bool QLine::isNull() const | - | ||||||||||||
| 95 | - | |||||||||||||
| 96 | Returns \c true if the line is not set up with valid start and end point; | - | ||||||||||||
| 97 | otherwise returns \c false. | - | ||||||||||||
| 98 | */ | - | ||||||||||||
| 99 | - | |||||||||||||
| 100 | /*! | - | ||||||||||||
| 101 | \fn QPoint QLine::p1() const | - | ||||||||||||
| 102 | - | |||||||||||||
| 103 | Returns the line's start point. | - | ||||||||||||
| 104 | - | |||||||||||||
| 105 | \sa x1(), y1(), p2() | - | ||||||||||||
| 106 | */ | - | ||||||||||||
| 107 | - | |||||||||||||
| 108 | /*! | - | ||||||||||||
| 109 | \fn QPoint QLine::p2() const | - | ||||||||||||
| 110 | - | |||||||||||||
| 111 | Returns the line's end point. | - | ||||||||||||
| 112 | - | |||||||||||||
| 113 | \sa x2(), y2(), p1() | - | ||||||||||||
| 114 | */ | - | ||||||||||||
| 115 | - | |||||||||||||
| 116 | /*! | - | ||||||||||||
| 117 | \fn int QLine::x1() const | - | ||||||||||||
| 118 | - | |||||||||||||
| 119 | Returns the x-coordinate of the line's start point. | - | ||||||||||||
| 120 | - | |||||||||||||
| 121 | \sa p1() | - | ||||||||||||
| 122 | */ | - | ||||||||||||
| 123 | - | |||||||||||||
| 124 | /*! | - | ||||||||||||
| 125 | \fn int QLine::y1() const | - | ||||||||||||
| 126 | - | |||||||||||||
| 127 | Returns the y-coordinate of the line's start point. | - | ||||||||||||
| 128 | - | |||||||||||||
| 129 | \sa p1() | - | ||||||||||||
| 130 | */ | - | ||||||||||||
| 131 | - | |||||||||||||
| 132 | /*! | - | ||||||||||||
| 133 | \fn int QLine::x2() const | - | ||||||||||||
| 134 | - | |||||||||||||
| 135 | Returns the x-coordinate of the line's end point. | - | ||||||||||||
| 136 | - | |||||||||||||
| 137 | \sa p2() | - | ||||||||||||
| 138 | */ | - | ||||||||||||
| 139 | - | |||||||||||||
| 140 | /*! | - | ||||||||||||
| 141 | \fn int QLine::y2() const | - | ||||||||||||
| 142 | - | |||||||||||||
| 143 | Returns the y-coordinate of the line's end point. | - | ||||||||||||
| 144 | - | |||||||||||||
| 145 | \sa p2() | - | ||||||||||||
| 146 | */ | - | ||||||||||||
| 147 | - | |||||||||||||
| 148 | /*! | - | ||||||||||||
| 149 | \fn int QLine::dx() const | - | ||||||||||||
| 150 | - | |||||||||||||
| 151 | Returns the horizontal component of the line's vector. | - | ||||||||||||
| 152 | - | |||||||||||||
| 153 | \sa dy() | - | ||||||||||||
| 154 | */ | - | ||||||||||||
| 155 | - | |||||||||||||
| 156 | /*! | - | ||||||||||||
| 157 | \fn int QLine::dy() const | - | ||||||||||||
| 158 | - | |||||||||||||
| 159 | Returns the vertical component of the line's vector. | - | ||||||||||||
| 160 | - | |||||||||||||
| 161 | \sa dx() | - | ||||||||||||
| 162 | */ | - | ||||||||||||
| 163 | - | |||||||||||||
| 164 | /*! | - | ||||||||||||
| 165 | \fn bool QLine::operator!=(const QLine &line) const | - | ||||||||||||
| 166 | - | |||||||||||||
| 167 | Returns \c true if the given \a line is not the same as \e this line. | - | ||||||||||||
| 168 | - | |||||||||||||
| 169 | A line is different from another line if any of their start or | - | ||||||||||||
| 170 | end points differ, or the internal order of the points is different. | - | ||||||||||||
| 171 | */ | - | ||||||||||||
| 172 | - | |||||||||||||
| 173 | /*! | - | ||||||||||||
| 174 | \fn bool QLine::operator==(const QLine &line) const | - | ||||||||||||
| 175 | - | |||||||||||||
| 176 | Returns \c true if the given \a line is the same as \e this line. | - | ||||||||||||
| 177 | - | |||||||||||||
| 178 | A line is identical to another line if the start and end points | - | ||||||||||||
| 179 | are identical, and the internal order of the points is the same. | - | ||||||||||||
| 180 | */ | - | ||||||||||||
| 181 | - | |||||||||||||
| 182 | /*! | - | ||||||||||||
| 183 | \fn void QLine::translate(const QPoint &offset) | - | ||||||||||||
| 184 | - | |||||||||||||
| 185 | Translates this line by the given \a offset. | - | ||||||||||||
| 186 | */ | - | ||||||||||||
| 187 | - | |||||||||||||
| 188 | /*! | - | ||||||||||||
| 189 | \fn void QLine::translate(int dx, int dy) | - | ||||||||||||
| 190 | \overload | - | ||||||||||||
| 191 | - | |||||||||||||
| 192 | Translates this line the distance specified by \a dx and \a dy. | - | ||||||||||||
| 193 | */ | - | ||||||||||||
| 194 | - | |||||||||||||
| 195 | /*! | - | ||||||||||||
| 196 | \fn QLine QLine::translated(const QPoint &offset) const | - | ||||||||||||
| 197 | - | |||||||||||||
| 198 | \since 4.4 | - | ||||||||||||
| 199 | - | |||||||||||||
| 200 | Returns this line translated by the given \a offset. | - | ||||||||||||
| 201 | */ | - | ||||||||||||
| 202 | - | |||||||||||||
| 203 | /*! | - | ||||||||||||
| 204 | \fn QLine QLine::translated(int dx, int dy) const | - | ||||||||||||
| 205 | \overload | - | ||||||||||||
| 206 | \since 4.4 | - | ||||||||||||
| 207 | - | |||||||||||||
| 208 | Returns this line translated the distance specified by \a dx and \a dy. | - | ||||||||||||
| 209 | */ | - | ||||||||||||
| 210 | - | |||||||||||||
| 211 | - | |||||||||||||
| 212 | /*! | - | ||||||||||||
| 213 | \fn void QLine::setP1(const QPoint &p1) | - | ||||||||||||
| 214 | \since 4.4 | - | ||||||||||||
| 215 | - | |||||||||||||
| 216 | Sets the starting point of this line to \a p1. | - | ||||||||||||
| 217 | - | |||||||||||||
| 218 | \sa setP2(), p1() | - | ||||||||||||
| 219 | */ | - | ||||||||||||
| 220 | - | |||||||||||||
| 221 | - | |||||||||||||
| 222 | /*! | - | ||||||||||||
| 223 | \fn void QLine::setP2(const QPoint &p2) | - | ||||||||||||
| 224 | \since 4.4 | - | ||||||||||||
| 225 | - | |||||||||||||
| 226 | Sets the end point of this line to \a p2. | - | ||||||||||||
| 227 | - | |||||||||||||
| 228 | \sa setP1(), p2() | - | ||||||||||||
| 229 | */ | - | ||||||||||||
| 230 | - | |||||||||||||
| 231 | - | |||||||||||||
| 232 | /*! | - | ||||||||||||
| 233 | \fn void QLine::setPoints(const QPoint &p1, const QPoint &p2) | - | ||||||||||||
| 234 | \since 4.4 | - | ||||||||||||
| 235 | - | |||||||||||||
| 236 | Sets the start point of this line to \a p1 and the end point of this line to \a p2. | - | ||||||||||||
| 237 | - | |||||||||||||
| 238 | \sa setP1(), setP2(), p1(), p2() | - | ||||||||||||
| 239 | */ | - | ||||||||||||
| 240 | - | |||||||||||||
| 241 | - | |||||||||||||
| 242 | /*! | - | ||||||||||||
| 243 | \fn void QLine::setLine(int x1, int y1, int x2, int y2) | - | ||||||||||||
| 244 | \since 4.4 | - | ||||||||||||
| 245 | - | |||||||||||||
| 246 | Sets this line to the start in \a x1, \a y1 and end in \a x2, \a y2. | - | ||||||||||||
| 247 | - | |||||||||||||
| 248 | \sa setP1(), setP2(), p1(), p2() | - | ||||||||||||
| 249 | */ | - | ||||||||||||
| 250 | - | |||||||||||||
| 251 | - | |||||||||||||
| 252 | - | |||||||||||||
| 253 | #ifndef QT_NO_DEBUG_STREAM | - | ||||||||||||
| 254 | QDebug operator<<(QDebug dbg, const QLine &p) | - | ||||||||||||
| 255 | { | - | ||||||||||||
| 256 | QDebugStateSaver saver(dbg); | - | ||||||||||||
| 257 | dbg.nospace() << "QLine(" << p.p1() << ',' << p.p2() << ')'; | - | ||||||||||||
| 258 | return dbg; executed 2 times by 2 tests: return dbg;Executed by:
| 2 | ||||||||||||
| 259 | } | - | ||||||||||||
| 260 | #endif | - | ||||||||||||
| 261 | - | |||||||||||||
| 262 | #ifndef QT_NO_DATASTREAM | - | ||||||||||||
| 263 | /*! | - | ||||||||||||
| 264 | \relates QLine | - | ||||||||||||
| 265 | - | |||||||||||||
| 266 | Writes the given \a line to the given \a stream and returns a | - | ||||||||||||
| 267 | reference to the stream. | - | ||||||||||||
| 268 | - | |||||||||||||
| 269 | \sa {Serializing Qt Data Types} | - | ||||||||||||
| 270 | */ | - | ||||||||||||
| 271 | - | |||||||||||||
| 272 | QDataStream &operator<<(QDataStream &stream, const QLine &line) | - | ||||||||||||
| 273 | { | - | ||||||||||||
| 274 | stream << line.p1() << line.p2(); | - | ||||||||||||
| 275 | return stream; executed 3 times by 2 tests: return stream;Executed by:
| 3 | ||||||||||||
| 276 | } | - | ||||||||||||
| 277 | - | |||||||||||||
| 278 | /*! | - | ||||||||||||
| 279 | \relates QLine | - | ||||||||||||
| 280 | - | |||||||||||||
| 281 | Reads a line from the given \a stream into the given \a line and | - | ||||||||||||
| 282 | returns a reference to the stream. | - | ||||||||||||
| 283 | - | |||||||||||||
| 284 | \sa {Serializing Qt Data Types} | - | ||||||||||||
| 285 | */ | - | ||||||||||||
| 286 | - | |||||||||||||
| 287 | QDataStream &operator>>(QDataStream &stream, QLine &line) | - | ||||||||||||
| 288 | { | - | ||||||||||||
| 289 | QPoint p1, p2; | - | ||||||||||||
| 290 | stream >> p1; | - | ||||||||||||
| 291 | stream >> p2; | - | ||||||||||||
| 292 | line = QLine(p1, p2); | - | ||||||||||||
| 293 | - | |||||||||||||
| 294 | return stream; executed 7 times by 2 tests: return stream;Executed by:
| 7 | ||||||||||||
| 295 | } | - | ||||||||||||
| 296 | - | |||||||||||||
| 297 | #endif // QT_NO_DATASTREAM | - | ||||||||||||
| 298 | - | |||||||||||||
| 299 | - | |||||||||||||
| 300 | #ifndef M_2PI | - | ||||||||||||
| 301 | #define M_2PI 6.28318530717958647692528676655900576 | - | ||||||||||||
| 302 | #endif | - | ||||||||||||
| 303 | - | |||||||||||||
| 304 | /*! | - | ||||||||||||
| 305 | \class QLineF | - | ||||||||||||
| 306 | \inmodule QtCore | - | ||||||||||||
| 307 | \ingroup painting | - | ||||||||||||
| 308 | - | |||||||||||||
| 309 | \brief The QLineF class provides a two-dimensional vector using | - | ||||||||||||
| 310 | floating point precision. | - | ||||||||||||
| 311 | - | |||||||||||||
| 312 | A QLineF describes a finite length line (or line segment) on a | - | ||||||||||||
| 313 | two-dimensional surface. QLineF defines the start and end points | - | ||||||||||||
| 314 | of the line using floating point accuracy for coordinates. Use | - | ||||||||||||
| 315 | the toLine() function to retrieve an integer based copy of this | - | ||||||||||||
| 316 | line. | - | ||||||||||||
| 317 | - | |||||||||||||
| 318 | \table | - | ||||||||||||
| 319 | \row | - | ||||||||||||
| 320 | \li \inlineimage qline-point.png | - | ||||||||||||
| 321 | \li \inlineimage qline-coordinates.png | - | ||||||||||||
| 322 | \endtable | - | ||||||||||||
| 323 | - | |||||||||||||
| 324 | The positions of the line's start and end points can be retrieved | - | ||||||||||||
| 325 | using the p1(), x1(), y1(), p2(), x2(), and y2() functions. The | - | ||||||||||||
| 326 | dx() and dy() functions return the horizontal and vertical | - | ||||||||||||
| 327 | components of the line, respectively. | - | ||||||||||||
| 328 | - | |||||||||||||
| 329 | The line's length can be retrieved using the length() function, | - | ||||||||||||
| 330 | and altered using the setLength() function. Similarly, angle() | - | ||||||||||||
| 331 | and setAngle() are respectively used for retrieving and altering | - | ||||||||||||
| 332 | the angle of the line. Use the isNull() | - | ||||||||||||
| 333 | function to determine whether the QLineF represents a valid line | - | ||||||||||||
| 334 | or a null line. | - | ||||||||||||
| 335 | - | |||||||||||||
| 336 | The intersect() function determines the IntersectType for this | - | ||||||||||||
| 337 | line and a given line, while the angleTo() function returns the | - | ||||||||||||
| 338 | angle between the lines. In addition, the unitVector() function | - | ||||||||||||
| 339 | returns a line that has the same starting point as this line, but | - | ||||||||||||
| 340 | with a length of only 1, while the normalVector() function returns | - | ||||||||||||
| 341 | a line that is perpendicular to this line with the same starting | - | ||||||||||||
| 342 | point and length. | - | ||||||||||||
| 343 | - | |||||||||||||
| 344 | Finally, the line can be translated a given offset using the | - | ||||||||||||
| 345 | translate() function, and can be traversed using the pointAt() | - | ||||||||||||
| 346 | function. | - | ||||||||||||
| 347 | - | |||||||||||||
| 348 | \sa QLine, QPolygonF, QRectF | - | ||||||||||||
| 349 | */ | - | ||||||||||||
| 350 | - | |||||||||||||
| 351 | /*! | - | ||||||||||||
| 352 | \enum QLineF::IntersectType | - | ||||||||||||
| 353 | - | |||||||||||||
| 354 | Describes the intersection between two lines. | - | ||||||||||||
| 355 | - | |||||||||||||
| 356 | \table | - | ||||||||||||
| 357 | \row | - | ||||||||||||
| 358 | \li \inlineimage qlinef-unbounded.png | - | ||||||||||||
| 359 | \li \inlineimage qlinef-bounded.png | - | ||||||||||||
| 360 | \row | - | ||||||||||||
| 361 | \li QLineF::UnboundedIntersection | - | ||||||||||||
| 362 | \li QLineF::BoundedIntersection | - | ||||||||||||
| 363 | \endtable | - | ||||||||||||
| 364 | - | |||||||||||||
| 365 | \value NoIntersection Indicates that the lines do not intersect; | - | ||||||||||||
| 366 | i.e. they are parallel. | - | ||||||||||||
| 367 | - | |||||||||||||
| 368 | \value UnboundedIntersection The two lines intersect, but not | - | ||||||||||||
| 369 | within the range defined by their lengths. This will be the case | - | ||||||||||||
| 370 | if the lines are not parallel. | - | ||||||||||||
| 371 | - | |||||||||||||
| 372 | intersect() will also return this value if the intersect point is | - | ||||||||||||
| 373 | within the start and end point of only one of the lines. | - | ||||||||||||
| 374 | - | |||||||||||||
| 375 | \value BoundedIntersection The two lines intersect with each other | - | ||||||||||||
| 376 | within the start and end points of each line. | - | ||||||||||||
| 377 | - | |||||||||||||
| 378 | \sa intersect() | - | ||||||||||||
| 379 | */ | - | ||||||||||||
| 380 | - | |||||||||||||
| 381 | /*! | - | ||||||||||||
| 382 | \fn QLineF::QLineF() | - | ||||||||||||
| 383 | - | |||||||||||||
| 384 | Constructs a null line. | - | ||||||||||||
| 385 | */ | - | ||||||||||||
| 386 | - | |||||||||||||
| 387 | /*! | - | ||||||||||||
| 388 | \fn QLineF::QLineF(const QPointF &p1, const QPointF &p2) | - | ||||||||||||
| 389 | - | |||||||||||||
| 390 | Constructs a line object that represents the line between \a p1 and | - | ||||||||||||
| 391 | \a p2. | - | ||||||||||||
| 392 | */ | - | ||||||||||||
| 393 | - | |||||||||||||
| 394 | /*! | - | ||||||||||||
| 395 | \fn QLineF::QLineF(qreal x1, qreal y1, qreal x2, qreal y2) | - | ||||||||||||
| 396 | - | |||||||||||||
| 397 | Constructs a line object that represents the line between (\a x1, \a y1) and | - | ||||||||||||
| 398 | (\a x2, \a y2). | - | ||||||||||||
| 399 | */ | - | ||||||||||||
| 400 | - | |||||||||||||
| 401 | /*! | - | ||||||||||||
| 402 | \fn QLineF::QLineF(const QLine &line) | - | ||||||||||||
| 403 | - | |||||||||||||
| 404 | Construct a QLineF object from the given integer-based \a line. | - | ||||||||||||
| 405 | - | |||||||||||||
| 406 | \sa toLine() | - | ||||||||||||
| 407 | */ | - | ||||||||||||
| 408 | - | |||||||||||||
| 409 | /*! | - | ||||||||||||
| 410 | \fn bool QLineF::isNull() const | - | ||||||||||||
| 411 | - | |||||||||||||
| 412 | Returns \c true if the line is not set up with valid start and end point; | - | ||||||||||||
| 413 | otherwise returns \c false. | - | ||||||||||||
| 414 | */ | - | ||||||||||||
| 415 | - | |||||||||||||
| 416 | /*! | - | ||||||||||||
| 417 | \fn QPointF QLineF::p1() const | - | ||||||||||||
| 418 | - | |||||||||||||
| 419 | Returns the line's start point. | - | ||||||||||||
| 420 | - | |||||||||||||
| 421 | \sa x1(), y1(), p2() | - | ||||||||||||
| 422 | */ | - | ||||||||||||
| 423 | - | |||||||||||||
| 424 | /*! | - | ||||||||||||
| 425 | \fn QPointF QLineF::p2() const | - | ||||||||||||
| 426 | - | |||||||||||||
| 427 | Returns the line's end point. | - | ||||||||||||
| 428 | - | |||||||||||||
| 429 | \sa x2(), y2(), p1() | - | ||||||||||||
| 430 | */ | - | ||||||||||||
| 431 | - | |||||||||||||
| 432 | /*! | - | ||||||||||||
| 433 | \fn QLine QLineF::toLine() const | - | ||||||||||||
| 434 | - | |||||||||||||
| 435 | Returns an integer based copy of this line. | - | ||||||||||||
| 436 | - | |||||||||||||
| 437 | Note that the returned line's start and end points are rounded to | - | ||||||||||||
| 438 | the nearest integer. | - | ||||||||||||
| 439 | - | |||||||||||||
| 440 | \sa QLineF() | - | ||||||||||||
| 441 | */ | - | ||||||||||||
| 442 | /*! | - | ||||||||||||
| 443 | \fn qreal QLineF::x1() const | - | ||||||||||||
| 444 | - | |||||||||||||
| 445 | Returns the x-coordinate of the line's start point. | - | ||||||||||||
| 446 | - | |||||||||||||
| 447 | \sa p1() | - | ||||||||||||
| 448 | */ | - | ||||||||||||
| 449 | - | |||||||||||||
| 450 | /*! | - | ||||||||||||
| 451 | \fn qreal QLineF::y1() const | - | ||||||||||||
| 452 | - | |||||||||||||
| 453 | Returns the y-coordinate of the line's start point. | - | ||||||||||||
| 454 | - | |||||||||||||
| 455 | \sa p1() | - | ||||||||||||
| 456 | */ | - | ||||||||||||
| 457 | - | |||||||||||||
| 458 | /*! | - | ||||||||||||
| 459 | \fn qreal QLineF::x2() const | - | ||||||||||||
| 460 | - | |||||||||||||
| 461 | Returns the x-coordinate of the line's end point. | - | ||||||||||||
| 462 | - | |||||||||||||
| 463 | \sa p2() | - | ||||||||||||
| 464 | */ | - | ||||||||||||
| 465 | - | |||||||||||||
| 466 | /*! | - | ||||||||||||
| 467 | \fn qreal QLineF::y2() const | - | ||||||||||||
| 468 | - | |||||||||||||
| 469 | Returns the y-coordinate of the line's end point. | - | ||||||||||||
| 470 | - | |||||||||||||
| 471 | \sa p2() | - | ||||||||||||
| 472 | */ | - | ||||||||||||
| 473 | - | |||||||||||||
| 474 | /*! | - | ||||||||||||
| 475 | \fn qreal QLineF::dx() const | - | ||||||||||||
| 476 | - | |||||||||||||
| 477 | Returns the horizontal component of the line's vector. | - | ||||||||||||
| 478 | - | |||||||||||||
| 479 | \sa dy(), pointAt() | - | ||||||||||||
| 480 | */ | - | ||||||||||||
| 481 | - | |||||||||||||
| 482 | /*! | - | ||||||||||||
| 483 | \fn qreal QLineF::dy() const | - | ||||||||||||
| 484 | - | |||||||||||||
| 485 | Returns the vertical component of the line's vector. | - | ||||||||||||
| 486 | - | |||||||||||||
| 487 | \sa dx(), pointAt() | - | ||||||||||||
| 488 | */ | - | ||||||||||||
| 489 | - | |||||||||||||
| 490 | /*! | - | ||||||||||||
| 491 | \fn QLineF::setLength(qreal length) | - | ||||||||||||
| 492 | - | |||||||||||||
| 493 | Sets the length of the line to the given \a length. QLineF will | - | ||||||||||||
| 494 | move the end point - p2() - of the line to give the line its new length. | - | ||||||||||||
| 495 | - | |||||||||||||
| 496 | If the line is a null line, the length will remain zero regardless | - | ||||||||||||
| 497 | of the length specified. | - | ||||||||||||
| 498 | - | |||||||||||||
| 499 | \sa length(), isNull() | - | ||||||||||||
| 500 | */ | - | ||||||||||||
| 501 | - | |||||||||||||
| 502 | /*! | - | ||||||||||||
| 503 | \fn QLineF QLineF::normalVector() const | - | ||||||||||||
| 504 | - | |||||||||||||
| 505 | Returns a line that is perpendicular to this line with the same starting | - | ||||||||||||
| 506 | point and length. | - | ||||||||||||
| 507 | - | |||||||||||||
| 508 | \image qlinef-normalvector.png | - | ||||||||||||
| 509 | - | |||||||||||||
| 510 | \sa unitVector() | - | ||||||||||||
| 511 | */ | - | ||||||||||||
| 512 | - | |||||||||||||
| 513 | /*! | - | ||||||||||||
| 514 | \fn bool QLineF::operator!=(const QLineF &line) const | - | ||||||||||||
| 515 | - | |||||||||||||
| 516 | Returns \c true if the given \a line is not the same as \e this line. | - | ||||||||||||
| 517 | - | |||||||||||||
| 518 | A line is different from another line if their start or end points | - | ||||||||||||
| 519 | differ, or the internal order of the points is different. | - | ||||||||||||
| 520 | */ | - | ||||||||||||
| 521 | - | |||||||||||||
| 522 | /*! | - | ||||||||||||
| 523 | \fn bool QLineF::operator==(const QLineF &line) const | - | ||||||||||||
| 524 | - | |||||||||||||
| 525 | Returns \c true if the given \a line is the same as this line. | - | ||||||||||||
| 526 | - | |||||||||||||
| 527 | A line is identical to another line if the start and end points | - | ||||||||||||
| 528 | are identical, and the internal order of the points is the same. | - | ||||||||||||
| 529 | */ | - | ||||||||||||
| 530 | - | |||||||||||||
| 531 | /*! | - | ||||||||||||
| 532 | \fn qreal QLineF::pointAt(qreal t) const | - | ||||||||||||
| 533 | - | |||||||||||||
| 534 | Returns the point at the parameterized position specified by \a | - | ||||||||||||
| 535 | t. The function returns the line's start point if t = 0, and its end | - | ||||||||||||
| 536 | point if t = 1. | - | ||||||||||||
| 537 | - | |||||||||||||
| 538 | \sa dx(), dy() | - | ||||||||||||
| 539 | */ | - | ||||||||||||
| 540 | - | |||||||||||||
| 541 | /*! | - | ||||||||||||
| 542 | Returns the length of the line. | - | ||||||||||||
| 543 | - | |||||||||||||
| 544 | \sa setLength() | - | ||||||||||||
| 545 | */ | - | ||||||||||||
| 546 | qreal QLineF::length() const | - | ||||||||||||
| 547 | { | - | ||||||||||||
| 548 | qreal x = pt2.x() - pt1.x(); | - | ||||||||||||
| 549 | qreal y = pt2.y() - pt1.y(); | - | ||||||||||||
| 550 | return qSqrt(x*x + y*y); executed 133013 times by 21 tests: return qSqrt(x*x + y*y);Executed by:
| 133013 | ||||||||||||
| 551 | } | - | ||||||||||||
| 552 | - | |||||||||||||
| 553 | /*! | - | ||||||||||||
| 554 | \since 4.4 | - | ||||||||||||
| 555 | - | |||||||||||||
| 556 | Returns the angle of the line in degrees. | - | ||||||||||||
| 557 | - | |||||||||||||
| 558 | The return value will be in the range of values from 0.0 up to but not | - | ||||||||||||
| 559 | including 360.0. The angles are measured counter-clockwise from a point | - | ||||||||||||
| 560 | on the x-axis to the right of the origin (x > 0). | - | ||||||||||||
| 561 | - | |||||||||||||
| 562 | \sa setAngle() | - | ||||||||||||
| 563 | */ | - | ||||||||||||
| 564 | qreal QLineF::angle() const | - | ||||||||||||
| 565 | { | - | ||||||||||||
| 566 | const qreal dx = pt2.x() - pt1.x(); | - | ||||||||||||
| 567 | const qreal dy = pt2.y() - pt1.y(); | - | ||||||||||||
| 568 | - | |||||||||||||
| 569 | const qreal theta = qAtan2(-dy, dx) * 360.0 / M_2PI; | - | ||||||||||||
| 570 | - | |||||||||||||
| 571 | const qreal theta_normalized = theta < 0 ? theta + 360 : theta;
| 53857-54304 | ||||||||||||
| 572 | - | |||||||||||||
| 573 | if (qFuzzyCompare(theta_normalized, qreal(360)))
| 2-108159 | ||||||||||||
| 574 | return qreal(0); executed 2 times by 1 test: return qreal(0);Executed by:
| 2 | ||||||||||||
| 575 | else | - | ||||||||||||
| 576 | return theta_normalized; executed 108159 times by 15 tests: return theta_normalized;Executed by:
| 108159 | ||||||||||||
| 577 | } | - | ||||||||||||
| 578 | - | |||||||||||||
| 579 | /*! | - | ||||||||||||
| 580 | \since 4.4 | - | ||||||||||||
| 581 | - | |||||||||||||
| 582 | Sets the angle of the line to the given \a angle (in degrees). | - | ||||||||||||
| 583 | This will change the position of the second point of the line such that | - | ||||||||||||
| 584 | the line has the given angle. | - | ||||||||||||
| 585 | - | |||||||||||||
| 586 | Positive values for the angles mean counter-clockwise while negative values | - | ||||||||||||
| 587 | mean the clockwise direction. Zero degrees is at the 3 o'clock position. | - | ||||||||||||
| 588 | - | |||||||||||||
| 589 | \sa angle() | - | ||||||||||||
| 590 | */ | - | ||||||||||||
| 591 | void QLineF::setAngle(qreal angle) | - | ||||||||||||
| 592 | { | - | ||||||||||||
| 593 | const qreal angleR = angle * M_2PI / 360.0; | - | ||||||||||||
| 594 | const qreal l = length(); | - | ||||||||||||
| 595 | - | |||||||||||||
| 596 | const qreal dx = qCos(angleR) * l; | - | ||||||||||||
| 597 | const qreal dy = -qSin(angleR) * l; | - | ||||||||||||
| 598 | - | |||||||||||||
| 599 | pt2.rx() = pt1.x() + dx; | - | ||||||||||||
| 600 | pt2.ry() = pt1.y() + dy; | - | ||||||||||||
| 601 | } executed 1804 times by 1 test: end of blockExecuted by:
| 1804 | ||||||||||||
| 602 | - | |||||||||||||
| 603 | /*! | - | ||||||||||||
| 604 | \since 4.4 | - | ||||||||||||
| 605 | - | |||||||||||||
| 606 | Returns a QLineF with the given \a length and \a angle. | - | ||||||||||||
| 607 | - | |||||||||||||
| 608 | The first point of the line will be on the origin. | - | ||||||||||||
| 609 | - | |||||||||||||
| 610 | Positive values for the angles mean counter-clockwise while negative values | - | ||||||||||||
| 611 | mean the clockwise direction. Zero degrees is at the 3 o'clock position. | - | ||||||||||||
| 612 | */ | - | ||||||||||||
| 613 | QLineF QLineF::fromPolar(qreal length, qreal angle) | - | ||||||||||||
| 614 | { | - | ||||||||||||
| 615 | const qreal angleR = angle * M_2PI / 360.0; | - | ||||||||||||
| 616 | return QLineF(0, 0, qCos(angleR) * length, -qSin(angleR) * length); executed 4169 times by 2 tests: return QLineF(0, 0, qCos(angleR) * length, -qSin(angleR) * length);Executed by:
| 4169 | ||||||||||||
| 617 | } | - | ||||||||||||
| 618 | - | |||||||||||||
| 619 | /*! | - | ||||||||||||
| 620 | Returns the unit vector for this line, i.e a line starting at the | - | ||||||||||||
| 621 | same point as \e this line with a length of 1.0. | - | ||||||||||||
| 622 | - | |||||||||||||
| 623 | \sa normalVector() | - | ||||||||||||
| 624 | */ | - | ||||||||||||
| 625 | QLineF QLineF::unitVector() const | - | ||||||||||||
| 626 | { | - | ||||||||||||
| 627 | qreal x = pt2.x() - pt1.x(); | - | ||||||||||||
| 628 | qreal y = pt2.y() - pt1.y(); | - | ||||||||||||
| 629 | - | |||||||||||||
| 630 | qreal len = qSqrt(x*x + y*y); | - | ||||||||||||
| 631 | QLineF f(p1(), QPointF(pt1.x() + x/len, pt1.y() + y/len)); | - | ||||||||||||
| 632 | - | |||||||||||||
| 633 | #ifndef QT_NO_DEBUG | - | ||||||||||||
| 634 | if (qAbs(f.length() - 1) >= 0.001)
| 0-102525 | ||||||||||||
| 635 | qWarning("QLine::unitVector: New line does not have unit length"); never executed: QMessageLogger(__FILE__, 635, __PRETTY_FUNCTION__).warning("QLine::unitVector: New line does not have unit length"); | 0 | ||||||||||||
| 636 | #endif | - | ||||||||||||
| 637 | - | |||||||||||||
| 638 | return f; executed 102525 times by 15 tests: return f;Executed by:
| 102525 | ||||||||||||
| 639 | } | - | ||||||||||||
| 640 | - | |||||||||||||
| 641 | /*! | - | ||||||||||||
| 642 | \fn QLineF::IntersectType QLineF::intersect(const QLineF &line, QPointF *intersectionPoint) const | - | ||||||||||||
| 643 | - | |||||||||||||
| 644 | Returns a value indicating whether or not \e this line intersects | - | ||||||||||||
| 645 | with the given \a line. | - | ||||||||||||
| 646 | - | |||||||||||||
| 647 | The actual intersection point is extracted to \a intersectionPoint | - | ||||||||||||
| 648 | (if the pointer is valid). If the lines are parallel, the | - | ||||||||||||
| 649 | intersection point is undefined. | - | ||||||||||||
| 650 | */ | - | ||||||||||||
| 651 | - | |||||||||||||
| 652 | QLineF::IntersectType QLineF::intersect(const QLineF &l, QPointF *intersectionPoint) const | - | ||||||||||||
| 653 | { | - | ||||||||||||
| 654 | // ipmlementation is based on Graphics Gems III's "Faster Line Segment Intersection" | - | ||||||||||||
| 655 | const QPointF a = pt2 - pt1; | - | ||||||||||||
| 656 | const QPointF b = l.pt1 - l.pt2; | - | ||||||||||||
| 657 | const QPointF c = pt1 - l.pt1; | - | ||||||||||||
| 658 | - | |||||||||||||
| 659 | const qreal denominator = a.y() * b.x() - a.x() * b.y(); | - | ||||||||||||
| 660 | if (denominator == 0 || !qt_is_finite(denominator))
| 0-53458 | ||||||||||||
| 661 | return NoIntersection; executed 3612 times by 8 tests: return NoIntersection;Executed by:
| 3612 | ||||||||||||
| 662 | - | |||||||||||||
| 663 | const qreal reciprocal = 1 / denominator; | - | ||||||||||||
| 664 | const qreal na = (b.y() * c.x() - b.x() * c.y()) * reciprocal; | - | ||||||||||||
| 665 | if (intersectionPoint)
| 0-53458 | ||||||||||||
| 666 | *intersectionPoint = pt1 + a * na; executed 53458 times by 14 tests: *intersectionPoint = pt1 + a * na;Executed by:
| 53458 | ||||||||||||
| 667 | - | |||||||||||||
| 668 | if (na < 0 || na > 1)
| 35-53423 | ||||||||||||
| 669 | return UnboundedIntersection; executed 26260 times by 13 tests: return UnboundedIntersection;Executed by:
| 26260 | ||||||||||||
| 670 | - | |||||||||||||
| 671 | const qreal nb = (a.x() * c.y() - a.y() * c.x()) * reciprocal; | - | ||||||||||||
| 672 | if (nb < 0 || nb > 1)
| 0-27198 | ||||||||||||
| 673 | return UnboundedIntersection; executed 1 time by 1 test: return UnboundedIntersection;Executed by:
| 1 | ||||||||||||
| 674 | - | |||||||||||||
| 675 | return BoundedIntersection; executed 27197 times by 14 tests: return BoundedIntersection;Executed by:
| 27197 | ||||||||||||
| 676 | } | - | ||||||||||||
| 677 | - | |||||||||||||
| 678 | /*! | - | ||||||||||||
| 679 | \fn void QLineF::translate(const QPointF &offset) | - | ||||||||||||
| 680 | - | |||||||||||||
| 681 | Translates this line by the given \a offset. | - | ||||||||||||
| 682 | */ | - | ||||||||||||
| 683 | - | |||||||||||||
| 684 | /*! | - | ||||||||||||
| 685 | \fn void QLineF::translate(qreal dx, qreal dy) | - | ||||||||||||
| 686 | \overload | - | ||||||||||||
| 687 | - | |||||||||||||
| 688 | Translates this line the distance specified by \a dx and \a dy. | - | ||||||||||||
| 689 | */ | - | ||||||||||||
| 690 | - | |||||||||||||
| 691 | /*! | - | ||||||||||||
| 692 | \fn QLineF QLineF::translated(const QPointF &offset) const | - | ||||||||||||
| 693 | - | |||||||||||||
| 694 | \since 4.4 | - | ||||||||||||
| 695 | - | |||||||||||||
| 696 | Returns this line translated by the given \a offset. | - | ||||||||||||
| 697 | */ | - | ||||||||||||
| 698 | - | |||||||||||||
| 699 | /*! | - | ||||||||||||
| 700 | \fn QLineF QLineF::translated(qreal dx, qreal dy) const | - | ||||||||||||
| 701 | \overload | - | ||||||||||||
| 702 | \since 4.4 | - | ||||||||||||
| 703 | - | |||||||||||||
| 704 | Returns this line translated the distance specified by \a dx and \a dy. | - | ||||||||||||
| 705 | */ | - | ||||||||||||
| 706 | - | |||||||||||||
| 707 | /*! | - | ||||||||||||
| 708 | \fn void QLineF::setP1(const QPointF &p1) | - | ||||||||||||
| 709 | \since 4.4 | - | ||||||||||||
| 710 | - | |||||||||||||
| 711 | Sets the starting point of this line to \a p1. | - | ||||||||||||
| 712 | - | |||||||||||||
| 713 | \sa setP2(), p1() | - | ||||||||||||
| 714 | */ | - | ||||||||||||
| 715 | - | |||||||||||||
| 716 | - | |||||||||||||
| 717 | /*! | - | ||||||||||||
| 718 | \fn void QLineF::setP2(const QPointF &p2) | - | ||||||||||||
| 719 | \since 4.4 | - | ||||||||||||
| 720 | - | |||||||||||||
| 721 | Sets the end point of this line to \a p2. | - | ||||||||||||
| 722 | - | |||||||||||||
| 723 | \sa setP1(), p2() | - | ||||||||||||
| 724 | */ | - | ||||||||||||
| 725 | - | |||||||||||||
| 726 | - | |||||||||||||
| 727 | /*! | - | ||||||||||||
| 728 | \fn void QLineF::setPoints(const QPointF &p1, const QPointF &p2) | - | ||||||||||||
| 729 | \since 4.4 | - | ||||||||||||
| 730 | - | |||||||||||||
| 731 | Sets the start point of this line to \a p1 and the end point of this line to \a p2. | - | ||||||||||||
| 732 | - | |||||||||||||
| 733 | \sa setP1(), setP2(), p1(), p2() | - | ||||||||||||
| 734 | */ | - | ||||||||||||
| 735 | - | |||||||||||||
| 736 | - | |||||||||||||
| 737 | /*! | - | ||||||||||||
| 738 | \fn void QLineF::setLine(qreal x1, qreal y1, qreal x2, qreal y2) | - | ||||||||||||
| 739 | \since 4.4 | - | ||||||||||||
| 740 | - | |||||||||||||
| 741 | Sets this line to the start in \a x1, \a y1 and end in \a x2, \a y2. | - | ||||||||||||
| 742 | - | |||||||||||||
| 743 | \sa setP1(), setP2(), p1(), p2() | - | ||||||||||||
| 744 | */ | - | ||||||||||||
| 745 | - | |||||||||||||
| 746 | /*! | - | ||||||||||||
| 747 | \fn qreal QLineF::angleTo(const QLineF &line) const | - | ||||||||||||
| 748 | - | |||||||||||||
| 749 | \since 4.4 | - | ||||||||||||
| 750 | - | |||||||||||||
| 751 | Returns the angle (in degrees) from this line to the given \a | - | ||||||||||||
| 752 | line, taking the direction of the lines into account. If the lines | - | ||||||||||||
| 753 | do not intersect within their range, it is the intersection point of | - | ||||||||||||
| 754 | the extended lines that serves as origin (see | - | ||||||||||||
| 755 | QLineF::UnboundedIntersection). | - | ||||||||||||
| 756 | - | |||||||||||||
| 757 | The returned value represents the number of degrees you need to add | - | ||||||||||||
| 758 | to this line to make it have the same angle as the given \a line, | - | ||||||||||||
| 759 | going counter-clockwise. | - | ||||||||||||
| 760 | - | |||||||||||||
| 761 | \sa intersect() | - | ||||||||||||
| 762 | */ | - | ||||||||||||
| 763 | qreal QLineF::angleTo(const QLineF &l) const | - | ||||||||||||
| 764 | { | - | ||||||||||||
| 765 | if (isNull() || l.isNull())
| 0-52779 | ||||||||||||
| 766 | return 0; never executed: return 0; | 0 | ||||||||||||
| 767 | - | |||||||||||||
| 768 | const qreal a1 = angle(); | - | ||||||||||||
| 769 | const qreal a2 = l.angle(); | - | ||||||||||||
| 770 | - | |||||||||||||
| 771 | const qreal delta = a2 - a1; | - | ||||||||||||
| 772 | const qreal delta_normalized = delta < 0 ? delta + 360 : delta;
| 19556-33223 | ||||||||||||
| 773 | - | |||||||||||||
| 774 | if (qFuzzyCompare(delta, qreal(360)))
| 0-52779 | ||||||||||||
| 775 | return 0; never executed: return 0; | 0 | ||||||||||||
| 776 | else | - | ||||||||||||
| 777 | return delta_normalized; executed 52779 times by 14 tests: return delta_normalized;Executed by:
| 52779 | ||||||||||||
| 778 | } | - | ||||||||||||
| 779 | - | |||||||||||||
| 780 | /*! | - | ||||||||||||
| 781 | \fn qreal QLineF::angle(const QLineF &line) const | - | ||||||||||||
| 782 | - | |||||||||||||
| 783 | \obsolete | - | ||||||||||||
| 784 | - | |||||||||||||
| 785 | Returns the angle (in degrees) between this line and the given \a | - | ||||||||||||
| 786 | line, taking the direction of the lines into account. If the lines | - | ||||||||||||
| 787 | do not intersect within their range, it is the intersection point of | - | ||||||||||||
| 788 | the extended lines that serves as origin (see | - | ||||||||||||
| 789 | QLineF::UnboundedIntersection). | - | ||||||||||||
| 790 | - | |||||||||||||
| 791 | \table | - | ||||||||||||
| 792 | \row | - | ||||||||||||
| 793 | \li \inlineimage qlinef-angle-identicaldirection.png | - | ||||||||||||
| 794 | \li \inlineimage qlinef-angle-oppositedirection.png | - | ||||||||||||
| 795 | \endtable | - | ||||||||||||
| 796 | - | |||||||||||||
| 797 | When the lines are parallel, this function returns 0 if they have | - | ||||||||||||
| 798 | the same direction; otherwise it returns 180. | - | ||||||||||||
| 799 | - | |||||||||||||
| 800 | \sa intersect() | - | ||||||||||||
| 801 | */ | - | ||||||||||||
| 802 | qreal QLineF::angle(const QLineF &l) const | - | ||||||||||||
| 803 | { | - | ||||||||||||
| 804 | if (isNull() || l.isNull())
| 0-183 | ||||||||||||
| 805 | return 0; never executed: return 0; | 0 | ||||||||||||
| 806 | qreal cos_line = (dx()*l.dx() + dy()*l.dy()) / (length()*l.length()); | - | ||||||||||||
| 807 | qreal rad = 0; | - | ||||||||||||
| 808 | // only accept cos_line in the range [-1,1], if it is outside, use 0 (we return 0 rather than PI for those cases) | - | ||||||||||||
| 809 | if (cos_line >= -1.0 && cos_line <= 1.0) rad = qAcos( cos_line ); executed 182 times by 1 test: rad = qAcos( cos_line );Executed by:
| 0-183 | ||||||||||||
| 810 | return rad * 360 / M_2PI; executed 183 times by 1 test: return rad * 360 / 6.28318530717958647692528676655900576;Executed by:
| 183 | ||||||||||||
| 811 | } | - | ||||||||||||
| 812 | - | |||||||||||||
| 813 | - | |||||||||||||
| 814 | #ifndef QT_NO_DEBUG_STREAM | - | ||||||||||||
| 815 | QDebug operator<<(QDebug dbg, const QLineF &p) | - | ||||||||||||
| 816 | { | - | ||||||||||||
| 817 | QDebugStateSaver saver(dbg); | - | ||||||||||||
| 818 | dbg.nospace() << "QLineF(" << p.p1() << ',' << p.p2() << ')'; | - | ||||||||||||
| 819 | return dbg; executed 2 times by 2 tests: return dbg;Executed by:
| 2 | ||||||||||||
| 820 | } | - | ||||||||||||
| 821 | #endif | - | ||||||||||||
| 822 | - | |||||||||||||
| 823 | #ifndef QT_NO_DATASTREAM | - | ||||||||||||
| 824 | /*! | - | ||||||||||||
| 825 | \relates QLineF | - | ||||||||||||
| 826 | - | |||||||||||||
| 827 | Writes the given \a line to the given \a stream and returns a | - | ||||||||||||
| 828 | reference to the stream. | - | ||||||||||||
| 829 | - | |||||||||||||
| 830 | \sa {Serializing Qt Data Types} | - | ||||||||||||
| 831 | */ | - | ||||||||||||
| 832 | - | |||||||||||||
| 833 | QDataStream &operator<<(QDataStream &stream, const QLineF &line) | - | ||||||||||||
| 834 | { | - | ||||||||||||
| 835 | stream << line.p1() << line.p2(); | - | ||||||||||||
| 836 | return stream; executed 3 times by 2 tests: return stream;Executed by:
| 3 | ||||||||||||
| 837 | } | - | ||||||||||||
| 838 | - | |||||||||||||
| 839 | /*! | - | ||||||||||||
| 840 | \relates QLineF | - | ||||||||||||
| 841 | - | |||||||||||||
| 842 | Reads a line from the given \a stream into the given \a line and | - | ||||||||||||
| 843 | returns a reference to the stream. | - | ||||||||||||
| 844 | - | |||||||||||||
| 845 | \sa {Serializing Qt Data Types} | - | ||||||||||||
| 846 | */ | - | ||||||||||||
| 847 | - | |||||||||||||
| 848 | QDataStream &operator>>(QDataStream &stream, QLineF &line) | - | ||||||||||||
| 849 | { | - | ||||||||||||
| 850 | QPointF start, end; | - | ||||||||||||
| 851 | stream >> start; | - | ||||||||||||
| 852 | stream >> end; | - | ||||||||||||
| 853 | line = QLineF(start, end); | - | ||||||||||||
| 854 | - | |||||||||||||
| 855 | return stream; executed 7 times by 2 tests: return stream;Executed by:
| 7 | ||||||||||||
| 856 | } | - | ||||||||||||
| 857 | - | |||||||||||||
| 858 | #endif // QT_NO_DATASTREAM | - | ||||||||||||
| 859 | - | |||||||||||||
| 860 | QT_END_NAMESPACE | - | ||||||||||||
| Source code | Switch to Preprocessed file |