LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
symbolpin.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_LIBRARY_SYMBOLPIN_H
21 #define LIBREPCB_LIBRARY_SYMBOLPIN_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
32 
33 #include <QtCore>
34 
35 /*******************************************************************************
36  * Namespace / Forward Declarations
37  ******************************************************************************/
38 namespace librepcb {
39 namespace library {
40 
41 class SymbolPinGraphicsItem;
42 
43 /*******************************************************************************
44  * Class SymbolPin
45  ******************************************************************************/
46 
54 class SymbolPin final : public SerializableObject {
55  Q_DECLARE_TR_FUNCTIONS(SymbolPin)
56 
57 public:
58  // Signals
59  enum class Event {
65  };
68 
69  // Constructors / Destructor
70  SymbolPin() = delete;
71  SymbolPin(const SymbolPin& other) noexcept;
72  SymbolPin(const Uuid& uuid, const CircuitIdentifier& name,
73  const Point& position, const UnsignedLength& length,
74  const Angle& rotation) noexcept;
75  explicit SymbolPin(const SExpression& node);
76  ~SymbolPin() noexcept;
77 
78  // Getters
79  const Uuid& getUuid() const noexcept { return mUuid; }
80  const CircuitIdentifier& getName() const noexcept { return mName; }
81  const Point& getPosition() const noexcept { return mPosition; }
82  const UnsignedLength& getLength() const noexcept { return mLength; }
83  const Angle& getRotation() const noexcept { return mRotation; }
84 
85  // Setters
86  bool setPosition(const Point& pos) noexcept;
87  bool setLength(const UnsignedLength& length) noexcept;
88  bool setRotation(const Angle& rotation) noexcept;
89  bool setName(const CircuitIdentifier& name) noexcept;
90 
91  // General Methods
92  void registerGraphicsItem(SymbolPinGraphicsItem& item) noexcept;
93  void unregisterGraphicsItem(SymbolPinGraphicsItem& item) noexcept;
94 
96  void serialize(SExpression& root) const override;
97 
98  // Operator Overloadings
99  bool operator==(const SymbolPin& rhs) const noexcept;
100  bool operator!=(const SymbolPin& rhs) const noexcept {
101  return !(*this == rhs);
102  }
103  SymbolPin& operator=(const SymbolPin& rhs) noexcept;
104 
105 private: // Data
111 
113 };
114 
115 /*******************************************************************************
116  * Class SymbolPinList
117  ******************************************************************************/
118 
120  static constexpr const char* tagname = "pin";
121 };
122 using SymbolPinList =
125 using CmdSymbolPinInsert =
128 using CmdSymbolPinRemove =
131 using CmdSymbolPinsSwap =
133 
134 /*******************************************************************************
135  * End of File
136  ******************************************************************************/
137 
138 } // namespace library
139 } // namespace librepcb
140 
141 #endif // LIBREPCB_LIBRARY_SYMBOLPIN_H
const Uuid & getUuid() const noexcept
Definition: symbolpin.h:79
bool operator==(const SymbolPin &rhs) const noexcept
Definition: symbolpin.cpp:149
The CmdListElementRemove class.
Definition: cmdlistelementremove.h:44
CircuitIdentifier mName
Definition: symbolpin.h:107
Signal< SymbolPin, Event > onEdited
Definition: symbolpin.h:66
Slot< SymbolPin, Event > OnEditedSlot
Definition: symbolpin.h:67
SymbolPin & operator=(const SymbolPin &rhs) noexcept
Definition: symbolpin.cpp:158
bool setRotation(const Angle &rotation) noexcept
Definition: symbolpin.cpp:112
SymbolPinGraphicsItem * mRegisteredGraphicsItem
Definition: symbolpin.h:112
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
Point mPosition
Definition: symbolpin.h:108
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 operator!=(const SymbolPin &rhs) const noexcept
Definition: symbolpin.h:100
static constexpr const char * tagname
Definition: symbolpin.h:120
const Point & getPosition() const noexcept
Definition: symbolpin.h:81
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
The SymbolPinGraphicsItem class.
Definition: symbolpingraphicsitem.h:53
Uuid mUuid
Definition: symbolpin.h:106
const CircuitIdentifier & getName() const noexcept
Definition: symbolpin.h:80
Angle mRotation
Definition: symbolpin.h:110
Event
Definition: symbolpin.h:59
bool setPosition(const Point &pos) noexcept
Definition: symbolpin.cpp:90
void registerGraphicsItem(SymbolPinGraphicsItem &item) noexcept
Definition: symbolpin.cpp:127
type_safe::constrained_type< QString, CircuitIdentifierConstraint, CircuitIdentifierVerifier > CircuitIdentifier
Definition: circuitidentifier.h:89
const Angle & getRotation() const noexcept
Definition: symbolpin.h:83
bool setLength(const UnsignedLength &length) noexcept
Definition: symbolpin.cpp:101
~SymbolPin() noexcept
Definition: symbolpin.cpp:71
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
The CmdListElementInsert class.
Definition: cmdlistelementinsert.h:44
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: symbolpin.cpp:137
void unregisterGraphicsItem(SymbolPinGraphicsItem &item) noexcept
Definition: symbolpin.cpp:132
const UnsignedLength & getLength() const noexcept
Definition: symbolpin.h:82
The SymbolPin class represents one pin of a symbol.
Definition: symbolpin.h:54
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
UnsignedLength mLength
Definition: symbolpin.h:109
The Slot class is used to receive signals from non-QObject derived classes.
Definition: signalslot.h:36
The SExpression class.
Definition: sexpression.h:57
bool setName(const CircuitIdentifier &name) noexcept
Definition: symbolpin.cpp:79
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:659