LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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_PROJECT_SI_NETPOINT_H
21 #define LIBREPCB_PROJECT_SI_NETPOINT_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../../erc/if_ercmsgprovider.h"
27 #include "../graphicsitems/sgi_netpoint.h"
28 #include "./si_netline.h"
29 #include "si_base.h"
30 
32 
33 #include <QtCore>
34 
35 /*******************************************************************************
36  * Namespace / Forward Declarations
37  ******************************************************************************/
38 namespace librepcb {
39 namespace project {
40 
41 /*******************************************************************************
42  * Class SI_NetPoint
43  ******************************************************************************/
44 
48 class SI_NetPoint final : public SI_Base,
49  public SI_NetLineAnchor,
50  public SerializableObject,
51  public IF_ErcMsgProvider {
52  Q_OBJECT
54 
55 public:
56  // Constructors / Destructor
57  SI_NetPoint() = delete;
58  SI_NetPoint(const SI_NetPoint& other) = delete;
59  SI_NetPoint(SI_NetSegment& segment, const SExpression& node);
60  SI_NetPoint(SI_NetSegment& segment, const Point& position);
61  SI_NetPoint(SI_NetSegment& segment, SI_SymbolPin& pin);
62  ~SI_NetPoint() noexcept;
63 
64  // Getters
65  const Uuid& getUuid() const noexcept { return mUuid; }
66  bool isVisibleJunction() const noexcept;
67  bool isOpenLineEnd() const noexcept;
68  SI_NetSegment& getNetSegment() const noexcept { return mNetSegment; }
69  NetSignal& getNetSignalOfNetSegment() const noexcept;
70  bool isUsed() const noexcept { return (mRegisteredNetLines.count() > 0); }
71 
72  // Setters
73  void setPosition(const Point& position) noexcept;
74 
75  // General Methods
76  void addToSchematic() override;
77  void removeFromSchematic() override;
78 
80  void serialize(SExpression& root) const override;
81 
82  // Inherited from SI_Base
83  Type_t getType() const noexcept override { return SI_Base::Type_t::NetPoint; }
84  const Point& getPosition() const noexcept override { return mPosition; }
85  QPainterPath getGrabAreaScenePx() const noexcept override;
86  void setSelected(bool selected) noexcept override;
87 
88  // Inherited from SI_NetLineAnchor
89  void registerNetLine(SI_NetLine& netline) override;
90  void unregisterNetLine(SI_NetLine& netline) override;
91  const QSet<SI_NetLine*>& getNetLines() const noexcept override {
92  return mRegisteredNetLines;
93  }
94 
95  // Operator Overloadings
96  SI_NetPoint& operator=(const SI_NetPoint& rhs) = delete;
97  bool operator==(const SI_NetPoint& rhs) noexcept { return (this == &rhs); }
98  bool operator!=(const SI_NetPoint& rhs) noexcept { return (this != &rhs); }
99 
100 private:
101  void init();
102 
103  // General
104  QScopedPointer<SGI_NetPoint> mGraphicsItem;
105  QMetaObject::Connection mHighlightChangedConnection;
106 
107  // Attributes
111 
112  // Registered Elements
113  QSet<SI_NetLine*> mRegisteredNetLines;
114 
115  // ERC Messages
117  QScopedPointer<ErcMsg> mErcMsgDeadNetPoint;
118 };
119 
120 /*******************************************************************************
121  * End of File
122  ******************************************************************************/
123 
124 } // namespace project
125 } // namespace librepcb
126 
127 #endif // LIBREPCB_PROJECT_SI_NETPOINT_H
bool operator==(const SI_NetPoint &rhs) noexcept
Definition: si_netpoint.h:97
QMetaObject::Connection mHighlightChangedConnection
Definition: si_netpoint.h:105
const QSet< SI_NetLine * > & getNetLines() const noexceptoverride
Definition: si_netpoint.h:91
#define DECLARE_ERC_MSG_CLASS_NAME(msgOwnerClassName)
Definition: if_ercmsgprovider.h:44
The SI_NetPoint class.
Definition: si_netpoint.h:48
void registerNetLine(SI_NetLine &netline) override
Definition: si_netpoint.cpp:127
bool operator!=(const SI_NetPoint &rhs) noexcept
Definition: si_netpoint.h:98
void setSelected(bool selected) noexceptoverride
Definition: si_netpoint.cpp:161
Point mPosition
Definition: si_netpoint.h:110
QSet< SI_NetLine * > mRegisteredNetLines
all registered netlines
Definition: si_netpoint.h:113
The Schematic Item Base (SI_Base) class.
Definition: si_base.h:52
QScopedPointer< SGI_NetPoint > mGraphicsItem
Definition: si_netpoint.h:104
SI_NetSegment & getNetSegment() const noexcept
Definition: si_netpoint.h:68
The IF_ErcMsgProvider class.
Definition: if_ercmsgprovider.h:62
QScopedPointer< ErcMsg > mErcMsgDeadNetPoint
The ERC message for dead netpoints.
Definition: si_netpoint.h:117
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:46
bool isUsed() const noexcept
Definition: si_netpoint.h:70
The SI_SymbolPin class.
Definition: si_symbolpin.h:58
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:81
~SI_NetPoint() noexcept
Definition: si_netpoint.cpp:71
NetSignal & getNetSignalOfNetSegment() const noexcept
Definition: si_netpoint.cpp:87
The SI_NetSegment class.
Definition: si_netsegment.h:55
void addToSchematic() override
Definition: si_netpoint.cpp:107
librepcb::project::SI_NetPoint
bool isOpenLineEnd() const noexcept
Definition: si_netpoint.cpp:83
Type_t
Definition: si_base.h:57
const Uuid & getUuid() const noexcept
Definition: si_netpoint.h:65
void setPosition(const Point &position) noexcept
Definition: si_netpoint.cpp:95
Definition: si_netline.h:46
bool isVisibleJunction() const noexcept
Definition: si_netpoint.cpp:79
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: si_netpoint.cpp:148
const Point & getPosition() const noexceptoverride
Definition: si_netpoint.h:84
The NetSignal class.
Definition: netsignal.h:56
SI_NetSegment & mNetSegment
Definition: si_netpoint.h:108
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:64
void removeFromSchematic() override
Definition: si_netpoint.cpp:118
QPainterPath getGrabAreaScenePx() const noexceptoverride
Definition: si_netpoint.cpp:157
void unregisterNetLine(SI_NetLine &netline) override
Definition: si_netpoint.cpp:138
The SExpression class.
Definition: sexpression.h:60
void init()
Definition: si_netpoint.cpp:57
Uuid mUuid
Definition: si_netpoint.h:109
SI_NetPoint & operator=(const SI_NetPoint &rhs)=delete
Type_t getType() const noexceptoverride
Definition: si_netpoint.h:83