LibrePCB Developers Documentation
netlabel.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_NETLABEL_H
21 #define LIBREPCB_CORE_NETLABEL_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../serialization/serializableobjectlist.h"
27 #include "../types/angle.h"
28 #include "../types/point.h"
29 
30 #include <QtCore>
31 
32 /*******************************************************************************
33  * Namespace / Forward Declarations
34  ******************************************************************************/
35 namespace librepcb {
36 
37 /*******************************************************************************
38  * Class NetLabel
39  ******************************************************************************/
40 
47 class NetLabel final {
48  Q_DECLARE_TR_FUNCTIONS(NetLabel)
49 
50 public:
51  // Signals
52  enum class Event {
57  };
60 
61  // Constructors / Destructor
62  NetLabel() = delete;
63  NetLabel(const NetLabel& other) noexcept;
64  NetLabel(const Uuid& uuid, const NetLabel& other) noexcept;
65  NetLabel(const Uuid& uuid, const Point& position, const Angle& rotation,
66  bool mirrored) noexcept;
67  explicit NetLabel(const SExpression& node);
68  ~NetLabel() noexcept;
69 
70  // Getters
71  const Uuid& getUuid() const noexcept { return mUuid; }
72  const Point& getPosition() const noexcept { return mPosition; }
73  const Angle& getRotation() const noexcept { return mRotation; }
74  bool getMirrored() const noexcept { return mMirrored; }
75 
76  // Setters
77  bool setUuid(const Uuid& uuid) noexcept;
78  bool setPosition(const Point& position) noexcept;
79  bool setRotation(const Angle& rotation) noexcept;
80  bool setMirrored(const bool mirrored) noexcept;
81 
82  // General Methods
83 
89  void serialize(SExpression& root) const;
90 
91  // Operator Overloadings
92  bool operator==(const NetLabel& rhs) const noexcept;
93  bool operator!=(const NetLabel& rhs) const noexcept {
94  return !(*this == rhs);
95  }
96  NetLabel& operator=(const NetLabel& rhs) noexcept;
97 
98 private: // Data
102  bool mMirrored;
103 };
104 
105 /*******************************************************************************
106  * Class NetLabelList
107  ******************************************************************************/
108 
110  static constexpr const char* tagname = "label";
111 };
112 using NetLabelList =
114 
115 /*******************************************************************************
116  * End of File
117  ******************************************************************************/
118 
119 } // namespace librepcb
120 
121 #endif
Point mPosition
Definition: netlabel.h:100
bool operator==(const NetLabel &rhs) const noexcept
Definition: netlabel.cpp:130
Signal< NetLabel, Event > onEdited
Definition: netlabel.h:58
const Angle & getRotation() const noexcept
Definition: netlabel.h:73
Slot< NetLabel, Event > OnEditedSlot
Definition: netlabel.h:59
bool setMirrored(const bool mirrored) noexcept
Definition: netlabel.cpp:103
Definition: occmodel.cpp:76
~NetLabel() noexcept
Definition: netlabel.cpp:66
const Point & getPosition() const noexcept
Definition: netlabel.h:72
Uuid mUuid
Definition: netlabel.h:99
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:76
Event
Definition: netlabel.h:52
Definition: netlabel.h:109
bool setUuid(const Uuid &uuid) noexcept
Definition: netlabel.cpp:73
The NetLabel class represents a net text label of a schematic.
Definition: netlabel.h:47
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
Angle mRotation
Definition: netlabel.h:101
NetLabel & operator=(const NetLabel &rhs) noexcept
Definition: netlabel.cpp:138
bool getMirrored() const noexcept
Definition: netlabel.h:74
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
bool setPosition(const Point &position) noexcept
Definition: netlabel.cpp:83
bool mMirrored
Definition: netlabel.h:102
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition: netlabel.cpp:117
const Uuid & getUuid() const noexcept
Definition: netlabel.h:71
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:56
The Slot class is used to receive signals from non-QObject derived classes.
Definition: signalslot.h:36
bool operator!=(const NetLabel &rhs) const noexcept
Definition: netlabel.h:93
The SExpression class.
Definition: sexpression.h:66
bool setRotation(const Angle &rotation) noexcept
Definition: netlabel.cpp:93