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_pad.h"
32#include "bi_via.h"
33
34#include <QtCore>
35
36/*******************************************************************************
37 * Namespace / Forward Declarations
38 ******************************************************************************/
39namespace librepcb {
40
41class BI_Device;
42class BI_NetLineAnchor;
43class BI_Pad;
44class NetSignal;
45
46/*******************************************************************************
47 * Class BI_NetSegment
48 ******************************************************************************/
49
53class BI_NetSegment final : public BI_Base {
54 Q_OBJECT
55
56public:
57 // Constructors / Destructor
58 BI_NetSegment() = delete;
59 BI_NetSegment(const BI_NetSegment& other) = delete;
60 BI_NetSegment(Board& board, const Uuid& uuid, NetSignal* signal);
61 ~BI_NetSegment() noexcept;
62
63 // Getters
64 const Uuid& getUuid() const noexcept { return mUuid; }
65
72 NetSignal* getNetSignal() const noexcept { return mNetSignal; }
73
85 QString getNetNameToDisplay(bool fallback = false) const noexcept;
86
87 bool isUsed() const noexcept;
88
89 // Setters
90 void setNetSignal(NetSignal* netsignal);
91
92 // Element Getters
93 const QMap<Uuid, BI_Pad*>& getPads() const noexcept { return mPads; }
94 const QMap<Uuid, BI_Via*>& getVias() const noexcept { return mVias; }
95 const QMap<Uuid, BI_NetPoint*>& getNetPoints() const noexcept {
96 return mNetPoints;
97 }
98 const QMap<Uuid, BI_NetLine*>& getNetLines() const noexcept {
99 return mNetLines;
100 }
101
102 // NetPoint+NetLine Methods
103 void addElements(const QList<BI_Pad*>& pads, const QList<BI_Via*>& vias,
104 const QList<BI_NetPoint*>& netpoints,
105 const QList<BI_NetLine*>& netlines);
106 void removeElements(const QList<BI_Pad*>& pads, const QList<BI_Via*>& vias,
107 const QList<BI_NetPoint*>& netpoints,
108 const QList<BI_NetLine*>& netlines);
109
110 // General Methods
111 void addToBoard() override;
112 void removeFromBoard() override;
113
119 void serialize(SExpression& root) const;
120
121 // Operator Overloadings
122 BI_NetSegment& operator=(const BI_NetSegment& rhs) = delete;
123 bool operator==(const BI_NetSegment& rhs) noexcept { return (this == &rhs); }
124 bool operator!=(const BI_NetSegment& rhs) noexcept { return (this != &rhs); }
125
126signals:
127 void elementsAdded(const QList<BI_Pad*>& pads, const QList<BI_Via*>& vias,
128 const QList<BI_NetPoint*>& netPoints,
129 const QList<BI_NetLine*>& netLines);
130 void elementsRemoved(const QList<BI_Pad*>& pads, const QList<BI_Via*>& vias,
131 const QList<BI_NetPoint*>& netPoints,
132 const QList<BI_NetLine*>& netLines);
133
134private:
135 bool checkAttributesValidity() const noexcept;
136 bool areAllNetPointsConnectedTogether() const noexcept;
138 QSet<const BI_Via*>& vias,
139 QSet<const BI_Pad*>& pads,
140 QSet<const BI_NetPoint*>& points,
141 QSet<const BI_NetLine*>& lines,
142 int& boardPads) const noexcept;
143
144 // Attributes
146
151
152 // Items
157};
158
159/*******************************************************************************
160 * End of File
161 ******************************************************************************/
162
163} // namespace librepcb
164
165#endif
The Board Item Base (BI_Base) class.
Definition bi_base.h:45
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:53
bool operator!=(const BI_NetSegment &rhs) noexcept
Definition bi_netsegment.h:124
~BI_NetSegment() noexcept
Definition bi_netsegment.cpp:52
bool areAllNetPointsConnectedTogether() const noexcept
Definition bi_netsegment.cpp:397
void elementsRemoved(const QList< BI_Pad * > &pads, const QList< BI_Via * > &vias, const QList< BI_NetPoint * > &netPoints, const QList< BI_NetLine * > &netLines)
QString getNetNameToDisplay(bool fallback=false) const noexcept
Definition bi_netsegment.cpp:66
void removeFromBoard() override
Definition bi_netsegment.cpp:326
const QMap< Uuid, BI_Via * > & getVias() const noexcept
Definition bi_netsegment.h:94
NetSignal * mNetSignal
Definition bi_netsegment.h:150
Uuid mUuid
Definition bi_netsegment.h:145
bool isUsed() const noexcept
Definition bi_netsegment.cpp:71
const QMap< Uuid, BI_NetLine * > & getNetLines() const noexcept
Definition bi_netsegment.h:98
void addElements(const QList< BI_Pad * > &pads, const QList< BI_Via * > &vias, const QList< BI_NetPoint * > &netpoints, const QList< BI_NetLine * > &netlines)
Definition bi_netsegment.cpp:106
BI_NetSegment & operator=(const BI_NetSegment &rhs)=delete
NetSignal * getNetSignal() const noexcept
Definition bi_netsegment.h:72
bool checkAttributesValidity() const noexcept
Definition bi_netsegment.cpp:392
QMap< Uuid, BI_Pad * > mPads
Definition bi_netsegment.h:153
bool operator==(const BI_NetSegment &rhs) noexcept
Definition bi_netsegment.h:123
QMap< Uuid, BI_Via * > mVias
Definition bi_netsegment.h:154
void removeElements(const QList< BI_Pad * > &pads, const QList< BI_Via * > &vias, const QList< BI_NetPoint * > &netpoints, const QList< BI_NetLine * > &netlines)
Definition bi_netsegment.cpp:211
void elementsAdded(const QList< BI_Pad * > &pads, const QList< BI_Via * > &vias, const QList< BI_NetPoint * > &netPoints, const QList< BI_NetLine * > &netLines)
void setNetSignal(NetSignal *netsignal)
Definition bi_netsegment.cpp:80
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition bi_netsegment.cpp:358
const Uuid & getUuid() const noexcept
Definition bi_netsegment.h:64
BI_NetSegment(const BI_NetSegment &other)=delete
void findAllConnectedNetPoints(const BI_NetLineAnchor &p, QSet< const BI_Via * > &vias, QSet< const BI_Pad * > &pads, QSet< const BI_NetPoint * > &points, QSet< const BI_NetLine * > &lines, int &boardPads) const noexcept
Definition bi_netsegment.cpp:422
void addToBoard() override
Definition bi_netsegment.cpp:294
const QMap< Uuid, BI_NetPoint * > & getNetPoints() const noexcept
Definition bi_netsegment.h:95
QMap< Uuid, BI_NetPoint * > mNetPoints
Definition bi_netsegment.h:155
const QMap< Uuid, BI_Pad * > & getPads() const noexcept
Definition bi_netsegment.h:93
QMap< Uuid, BI_NetLine * > mNetLines
Definition bi_netsegment.h:156
A pad in a board (either standalone or from a footprint)
Definition bi_pad.h:49
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:74
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:77