LibrePCB Developers Documentation
Loading...
Searching...
No Matches
si_netsegment.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_NETSEGMENT_H
21#define LIBREPCB_CORE_SI_NETSEGMENT_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../../types/point.h"
27#include "../../../types/uuid.h"
28#include "si_base.h"
29
30#include <QtCore>
31
32/*******************************************************************************
33 * Namespace / Forward Declarations
34 ******************************************************************************/
35namespace librepcb {
36
37class NetSignal;
38class SI_BusJunction;
39class SI_BusSegment;
40class SI_NetLabel;
41class SI_NetLine;
42class SI_NetLineAnchor;
43class SI_NetPoint;
44class SI_SymbolPin;
45
46/*******************************************************************************
47 * Class SI_NetSegment
48 ******************************************************************************/
49
55class SI_NetSegment final : public SI_Base {
56 Q_OBJECT
57
58public:
59 // Constructors / Destructor
60 SI_NetSegment() = delete;
61 SI_NetSegment(const SI_NetSegment& other) = delete;
62 SI_NetSegment(Schematic& schematic, const Uuid& uuid, NetSignal& signal);
63 ~SI_NetSegment() noexcept;
64
65 // Getters
66 const Uuid& getUuid() const noexcept { return mUuid; }
67 NetSignal& getNetSignal() const noexcept { return *mNetSignal; }
68 bool isUsed() const noexcept;
69 QSet<QString> getForcedNetNames() const noexcept;
70 QString getForcedNetName() const noexcept;
71 Point calcNearestPoint(const Point& p) const noexcept;
72 QSet<SI_SymbolPin*> getAllConnectedPins() const noexcept;
73 QSet<SI_BusJunction*> getAllConnectedBusJunctions() const noexcept;
74 QSet<SI_BusSegment*> getAllConnectedBusSegments() const noexcept;
75
76 // Setters
77 void setNetSignal(NetSignal& netsignal);
78
79 // Element Getters
80 const QMap<Uuid, SI_NetPoint*>& getNetPoints() const noexcept {
81 return mNetPoints;
82 }
83 const QMap<Uuid, SI_NetLine*>& getNetLines() const noexcept {
84 return mNetLines;
85 }
86
87 // NetPoint+NetLine Methods
88 void addNetPointsAndNetLines(const QList<SI_NetPoint*>& netpoints,
89 const QList<SI_NetLine*>& netlines);
90 void removeNetPointsAndNetLines(const QList<SI_NetPoint*>& netpoints,
91 const QList<SI_NetLine*>& netlines);
92
93 // NetLabel Methods
94 const QMap<Uuid, SI_NetLabel*>& getNetLabels() const noexcept {
95 return mNetLabels;
96 }
97 void addNetLabel(SI_NetLabel& netlabel);
98 void removeNetLabel(SI_NetLabel& netlabel);
99 void updateAllNetLabelAnchors() noexcept;
100
101 // General Methods
102 void addToSchematic() override;
103 void removeFromSchematic() override;
104
110 void serialize(SExpression& root) const;
111
112 // Operator Overloadings
113 SI_NetSegment& operator=(const SI_NetSegment& rhs) = delete;
114 bool operator==(const SI_NetSegment& rhs) noexcept { return (this == &rhs); }
115 bool operator!=(const SI_NetSegment& rhs) noexcept { return (this != &rhs); }
116
117signals:
118 void netPointsAndNetLinesAdded(const QList<SI_NetPoint*>& netPoints,
119 const QList<SI_NetLine*>& netLines);
120 void netPointsAndNetLinesRemoved(const QList<SI_NetPoint*>& netPoints,
121 const QList<SI_NetLine*>& netLines);
122 void netLabelAdded(SI_NetLabel& netLabel);
124
125private:
126 bool checkAttributesValidity() const noexcept;
127 bool areAllNetPointsConnectedTogether() const noexcept;
129 QSet<const SI_SymbolPin*>& pins,
130 QSet<const SI_BusJunction*>& buses,
131 QSet<const SI_NetPoint*>& points,
132 QSet<const SI_NetLine*>& lines) const noexcept;
133
134 // Attributes
137
138 // Items
142};
143
144/*******************************************************************************
145 * End of File
146 ******************************************************************************/
147
148} // namespace librepcb
149
150#endif
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:78
The SExpression class.
Definition sexpression.h:69
The Schematic Item Base (SI_Base) class.
Definition si_base.h:45
The SI_BusJunction class.
Definition si_busjunction.h:45
The SI_BusSegment class.
Definition si_bussegment.h:52
The SI_NetLabel class.
Definition si_netlabel.h:48
Definition si_netline.h:43
The SI_NetLine class.
Definition si_netline.h:64
The SI_NetPoint class.
Definition si_netpoint.h:44
The SI_NetSegment class.
Definition si_netsegment.h:55
QSet< SI_SymbolPin * > getAllConnectedPins() const noexcept
Definition si_netsegment.cpp:116
bool areAllNetPointsConnectedTogether() const noexcept
Definition si_netsegment.cpp:424
QSet< SI_BusSegment * > getAllConnectedBusSegments() const noexcept
Definition si_netsegment.cpp:147
void addNetPointsAndNetLines(const QList< SI_NetPoint * > &netpoints, const QList< SI_NetLine * > &netlines)
Definition si_netsegment.cpp:187
NetSignal & getNetSignal() const noexcept
Definition si_netsegment.h:67
void findAllConnectedNetPoints(const SI_NetLineAnchor &p, QSet< const SI_SymbolPin * > &pins, QSet< const SI_BusJunction * > &buses, QSet< const SI_NetPoint * > &points, QSet< const SI_NetLine * > &lines) const noexcept
Definition si_netsegment.cpp:443
QSet< SI_BusJunction * > getAllConnectedBusJunctions() const noexcept
Definition si_netsegment.cpp:132
QSet< QString > getForcedNetNames() const noexcept
Definition si_netsegment.cpp:74
const QMap< Uuid, SI_NetPoint * > & getNetPoints() const noexcept
Definition si_netsegment.h:80
const QMap< Uuid, SI_NetLabel * > & getNetLabels() const noexcept
Definition si_netsegment.h:94
NetSignal * mNetSignal
Definition si_netsegment.h:136
Uuid mUuid
Definition si_netsegment.h:135
bool isUsed() const noexcept
Definition si_netsegment.cpp:69
void removeNetPointsAndNetLines(const QList< SI_NetPoint * > &netpoints, const QList< SI_NetLine * > &netlines)
Definition si_netsegment.cpp:251
SI_NetSegment(const SI_NetSegment &other)=delete
bool checkAttributesValidity() const noexcept
Definition si_netsegment.cpp:418
void removeFromSchematic() override
Definition si_netsegment.cpp:364
void netLabelAdded(SI_NetLabel &netLabel)
void addNetLabel(SI_NetLabel &netlabel)
Definition si_netsegment.cpp:299
void removeNetLabel(SI_NetLabel &netlabel)
Definition si_netsegment.cpp:317
QMap< Uuid, SI_NetLine * > mNetLines
Definition si_netsegment.h:140
void setNetSignal(NetSignal &netsignal)
Definition si_netsegment.cpp:166
void addToSchematic() override
Definition si_netsegment.cpp:338
void netPointsAndNetLinesRemoved(const QList< SI_NetPoint * > &netPoints, const QList< SI_NetLine * > &netLines)
~SI_NetSegment() noexcept
Definition si_netsegment.cpp:55
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition si_netsegment.cpp:390
const Uuid & getUuid() const noexcept
Definition si_netsegment.h:66
const QMap< Uuid, SI_NetLine * > & getNetLines() const noexcept
Definition si_netsegment.h:83
QString getForcedNetName() const noexcept
Definition si_netsegment.cpp:91
Point calcNearestPoint(const Point &p) const noexcept
Definition si_netsegment.cpp:100
bool operator!=(const SI_NetSegment &rhs) noexcept
Definition si_netsegment.h:115
QMap< Uuid, SI_NetPoint * > mNetPoints
Definition si_netsegment.h:139
QMap< Uuid, SI_NetLabel * > mNetLabels
Definition si_netsegment.h:141
void netLabelRemoved(SI_NetLabel &netLabel)
void netPointsAndNetLinesAdded(const QList< SI_NetPoint * > &netPoints, const QList< SI_NetLine * > &netLines)
void updateAllNetLabelAnchors() noexcept
Definition si_netsegment.cpp:328
The SI_SymbolPin class.
Definition si_symbolpin.h:53
The Schematic class represents one schematic page of a project and is always part of a circuit.
Definition schematic.h:81
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition uuid.h:56
Definition occmodel.cpp:77