LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
vertex.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_VERTEX_H
21 #define LIBREPCB_VERTEX_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../fileio/serializableobject.h"
27 #include "../units/all_length_units.h"
28 
29 #include <QtCore>
30 
31 /*******************************************************************************
32  * Namespace / Forward Declarations
33  ******************************************************************************/
34 namespace librepcb {
35 
36 /*******************************************************************************
37  * Class Vertex
38  ******************************************************************************/
39 
43 class Vertex final : public SerializableObject {
44 public:
45  // Constructors / Destructor
46  Vertex() noexcept : mPos(), mAngle() {}
47  Vertex(const Vertex& other) noexcept
48  : mPos(other.mPos), mAngle(other.mAngle) {}
49  explicit Vertex(const Point& pos, const Angle& angle = Angle::deg0()) noexcept
50  : mPos(pos), mAngle(angle) {}
51  explicit Vertex(const SExpression& node);
52  ~Vertex() noexcept {}
53 
54  // Getters
55  const Point& getPos() const noexcept { return mPos; }
56  const Angle& getAngle() const noexcept { return mAngle; }
57 
58  // Setters
59  void setPos(const Point& pos) noexcept { mPos = pos; }
60  void setAngle(const Angle& angle) noexcept { mAngle = angle; }
61 
62  // General Methods
64  void serialize(SExpression& root) const override;
65 
66  // Operator Overloadings
67  bool operator==(const Vertex& rhs) const noexcept;
68  bool operator!=(const Vertex& rhs) const noexcept { return !(*this == rhs); }
69  Vertex& operator=(const Vertex& rhs) noexcept;
70 
71 private: // Data
74 };
76 
77 /*******************************************************************************
78  * Non-Member Functions
79  ******************************************************************************/
80 
81 QDebug operator<<(QDebug stream, const Vertex& vertex);
82 
83 inline uint qHash(const Vertex& key, uint seed = 0) noexcept {
84  return ::qHash(qMakePair(key.getPos(), key.getAngle()), seed);
85 }
86 
87 /*******************************************************************************
88  * End of File
89  ******************************************************************************/
90 
91 } // namespace librepcb
92 
93 #endif // LIBREPCB_VERTEX_H
The Vertex class.
Definition: vertex.h:43
QDataStream & operator<<(QDataStream &stream, const AttributeKey &obj)
Definition: attributekey.h:109
Vertex(const Vertex &other) noexcept
Definition: vertex.h:47
Angle mAngle
Definition: vertex.h:73
Vertex() noexcept
Definition: vertex.h:46
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:81
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:46
Vertex(const Point &pos, const Angle &angle=Angle::deg0()) noexcept
Definition: vertex.h:49
Vertex & operator=(const Vertex &rhs) noexcept
Definition: vertex.cpp:63
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:81
static Angle deg0() noexcept
0 degrees
Definition: angle.h:303
const Angle & getAngle() const noexcept
Definition: vertex.h:56
uint qHash(const Vertex &key, uint seed=0) noexcept
Definition: vertex.h:83
bool operator==(const Vertex &rhs) const noexcept
Definition: vertex.cpp:59
void setAngle(const Angle &angle) noexcept
Definition: vertex.h:60
~Vertex() noexcept
Definition: vertex.h:52
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: vertex.cpp:50
Point mPos
Definition: vertex.h:72
const Point & getPos() const noexcept
Definition: vertex.h:55
The SExpression class.
Definition: sexpression.h:60
bool operator!=(const Vertex &rhs) const noexcept
Definition: vertex.h:68
uint qHash(const AttributeKey &key, uint seed=0) noexcept
Definition: attributekey.h:119
void setPos(const Point &pos) noexcept
Definition: vertex.h:59