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  ******************************************************************************/
35 namespace librepcb {
36 
37 class BI_NetLine;
38 class BI_NetSegment;
39 class Layer;
40 class NetSignal;
41 
42 /*******************************************************************************
43  * Class BI_NetLineAnchor
44  ******************************************************************************/
45 
47 public:
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 
71 class BI_NetLine final : public BI_Base {
72  Q_OBJECT
73 
74 public:
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(const BI_NetLineAnchor& firstPoint) const
102  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 
118 private:
119  BI_NetLineAnchor* getAnchor(const TraceAnchor& anchor);
120 
121  // General
124  QMetaObject::Connection mNetSignalNameChangedConnection;
125 
126  // References
129 };
130 
131 /*******************************************************************************
132  * End of File
133  ******************************************************************************/
134 
135 } // namespace librepcb
136 
137 #endif
The BI_NetLine class.
Definition: bi_netline.h:71
virtual void unregisterNetLine(BI_NetLine &netline)=0
const Layer & getLayer() const noexcept
Definition: bi_netline.h:97
UnsignedLength getMedianLineWidth() const noexcept
Definition: bi_netline.cpp:64
Signal< BI_NetLine, Event > onEdited
Definition: bi_netline.h:82
QMetaObject::Connection mNetSignalNameChangedConnection
Definition: bi_netline.h:124
virtual const Point & getPosition() const noexcept=0
virtual const QSet< BI_NetLine * > & getNetLines() const noexcept=0
Definition: occmodel.cpp:76
const Uuid & getUuid() const noexcept
Definition: bi_netline.h:96
Trace mTrace
Definition: bi_netline.h:123
The TraceAnchor class.
Definition: trace.h:45
The Layer class provides all supported geometry layers.
Definition: layer.h:40
const Trace & getTrace() const noexcept
Definition: bi_netline.h:95
Definition: bi_netline.h:46
UnsignedLength getMaxLineWidth() const noexcept
Definition: bi_netline.cpp:54
BI_NetLineAnchor * mStartPoint
Definition: bi_netline.h:127
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
virtual ~BI_NetLineAnchor() noexcept=default
virtual void registerNetLine(BI_NetLine &netline)=0
The Board Item Base (BI_Base) class.
Definition: bi_base.h:45
virtual TraceAnchor toTraceAnchor() const noexcept=0
Event
Definition: bi_netline.h:76
The BI_NetSegment class.
Definition: bi_netsegment.h:52
The Trace class represents a trace within a board.
Definition: trace.h:112
BI_NetSegment & mNetSegment
Definition: bi_netline.h:122
BI_NetLineAnchor() noexcept=default
Slot< BI_NetLine, Event > OnEditedSlot
Definition: bi_netline.h:83
The Path class represents a list of vertices connected by straight lines or circular arc segments...
Definition: path.h:57
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
const PositiveLength & getWidth() const noexcept
Definition: bi_netline.h:98
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:785
BI_NetLineAnchor * mEndPoint
Definition: bi_netline.h:128
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:56
The Length class is used to represent a length (for example 12.75 millimeters)
Definition: length.h:82
BI_NetLineAnchor & getStartPoint() const noexcept
Definition: bi_netline.h:99
BI_NetSegment * getNetSegmentOfLines() const noexcept
Definition: bi_netline.cpp:71
BI_NetLineAnchor & getEndPoint() const noexcept
Definition: bi_netline.h:100
std::vector< PositiveLength > getLineWidths() const noexcept
Definition: bi_netline.cpp:46
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:670