LibrePCB Developers Documentation
Loading...
Searching...
No Matches
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_CORE_SYMBOLPIN_H
21#define LIBREPCB_CORE_SYMBOLPIN_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../serialization/serializableobjectlist.h"
27#include "../../types/alignment.h"
28#include "../../types/angle.h"
29#include "../../types/circuitidentifier.h"
30#include "../../types/length.h"
31#include "../../types/point.h"
32
33#include <QtCore>
34
35/*******************************************************************************
36 * Namespace / Forward Declarations
37 ******************************************************************************/
38namespace librepcb {
39
40/*******************************************************************************
41 * Class SymbolPin
42 ******************************************************************************/
43
51class SymbolPin final {
52 Q_DECLARE_TR_FUNCTIONS(SymbolPin)
53
54public:
55 // Signals
69
70 // Constructors / Destructor
71 SymbolPin() = delete;
72 SymbolPin(const SymbolPin& other) noexcept;
73 SymbolPin(const Uuid& uuid, const SymbolPin& other) noexcept;
74 SymbolPin(const Uuid& uuid, const CircuitIdentifier& name,
75 const Point& position, const UnsignedLength& length,
76 const Angle& rotation, const Point& namePosition,
77 const Angle& nameRotation, const PositiveLength& nameHeight,
78 const Alignment& nameAlign) noexcept;
79 explicit SymbolPin(const SExpression& node);
80 ~SymbolPin() noexcept;
81
82 // Getters
83 const Uuid& getUuid() const noexcept { return mUuid; }
84 const CircuitIdentifier& getName() const noexcept { return mName; }
85 const Point& getPosition() const noexcept { return mPosition; }
86 const UnsignedLength& getLength() const noexcept { return mLength; }
87 const Angle& getRotation() const noexcept { return mRotation; }
88 const Point& getNamePosition() const noexcept { return mNamePosition; }
89 const Angle& getNameRotation() const noexcept { return mNameRotation; }
90 const PositiveLength& getNameHeight() const noexcept { return mNameHeight; }
91 const Alignment& getNameAlignment() const noexcept { return mNameAlignment; }
92 Point getNumbersPosition(bool flipped) const noexcept;
93
94 // Setters
95 bool setPosition(const Point& pos) noexcept;
96 bool setLength(const UnsignedLength& length) noexcept;
97 bool setRotation(const Angle& rotation) noexcept;
98 bool setName(const CircuitIdentifier& name) noexcept;
99 bool setNamePosition(const Point& position) noexcept;
100 bool setNameRotation(const Angle& rotation) noexcept;
101 bool setNameHeight(const PositiveLength& height) noexcept;
102 bool setNameAlignment(const Alignment& align) noexcept;
103
104 // General Methods
105
111 void serialize(SExpression& root) const;
112
113 // Operator Overloadings
114 bool operator==(const SymbolPin& rhs) const noexcept;
115 bool operator!=(const SymbolPin& rhs) const noexcept {
116 return !(*this == rhs);
117 }
118 SymbolPin& operator=(const SymbolPin& rhs) noexcept;
119
120 // Static Methods
121 static Point getDefaultNamePosition(const UnsignedLength& length) noexcept {
122 return Point(length + Length(1270000), 0);
123 }
125 return PositiveLength(2500000);
126 }
129 }
131 return PositiveLength(1500000);
132 }
133 static Alignment getNumbersAlignment(bool flipped) noexcept {
134 return Alignment(HAlign::right(),
135 flipped ? VAlign::top() : VAlign::bottom());
136 }
137
138private: // Data
148};
149
150/*******************************************************************************
151 * Class SymbolPinList
152 ******************************************************************************/
153
155 static constexpr const char* tagname = "pin";
156};
160
161/*******************************************************************************
162 * End of File
163 ******************************************************************************/
164
165} // namespace librepcb
166
167#endif
The Alignment class.
Definition alignment.h:115
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition angle.h:76
static HAlign right() noexcept
Definition alignment.h:54
static HAlign left() noexcept
Definition alignment.h:52
The Length class is used to represent a length (for example 12.75 millimeters)
Definition length.h:82
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 Signal class is used to emit signals on non-QObject derived classes.
Definition signalslot.h:65
The Slot class is used to receive signals from non-QObject derived classes.
Definition signalslot.h:170
The SymbolPin class represents one pin of a symbol.
Definition symbolpin.h:51
SymbolPin & operator=(const SymbolPin &rhs) noexcept
Definition symbolpin.cpp:217
const Angle & getRotation() const noexcept
Definition symbolpin.h:87
bool setPosition(const Point &pos) noexcept
Definition symbolpin.cpp:110
Alignment mNameAlignment
Definition symbolpin.h:147
bool setName(const CircuitIdentifier &name) noexcept
Definition symbolpin.cpp:100
const PositiveLength & getNameHeight() const noexcept
Definition symbolpin.h:90
const Point & getNamePosition() const noexcept
Definition symbolpin.h:88
static Point getDefaultNamePosition(const UnsignedLength &length) noexcept
Definition symbolpin.h:121
bool setNameHeight(const PositiveLength &height) noexcept
Definition symbolpin.cpp:160
Uuid mUuid
Definition symbolpin.h:139
Event
Definition symbolpin.h:56
bool setNameAlignment(const Alignment &align) noexcept
Definition symbolpin.cpp:170
static PositiveLength getNumbersHeight() noexcept
Definition symbolpin.h:130
Point mNamePosition
Definition symbolpin.h:144
const CircuitIdentifier & getName() const noexcept
Definition symbolpin.h:84
~SymbolPin() noexcept
Definition symbolpin.cpp:85
Signal< SymbolPin, Event > onEdited
Definition symbolpin.h:67
bool setNameRotation(const Angle &rotation) noexcept
Definition symbolpin.cpp:150
const UnsignedLength & getLength() const noexcept
Definition symbolpin.h:86
static Alignment getNumbersAlignment(bool flipped) noexcept
Definition symbolpin.h:133
Angle mRotation
Definition symbolpin.h:143
bool operator==(const SymbolPin &rhs) const noexcept
Definition symbolpin.cpp:204
bool setNamePosition(const Point &position) noexcept
Definition symbolpin.cpp:140
const Point & getPosition() const noexcept
Definition symbolpin.h:85
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition symbolpin.cpp:184
bool operator!=(const SymbolPin &rhs) const noexcept
Definition symbolpin.h:115
const Angle & getNameRotation() const noexcept
Definition symbolpin.h:89
const Uuid & getUuid() const noexcept
Definition symbolpin.h:83
static Alignment getDefaultNameAlignment() noexcept
Definition symbolpin.h:127
bool setRotation(const Angle &rotation) noexcept
Definition symbolpin.cpp:130
UnsignedLength mLength
Definition symbolpin.h:142
Angle mNameRotation
Definition symbolpin.h:145
bool setLength(const UnsignedLength &length) noexcept
Definition symbolpin.cpp:120
const Alignment & getNameAlignment() const noexcept
Definition symbolpin.h:91
CircuitIdentifier mName
Definition symbolpin.h:140
PositiveLength mNameHeight
Definition symbolpin.h:146
Slot< SymbolPin, Event > OnEditedSlot
Definition symbolpin.h:68
Point mPosition
Definition symbolpin.h:141
Point getNumbersPosition(bool flipped) const noexcept
Definition symbolpin.cpp:92
static PositiveLength getDefaultNameHeight() noexcept
Definition symbolpin.h:124
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition uuid.h:56
static VAlign bottom() noexcept
Definition alignment.h:90
static VAlign top() noexcept
Definition alignment.h:88
static VAlign center() noexcept
Definition alignment.h:89
Definition occmodel.cpp:77
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition length.h:810
type_safe::constrained_type< QString, CircuitIdentifierConstraint, CircuitIdentifierVerifier > CircuitIdentifier
Definition circuitidentifier.h:88
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition length.h:694
Definition symbolpin.h:154
static constexpr const char * tagname
Definition symbolpin.h:155