LibrePCB Developers Documentation
si_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_SI_NETPOINT_H
21 #define LIBREPCB_CORE_SI_NETPOINT_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../../../geometry/junction.h"
27 #include "./si_netline.h"
28 #include "si_base.h"
29 
30 #include <QtCore>
31 
32 /*******************************************************************************
33  * Namespace / Forward Declarations
34  ******************************************************************************/
35 namespace librepcb {
36 
37 /*******************************************************************************
38  * Class SI_NetPoint
39  ******************************************************************************/
40 
44 class SI_NetPoint final : public SI_Base, public SI_NetLineAnchor {
45  Q_OBJECT
46 
47 public:
48  // Signals
49  enum class Event {
53  };
56 
57  // Constructors / Destructor
58  SI_NetPoint() = delete;
59  SI_NetPoint(const SI_NetPoint& other) = delete;
60  SI_NetPoint(SI_NetSegment& segment, const Uuid& uuid, const Point& position);
61  ~SI_NetPoint() noexcept;
62 
63  // Getters
64  const Uuid& getUuid() const noexcept { return mJunction.getUuid(); }
65  const Point& getPosition() const noexcept override {
66  return mJunction.getPosition();
67  }
68  const Junction& getJunction() const noexcept { return mJunction; }
69  bool isVisibleJunction() const noexcept;
70  bool isOpenLineEnd() const noexcept;
71  SI_NetSegment& getNetSegment() const noexcept { return mNetSegment; }
72  NetSignal& getNetSignalOfNetSegment() const noexcept;
73  bool isUsed() const noexcept { return (mRegisteredNetLines.count() > 0); }
74  bool isOpen() const noexcept override {
75  return mRegisteredNetLines.count() < 2;
76  }
77  NetLineAnchor toNetLineAnchor() const noexcept override;
78 
79  // Setters
80  void setPosition(const Point& position) noexcept;
81 
82  // General Methods
83  void addToSchematic() override;
84  void removeFromSchematic() override;
85 
86  // Inherited from SI_NetLineAnchor
87  void registerNetLine(SI_NetLine& netline) override;
88  void unregisterNetLine(SI_NetLine& netline) override;
89  const QSet<SI_NetLine*>& getNetLines() const noexcept override {
90  return mRegisteredNetLines;
91  }
92 
93  // Operator Overloadings
94  SI_NetPoint& operator=(const SI_NetPoint& rhs) = delete;
95  bool operator==(const SI_NetPoint& rhs) noexcept { return (this == &rhs); }
96  bool operator!=(const SI_NetPoint& rhs) noexcept { return (this != &rhs); }
97 
98 private:
99  // Attributes
102 
103  // Registered Elements
104  QSet<SI_NetLine*> mRegisteredNetLines;
105 };
106 
107 /*******************************************************************************
108  * End of File
109  ******************************************************************************/
110 
111 } // namespace librepcb
112 
113 #endif
bool operator!=(const SI_NetPoint &rhs) noexcept
Definition: si_netpoint.h:96
NetLineAnchor toNetLineAnchor() const noexcept override
Definition: si_netpoint.cpp:68
void registerNetLine(SI_NetLine &netline) override
Definition: si_netpoint.cpp:103
QSet< SI_NetLine * > mRegisteredNetLines
all registered netlines
Definition: si_netpoint.h:104
SI_NetSegment & mNetSegment
Definition: si_netpoint.h:100
The Junction class represents the connection point between netlines or traces.
Definition: junction.h:47
Definition: occmodel.cpp:76
bool isOpenLineEnd() const noexcept
Definition: si_netpoint.cpp:60
bool operator==(const SI_NetPoint &rhs) noexcept
Definition: si_netpoint.h:95
~SI_NetPoint() noexcept
Definition: si_netpoint.cpp:49
void removeFromSchematic() override
Definition: si_netpoint.cpp:96
The Schematic Item Base (SI_Base) class.
Definition: si_base.h:45
NetSignal & getNetSignalOfNetSegment() const noexcept
Definition: si_netpoint.cpp:64
Definition: si_netline.h:44
SI_NetPoint & operator=(const SI_NetPoint &rhs)=delete
void setPosition(const Point &position) noexcept
Definition: si_netpoint.cpp:76
void unregisterNetLine(SI_NetLine &netline) override
Definition: si_netpoint.cpp:114
const Point & getPosition() const noexcept override
Definition: si_netpoint.h:65
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
void addToSchematic() override
Definition: si_netpoint.cpp:89
Slot< SI_NetPoint, Event > OnEditedSlot
Definition: si_netpoint.h:55
const Uuid & getUuid() const noexcept
Definition: si_netpoint.h:64
const Uuid & getUuid() const noexcept
Definition: junction.h:68
The SI_NetPoint class.
Definition: si_netpoint.h:44
Signal< SI_NetPoint, Event > onEdited
Definition: si_netpoint.h:54
The NetSignal class.
Definition: netsignal.h:50
Junction mJunction
Definition: si_netpoint.h:101
SI_NetSegment & getNetSegment() const noexcept
Definition: si_netpoint.h:71
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
bool isUsed() const noexcept
Definition: si_netpoint.h:73
bool isVisibleJunction() const noexcept
Definition: si_netpoint.cpp:56
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:56
const QSet< SI_NetLine * > & getNetLines() const noexcept override
Definition: si_netpoint.h:89
The SI_NetLine class.
Definition: si_netline.h:65
Event
Definition: si_netpoint.h:49
The NetLineAnchor class.
Definition: netline.h:43
bool isOpen() const noexcept override
Definition: si_netpoint.h:74
const Junction & getJunction() const noexcept
Definition: si_netpoint.h:68
The SI_NetSegment class.
Definition: si_netsegment.h:53
const Point & getPosition() const noexcept
Definition: junction.h:69