LibrePCB Developers Documentation
Loading...
Searching...
No Matches
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_CORE_VERTEX_H
21#define LIBREPCB_CORE_VERTEX_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../types/angle.h"
27#include "../types/point.h"
28
29#include <QtCore>
30
31/*******************************************************************************
32 * Namespace / Forward Declarations
33 ******************************************************************************/
34namespace librepcb {
35
36/*******************************************************************************
37 * Class Vertex
38 ******************************************************************************/
39
43class Vertex final {
44public:
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
63
69 void serialize(SExpression& root) const;
70
71 // Operator Overloadings
72 Vertex& operator=(const Vertex& rhs) noexcept;
73 bool operator==(const Vertex& rhs) const noexcept;
74 bool operator!=(const Vertex& rhs) const noexcept { return !(*this == rhs); }
75
86 bool operator<(const Vertex& rhs) const noexcept;
87
88private: // Data
92};
93
94/*******************************************************************************
95 * Non-Member Functions
96 ******************************************************************************/
97
98QDebug operator<<(QDebug stream, const Vertex& vertex);
99
100inline std::size_t qHash(const Vertex& key, std::size_t seed = 0) noexcept {
101 return ::qHash(qMakePair(key.getPos(), key.getAngle()), seed);
102}
103
104/*******************************************************************************
105 * End of File
106 ******************************************************************************/
107
108} // namespace librepcb
109
110#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition angle.h:76
static Angle deg0() noexcept
0 degrees
Definition angle.h:349
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition point.h:78
The SExpression class.
Definition sexpression.h:69
The Vertex class.
Definition vertex.h:43
Angle mAngle
Definition vertex.h:90
const Point & getPos() const noexcept
Definition vertex.h:55
Vertex(const Point &pos, const Angle &angle=Angle::deg0()) noexcept
Definition vertex.h:49
bool operator!=(const Vertex &rhs) const noexcept
Definition vertex.h:74
Vertex() noexcept
Definition vertex.h:46
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition vertex.cpp:47
bool operator==(const Vertex &rhs) const noexcept
Definition vertex.cpp:62
void setAngle(const Angle &angle) noexcept
Definition vertex.h:60
~Vertex() noexcept
Definition vertex.h:52
void setPos(const Point &pos) noexcept
Definition vertex.h:59
Vertex(const Vertex &other) noexcept
Definition vertex.h:47
bool operator<(const Vertex &rhs) const noexcept
The "<" operator to compare two librepcb::Vertex objects.
Definition vertex.cpp:66
Vertex & operator=(const Vertex &rhs) noexcept
Definition vertex.cpp:56
Point mPos
Definition vertex.h:89
const Angle & getAngle() const noexcept
Definition vertex.h:56
Definition occmodel.cpp:76
std::size_t qHash(const AttributeKey &key, std::size_t seed=0) noexcept
Definition attributekey.h:118
QDataStream & operator<<(QDataStream &stream, const AttributeKey &obj)
Definition attributekey.h:108