LibrePCB Developers Documentation
Loading...
Searching...
No Matches
netclass.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_NETCLASS_H
21#define LIBREPCB_CORE_NETCLASS_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../types/elementname.h"
27#include "../../types/uuid.h"
28
29#include <QtCore>
30
31/*******************************************************************************
32 * Namespace / Forward Declarations
33 ******************************************************************************/
34namespace librepcb {
35
36class Circuit;
37class NetSignal;
38class SExpression;
39
40/*******************************************************************************
41 * Class NetClass
42 ******************************************************************************/
43
47class NetClass final : public QObject {
48 Q_OBJECT
49
50public:
51 // Constructors / Destructor
52 NetClass() = delete;
53 NetClass(const NetClass& other) = delete;
54 explicit NetClass(Circuit& circuit, const Uuid& uuid,
55 const ElementName& name);
56 explicit NetClass(Circuit& circuit, const SExpression& node);
57 ~NetClass() noexcept;
58
59 // Getters
60 Circuit& getCircuit() const noexcept { return mCircuit; }
61 const Uuid& getUuid() const noexcept { return mUuid; }
62 const ElementName& getName() const noexcept { return mName; }
63 const std::optional<PositiveLength>& getDefaultTraceWidth() const noexcept {
64 return mDefaultTraceWidth;
65 }
66 const std::optional<PositiveLength>& getDefaultViaDrill() const noexcept {
67 return mDefaultViaDrill;
68 }
71 }
72 const UnsignedLength& getMinCopperWidth() const noexcept {
73 return mMinCopperWidth;
74 }
75 const UnsignedLength& getMinViaDrillDiameter() const noexcept {
77 }
78 int getNetSignalCount() const noexcept {
79 return mRegisteredNetSignals.count();
80 }
81 bool isUsed() const noexcept { return (getNetSignalCount() > 0); }
82
83 // Setters
84 void setName(const ElementName& name) noexcept;
86 const std::optional<PositiveLength>& value) noexcept;
87 void setDefaultViaDrill(const std::optional<PositiveLength>& value) noexcept;
88 void setMinCopperCopperClearance(const UnsignedLength& value) noexcept;
89 void setMinCopperWidth(const UnsignedLength& value) noexcept;
90 void setMinViaDrillDiameter(const UnsignedLength& value) noexcept;
91
92 // General Methods
93 void addToCircuit();
94 void removeFromCircuit();
95 void registerNetSignal(NetSignal& signal);
96 void unregisterNetSignal(NetSignal& signal);
97
103 void serialize(SExpression& root) const;
104
105 // Operator Overloadings
106 NetClass& operator=(const NetClass& rhs) = delete;
107
108signals:
110
111private:
112 // General
115
116 // Attributes
119
120 // Design Rules
121 // Note: If `std::nullopt` (the default), the values from the corresponding
122 // board's design rules are used instead.
123 std::optional<PositiveLength> mDefaultTraceWidth;
124 std::optional<PositiveLength> mDefaultViaDrill;
125
126 // DRC Settings
127 // Note: These values only have an effect if they are higher than the
128 // corresponding values in the board's DRC settings. This ensures it is not
129 // possible to end up with rules more relaxed than what is configured in the
130 // board.
134
135 // Registered Elements
137 QHash<Uuid, NetSignal*> mRegisteredNetSignals;
138};
139
140/*******************************************************************************
141 * End of File
142 ******************************************************************************/
143
144} // namespace librepcb
145
146#endif
The Circuit class represents all electrical connections in a project (drawn in the schematics)
Definition circuit.h:72
The NetClass class.
Definition netclass.h:47
int getNetSignalCount() const noexcept
Definition netclass.h:78
void setName(const ElementName &name) noexcept
Definition netclass.cpp:103
void setDefaultTraceWidth(const std::optional< PositiveLength > &value) noexcept
Definition netclass.cpp:107
const UnsignedLength & getMinCopperWidth() const noexcept
Definition netclass.h:72
const std::optional< PositiveLength > & getDefaultViaDrill() const noexcept
Definition netclass.h:66
Circuit & mCircuit
Definition netclass.h:113
const std::optional< PositiveLength > & getDefaultTraceWidth() const noexcept
Definition netclass.h:63
void setDefaultViaDrill(const std::optional< PositiveLength > &value) noexcept
Definition netclass.cpp:112
void setMinCopperWidth(const UnsignedLength &value) noexcept
Definition netclass.cpp:126
const ElementName & getName() const noexcept
Definition netclass.h:62
Uuid mUuid
Definition netclass.h:117
bool isUsed() const noexcept
Definition netclass.h:81
ElementName mName
Definition netclass.h:118
void unregisterNetSignal(NetSignal &signal)
Definition netclass.cpp:167
UnsignedLength mMinCopperWidth
Definition netclass.h:132
std::optional< PositiveLength > mDefaultTraceWidth
Definition netclass.h:123
void registerNetSignal(NetSignal &signal)
Definition netclass.cpp:158
const UnsignedLength & getMinViaDrillDiameter() const noexcept
Definition netclass.h:75
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition netclass.cpp:175
void designRulesModified()
NetClass & operator=(const NetClass &rhs)=delete
const Uuid & getUuid() const noexcept
Definition netclass.h:61
UnsignedLength mMinViaDrillDiameter
Definition netclass.h:133
void removeFromCircuit()
Definition netclass.cpp:145
Circuit & getCircuit() const noexcept
Definition netclass.h:60
std::optional< PositiveLength > mDefaultViaDrill
Definition netclass.h:124
void setMinViaDrillDiameter(const UnsignedLength &value) noexcept
Definition netclass.cpp:130
UnsignedLength mMinCopperCopperClearance
Definition netclass.h:131
QHash< Uuid, NetSignal * > mRegisteredNetSignals
all registered netsignals
Definition netclass.h:137
NetClass(const NetClass &other)=delete
const UnsignedLength & getMinCopperCopperClearance() const noexcept
Definition netclass.h:69
bool mIsAddedToCircuit
Definition netclass.h:114
void setMinCopperCopperClearance(const UnsignedLength &value) noexcept
Definition netclass.cpp:121
void addToCircuit()
Definition netclass.cpp:138
~NetClass() noexcept
Definition netclass.cpp:94
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
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition length.h:694
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition elementname.h:84