summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qline.h
Commit message (Collapse)AuthorAgeFilesLines
* QLineF: add qFuzzyCompare and qFuzzyIsNull overloadsIvan Solovev4 days1-0/+6
| | | | | | | | | [ChangeLog][QtCore][QLineF] Added qFuzzyCompare and qFuzzyIsNull overloads for QLineF Task-number: QTBUG-120308 Change-Id: I3d032f47851d886adce95ac72109fde169892688 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix QLineF::isNull behavior when handling zero pointsIvan Solovev4 days1-1/+1
| | | | | | | | | | | | | | | | | QLineF::isNull was using qFuzzyCompare on the x and y components of its points, which was not working correctly if some of the components was equal to zero. The correct approach is to use qFuzzyIsNull togeter with qFuzzyCompare. This approach is already implemented in qFuzzyCompare() overload for QPointF, so just use it. Add unit-tests for QLine(F)::isNull. [ChangeLog][QtCore][QLineF] Fixed a bug when QLineF::isNull() returned incorrect result if the start or end point contained a zero component. Change-Id: I3cfe6406b1299de32fe82b1fcbfb0416f0eaac15 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLine(F): use comparison helper macrosIvan Solovev4 days1-6/+28
| | | | | | | | | | | | | | | | | | | | | | | Also explicitly add QLineF vs QLine comparison. Previously such comparison was implicitly converting QLine to QLineF, and doing the fuzzy comparison. The new operators are directly calling operator==(QPointF, QPoint), which also does the fuzzy comparison, so the old behavior is preserved. Remove the old relational operators using QT_CORE_REMOVED_SINCE, but also wrap the new operators in !defined(QT_CORE_REMOVED_SINCE). That is required, because on Windows the instantiation of QMetaTypeInterface<QLine(F)> happens in removed_api.cpp (as both qline.h and qmetatype.h are already included there). If we just add removed member operators into removed_api.cpp, the metatype interface will not be able to create an equals() function, because of the ambiguity in equality operators (member vs friend). That's why we have to exclude the new friend operators from removed_api.cpp. Done-with: Fabian Kosmale <fabian.kosmale@qt.io> Task-number: QTBUG-120308 Change-Id: Ibbf5ec077f69c75da0d36a8be5596acd0fcd44d0 Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
* QLine/F: mark as primitive typeMarc Mutz2022-07-081-2/+2
| | | | | | | | | | QPoint/F are, then so are QLine/F, being a pair of points. Found by static_assert()ing !isComplex in QDataBuffer. Pick-to: 6.4 Change-Id: I358a38d79820c9262a86018253002bc991c5a6e4 Reviewed-by: Lars Knoll <lars.knoll@gmail.com>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QLine/QMargins: add toLineF/toMarginsF()Marc Mutz2022-03-191-1/+6
| | | | | | | | | | | | | For symmetry with QLineF::toLine(). [ChangeLog][QtCore][QLine] Added toLineF(). [ChangeLog][QtCore][QMargins] Added toMarginsF(). Task-number: QTBUG-73160 Change-Id: I69051cdd2fe4a3c0a000ab86e363a2918a7aea7c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Make explicit that we expect co-ordinates to be finiteEdward Welbourne2021-02-041-0/+2
| | | | | | | | | | | | | | | | | | | The various spatial-vector, line, point, region and margin types have all long taken for granted that their co-ordinates are finite and, in particular, not NaN. Make this expectation explicit in the documentation. Added assertions where (chiefly) noexcept and (where the assertion would be a simple qIsFinite() call) constexpr didn't preclude doing so. Also assert against zero divisors that would lead to non-finite results. Make minor clean-ups to docs in the process. QMarginsF had several methods whose declaration, definition and docs weren't consistent in their parameter names. Task-number: QTBUG-89010 Change-Id: I601a830959d13a73dcb17ce31a1202a1486c8f7f Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Change QLineF::setLength() to work whenever length() is non-zeroEdward Welbourne2021-01-051-6/+5
| | | | | | | | | | | | | | | | Previously it only worked when isNull() was false, which is true for very short lines, even though length() may be non-zero. [ChangeLog][QtCore][QLineF] QLineF::setLength() will now set the length if the line's length() is non-zero. Previously, it was documented to only set the length if isNull() was false; this is a fuzzy check, so isNull() could be true for a line with non-zero length(). Fixes: QTBUG-89569 Pick-to: 6.0 5.15 Change-Id: I803e622ad09c85815dde25df8dd3ba6dfcba0714 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Replace discouraged Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPEAndreas Buhr2020-11-301-2/+2
| | | | | | | | | | | | | | Q_MOVABLE_TYPE was conceived before C++ had move semantics. Now, with move semantics, its name is misleading. Q_RELOCATABLE_TYPE was introduced as a synonym to Q_MOVABLE_TYPE. Usage of Q_MOVABLE_TYPE is discouraged now. This patch replaces all usages of Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPE in QtBase. As the two are synonymous, this patch should have no impact on users. Pick-to: 6.0 Change-Id: Ie653984363198c1aeb1f70f8e0fa189aae38eb5c Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Add noexcept to QLine comparisonsAllan Sandfeld Jensen2020-10-301-3/+3
| | | | | Change-Id: Id75a8511c66d9fe23450043a9230f8dc8925be28 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Deal with {und,ov}erflow issues in QLine's length handlingEdward Welbourne2020-09-301-8/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use std::hypot() instead of sqrt() of a sum of squares. This ensures length() can't be zero when isNull() is false. Use length() in QLine::setLength() rather than duplicating that. Clarify and expand some documentation; isNull() never said what constituted validity, nor did unitVector() mention that is should not be used on a line for which isNull() is true. Make clear that lines of denormal length cannot be rescaled accurately. Given that we use fuzzy comparison to determine equality of end-points, isNull() can be false for a line with displacements less than sqrt(numeric_limits<qreal>::denorm_min()) between the coordinates of its end-points (as long as these are not much bigger); squaring these would give zero, hence a zero length, where using hypot() avoids the underflow and gives a non-zero length. Having a zero length for a line with isNull() false would lead to problems in setLength(), which uses an isNull() pre-test, protecting a call to unitVector(). (It was already possible for a null line to have non-zero length; this now arises in more cases.) Restored QLine::setLength() to the form it had before a recent change to avoid division by zero (which resulted from underflow in computing the length of a non-null line) but allow for the possibility that the unit vector it computes as transient may not have length exactly one. Add tests against {ov,und}erflow problems in QLine. Reworked the test added during the divide-by-zero fix to make it part of the existing test. Pick-to: 5.15 5.12 Change-Id: I7b71d66b872ccc08a64e941acd36b45b0ea15fab Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com>
* Replace Q_REQUIRED_RESULT with [[nodiscard]]Allan Sandfeld Jensen2020-09-251-9/+9
| | | | | | | It was already used many places directly making the code inconsistent. Change-Id: I3b14bc6c333640fb3ba33c71eba97e78c973e44b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix include style violation in qline.hFriedemann Kleint2020-09-021-1/+1
| | | | | | | | Amends c0d0949448c5a75d50ca189974d4d9f48133aea8. Pick-to: 5.12 5.15 Change-Id: Ie220a245ae2000af6e52c000c6836b9830c56de6 Reviewed-by: hjk <hjk@qt.io>
* QLine: swap IntersectType and IntersectionTypeEdward Welbourne2020-08-281-3/+4
| | | | | | | | | | | Make IntersectionType the enum and the obsolete IntersectType an alias, with at least a comment to say it's deprecated. Adjust the docs to match. Task-number: QTBUG-85700 Change-Id: I0de9166b0d936f5b9a15fdd4f90cf7b01198e8d7 Reviewed-by: Konstantin Shegunov <kshegunov@gmail.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QLineF: Don't try calculating a unit vector when length is nullRobert Loehning2020-08-251-3/+8
| | | | | | | | | | It's undefined and causes a division by zero. Fixes: oss-fuzz-24561 Pick-to: 5.12 5.15 Change-Id: Idebaba4b286e3ab0ecb74825d203244958ce6aec Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLineF::intersects(): Make the output parameter optionalSze Howe Koh2020-08-231-1/+1
| | | | | | Change-Id: I1ccd290a81b38db2e86958fa8ce188878484dcc4 Reviewed-by: Konstantin Shegunov <kshegunov@gmail.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Replace Qt CONSTEXPR defines with constexprAllan Sandfeld Jensen2020-08-141-73/+73
| | | | | | | | Both normal and relaxed constexpr are required by our new minimum of C++17. Change-Id: Ic028b88a2e7a6cb7d5925f3133b9d54859a81744 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QLine: purge deprecated APIEdward Welbourne2020-07-271-8/+1
| | | | | | | | Since 5.14: intersect(), angle(). Also removed definition of M_2PI from test, since its last use was in the tests being removed. Change-Id: Ie3a12247e3760e8bfdd3a659cd06245c86b198c2 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Improve deprecation message for QLine::angle(QLine)Eirik Aavitsland2020-06-261-1/+1
| | | | | | | | | | | | | | angleTo() always gives an answer measured ccw, so between 0 and 360 degrees. The deprecated angle() would give either cw or ccw, depending on which is smaller, so between 0 and 180 degrees. Help users porting by showing a simple way to achieve the angle() behavior in the deprecation message. Change-Id: I66f77d2b4e688562e443428209737aa3332a448f Pick-to: 5.15 Fixes: QTBUG-85087 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QLineF: add intersects() as a replacement for intersect()Christian Ehrlicher2019-04-251-2/+4
| | | | | | | | | | | | | QLineF::intersect() does not follow the naming rules for functions. Therefore add a replacement function intersects() instead and also rename the return type from IntersectType to IntersectionType [ChangeLog][QtCore][QLineF] added QLineF::intersects() as a replacement for QLineF::intersect() Change-Id: I744b960ea339cb817facb12f296f78cca3e7d938 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io> Reviewed-by: Konstantin Shegunov <kshegunov@gmail.com>
* QLineF: mark angle(const QLineF&) as deprecatedChristian Ehrlicher2019-03-051-0/+3
| | | | | | | | QLineF::angle(const QLineF&) was deprecated during Qt4 times but not decorated with QT_DEPRECATED_X. Add this so it can be removed with Qt6 Change-Id: I8950b646cc5fa8206e47bdd16647d17d615f6c6a Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Move Q_REQUIRED_RESULT to its correct positionThiago Macieira2017-04-201-9/+9
| | | | | | | | | | | That's before the return type or static, inline, constexpr or such keywords (if any). Perl Script: s/^(\s+)(.*) Q_REQUIRED_RESULT(;)?(\s*\/\/.*)?$/\1Q_REQUIRED_RESULT \2\3\4/ Change-Id: I7814054a102a407d876ffffd14b6a16182f159e2 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Add QLineF::center() returning the point in the center of the lineLorenz Haas2016-05-271-0/+14
| | | | | | | [ChangeLog][QtCore][QLine/QLineF] Added center(). Change-Id: I6dcfa9e839190c0a4caf36fb6ecd01b37d65d274 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Updated license headersJani Heikkinen2016-01-151-14/+20
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* QtCore: Use Q_REQUIRED_RESULT in many more placesDavid Faure2014-04-111-7/+7
| | | | | | | | | | | | gcc doesn't yet warn when a non-POD return datatype is unused, but clang does, at least. This detected two bugs in qtbase due to the bad QDate method naming, and will help application developers to avoid this trap too. Change-Id: I106c1a32d2c6fc8d02f57beb7b61940605c80d76 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Remove QT_{BEGIN,END}_HEADER macro usageSergio Ahumada2013-01-291-4/+0
| | | | | | | | | | | The macro was made empty in ba3dc5f3b56d1fab6fe37fe7ae08096d7dc68bcb and is no longer necessary or used. Discussed-on: http://lists.qt-project.org/pipermail/development/2013-January/009284.html Change-Id: Id2bb2e2cabde059305d4af5f12593344ba30f001 Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: hjk <hjk121@nokiamail.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* Bump some Qt 5 to-do's to Qt 6.Jason McDonald2012-04-101-1/+1
| | | | | | | | | | Source-incompatible changes are no longer desirable for Qt 5, so these items must wait until at least Qt 6. Task-number: QTBUG-23524 Change-Id: I0b9ae5f6f3a792e0169a4b0d3aefbdcb744acd2f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* QtCore: add constexpr to geometric classesMarc Mutz2012-02-221-72/+70
| | | | | | | | | | | | | | This turns code like QPoint(12, 12) into a compile-time expression, under a C++11 compiler, and allows to define arrays of these types that end up in read-only memory, just like PODs would. Some constructors and QLine::pointAt() needed to be adjusted to fit into the empty-body/only-return-expression requirement for constexpr constructors/functions. Change-Id: Id11ee2752c948930c3e40a91d1f6d7c97db7a373 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QPoint/QPointF: inline manhattanLength(); QLineF: inline isNull()Marc Mutz2012-02-201-0/+5
| | | | | | | | | There's no reason for them not to be, and it's a prerequisite for making these functions constexpr. Change-Id: I03c9965147b51014c7af60a4c2d7f25a3f6e21a7 Reviewed-by: David Faure <faure@kde.org> Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
* Remove "All rights reserved" line from license headers.Jason McDonald2012-01-301-1/+1
| | | | | | | | | | As in the past, to avoid rewriting various autotests that contain line-number information, an extra blank line has been inserted at the end of the license text to ensure that this commit does not change the total number of lines in the license header. Change-Id: I311e001373776812699d6efc045b5f742890c689 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Remove use of QT_MODULE from libraryGunnar Sletta2012-01-251-1/+0
| | | | | | | | | | These defines were there to aid in the commercial licensing scheme we used long ago, and are no longer needed. Keep a QT_MODULE(x) define so other modules continue compiling. Change-Id: I8fd76cd5270df8f14aee746b6cf32ebf7c23fec7 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Update contact information in license headers.Jason McDonald2012-01-231-1/+1
| | | | | | | Replace Nokia contact email address with Qt Project website. Change-Id: I431bbbf76d7c27d8b502f87947675c116994c415 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update copyright year in license headers.Jason McDonald2012-01-051-1/+1
| | | | | Change-Id: I02f2c620296fcd91d4967d58767ea33fc4e1e7dc Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update licenseheader text in source files for qtbase Qt moduleJyri Tahtela2011-05-241-17/+17
| | | | | | | Updated version of LGPL and FDL licenseheaders. Apply release phase licenseheaders for all source files. Reviewed-by: Trust Me
* Initial import from the monolithic Qt.Qt by Nokia2011-04-271-0/+424
This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12