LibrePCB Developers Documentation
bi_netpoint.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_NETPOINT_H
21 #define LIBREPCB_CORE_BI_NETPOINT_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../../../geometry/junction.h"
27 #include "bi_base.h"
28 #include "bi_netline.h"
29 
30 #include <QtCore>
31 
32 /*******************************************************************************
33  * Namespace / Forward Declarations
34  ******************************************************************************/
35 namespace librepcb {
36 
37 class Layer;
38 
39 /*******************************************************************************
40  * Class BI_NetPoint
41  ******************************************************************************/
42 
46 class BI_NetPoint final : public BI_Base, public BI_NetLineAnchor {
47  Q_OBJECT
48 
49 public:
50  // Signals
51  enum class Event {
56  };
59 
60  // Constructors / Destructor
61  BI_NetPoint() = delete;
62  BI_NetPoint(const BI_NetPoint& other) = delete;
63  BI_NetPoint(BI_NetSegment& segment, const Uuid& uuid, const Point& position);
64  ~BI_NetPoint() noexcept;
65 
66  // Getters
67  const Uuid& getUuid() const noexcept { return mJunction.getUuid(); }
68  const Point& getPosition() const noexcept override {
69  return mJunction.getPosition();
70  }
71  const Junction& getJunction() const noexcept { return mJunction; }
72  BI_NetSegment& getNetSegment() const noexcept { return mNetSegment; }
73  bool isUsed() const noexcept { return (mRegisteredNetLines.count() > 0); }
74  const Layer* getLayerOfTraces() const noexcept { return mLayerOfTraces; }
75  const UnsignedLength& getMaxTraceWidth() const noexcept {
76  return mMaxTraceWidth;
77  }
78  TraceAnchor toTraceAnchor() const noexcept override;
79 
80  // Setters
81  void setPosition(const Point& position) noexcept;
82 
83  // General Methods
84  void addToBoard() override;
85  void removeFromBoard() override;
86 
87  // Inherited from BI_NetLineAnchor
88  void registerNetLine(BI_NetLine& netline) override;
89  void unregisterNetLine(BI_NetLine& netline) override;
90  const QSet<BI_NetLine*>& getNetLines() const noexcept override {
91  return mRegisteredNetLines;
92  }
93 
94  // Operator Overloadings
95  BI_NetPoint& operator=(const BI_NetPoint& rhs) = delete;
96  bool operator==(const BI_NetPoint& rhs) noexcept { return (this == &rhs); }
97  bool operator!=(const BI_NetPoint& rhs) noexcept { return (this != &rhs); }
98 
99 private: // Methods
100  void netLineEdited(const BI_NetLine& obj, BI_NetLine::Event event) noexcept;
101  void updateLayerOfTraces() noexcept;
102  void updateMaxTraceWidth() noexcept;
103 
104 private: // Data
107  QMetaObject::Connection mNetSignalNameChangedConnection;
108 
109  // Cached Attributes
112 
113  // Registered Elements
114  QSet<BI_NetLine*> mRegisteredNetLines;
115 
116  // Slots
118 };
119 
120 /*******************************************************************************
121  * End of File
122  ******************************************************************************/
123 
124 } // namespace librepcb
125 
126 #endif
The BI_NetLine class.
Definition: bi_netline.h:71
BI_NetSegment & getNetSegment() const noexcept
Definition: bi_netpoint.h:72
bool operator==(const BI_NetPoint &rhs) noexcept
Definition: bi_netpoint.h:96
Slot< BI_NetPoint, Event > OnEditedSlot
Definition: bi_netpoint.h:58
bool isUsed() const noexcept
Definition: bi_netpoint.h:73
const Uuid & getUuid() const noexcept
Definition: bi_netpoint.h:67
BI_NetLine::OnEditedSlot mOnNetLineEditedSlot
Definition: bi_netpoint.h:117
Junction mJunction
Definition: bi_netpoint.h:106
The Junction class represents the connection point between netlines or traces.
Definition: junction.h:47
Definition: occmodel.cpp:77
The TraceAnchor class.
Definition: trace.h:46
void updateLayerOfTraces() noexcept
Definition: bi_netpoint.cpp:169
void addToBoard() override
Definition: bi_netpoint.cpp:83
The Layer class provides all supported geometry layers.
Definition: layer.h:40
void updateMaxTraceWidth() noexcept
Definition: bi_netpoint.cpp:180
~BI_NetPoint() noexcept
Definition: bi_netpoint.cpp:51
const Layer * mLayerOfTraces
Definition: bi_netpoint.h:110
BI_NetPoint & operator=(const BI_NetPoint &rhs)=delete
TraceAnchor toTraceAnchor() const noexcept override
Definition: bi_netpoint.cpp:58
Definition: bi_netline.h:46
void unregisterNetLine(BI_NetLine &netline) override
Definition: bi_netpoint.cpp:141
UnsignedLength mMaxTraceWidth
Definition: bi_netpoint.h:111
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:79
const Junction & getJunction() const noexcept
Definition: bi_netpoint.h:71
The Board Item Base (BI_Base) class.
Definition: bi_base.h:45
Event
Definition: bi_netline.h:76
The BI_NetSegment class.
Definition: bi_netsegment.h:52
Event
Definition: bi_netpoint.h:51
const Uuid & getUuid() const noexcept
Definition: junction.h:68
The BI_NetPoint class.
Definition: bi_netpoint.h:46
QSet< BI_NetLine * > mRegisteredNetLines
all registered netlines
Definition: bi_netpoint.h:114
void removeFromBoard() override
Definition: bi_netpoint.cpp:102
const QSet< BI_NetLine * > & getNetLines() const noexcept override
Definition: bi_netpoint.h:90
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
void setPosition(const Point &position) noexcept
Definition: bi_netpoint.cpp:66
const Layer * getLayerOfTraces() const noexcept
Definition: bi_netpoint.h:74
const Point & getPosition() const noexcept override
Definition: bi_netpoint.h:68
QMetaObject::Connection mNetSignalNameChangedConnection
Definition: bi_netpoint.h:107
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
bool operator!=(const BI_NetPoint &rhs) noexcept
Definition: bi_netpoint.h:97
Signal< BI_NetPoint, Event > onEdited
Definition: bi_netpoint.h:57
void registerNetLine(BI_NetLine &netline) override
Definition: bi_netpoint.cpp:120
void netLineEdited(const BI_NetLine &obj, BI_NetLine::Event event) noexcept
Definition: bi_netpoint.cpp:157
BI_NetSegment & mNetSegment
Definition: bi_netpoint.h:105
const UnsignedLength & getMaxTraceWidth() const noexcept
Definition: bi_netpoint.h:75
const Point & getPosition() const noexcept
Definition: junction.h:69
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:696