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 ******************************************************************************/
35namespace librepcb {
36
37/*******************************************************************************
38 * Class SI_NetPoint
39 ******************************************************************************/
40
44class SI_NetPoint final : public SI_Base, public SI_NetLineAnchor {
45 Q_OBJECT
46
47public:
48 // Signals
49 enum class Event {
50 PositionChanged,
51 JunctionChanged,
52 NetSignalNameChanged,
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 {
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
98private:
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
The Junction class represents the connection point between netlines or traces.
Definition: junction.h:47
const Point & getPosition() const noexcept
Definition: junction.h:69
const Uuid & getUuid() const noexcept
Definition: junction.h:68
The NetLineAnchor class.
Definition: netline.h:44
The NetSignal class.
Definition: netsignal.h:50
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition: point.h:79
The Schematic Item Base (SI_Base) class.
Definition: si_base.h:45
Definition: si_netline.h:44
The SI_NetLine class.
Definition: si_netline.h:65
The SI_NetPoint class.
Definition: si_netpoint.h:44
~SI_NetPoint() noexcept
Definition: si_netpoint.cpp:49
const Point & getPosition() const noexcept override
Definition: si_netpoint.h:65
bool operator!=(const SI_NetPoint &rhs) noexcept
Definition: si_netpoint.h:96
void unregisterNetLine(SI_NetLine &netline) override
Definition: si_netpoint.cpp:114
NetSignal & getNetSignalOfNetSegment() const noexcept
Definition: si_netpoint.cpp:64
QSet< SI_NetLine * > mRegisteredNetLines
all registered netlines
Definition: si_netpoint.h:104
void registerNetLine(SI_NetLine &netline) override
Definition: si_netpoint.cpp:103
SI_NetPoint & operator=(const SI_NetPoint &rhs)=delete
bool isUsed() const noexcept
Definition: si_netpoint.h:73
NetLineAnchor toNetLineAnchor() const noexcept override
Definition: si_netpoint.cpp:68
Event
Definition: si_netpoint.h:49
Slot< SI_NetPoint, Event > OnEditedSlot
Definition: si_netpoint.h:55
const QSet< SI_NetLine * > & getNetLines() const noexcept override
Definition: si_netpoint.h:89
const Junction & getJunction() const noexcept
Definition: si_netpoint.h:68
bool isOpen() const noexcept override
Definition: si_netpoint.h:74
void removeFromSchematic() override
Definition: si_netpoint.cpp:96
Junction mJunction
Definition: si_netpoint.h:101
bool isOpenLineEnd() const noexcept
Definition: si_netpoint.cpp:60
SI_NetSegment & mNetSegment
Definition: si_netpoint.h:100
Signal< SI_NetPoint, Event > onEdited
Definition: si_netpoint.h:54
void addToSchematic() override
Definition: si_netpoint.cpp:89
bool operator==(const SI_NetPoint &rhs) noexcept
Definition: si_netpoint.h:95
const Uuid & getUuid() const noexcept
Definition: si_netpoint.h:64
SI_NetPoint(const SI_NetPoint &other)=delete
SI_NetSegment & getNetSegment() const noexcept
Definition: si_netpoint.h:71
void setPosition(const Point &position) noexcept
Definition: si_netpoint.cpp:76
bool isVisibleJunction() const noexcept
Definition: si_netpoint.cpp:56
The SI_NetSegment class.
Definition: si_netsegment.h:53
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
Definition: occmodel.cpp:77