LibrePCB Developers Documentation
Loading...
Searching...
No Matches
length.h
Go to the documentation of this file.
1/*
2 * LibrePCB - Professional EDA for everyone!
3 * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4 * https://librepcb.org/
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef LIBREPCB_CORE_LENGTH_H
21#define LIBREPCB_CORE_LENGTH_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../exceptions.h"
27
28#include <type_safe/constrained_type.hpp>
29
30#include <QtCore>
31
32/*******************************************************************************
33 * Namespace / Forward Declarations
34 ******************************************************************************/
35namespace librepcb {
36
37/*******************************************************************************
38 * Typedefs
39 ******************************************************************************/
40
58#ifdef USE_32BIT_LENGTH_UNITS
59typedef qint32 LengthBase_t;
60#else
61typedef qint64 LengthBase_t;
62#endif
63
64/*******************************************************************************
65 * Class Length
66 ******************************************************************************/
67
82class Length {
83 Q_DECLARE_TR_FUNCTIONS(Length)
84
85public:
86 // Constructors / Destructor
87
93 constexpr Length() noexcept : Length(0) {}
94
100 constexpr Length(const Length& length) noexcept
101 : mNanometers(length.mNanometers) {}
102
108 constexpr Length(LengthBase_t nanometers) noexcept
109 : mNanometers(nanometers) {}
110
114 ~Length() = default;
115
116 // Setters
117
123 void setLengthNm(LengthBase_t nanometers) noexcept {
124 mNanometers = nanometers;
125 }
126
140 void setLengthMm(qreal millimeters) { setLengthFromFloat(millimeters * 1e6); }
141
155 void setLengthMm(const QString& millimeters) {
156 mNanometers = mmStringToNm(millimeters);
157 }
158
172 void setLengthInch(qreal inches) { setLengthFromFloat(inches * sNmPerInch); }
173
187 void setLengthMil(qreal mils) { setLengthFromFloat(mils * sNmPerMil); }
188
204 void setLengthPx(qreal pixels) { setLengthFromFloat(pixels * sNmPerPixel); }
205
206 // Conversions
207
213 LengthBase_t toNm() const noexcept { return mNanometers; }
214
221 QString toNmString() const noexcept { return QString::number(toNm()); }
222
230 qreal toMicrometers() const noexcept { return (qreal)mNanometers / 1e3; }
231
239 qreal toMm() const noexcept { return (qreal)mNanometers / 1e6; }
240
252 QString toMmString() const noexcept;
253
261 qreal toInch() const noexcept { return (qreal)mNanometers / sNmPerInch; }
262
270 qreal toMil() const noexcept { return (qreal)mNanometers / sNmPerMil; }
271
282 qreal toPx() const noexcept { return mNanometers * sPixelsPerNm; }
283
284 // General Methods
285
293 Length abs() const noexcept;
294
302 Length& makeAbs() noexcept;
303
314 Length mappedToGrid(const Length& gridInterval) const noexcept;
315
326 Length& mapToGrid(const Length& gridInterval) noexcept;
327
340 Length scaled(qreal factor) const noexcept;
341
354 Length& scale(qreal factor) noexcept;
355
356 // Static Functions
357
366 static bool isValidMm(qreal millimeters) noexcept {
367 return checkRange(millimeters * 1e6);
368 }
369
388 static Length fromMm(qreal millimeters,
389 const Length& gridInterval = Length(0));
390
416 static Length fromMm(const QString& millimeters,
417 const Length& gridInterval = Length(0));
418
437 static Length fromInch(qreal inches, const Length& gridInterval = Length(0));
438
457 static Length fromMil(qreal mils, const Length& gridInterval = Length(0));
458
480 static Length fromPx(qreal pixels, const Length& gridInterval = Length(0));
481
487 static Length min() noexcept;
488
494 static Length max() noexcept;
495
496 // Operators
497 Length& operator=(const Length& rhs) {
499 return *this;
500 }
501 Length& operator+=(const Length& rhs) {
503 return *this;
504 }
505 Length& operator-=(const Length& rhs) {
507 return *this;
508 }
509 Length& operator*=(const Length& rhs) {
511 return *this;
512 }
514 mNanometers *= rhs;
515 return *this;
516 }
517 Length& operator/=(const Length& rhs) {
519 return *this;
520 }
522 mNanometers /= rhs;
523 return *this;
524 }
525 Length operator+(const Length& rhs) const {
526 return Length(mNanometers + rhs.mNanometers);
527 }
528 Length operator-() const { return Length(-mNanometers); }
529 Length operator-(const Length& rhs) const {
530 return Length(mNanometers - rhs.mNanometers);
531 }
532 Length operator*(const Length& rhs) const {
533 return Length(mNanometers * rhs.mNanometers);
534 }
535 Length operator*(LengthBase_t rhs) const { return Length(mNanometers * rhs); }
536 Length operator/(const Length& rhs) const {
537 return Length(mNanometers / rhs.mNanometers);
538 }
539 Length operator/(LengthBase_t rhs) const { return Length(mNanometers / rhs); }
540 Length operator%(const Length& rhs) const {
541 return Length(mNanometers % rhs.mNanometers);
542 }
543 constexpr bool operator>(const Length& rhs) const {
544 return mNanometers > rhs.mNanometers;
545 }
546 constexpr bool operator>(LengthBase_t rhs) const { return mNanometers > rhs; }
547 constexpr bool operator<(const Length& rhs) const {
548 return mNanometers < rhs.mNanometers;
549 }
550 constexpr bool operator<(LengthBase_t rhs) const { return mNanometers < rhs; }
551 constexpr bool operator>=(const Length& rhs) const {
552 return mNanometers >= rhs.mNanometers;
553 }
554 constexpr bool operator>=(LengthBase_t rhs) const {
555 return mNanometers >= rhs;
556 }
557 constexpr bool operator<=(const Length& rhs) const {
558 return mNanometers <= rhs.mNanometers;
559 }
560 constexpr bool operator<=(LengthBase_t rhs) const {
561 return mNanometers <= rhs;
562 }
563 constexpr bool operator==(const Length& rhs) const {
564 return mNanometers == rhs.mNanometers;
565 }
566 constexpr bool operator==(LengthBase_t rhs) const {
567 return mNanometers == rhs;
568 }
569 constexpr bool operator!=(const Length& rhs) const {
570 return mNanometers != rhs.mNanometers;
571 }
572 constexpr bool operator!=(LengthBase_t rhs) const {
573 return mNanometers != rhs;
574 }
575
576private:
577 // Private Functions
578
592 void setLengthFromFloat(qreal nanometers);
593
594 // Private Static Functions
595
606 static bool checkRange(qreal nanometers, bool doThrow = false);
607
619 static LengthBase_t mapNmToGrid(LengthBase_t nanometers,
620 const Length& gridInterval) noexcept;
621
634 static LengthBase_t mmStringToNm(const QString& millimeters);
635
636 // Private Member Variables
638
639 // Static Length Converting Constants
640 static constexpr LengthBase_t sNmPerInch = 25400000;
641 static constexpr LengthBase_t sNmPerMil = 25400;
642 static constexpr LengthBase_t sPixelsPerInch =
643 72;
644 static constexpr qreal sNmPerPixel = (qreal)sNmPerInch / sPixelsPerInch;
645 static constexpr qreal sPixelsPerNm = (qreal)sPixelsPerInch / sNmPerInch;
646};
647
648/*******************************************************************************
649 * Non-Member Functions
650 ******************************************************************************/
651
652inline QDataStream& operator<<(QDataStream& stream, const Length& length) {
653 stream << length.toMm();
654 return stream;
655}
656
657inline QDebug operator<<(QDebug stream, const Length& length) {
658 stream << QString("Length(%1mm)").arg(length.toMm());
659 return stream;
660}
661
662inline std::size_t qHash(const Length& key, std::size_t seed = 0) noexcept {
663 return ::qHash(key.toNm(), seed);
664}
665
666/*******************************************************************************
667 * Class UnsignedLength
668 ******************************************************************************/
669
671 template <typename Value, typename Predicate>
672 static constexpr auto verify(Value&& val, const Predicate& p) ->
673 typename std::decay<Value>::type {
674 return p(val) ? std::forward<Value>(val)
675 : (throw RuntimeError(__FILE__, __LINE__,
676 Length::tr("Value must be >= 0!")),
677 std::forward<Value>(val));
678 }
679};
680
682 constexpr bool operator()(const Length& l) const noexcept { return l >= 0; }
683};
684
693 type_safe::constrained_type<Length, UnsignedLengthConstraint,
695
697 const UnsignedLength& rhs) noexcept {
698 return UnsignedLength(*lhs +
699 *rhs); // will not throw as long as there's no overflow
700}
701
703 const UnsignedLength& rhs) noexcept {
704 lhs = lhs + rhs; // will not throw as long as there's no overflow
705 return lhs;
706}
707
708inline Length operator*(const UnsignedLength& lhs, LengthBase_t rhs) noexcept {
709 return (*lhs) * rhs;
710}
711inline Length operator/(const UnsignedLength& lhs, LengthBase_t rhs) noexcept {
712 return (*lhs) / rhs;
713}
714inline Length operator+(const Length& lhs, const UnsignedLength& rhs) noexcept {
715 return lhs + *rhs;
716}
717inline Length operator+(const UnsignedLength& lhs, const Length& rhs) noexcept {
718 return *lhs + rhs;
719}
720inline Length operator-(const Length& lhs, const UnsignedLength& rhs) noexcept {
721 return lhs - *rhs;
722}
723inline Length operator-(const UnsignedLength& lhs, const Length& rhs) noexcept {
724 return *lhs - rhs;
725}
726inline Length operator-(const UnsignedLength& lhs) noexcept {
727 return -(*lhs);
728}
729inline bool operator>(const UnsignedLength& lhs, const Length& rhs) noexcept {
730 return (*lhs) > rhs;
731}
732inline bool operator>(const UnsignedLength& lhs, LengthBase_t rhs) noexcept {
733 return (*lhs) > rhs;
734}
735inline bool operator>=(const UnsignedLength& lhs, const Length& rhs) noexcept {
736 return (*lhs) >= rhs;
737}
738inline bool operator>=(const UnsignedLength& lhs, LengthBase_t rhs) noexcept {
739 return (*lhs) >= rhs;
740}
741inline bool operator<(const UnsignedLength& lhs, const Length& rhs) noexcept {
742 return (*lhs) < rhs;
743}
744inline bool operator<(const UnsignedLength& lhs, LengthBase_t rhs) noexcept {
745 return (*lhs) < rhs;
746}
747inline bool operator<=(const UnsignedLength& lhs, const Length& rhs) noexcept {
748 return (*lhs) <= rhs;
749}
750inline bool operator<=(const UnsignedLength& lhs, LengthBase_t rhs) noexcept {
751 return (*lhs) <= rhs;
752}
753inline bool operator==(const UnsignedLength& lhs, const Length& rhs) noexcept {
754 return (*lhs) == rhs;
755}
756inline bool operator==(const UnsignedLength& lhs, LengthBase_t rhs) noexcept {
757 return (*lhs) == rhs;
758}
759inline bool operator!=(const UnsignedLength& lhs, const Length& rhs) noexcept {
760 return (*lhs) != rhs;
761}
762inline bool operator!=(const UnsignedLength& lhs, LengthBase_t rhs) noexcept {
763 return (*lhs) != rhs;
764}
765
766inline QDataStream& operator<<(QDataStream& stream,
767 const UnsignedLength& length) {
768 stream << length->toMm();
769 return stream;
770}
771
772inline QDebug operator<<(QDebug stream, const UnsignedLength& length) {
773 stream << QString("UnsignedLength(%1mm)").arg(length->toMm());
774 return stream;
775}
776
777inline std::size_t qHash(const UnsignedLength& key,
778 std::size_t seed = 0) noexcept {
779 return ::qHash(key->toNm(), seed);
780}
781
782/*******************************************************************************
783 * Class PositiveLength
784 ******************************************************************************/
785
787 template <typename Value, typename Predicate>
788 static constexpr auto verify(Value&& val, const Predicate& p) ->
789 typename std::decay<Value>::type {
790 return p(val) ? std::forward<Value>(val)
791 : (throw RuntimeError(__FILE__, __LINE__,
792 Length::tr("Value must be > 0!")),
793 std::forward<Value>(val));
794 }
795};
796
798 constexpr bool operator()(const Length& l) const noexcept { return l > 0; }
799};
800
809 type_safe::constrained_type<Length, PositiveLengthConstraint,
811
813 return UnsignedLength(*l);
814}
815
817 const PositiveLength& rhs) noexcept {
818 return PositiveLength(*lhs +
819 *rhs); // will not throw as long as there's no overflow
820}
821
823 const UnsignedLength& rhs) noexcept {
824 return PositiveLength(*lhs +
825 *rhs); // will not throw as long as there's no overflow
826}
827
829 const PositiveLength& rhs) noexcept {
830 return PositiveLength(*lhs +
831 *rhs); // will not throw as long as there's no overflow
832}
833
835 const PositiveLength& rhs) noexcept {
836 lhs = lhs + rhs; // will not throw as long as there's no overflow
837 return lhs;
838}
839
841 const UnsignedLength& rhs) noexcept {
842 lhs = lhs + rhs; // will not throw as long as there's no overflow
843 return lhs;
844}
845
847 const PositiveLength& rhs) noexcept {
848 lhs = positiveToUnsigned(
849 lhs + rhs); // will not throw as long as there's no overflow
850 return lhs;
851}
852
853inline Length operator*(const PositiveLength& lhs, LengthBase_t rhs) noexcept {
854 return (*lhs) * rhs;
855}
856inline Length operator/(const PositiveLength& lhs, LengthBase_t rhs) noexcept {
857 return (*lhs) / rhs;
858}
859inline Length operator+(const Length& lhs, const PositiveLength& rhs) noexcept {
860 return lhs + *rhs;
861}
862inline Length operator+(const PositiveLength& lhs, const Length& rhs) noexcept {
863 return *lhs + rhs;
864}
865inline Length operator-(const Length& lhs, const PositiveLength& rhs) noexcept {
866 return lhs - *rhs;
867}
868inline Length operator-(const PositiveLength& lhs, const Length& rhs) noexcept {
869 return *lhs - rhs;
870}
872 const PositiveLength& rhs) noexcept {
873 return *lhs - *rhs;
874}
876 const UnsignedLength& rhs) noexcept {
877 return *lhs - *rhs;
878}
879inline Length operator-(const PositiveLength& lhs) noexcept {
880 return -(*lhs);
881}
882inline bool operator>(const UnsignedLength& lhs,
883 const PositiveLength& rhs) noexcept {
884 return (*lhs) > (*rhs);
885}
886inline bool operator>(const PositiveLength& lhs,
887 const UnsignedLength& rhs) noexcept {
888 return (*lhs) > (*rhs);
889}
890inline bool operator>(const PositiveLength& lhs, const Length& rhs) noexcept {
891 return (*lhs) > rhs;
892}
893inline bool operator>(const PositiveLength& lhs, LengthBase_t rhs) noexcept {
894 return (*lhs) > rhs;
895}
896inline bool operator>=(const UnsignedLength& lhs,
897 const PositiveLength& rhs) noexcept {
898 return (*lhs) >= (*rhs);
899}
900inline bool operator>=(const PositiveLength& lhs,
901 const UnsignedLength& rhs) noexcept {
902 return (*lhs) >= (*rhs);
903}
904inline bool operator>=(const PositiveLength& lhs, const Length& rhs) noexcept {
905 return (*lhs) >= rhs;
906}
907inline bool operator>=(const PositiveLength& lhs, LengthBase_t rhs) noexcept {
908 return (*lhs) >= rhs;
909}
910inline bool operator<(const UnsignedLength& lhs,
911 const PositiveLength& rhs) noexcept {
912 return (*lhs) < (*rhs);
913}
914inline bool operator<(const PositiveLength& lhs,
915 const UnsignedLength& rhs) noexcept {
916 return (*lhs) < (*rhs);
917}
918inline bool operator<(const PositiveLength& lhs, const Length& rhs) noexcept {
919 return (*lhs) < rhs;
920}
921inline bool operator<(const PositiveLength& lhs, LengthBase_t rhs) noexcept {
922 return (*lhs) < rhs;
923}
924inline bool operator<=(const UnsignedLength& lhs,
925 const PositiveLength& rhs) noexcept {
926 return (*lhs) <= (*rhs);
927}
928inline bool operator<=(const PositiveLength& lhs,
929 const UnsignedLength& rhs) noexcept {
930 return (*lhs) <= (*rhs);
931}
932inline bool operator<=(const PositiveLength& lhs, const Length& rhs) noexcept {
933 return (*lhs) <= rhs;
934}
935inline bool operator<=(const PositiveLength& lhs, LengthBase_t rhs) noexcept {
936 return (*lhs) <= rhs;
937}
938inline bool operator==(const UnsignedLength& lhs,
939 const PositiveLength& rhs) noexcept {
940 return (*lhs) == (*rhs);
941}
942inline bool operator==(const PositiveLength& lhs,
943 const UnsignedLength& rhs) noexcept {
944 return (*lhs) == (*rhs);
945}
946inline bool operator==(const PositiveLength& lhs, const Length& rhs) noexcept {
947 return (*lhs) == rhs;
948}
949inline bool operator==(const PositiveLength& lhs, LengthBase_t rhs) noexcept {
950 return (*lhs) == rhs;
951}
952inline bool operator!=(const UnsignedLength& lhs,
953 const PositiveLength& rhs) noexcept {
954 return (*lhs) != (*rhs);
955}
956inline bool operator!=(const PositiveLength& lhs,
957 const UnsignedLength& rhs) noexcept {
958 return (*lhs) != (*rhs);
959}
960inline bool operator!=(const PositiveLength& lhs, const Length& rhs) noexcept {
961 return (*lhs) != rhs;
962}
963inline bool operator!=(const PositiveLength& lhs, LengthBase_t rhs) noexcept {
964 return (*lhs) != rhs;
965}
966
967inline QDataStream& operator<<(QDataStream& stream,
968 const PositiveLength& length) {
969 stream << length->toMm();
970 return stream;
971}
972
973inline QDebug operator<<(QDebug stream, const PositiveLength& length) {
974 stream << QString("PositiveLength(%1mm)").arg(length->toMm());
975 return stream;
976}
977
978inline std::size_t qHash(const PositiveLength& key,
979 std::size_t seed = 0) noexcept {
980 return ::qHash(key->toNm(), seed);
981}
982
983/*******************************************************************************
984 * Class Point3D
985 ******************************************************************************/
986
987using Point3D = std::tuple<Length, Length, Length>;
988
989QDebug operator<<(QDebug stream, const Point3D& obj);
990
991/*******************************************************************************
992 * End of File
993 ******************************************************************************/
994
995} // namespace librepcb
996
997Q_DECLARE_METATYPE(librepcb::Length)
998
999#endif
The Length class is used to represent a length (for example 12.75 millimeters)
Definition length.h:82
constexpr bool operator!=(const Length &rhs) const
Definition length.h:569
void setLengthMil(qreal mils)
Set the length in mils (1/1000 inch)
Definition length.h:187
Length & operator/=(const Length &rhs)
Definition length.h:517
Length & mapToGrid(const Length &gridInterval) noexcept
Map this Length object to a specific grid interval.
Definition length.cpp:75
Length & makeAbs() noexcept
Make the length absolute (mNanometers >= 0)
Definition length.cpp:61
void setLengthMm(const QString &millimeters)
Set the length in millimeters, represented in a QString.
Definition length.h:155
Length & operator*=(LengthBase_t rhs)
Definition length.h:513
constexpr bool operator==(LengthBase_t rhs) const
Definition length.h:566
Length & operator-=(const Length &rhs)
Definition length.h:505
Length operator-() const
Definition length.h:528
static constexpr LengthBase_t sNmPerMil
1 inch = 25.4mm
Definition length.h:641
Length operator/(const Length &rhs) const
Definition length.h:536
constexpr bool operator!=(LengthBase_t rhs) const
Definition length.h:572
constexpr bool operator<=(const Length &rhs) const
Definition length.h:557
Length abs() const noexcept
Get a Length object with absolute value (mNanometers >= 0)
Definition length.cpp:55
constexpr bool operator<(LengthBase_t rhs) const
Definition length.h:550
Length mappedToGrid(const Length &gridInterval) const noexcept
Get a Length object which is mapped to a specific grid interval.
Definition length.cpp:70
constexpr bool operator==(const Length &rhs) const
Definition length.h:563
static LengthBase_t mmStringToNm(const QString &millimeters)
Convert a length from a QString (in millimeters) to an integer (in nanometers)
Definition length.cpp:200
constexpr bool operator>=(const Length &rhs) const
Definition length.h:551
void setLengthPx(qreal pixels)
Set the length in pixels (from QGraphics* objects)
Definition length.h:204
QString toMmString() const noexcept
Get the length in millimeters as a QString.
Definition length.cpp:47
Length & operator+=(const Length &rhs)
Definition length.h:501
Length operator*(LengthBase_t rhs) const
Definition length.h:535
qreal toMm() const noexcept
Get the length in millimeters.
Definition length.h:239
static constexpr LengthBase_t sNmPerInch
1 inch = 25.4mm
Definition length.h:640
constexpr Length() noexcept
Default Constructor.
Definition length.h:93
qreal toInch() const noexcept
Get the length in inches.
Definition length.h:261
Length & scale(qreal factor) noexcept
Scale this Length object with a specific factor.
Definition length.cpp:85
void setLengthFromFloat(qreal nanometers)
Set the length from a floating point number in nanometers.
Definition length.cpp:136
static Length fromMm(qreal millimeters, const Length &gridInterval=Length(0))
Get a Length object with a specific length and map it to a specific grid.
Definition length.cpp:94
constexpr bool operator>=(LengthBase_t rhs) const
Definition length.h:554
Length & operator/=(LengthBase_t rhs)
Definition length.h:521
static Length fromInch(qreal inches, const Length &gridInterval=Length(0))
Get a Length object with a specific length and map it to a specific grid.
Definition length.cpp:106
Length & operator*=(const Length &rhs)
Definition length.h:509
qreal toMicrometers() const noexcept
Get the length in micrometers.
Definition length.h:230
Length operator/(LengthBase_t rhs) const
Definition length.h:539
static bool isValidMm(qreal millimeters) noexcept
Check if a float value in millimeters is in the allowed range.
Definition length.h:366
void setLengthNm(LengthBase_t nanometers) noexcept
Set the length in nanometers.
Definition length.h:123
static LengthBase_t mapNmToGrid(LengthBase_t nanometers, const Length &gridInterval) noexcept
Map a length in nanometers to a grid interval in nanometers.
Definition length.cpp:160
static constexpr LengthBase_t sPixelsPerInch
72 dpi for the QGraphics* objects
Definition length.h:642
Length operator-(const Length &rhs) const
Definition length.h:529
constexpr bool operator>(const Length &rhs) const
Definition length.h:543
static Length min() noexcept
Get the smallest possible length value.
Definition length.cpp:124
static bool checkRange(qreal nanometers, bool doThrow=false)
Check if a float value in nanometers is in the allowed range.
Definition length.cpp:147
void setLengthInch(qreal inches)
Set the length in inches.
Definition length.h:172
Length operator*(const Length &rhs) const
Definition length.h:532
constexpr bool operator<(const Length &rhs) const
Definition length.h:547
constexpr bool operator>(LengthBase_t rhs) const
Definition length.h:546
qreal toPx() const noexcept
Get the length in pixels (for QGraphics* objects)
Definition length.h:282
LengthBase_t mNanometers
the length in nanometers
Definition length.h:637
QString toNmString() const noexcept
Get the length in nanometers as a QString.
Definition length.h:221
static constexpr qreal sNmPerPixel
Definition length.h:644
constexpr Length(LengthBase_t nanometers) noexcept
Constructor with length in nanometers.
Definition length.h:108
static Length fromMil(qreal mils, const Length &gridInterval=Length(0))
Get a Length object with a specific length and map it to a specific grid.
Definition length.cpp:112
void setLengthMm(qreal millimeters)
Set the length in millimeters.
Definition length.h:140
Length scaled(qreal factor) const noexcept
Get a Length object which is scaled with a specific factor.
Definition length.cpp:80
constexpr Length(const Length &length) noexcept
Copy Constructor.
Definition length.h:100
qreal toMil() const noexcept
Get the length in mils (1/1000 inches)
Definition length.h:270
LengthBase_t toNm() const noexcept
Get the length in nanometers.
Definition length.h:213
static Length fromPx(qreal pixels, const Length &gridInterval=Length(0))
Get a Length object with a specific length and map it to a specific grid.
Definition length.cpp:118
~Length()=default
Destructor.
static Length max() noexcept
Get the highest possible length value.
Definition length.cpp:128
static constexpr qreal sPixelsPerNm
Definition length.h:645
Length operator%(const Length &rhs) const
Definition length.h:540
Length operator+(const Length &rhs) const
Definition length.h:525
constexpr bool operator<=(LengthBase_t rhs) const
Definition length.h:560
The RuntimeError class.
Definition exceptions.h:218
Definition occmodel.cpp:76
std::size_t qHash(const AttributeKey &key, std::size_t seed=0) noexcept
Definition attributekey.h:118
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition length.h:810
bool operator==(const AttributeKey &lhs, const QString &rhs) noexcept
Definition attributekey.h:85
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition length.h:694
bool operator>=(const UnsignedLength &lhs, const Length &rhs) noexcept
Definition length.h:735
std::tuple< Length, Length, Length > Point3D
Definition length.h:987
qint64 LengthBase_t
This type is the ONLY base type to store all lengths (always in nanometers)!
Definition length.h:61
bool operator!=(const AttributeKey &lhs, const QString &rhs) noexcept
Definition attributekey.h:91
static bool operator<(const BoardGerberExport::LayerPair &lhs, const BoardGerberExport::LayerPair &rhs) noexcept
Definition boardgerberexport.cpp:62
Length operator-(const Length &lhs, const UnsignedLength &rhs) noexcept
Definition length.h:720
Length operator*(const UnsignedLength &lhs, LengthBase_t rhs) noexcept
Definition length.h:708
UnsignedLength positiveToUnsigned(const PositiveLength &l) noexcept
Definition length.h:812
UnsignedLength operator+(const UnsignedLength &lhs, const UnsignedLength &rhs) noexcept
Definition length.h:696
Length operator/(const UnsignedLength &lhs, LengthBase_t rhs) noexcept
Definition length.h:711
UnsignedLength & operator+=(UnsignedLength &lhs, const UnsignedLength &rhs) noexcept
Definition length.h:702
QDataStream & operator<<(QDataStream &stream, const AttributeKey &obj)
Definition attributekey.h:108
bool operator<=(const UnsignedLength &lhs, const Length &rhs) noexcept
Definition length.h:747
bool operator>(const UnsignedLength &lhs, const Length &rhs) noexcept
Definition length.h:729
Definition length.h:797
constexpr bool operator()(const Length &l) const noexcept
Definition length.h:798
Definition length.h:786
static constexpr auto verify(Value &&val, const Predicate &p) -> typename std::decay< Value >::type
Definition length.h:788
Definition length.h:681
constexpr bool operator()(const Length &l) const noexcept
Definition length.h:682
Definition length.h:670
static constexpr auto verify(Value &&val, const Predicate &p) -> typename std::decay< Value >::type
Definition length.h:672