LibrePCB Developers Documentation
si_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_SI_NETLINE_H
21 #define LIBREPCB_CORE_SI_NETLINE_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../../../geometry/netline.h"
27 #include "si_base.h"
28 
29 #include <QtCore>
30 
31 /*******************************************************************************
32  * Namespace / Forward Declarations
33  ******************************************************************************/
34 namespace librepcb {
35 
36 class NetSignal;
37 class SI_NetLine;
38 class SI_NetSegment;
39 
40 /*******************************************************************************
41  * Class SI_NetLineAnchor
42  ******************************************************************************/
43 
45 public:
46  SI_NetLineAnchor() noexcept = default;
47  virtual ~SI_NetLineAnchor() noexcept = default;
48 
49  virtual void registerNetLine(SI_NetLine& netline) = 0;
50  virtual void unregisterNetLine(SI_NetLine& netline) = 0;
51  virtual const QSet<SI_NetLine*>& getNetLines() const noexcept = 0;
52  virtual const Point& getPosition() const noexcept = 0;
53  virtual bool isOpen() const noexcept = 0;
54 
55  virtual NetLineAnchor toNetLineAnchor() const noexcept = 0;
56 };
57 
58 /*******************************************************************************
59  * Class SI_NetLine
60  ******************************************************************************/
61 
65 class SI_NetLine final : public SI_Base {
66  Q_OBJECT
67 
68 public:
69  // Signals
70  enum class Event {
71  PositionsChanged,
72  NetSignalNameChanged,
73  };
76 
77  // Constructors / Destructor
78  SI_NetLine() = delete;
79  SI_NetLine(const SI_NetLine& other) = delete;
80  SI_NetLine(SI_NetSegment& segment, const Uuid& uuid,
81  SI_NetLineAnchor& startPoint, SI_NetLineAnchor& endPoint,
82  const UnsignedLength& width);
83  ~SI_NetLine() noexcept;
84 
85  // Getters
86  SI_NetSegment& getNetSegment() const noexcept { return mNetSegment; }
87  const NetLine& getNetLine() const noexcept { return mNetLine; }
88  const Uuid& getUuid() const noexcept { return mNetLine.getUuid(); }
89  const UnsignedLength& getWidth() const noexcept {
90  return mNetLine.getWidth();
91  }
92  SI_NetLineAnchor& getStartPoint() const noexcept { return *mStartPoint; }
93  SI_NetLineAnchor& getEndPoint() const noexcept { return *mEndPoint; }
94  SI_NetLineAnchor* getOtherPoint(
95  const SI_NetLineAnchor& firstPoint) const noexcept;
96  NetSignal& getNetSignalOfNetSegment() const noexcept;
97 
98  // Setters
99  void setWidth(const UnsignedLength& width) noexcept;
100 
101  // General Methods
102  void addToSchematic() override;
103  void removeFromSchematic() override;
104  void updatePositions() noexcept;
105 
106  // Operator Overloadings
107  SI_NetLine& operator=(const SI_NetLine& rhs) = delete;
108 
109 private: // Data
112 
113  // References
116 };
117 
118 /*******************************************************************************
119  * End of File
120  ******************************************************************************/
121 
122 } // namespace librepcb
123 
124 #endif
virtual NetLineAnchor toNetLineAnchor() const noexcept=0
NetLine mNetLine
Definition: si_netline.h:111
SI_NetLineAnchor * mStartPoint
Definition: si_netline.h:114
SI_NetSegment & mNetSegment
Definition: si_netline.h:110
The NetLine class represents a net line within a schematic.
Definition: netline.h:109
Definition: occmodel.cpp:77
virtual void registerNetLine(SI_NetLine &netline)=0
SI_NetLineAnchor & getStartPoint() const noexcept
Definition: si_netline.h:92
The Schematic Item Base (SI_Base) class.
Definition: si_base.h:45
virtual void unregisterNetLine(SI_NetLine &netline)=0
virtual ~SI_NetLineAnchor() noexcept=default
Definition: si_netline.h:44
virtual const Point & getPosition() const noexcept=0
const Uuid & getUuid() const noexcept
Definition: si_netline.h:88
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:79
SI_NetLineAnchor() noexcept=default
The NetSignal class.
Definition: netsignal.h:50
virtual bool isOpen() const noexcept=0
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
const NetLine & getNetLine() const noexcept
Definition: si_netline.h:87
Event
Definition: si_netline.h:70
virtual const QSet< SI_NetLine * > & getNetLines() const noexcept=0
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
The SI_NetLine class.
Definition: si_netline.h:65
Slot< SI_NetLine, Event > OnEditedSlot
Definition: si_netline.h:75
const UnsignedLength & getWidth() const noexcept
Definition: si_netline.h:89
The NetLineAnchor class.
Definition: netline.h:44
Signal< SI_NetLine, Event > onEdited
Definition: si_netline.h:74
The SI_NetSegment class.
Definition: si_netsegment.h:53
SI_NetLineAnchor & getEndPoint() const noexcept
Definition: si_netline.h:93
SI_NetLineAnchor * mEndPoint
Definition: si_netline.h:115
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:696