LibrePCB Developers Documentation
Loading...
Searching...
No Matches
bi_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_BI_NETSEGMENT_H
21#define LIBREPCB_CORE_BI_NETSEGMENT_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../../types/point.h"
27#include "../../../types/uuid.h"
28#include "bi_base.h"
29#include "bi_netline.h"
30#include "bi_netpoint.h"
31#include "bi_via.h"
32
33#include <QtCore>
34
35/*******************************************************************************
36 * Namespace / Forward Declarations
37 ******************************************************************************/
38namespace librepcb {
39
40class BI_Device;
41class BI_FootprintPad;
42class BI_NetLineAnchor;
43class NetSignal;
44
45/*******************************************************************************
46 * Class BI_NetSegment
47 ******************************************************************************/
48
52class BI_NetSegment final : public BI_Base {
53 Q_OBJECT
54
55public:
56 // Constructors / Destructor
57 BI_NetSegment() = delete;
58 BI_NetSegment(const BI_NetSegment& other) = delete;
59 BI_NetSegment(Board& board, const Uuid& uuid, NetSignal* signal);
60 ~BI_NetSegment() noexcept;
61
62 // Getters
63 const Uuid& getUuid() const noexcept { return mUuid; }
64
71 NetSignal* getNetSignal() const noexcept { return mNetSignal; }
72
84 QString getNetNameToDisplay(bool fallback = false) const noexcept;
85
86 bool isUsed() const noexcept;
87
88 // Setters
89 void setNetSignal(NetSignal* netsignal);
90
91 // Element Getters
92 const QMap<Uuid, BI_Via*>& getVias() const noexcept { return mVias; }
93 const QMap<Uuid, BI_NetPoint*>& getNetPoints() const noexcept {
94 return mNetPoints;
95 }
96 const QMap<Uuid, BI_NetLine*>& getNetLines() const noexcept {
97 return mNetLines;
98 }
99
100 // NetPoint+NetLine Methods
101 void addElements(const QList<BI_Via*>& vias,
102 const QList<BI_NetPoint*>& netpoints,
103 const QList<BI_NetLine*>& netlines);
104 void removeElements(const QList<BI_Via*>& vias,
105 const QList<BI_NetPoint*>& netpoints,
106 const QList<BI_NetLine*>& netlines);
107
108 // General Methods
109 void addToBoard() override;
110 void removeFromBoard() override;
111
117 void serialize(SExpression& root) const;
118
119 // Operator Overloadings
120 BI_NetSegment& operator=(const BI_NetSegment& rhs) = delete;
121 bool operator==(const BI_NetSegment& rhs) noexcept { return (this == &rhs); }
122 bool operator!=(const BI_NetSegment& rhs) noexcept { return (this != &rhs); }
123
124signals:
125 void elementsAdded(const QList<BI_Via*>& vias,
126 const QList<BI_NetPoint*>& netPoints,
127 const QList<BI_NetLine*>& netLines);
128 void elementsRemoved(const QList<BI_Via*>& vias,
129 const QList<BI_NetPoint*>& netPoints,
130 const QList<BI_NetLine*>& netLines);
131
132private:
133 bool checkAttributesValidity() const noexcept;
134 bool areAllNetPointsConnectedTogether() const noexcept;
136 const BI_NetLineAnchor& p, QSet<const BI_Via*>& vias,
137 QSet<const BI_FootprintPad*>& pads,
138 QSet<const BI_NetPoint*>& points) const noexcept;
139
140 // Attributes
142
147
148 // Items
152};
153
154/*******************************************************************************
155 * End of File
156 ******************************************************************************/
157
158} // namespace librepcb
159
160#endif
The Board Item Base (BI_Base) class.
Definition bi_base.h:45
The BI_FootprintPad class.
Definition bi_footprintpad.h:48
Definition bi_netline.h:46
The BI_NetLine class.
Definition bi_netline.h:71
The BI_NetPoint class.
Definition bi_netpoint.h:46
The BI_NetSegment class.
Definition bi_netsegment.h:52
bool operator!=(const BI_NetSegment &rhs) noexcept
Definition bi_netsegment.h:122
~BI_NetSegment() noexcept
Definition bi_netsegment.cpp:52
bool areAllNetPointsConnectedTogether() const noexcept
Definition bi_netsegment.cpp:341
QString getNetNameToDisplay(bool fallback=false) const noexcept
Definition bi_netsegment.cpp:66
void findAllConnectedNetPoints(const BI_NetLineAnchor &p, QSet< const BI_Via * > &vias, QSet< const BI_FootprintPad * > &pads, QSet< const BI_NetPoint * > &points) const noexcept
Definition bi_netsegment.cpp:360
void removeFromBoard() override
Definition bi_netsegment.cpp:280
const QMap< Uuid, BI_Via * > & getVias() const noexcept
Definition bi_netsegment.h:92
void elementsAdded(const QList< BI_Via * > &vias, const QList< BI_NetPoint * > &netPoints, const QList< BI_NetLine * > &netLines)
NetSignal * mNetSignal
Definition bi_netsegment.h:146
Uuid mUuid
Definition bi_netsegment.h:141
bool isUsed() const noexcept
Definition bi_netsegment.cpp:71
const QMap< Uuid, BI_NetLine * > & getNetLines() const noexcept
Definition bi_netsegment.h:96
BI_NetSegment & operator=(const BI_NetSegment &rhs)=delete
NetSignal * getNetSignal() const noexcept
Definition bi_netsegment.h:71
bool checkAttributesValidity() const noexcept
Definition bi_netsegment.cpp:336
bool operator==(const BI_NetSegment &rhs) noexcept
Definition bi_netsegment.h:121
void removeElements(const QList< BI_Via * > &vias, const QList< BI_NetPoint * > &netpoints, const QList< BI_NetLine * > &netlines)
Definition bi_netsegment.cpp:187
void elementsRemoved(const QList< BI_Via * > &vias, const QList< BI_NetPoint * > &netPoints, const QList< BI_NetLine * > &netLines)
QMap< Uuid, BI_Via * > mVias
Definition bi_netsegment.h:149
void addElements(const QList< BI_Via * > &vias, const QList< BI_NetPoint * > &netpoints, const QList< BI_NetLine * > &netlines)
Definition bi_netsegment.cpp:106
void setNetSignal(NetSignal *netsignal)
Definition bi_netsegment.cpp:80
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition bi_netsegment.cpp:307
const Uuid & getUuid() const noexcept
Definition bi_netsegment.h:63
BI_NetSegment(const BI_NetSegment &other)=delete
void addToBoard() override
Definition bi_netsegment.cpp:253
const QMap< Uuid, BI_NetPoint * > & getNetPoints() const noexcept
Definition bi_netsegment.h:93
QMap< Uuid, BI_NetPoint * > mNetPoints
Definition bi_netsegment.h:150
QMap< Uuid, BI_NetLine * > mNetLines
Definition bi_netsegment.h:151
The BI_Via class.
Definition bi_via.h:44
The Board class represents a PCB of a project and is always part of a circuit.
Definition board.h:73
The NetSignal class.
Definition netsignal.h:50
The SExpression class.
Definition sexpression.h:69
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition uuid.h:56
Definition occmodel.cpp:76