LibrePCB Developers Documentation
bi_netline.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_NETLINE_H
21#define LIBREPCB_CORE_BI_NETLINE_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../../geometry/path.h"
27#include "../../../geometry/trace.h"
28#include "bi_base.h"
29
30#include <QtCore>
31
32/*******************************************************************************
33 * Namespace / Forward Declarations
34 ******************************************************************************/
35namespace librepcb {
36
37class BI_NetLine;
38class BI_NetSegment;
39class Layer;
40class NetSignal;
41
42/*******************************************************************************
43 * Class BI_NetLineAnchor
44 ******************************************************************************/
45
47public:
48 BI_NetLineAnchor() noexcept = default;
49 virtual ~BI_NetLineAnchor() noexcept = default;
50
51 virtual void registerNetLine(BI_NetLine& netline) = 0;
52 virtual void unregisterNetLine(BI_NetLine& netline) = 0;
53 virtual const QSet<BI_NetLine*>& getNetLines() const noexcept = 0;
54 virtual const Point& getPosition() const noexcept = 0;
55
56 virtual TraceAnchor toTraceAnchor() const noexcept = 0;
57
58 std::vector<PositiveLength> getLineWidths() const noexcept;
59 UnsignedLength getMaxLineWidth() const noexcept;
60 UnsignedLength getMedianLineWidth() const noexcept;
61 BI_NetSegment* getNetSegmentOfLines() const noexcept;
62};
63
64/*******************************************************************************
65 * Class BI_NetLine
66 ******************************************************************************/
67
71class BI_NetLine final : public BI_Base {
72 Q_OBJECT
73
74public:
75 // Signals
76 enum class Event {
77 PositionsChanged,
78 LayerChanged,
79 WidthChanged,
80 NetSignalNameChanged,
81 };
84
85 // Constructors / Destructor
86 BI_NetLine() = delete;
87 BI_NetLine(const BI_NetLine& other) = delete;
88 BI_NetLine(BI_NetSegment& segment, const Uuid& uuid,
89 BI_NetLineAnchor& startPoint, BI_NetLineAnchor& endPoint,
90 const Layer& layer, const PositiveLength& width);
91 ~BI_NetLine() noexcept;
92
93 // Getters
94 BI_NetSegment& getNetSegment() const noexcept { return mNetSegment; }
95 const Trace& getTrace() const noexcept { return mTrace; }
96 const Uuid& getUuid() const noexcept { return mTrace.getUuid(); }
97 const Layer& getLayer() const noexcept { return mTrace.getLayer(); }
98 const PositiveLength& getWidth() const noexcept { return mTrace.getWidth(); }
99 BI_NetLineAnchor& getStartPoint() const noexcept { return *mStartPoint; }
100 BI_NetLineAnchor& getEndPoint() const noexcept { return *mEndPoint; }
101 BI_NetLineAnchor* getOtherPoint(
102 const BI_NetLineAnchor& firstPoint) const noexcept;
103 Path getSceneOutline(const Length& expansion = Length(0)) const noexcept;
104 UnsignedLength getLength() const noexcept;
105
106 // Setters
107 void setLayer(const Layer& layer);
108 void setWidth(const PositiveLength& width) noexcept;
109
110 // General Methods
111 void addToBoard() override;
112 void removeFromBoard() override;
113 void updatePositions() noexcept;
114
115 // Operator Overloadings
116 BI_NetLine& operator=(const BI_NetLine& rhs) = delete;
117
118private:
119 BI_NetLineAnchor* getAnchor(const TraceAnchor& anchor);
120
121 // General
122 BI_NetSegment& mNetSegment;
123 Trace mTrace;
124 QMetaObject::Connection mNetSignalNameChangedConnection;
125
126 // References
127 BI_NetLineAnchor* mStartPoint;
129};
130
131/*******************************************************************************
132 * End of File
133 ******************************************************************************/
134
135} // namespace librepcb
136
137#endif
The Board Item Base (BI_Base) class.
Definition: bi_base.h:45
Definition: bi_netline.h:46
std::vector< PositiveLength > getLineWidths() const noexcept
Definition: bi_netline.cpp:46
virtual TraceAnchor toTraceAnchor() const noexcept=0
virtual const Point & getPosition() const noexcept=0
BI_NetSegment * getNetSegmentOfLines() const noexcept
Definition: bi_netline.cpp:71
BI_NetLineAnchor() noexcept=default
virtual void unregisterNetLine(BI_NetLine &netline)=0
UnsignedLength getMedianLineWidth() const noexcept
Definition: bi_netline.cpp:64
UnsignedLength getMaxLineWidth() const noexcept
Definition: bi_netline.cpp:54
virtual void registerNetLine(BI_NetLine &netline)=0
virtual const QSet< BI_NetLine * > & getNetLines() const noexcept=0
The BI_NetLine class.
Definition: bi_netline.h:71
const PositiveLength & getWidth() const noexcept
Definition: bi_netline.h:98
BI_NetLineAnchor & getEndPoint() const noexcept
Definition: bi_netline.h:100
Event
Definition: bi_netline.h:76
Signal< BI_NetLine, Event > onEdited
Definition: bi_netline.h:82
BI_NetLineAnchor & getStartPoint() const noexcept
Definition: bi_netline.h:99
const Layer & getLayer() const noexcept
Definition: bi_netline.h:97
Slot< BI_NetLine, Event > OnEditedSlot
Definition: bi_netline.h:83
const Uuid & getUuid() const noexcept
Definition: bi_netline.h:96
const Trace & getTrace() const noexcept
Definition: bi_netline.h:95
BI_NetLine(const BI_NetLine &other)=delete
The BI_NetSegment class.
Definition: bi_netsegment.h:52
The Layer class provides all supported geometry layers.
Definition: layer.h:42
The Length class is used to represent a length (for example 12.75 millimeters)
Definition: length.h:83
The Path class represents a list of vertices connected by straight lines or circular arc segments.
Definition: path.h:58
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition: point.h:79
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
The TraceAnchor class.
Definition: trace.h:46
The Trace class represents a trace within a board.
Definition: trace.h:113
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
Definition: occmodel.cpp:77
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:812
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:696