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 CircuitIdentifier& name,
74 const Point& position, const UnsignedLength& length,
75 const Angle& rotation, const Point& namePosition,
76 const Angle& nameRotation, const PositiveLength& nameHeight,
77 const Alignment& nameAlign) noexcept;
78 explicit SymbolPin(const SExpression& node);
79 ~SymbolPin() noexcept;
80
81 // Getters
82 const Uuid& getUuid() const noexcept { return mUuid; }
83 const CircuitIdentifier& getName() const noexcept { return mName; }
84 const Point& getPosition() const noexcept { return mPosition; }
85 const UnsignedLength& getLength() const noexcept { return mLength; }
86 const Angle& getRotation() const noexcept { return mRotation; }
87 const Point& getNamePosition() const noexcept { return mNamePosition; }
88 const Angle& getNameRotation() const noexcept { return mNameRotation; }
89 const PositiveLength& getNameHeight() const noexcept { return mNameHeight; }
90 const Alignment& getNameAlignment() const noexcept { return mNameAlignment; }
91 Point getNumbersPosition(bool flipped) const noexcept;
92
93 // Setters
94 bool setPosition(const Point& pos) noexcept;
95 bool setLength(const UnsignedLength& length) noexcept;
96 bool setRotation(const Angle& rotation) noexcept;
97 bool setName(const CircuitIdentifier& name) noexcept;
98 bool setNamePosition(const Point& position) noexcept;
99 bool setNameRotation(const Angle& rotation) noexcept;
100 bool setNameHeight(const PositiveLength& height) noexcept;
101 bool setNameAlignment(const Alignment& align) noexcept;
102
103 // General Methods
104
110 void serialize(SExpression& root) const;
111
112 // Operator Overloadings
113 bool operator==(const SymbolPin& rhs) const noexcept;
114 bool operator!=(const SymbolPin& rhs) const noexcept {
115 return !(*this == rhs);
116 }
117 SymbolPin& operator=(const SymbolPin& rhs) noexcept;
118
119 // Static Methods
120 static Point getDefaultNamePosition(const UnsignedLength& length) noexcept {
121 return Point(length + Length(1270000), 0);
122 }
124 return PositiveLength(2500000);
125 }
128 }
130 return PositiveLength(1500000);
131 }
132 static Alignment getNumbersAlignment(bool flipped) noexcept {
133 return Alignment(HAlign::right(),
134 flipped ? VAlign::top() : VAlign::bottom());
135 }
136
137private: // Data
147};
148
149/*******************************************************************************
150 * Class SymbolPinList
151 ******************************************************************************/
152
154 static constexpr const char* tagname = "pin";
155};
159
160/*******************************************************************************
161 * End of File
162 ******************************************************************************/
163
164} // namespace librepcb
165
166#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:212
const Angle & getRotation() const noexcept
Definition symbolpin.h:86
bool setPosition(const Point &pos) noexcept
Definition symbolpin.cpp:105
Alignment mNameAlignment
Definition symbolpin.h:146
bool setName(const CircuitIdentifier &name) noexcept
Definition symbolpin.cpp:95
const PositiveLength & getNameHeight() const noexcept
Definition symbolpin.h:89
const Point & getNamePosition() const noexcept
Definition symbolpin.h:87
static Point getDefaultNamePosition(const UnsignedLength &length) noexcept
Definition symbolpin.h:120
bool setNameHeight(const PositiveLength &height) noexcept
Definition symbolpin.cpp:155
Uuid mUuid
Definition symbolpin.h:138
Event
Definition symbolpin.h:56
bool setNameAlignment(const Alignment &align) noexcept
Definition symbolpin.cpp:165
static PositiveLength getNumbersHeight() noexcept
Definition symbolpin.h:129
Point mNamePosition
Definition symbolpin.h:143
const CircuitIdentifier & getName() const noexcept
Definition symbolpin.h:83
~SymbolPin() noexcept
Definition symbolpin.cpp:80
Signal< SymbolPin, Event > onEdited
Definition symbolpin.h:67
bool setNameRotation(const Angle &rotation) noexcept
Definition symbolpin.cpp:145
const UnsignedLength & getLength() const noexcept
Definition symbolpin.h:85
static Alignment getNumbersAlignment(bool flipped) noexcept
Definition symbolpin.h:132
Angle mRotation
Definition symbolpin.h:142
bool operator==(const SymbolPin &rhs) const noexcept
Definition symbolpin.cpp:199
bool setNamePosition(const Point &position) noexcept
Definition symbolpin.cpp:135
const Point & getPosition() const noexcept
Definition symbolpin.h:84
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition symbolpin.cpp:179
bool operator!=(const SymbolPin &rhs) const noexcept
Definition symbolpin.h:114
const Angle & getNameRotation() const noexcept
Definition symbolpin.h:88
const Uuid & getUuid() const noexcept
Definition symbolpin.h:82
static Alignment getDefaultNameAlignment() noexcept
Definition symbolpin.h:126
bool setRotation(const Angle &rotation) noexcept
Definition symbolpin.cpp:125
UnsignedLength mLength
Definition symbolpin.h:141
Angle mNameRotation
Definition symbolpin.h:144
bool setLength(const UnsignedLength &length) noexcept
Definition symbolpin.cpp:115
const Alignment & getNameAlignment() const noexcept
Definition symbolpin.h:90
CircuitIdentifier mName
Definition symbolpin.h:139
PositiveLength mNameHeight
Definition symbolpin.h:145
Slot< SymbolPin, Event > OnEditedSlot
Definition symbolpin.h:68
Point mPosition
Definition symbolpin.h:140
Point getNumbersPosition(bool flipped) const noexcept
Definition symbolpin.cpp:87
static PositiveLength getDefaultNameHeight() noexcept
Definition symbolpin.h:123
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:76
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition length.h:810
type_safe::constrained_type< QString, CircuitIdentifierConstraint, CircuitIdentifierVerifier > CircuitIdentifier
Definition circuitidentifier.h:95
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition length.h:694
Definition symbolpin.h:153
static constexpr const char * tagname
Definition symbolpin.h:154