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  // Constructors / Destructor
59  SymbolPin() = delete;
60  SymbolPin(const SymbolPin& other) noexcept;
61  SymbolPin(const Uuid& uuid, const CircuitIdentifier& name,
62  const Point& position, const UnsignedLength& length,
63  const Angle& rotation) noexcept;
64  explicit SymbolPin(const SExpression& node);
65  ~SymbolPin() noexcept;
66 
67  // Getters
68  const Uuid& getUuid() const noexcept { return mUuid; }
69  const CircuitIdentifier& getName() const noexcept { return mName; }
70  const Point& getPosition() const noexcept { return mPosition; }
71  const UnsignedLength& getLength() const noexcept { return mLength; }
72  const Angle& getRotation() const noexcept { return mRotation; }
73 
74  // Setters
75  void setPosition(const Point& pos) noexcept;
76  void setLength(const UnsignedLength& length) noexcept;
77  void setRotation(const Angle& rotation) noexcept;
78  void setName(const CircuitIdentifier& name) noexcept;
79 
80  // General Methods
81  void registerGraphicsItem(SymbolPinGraphicsItem& item) noexcept;
82  void unregisterGraphicsItem(SymbolPinGraphicsItem& item) noexcept;
83 
85  void serialize(SExpression& root) const override;
86 
87  // Operator Overloadings
88  bool operator==(const SymbolPin& rhs) const noexcept;
89  bool operator!=(const SymbolPin& rhs) const noexcept {
90  return !(*this == rhs);
91  }
92  SymbolPin& operator=(const SymbolPin& rhs) noexcept;
93 
94 private: // Data
100 
102 };
103 
104 /*******************************************************************************
105  * Class SymbolPinList
106  ******************************************************************************/
107 
109  static constexpr const char* tagname = "pin";
110 };
111 using SymbolPinList =
113 using CmdSymbolPinInsert =
115 using CmdSymbolPinRemove =
117 using CmdSymbolPinsSwap =
119 
120 /*******************************************************************************
121  * End of File
122  ******************************************************************************/
123 
124 } // namespace library
125 } // namespace librepcb
126 
127 #endif // LIBREPCB_LIBRARY_SYMBOLPIN_H
const Uuid & getUuid() const noexcept
Definition: symbolpin.h:68
void setPosition(const Point &pos) noexcept
Definition: symbolpin.cpp:81
bool operator==(const SymbolPin &rhs) const noexcept
Definition: symbolpin.cpp:122
The CmdListElementRemove class.
Definition: cmdlistelementremove.h:44
CircuitIdentifier mName
Definition: symbolpin.h:96
void setName(const CircuitIdentifier &name) noexcept
Definition: symbolpin.cpp:76
SymbolPin & operator=(const SymbolPin &rhs) noexcept
Definition: symbolpin.cpp:131
SymbolPinGraphicsItem * mRegisteredGraphicsItem
Definition: symbolpin.h:101
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:81
Point mPosition
Definition: symbolpin.h:97
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:46
The CmdListElementsSwap class.
Definition: cmdlistelementsswap.h:44
bool operator!=(const SymbolPin &rhs) const noexcept
Definition: symbolpin.h:89
static constexpr const char * tagname
Definition: symbolpin.h:109
const Point & getPosition() const noexcept
Definition: symbolpin.h:70
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:81
void setLength(const UnsignedLength &length) noexcept
Definition: symbolpin.cpp:86
The SymbolPinGraphicsItem class.
Definition: symbolpingraphicsitem.h:56
Uuid mUuid
Definition: symbolpin.h:95
const CircuitIdentifier & getName() const noexcept
Definition: symbolpin.h:69
Angle mRotation
Definition: symbolpin.h:99
void registerGraphicsItem(SymbolPinGraphicsItem &item) noexcept
Definition: symbolpin.cpp:100
type_safe::constrained_type< QString, CircuitIdentifierConstraint, CircuitIdentifierVerifier > CircuitIdentifier
Definition: circuitidentifier.h:89
const Angle & getRotation() const noexcept
Definition: symbolpin.h:72
~SymbolPin() noexcept
Definition: symbolpin.cpp:68
void setRotation(const Angle &rotation) noexcept
Definition: symbolpin.cpp:91
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:110
void unregisterGraphicsItem(SymbolPinGraphicsItem &item) noexcept
Definition: symbolpin.cpp:105
const UnsignedLength & getLength() const noexcept
Definition: symbolpin.h:71
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:98
The SExpression class.
Definition: sexpression.h:60
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:662