LibrePCB Developers Documentation
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_NetLabel;
39class SI_NetLine;
40class SI_NetLineAnchor;
41class SI_NetPoint;
42class SI_SymbolPin;
43
44/*******************************************************************************
45 * Class SI_NetSegment
46 ******************************************************************************/
47
53class SI_NetSegment final : public SI_Base {
54 Q_OBJECT
55
56public:
57 // Constructors / Destructor
58 SI_NetSegment() = delete;
59 SI_NetSegment(const SI_NetSegment& other) = delete;
60 SI_NetSegment(Schematic& schematic, const Uuid& uuid, NetSignal& signal);
61 ~SI_NetSegment() noexcept;
62
63 // Getters
64 const Uuid& getUuid() const noexcept { return mUuid; }
65 NetSignal& getNetSignal() const noexcept { return *mNetSignal; }
66 bool isUsed() const noexcept;
67 QSet<QString> getForcedNetNames() const noexcept;
68 QString getForcedNetName() const noexcept;
69 Point calcNearestPoint(const Point& p) const noexcept;
70 QSet<SI_SymbolPin*> getAllConnectedPins() const noexcept;
71
72 // Setters
73 void setNetSignal(NetSignal& netsignal);
74
75 // Element Getters
76 const QMap<Uuid, SI_NetPoint*>& getNetPoints() const noexcept {
77 return mNetPoints;
78 }
79 const QMap<Uuid, SI_NetLine*>& getNetLines() const noexcept {
80 return mNetLines;
81 }
82
83 // NetPoint+NetLine Methods
84 void addNetPointsAndNetLines(const QList<SI_NetPoint*>& netpoints,
85 const QList<SI_NetLine*>& netlines);
86 void removeNetPointsAndNetLines(const QList<SI_NetPoint*>& netpoints,
87 const QList<SI_NetLine*>& netlines);
88
89 // NetLabel Methods
90 const QMap<Uuid, SI_NetLabel*>& getNetLabels() const noexcept {
91 return mNetLabels;
92 }
93 void addNetLabel(SI_NetLabel& netlabel);
94 void removeNetLabel(SI_NetLabel& netlabel);
95 void updateAllNetLabelAnchors() noexcept;
96
97 // General Methods
98 void addToSchematic() override;
99 void removeFromSchematic() override;
100
106 void serialize(SExpression& root) const;
107
108 // Operator Overloadings
109 SI_NetSegment& operator=(const SI_NetSegment& rhs) = delete;
110 bool operator==(const SI_NetSegment& rhs) noexcept { return (this == &rhs); }
111 bool operator!=(const SI_NetSegment& rhs) noexcept { return (this != &rhs); }
112
113signals:
114 void netPointsAndNetLinesAdded(const QList<SI_NetPoint*>& netPoints,
115 const QList<SI_NetLine*>& netLines);
116 void netPointsAndNetLinesRemoved(const QList<SI_NetPoint*>& netPoints,
117 const QList<SI_NetLine*>& netLines);
118 void netLabelAdded(SI_NetLabel& netLabel);
120
121private:
122 bool checkAttributesValidity() const noexcept;
123 bool areAllNetPointsConnectedTogether() const noexcept;
125 const SI_NetLineAnchor& p, QSet<const SI_SymbolPin*>& pins,
126 QSet<const SI_NetPoint*>& points) const noexcept;
127
128 // Attributes
131
132 // Items
136};
137
138/*******************************************************************************
139 * End of File
140 ******************************************************************************/
141
142} // namespace librepcb
143
144#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:79
The SExpression class.
Definition: sexpression.h:69
The Schematic Item Base (SI_Base) class.
Definition: si_base.h:45
The SI_NetLabel class.
Definition: si_netlabel.h:49
Definition: si_netline.h:44
The SI_NetLine class.
Definition: si_netline.h:65
The SI_NetPoint class.
Definition: si_netpoint.h:44
The SI_NetSegment class.
Definition: si_netsegment.h:53
QSet< SI_SymbolPin * > getAllConnectedPins() const noexcept
Definition: si_netsegment.cpp:115
bool areAllNetPointsConnectedTogether() const noexcept
Definition: si_netsegment.cpp:387
void addNetPointsAndNetLines(const QList< SI_NetPoint * > &netpoints, const QList< SI_NetLine * > &netlines)
Definition: si_netsegment.cpp:159
NetSignal & getNetSignal() const noexcept
Definition: si_netsegment.h:65
void findAllConnectedNetPoints(const SI_NetLineAnchor &p, QSet< const SI_SymbolPin * > &pins, QSet< const SI_NetPoint * > &points) const noexcept
Definition: si_netsegment.cpp:400
QSet< QString > getForcedNetNames() const noexcept
Definition: si_netsegment.cpp:73
const QMap< Uuid, SI_NetPoint * > & getNetPoints() const noexcept
Definition: si_netsegment.h:76
const QMap< Uuid, SI_NetLabel * > & getNetLabels() const noexcept
Definition: si_netsegment.h:90
NetSignal * mNetSignal
Definition: si_netsegment.h:130
Uuid mUuid
Definition: si_netsegment.h:129
bool isUsed() const noexcept
Definition: si_netsegment.cpp:68
void removeNetPointsAndNetLines(const QList< SI_NetPoint * > &netpoints, const QList< SI_NetLine * > &netlines)
Definition: si_netsegment.cpp:217
SI_NetSegment(const SI_NetSegment &other)=delete
bool checkAttributesValidity() const noexcept
Definition: si_netsegment.cpp:381
void removeFromSchematic() override
Definition: si_netsegment.cpp:327
void netLabelAdded(SI_NetLabel &netLabel)
void addNetLabel(SI_NetLabel &netlabel)
Definition: si_netsegment.cpp:265
void removeNetLabel(SI_NetLabel &netlabel)
Definition: si_netsegment.cpp:281
QMap< Uuid, SI_NetLine * > mNetLines
Definition: si_netsegment.h:134
void setNetSignal(NetSignal &netsignal)
Definition: si_netsegment.cpp:138
void addToSchematic() override
Definition: si_netsegment.cpp:301
void netPointsAndNetLinesRemoved(const QList< SI_NetPoint * > &netPoints, const QList< SI_NetLine * > &netLines)
~SI_NetSegment() noexcept
Definition: si_netsegment.cpp:54
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition: si_netsegment.cpp:353
const Uuid & getUuid() const noexcept
Definition: si_netsegment.h:64
const QMap< Uuid, SI_NetLine * > & getNetLines() const noexcept
Definition: si_netsegment.h:79
QString getForcedNetName() const noexcept
Definition: si_netsegment.cpp:90
Point calcNearestPoint(const Point &p) const noexcept
Definition: si_netsegment.cpp:99
bool operator!=(const SI_NetSegment &rhs) noexcept
Definition: si_netsegment.h:111
QMap< Uuid, SI_NetPoint * > mNetPoints
Definition: si_netsegment.h:133
QMap< Uuid, SI_NetLabel * > mNetLabels
Definition: si_netsegment.h:135
void netLabelRemoved(SI_NetLabel &netLabel)
void netPointsAndNetLinesAdded(const QList< SI_NetPoint * > &netPoints, const QList< SI_NetLine * > &netLines)
void updateAllNetLabelAnchors() noexcept
Definition: si_netsegment.cpp:291
The SI_SymbolPin class.
Definition: si_symbolpin.h:52
The Schematic class represents one schematic page of a project and is always part of a circuit.
Definition: schematic.h:74
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
Definition: occmodel.cpp:77