LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
hole.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_HOLE_H
21 #define LIBREPCB_HOLE_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../fileio/cmd/cmdlistelementinsert.h"
27 #include "../fileio/cmd/cmdlistelementremove.h"
28 #include "../fileio/cmd/cmdlistelementsswap.h"
29 #include "../fileio/serializableobjectlist.h"
30 #include "../units/all_length_units.h"
31 
32 #include <QtCore>
33 
34 /*******************************************************************************
35  * Namespace / Forward Declarations
36  ******************************************************************************/
37 namespace librepcb {
38 
39 /*******************************************************************************
40  * Class Hole
41  ******************************************************************************/
42 
46 class Hole final : public SerializableObject {
47  Q_DECLARE_TR_FUNCTIONS(Hole)
48 
49 public:
50  // Signals
51  enum class Event {
55  };
58 
59  // Constructors / Destructor
60  Hole() = delete;
61  Hole(const Hole& other) noexcept;
62  Hole(const Uuid& uuid, const Hole& other) noexcept;
63  Hole(const Uuid& uuid, const Point& position,
64  const PositiveLength& diameter) noexcept;
65  explicit Hole(const SExpression& node);
66  ~Hole() noexcept;
67 
68  // Getters
69  const Uuid& getUuid() const noexcept { return mUuid; }
70  const Point& getPosition() const noexcept { return mPosition; }
71  const PositiveLength& getDiameter() const noexcept { return mDiameter; }
72 
73  // Setters
74  bool setPosition(const Point& position) noexcept;
75  bool setDiameter(const PositiveLength& diameter) noexcept;
76 
78  void serialize(SExpression& root) const override;
79 
80  // Operator Overloadings
81  bool operator==(const Hole& rhs) const noexcept;
82  bool operator!=(const Hole& rhs) const noexcept { return !(*this == rhs); }
83  Hole& operator=(const Hole& rhs) noexcept;
84 
85 private: // Data
89 };
90 
91 /*******************************************************************************
92  * Class HoleList
93  ******************************************************************************/
94 
96  static constexpr const char* tagname = "hole";
97 };
98 using HoleList =
100 using CmdHoleInsert =
102 using CmdHoleRemove =
104 using CmdHolesSwap =
106 
107 /*******************************************************************************
108  * End of File
109  ******************************************************************************/
110 
111 } // namespace librepcb
112 
113 #endif // LIBREPCB_HOLE_H
Uuid mUuid
Definition: hole.h:86
Slot< Hole, Event > OnEditedSlot
Definition: hole.h:57
The CmdListElementRemove class.
Definition: cmdlistelementremove.h:44
Hole & operator=(const Hole &rhs) noexcept
Definition: hole.cpp:107
PositiveLength mDiameter
Definition: hole.h:88
Signal< Hole, Event > onEdited
Definition: hole.h:56
The Hole class.
Definition: hole.h:46
static constexpr const char * tagname
Definition: hole.h:96
bool operator==(const Hole &rhs) const noexcept
Definition: hole.cpp:100
bool setPosition(const Point &position) noexcept
Definition: hole.cpp:66
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:43
The CmdListElementsSwap class.
Definition: cmdlistelementsswap.h:44
bool setDiameter(const PositiveLength &diameter) noexcept
Definition: hole.cpp:76
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: hole.cpp:90
Event
Definition: hole.h:51
Definition: hole.h:95
bool operator!=(const Hole &rhs) const noexcept
Definition: hole.h:82
const PositiveLength & getDiameter() const noexcept
Definition: hole.h:71
~Hole() noexcept
Definition: hole.cpp:59
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
const Point & getPosition() const noexcept
Definition: hole.h:70
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:780
The CmdListElementInsert class.
Definition: cmdlistelementinsert.h:44
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
The SExpression class.
Definition: sexpression.h:57
const Uuid & getUuid() const noexcept
Definition: hole.h:69
Point mPosition
Definition: hole.h:87