LibrePCB Developers Documentation
si_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_SI_SYMBOLPIN_H
21#define LIBREPCB_CORE_SI_SYMBOLPIN_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../../types/angle.h"
27#include "../../../types/point.h"
28#include "si_base.h"
29#include "si_netline.h"
30#include "si_symbol.h"
31
32#include <QtCore>
33
34/*******************************************************************************
35 * Namespace / Forward Declarations
36 ******************************************************************************/
37namespace librepcb {
38
39class Circuit;
40class ComponentPinSignalMapItem;
41class ComponentSignal;
42class ComponentSignalInstance;
43class SymbolPin;
44
45/*******************************************************************************
46 * Class SI_SymbolPin
47 ******************************************************************************/
48
52class SI_SymbolPin final : public SI_Base, public SI_NetLineAnchor {
53 Q_OBJECT
54
55public:
56 // Signals
57 enum class Event {
58 PositionChanged,
59 RotationChanged,
60 JunctionChanged,
61 NameChanged,
62 NumbersChanged,
63 NumbersPositionChanged,
64 NumbersAlignmentChanged,
65 NetNameChanged,
66 };
69
70 // Constructors / Destructor
71 SI_SymbolPin() = delete;
72 SI_SymbolPin(const SI_SymbolPin& other) = delete;
73 explicit SI_SymbolPin(SI_Symbol& symbol, const Uuid& pinUuid);
75
76 // Getters
77
83 const Point& getPosition() const noexcept override { return mPosition; }
84
90 const Angle& getRotation() const noexcept { return mRotation; }
91
92 const QString& getName() const noexcept { return mName; }
93
94 const QStringList& getNumbers() const noexcept { return mNumbers; }
95
96 const QString& getNumbersTruncated() const noexcept {
97 return mNumbersTruncated;
98 }
99
100 const Point& getNumbersPosition() const noexcept { return mNumbersPosition; }
101
102 const Alignment& getNumbersAlignment() const noexcept {
103 return mNumbersAlignment;
104 }
105
106 const Uuid& getLibPinUuid() const noexcept;
107 SI_Symbol& getSymbol() const noexcept { return mSymbol; }
108 const SymbolPin& getLibPin() const noexcept { return *mSymbolPin; }
111 }
112 NetSignal* getCompSigInstNetSignal() const noexcept;
113 SI_NetSegment* getNetSegmentOfLines() const noexcept;
114 bool isRequired() const noexcept;
115 bool isUsed() const noexcept { return (mRegisteredNetLines.count() > 0); }
116 bool isVisibleJunction() const noexcept;
117 bool isOpen() const noexcept override {
118 return mRegisteredNetLines.isEmpty();
119 }
120 NetLineAnchor toNetLineAnchor() const noexcept override;
121
122 // General Methods
123 void addToSchematic() override;
124 void removeFromSchematic() override;
125
126 // Inherited from SI_NetLineAnchor
127 void registerNetLine(SI_NetLine& netline) override;
128 void unregisterNetLine(SI_NetLine& netline) override;
129 const QSet<SI_NetLine*>& getNetLines() const noexcept override {
130 return mRegisteredNetLines;
131 }
132
133 // Operator Overloadings
134 SI_SymbolPin& operator=(const SI_SymbolPin& rhs) = delete;
135
136private:
137 void symbolEdited(const SI_Symbol& obj, SI_Symbol::Event event) noexcept;
138 void netSignalChanged(NetSignal* from, NetSignal* to) noexcept;
139 void netSignalNameChanged() noexcept;
140 void padNamesChanged(const QStringList& names) noexcept;
141 void updateTransform() noexcept;
142 void updateName() noexcept;
143 void updateNumbers() noexcept;
144 void updateNumbersTransform() noexcept;
145 QString getLibraryComponentName() const noexcept;
146 QString getComponentSignalNameOrPinUuid() const noexcept;
147 QString getNetSignalName() const noexcept;
148
149 // General
154
155 // Cached Properties
158 QString mName;
159 QStringList mNumbers;
163
164 // Registered Elements
166
167 // Slots
169};
170
171/*******************************************************************************
172 * End of File
173 ******************************************************************************/
174
175} // namespace librepcb
176
177#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:78
The ComponentPinSignalMapItem class maps a symbol pin to a component signal.
Definition: componentpinsignalmap.h:50
The ComponentSignalInstance class.
Definition: componentsignalinstance.h:49
The NetLineAnchor class.
Definition: netline.h:44
The NetSignal class.
Definition: netsignal.h:50
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition: point.h:79
The Schematic Item Base (SI_Base) class.
Definition: si_base.h:45
Definition: si_netline.h:44
The SI_NetLine class.
Definition: si_netline.h:65
The SI_NetSegment class.
Definition: si_netsegment.h:53
The SI_Symbol class.
Definition: si_symbol.h:54
Event
Definition: si_symbol.h:59
The SI_SymbolPin class.
Definition: si_symbolpin.h:52
const Alignment & getNumbersAlignment() const noexcept
Definition: si_symbolpin.h:102
const Angle & getRotation() const noexcept
Get the absolute rotation of the pin (scene coordinates)
Definition: si_symbolpin.h:90
~SI_SymbolPin()
Definition: si_symbolpin.cpp:86
const Point & getPosition() const noexcept override
Get the absolute position of the pin (scene coordinates)
Definition: si_symbolpin.h:83
ComponentSignalInstance * getComponentSignalInstance() const noexcept
Definition: si_symbolpin.h:109
const Uuid & getLibPinUuid() const noexcept
Definition: si_symbolpin.cpp:94
SI_Symbol::OnEditedSlot mOnSymbolEditedSlot
Definition: si_symbolpin.h:168
const QString & getName() const noexcept
Definition: si_symbolpin.h:92
void unregisterNetLine(SI_NetLine &netline) override
Definition: si_symbolpin.cpp:185
QString getNetSignalName() const noexcept
Definition: si_symbolpin.cpp:341
QSet< SI_NetLine * > mRegisteredNetLines
all registered netlines
Definition: si_symbolpin.h:165
void registerNetLine(SI_NetLine &netline) override
Definition: si_symbolpin.cpp:152
SI_Symbol & getSymbol() const noexcept
Definition: si_symbolpin.h:107
Slot< SI_SymbolPin, Event > OnEditedSlot
Definition: si_symbolpin.h:68
const QStringList & getNumbers() const noexcept
Definition: si_symbolpin.h:94
ComponentSignalInstance * mComponentSignalInstance
Definition: si_symbolpin.h:153
bool isUsed() const noexcept
Definition: si_symbolpin.h:115
NetLineAnchor toNetLineAnchor() const noexcept override
Definition: si_symbolpin.cpp:124
const SymbolPin & getLibPin() const noexcept
Definition: si_symbolpin.h:108
Event
Definition: si_symbolpin.h:57
SI_SymbolPin(const SI_SymbolPin &other)=delete
QString mName
Definition: si_symbolpin.h:158
void symbolEdited(const SI_Symbol &obj, SI_Symbol::Event event) noexcept
Definition: si_symbolpin.cpp:199
const QSet< SI_NetLine * > & getNetLines() const noexcept override
Definition: si_symbolpin.h:129
const ComponentPinSignalMapItem * mPinSignalMapItem
Definition: si_symbolpin.h:152
bool isOpen() const noexcept override
Definition: si_symbolpin.h:117
void removeFromSchematic() override
Definition: si_symbolpin.cpp:142
const Point & getNumbersPosition() const noexcept
Definition: si_symbolpin.h:100
void netSignalChanged(NetSignal *from, NetSignal *to) noexcept
Definition: si_symbolpin.cpp:215
bool isRequired() const noexcept
Definition: si_symbolpin.cpp:112
Signal< SI_SymbolPin, Event > onEdited
Definition: si_symbolpin.h:67
void updateName() noexcept
Definition: si_symbolpin.cpp:256
const QString & getNumbersTruncated() const noexcept
Definition: si_symbolpin.h:96
void updateNumbers() noexcept
Definition: si_symbolpin.cpp:279
void updateTransform() noexcept
Definition: si_symbolpin.cpp:238
void addToSchematic() override
Definition: si_symbolpin.cpp:132
Angle mRotation
Definition: si_symbolpin.h:157
SI_SymbolPin & operator=(const SI_SymbolPin &rhs)=delete
QString getComponentSignalNameOrPinUuid() const noexcept
Definition: si_symbolpin.cpp:335
const SymbolPin * mSymbolPin
Definition: si_symbolpin.h:151
QString getLibraryComponentName() const noexcept
Definition: si_symbolpin.cpp:328
void padNamesChanged(const QStringList &names) noexcept
Alignment mNumbersAlignment
Definition: si_symbolpin.h:162
SI_Symbol & mSymbol
Definition: si_symbolpin.h:150
void netSignalNameChanged() noexcept
Definition: si_symbolpin.cpp:233
void updateNumbersTransform() noexcept
Definition: si_symbolpin.cpp:314
NetSignal * getCompSigInstNetSignal() const noexcept
Definition: si_symbolpin.cpp:98
QStringList mNumbers
Definition: si_symbolpin.h:159
Point mPosition
Definition: si_symbolpin.h:156
Point mNumbersPosition
Definition: si_symbolpin.h:161
bool isVisibleJunction() const noexcept
Definition: si_symbolpin.cpp:120
SI_NetSegment * getNetSegmentOfLines() const noexcept
Definition: si_symbolpin.cpp:106
QString mNumbersTruncated
Definition: si_symbolpin.h:160
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
The SymbolPin class represents one pin of a symbol.
Definition: symbolpin.h:51
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
Definition: occmodel.cpp:77