LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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_PROJECT_BI_NETPOINT_H
21 #define LIBREPCB_PROJECT_BI_NETPOINT_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../../erc/if_ercmsgprovider.h"
27 #include "../graphicsitems/bgi_netpoint.h"
28 #include "./bi_netline.h"
29 #include "bi_base.h"
30 
32 
33 #include <QtCore>
34 
35 /*******************************************************************************
36  * Namespace / Forward Declarations
37  ******************************************************************************/
38 namespace librepcb {
39 namespace project {
40 
41 /*******************************************************************************
42  * Class BI_NetPoint
43  ******************************************************************************/
44 
48 class BI_NetPoint final : public BI_Base,
49  public BI_NetLineAnchor,
50  public SerializableObject,
51  public IF_ErcMsgProvider {
52  Q_OBJECT
54 
55 public:
56  // Constructors / Destructor
57  BI_NetPoint() = delete;
58  BI_NetPoint(const BI_NetPoint& other) = delete;
59  BI_NetPoint(BI_NetSegment& segment, const BI_NetPoint& other);
60  BI_NetPoint(BI_NetSegment& segment, const SExpression& node);
61  BI_NetPoint(BI_NetSegment& segment, const Point& position);
62  ~BI_NetPoint() noexcept;
63 
64  // Getters
65  const Uuid& getUuid() const noexcept { return mUuid; }
66  BI_NetSegment& getNetSegment() const noexcept { return mNetSegment; }
67  NetSignal& getNetSignalOfNetSegment() const noexcept;
68  bool isUsed() const noexcept { return (mRegisteredNetLines.count() > 0); }
69  GraphicsLayer* getLayerOfLines() const noexcept;
70  bool isSelectable() const noexcept override;
71 
72  // Setters
73  void setPosition(const Point& position) noexcept;
74 
75  // General Methods
76  void addToBoard() override;
77  void removeFromBoard() override;
78 
80  void serialize(SExpression& root) const override;
81 
82  // Inherited from SI_Base
83  Type_t getType() const noexcept override { return BI_Base::Type_t::NetPoint; }
84  const Point& getPosition() const noexcept override { return mPosition; }
85  bool getIsMirrored() const noexcept override { return false; }
86  QPainterPath getGrabAreaScenePx() const noexcept override;
87  void setSelected(bool selected) noexcept override;
88 
89  // Inherited from BI_NetLineAnchor
90  void registerNetLine(BI_NetLine& netline) override;
91  void unregisterNetLine(BI_NetLine& netline) override;
92  const QSet<BI_NetLine*>& getNetLines() const noexcept override {
93  return mRegisteredNetLines;
94  }
95 
96  // Operator Overloadings
97  BI_NetPoint& operator=(const BI_NetPoint& rhs) = delete;
98  bool operator==(const BI_NetPoint& rhs) noexcept { return (this == &rhs); }
99  bool operator!=(const BI_NetPoint& rhs) noexcept { return (this != &rhs); }
100 
101 private:
102  void init();
103 
104  // General
105  QScopedPointer<BGI_NetPoint> mGraphicsItem;
106  QMetaObject::Connection mHighlightChangedConnection;
107 
108  // Attributes
112 
113  // Registered Elements
114  QSet<BI_NetLine*> mRegisteredNetLines;
115 
116  // ERC Messages
118  QScopedPointer<ErcMsg> mErcMsgDeadNetPoint;
119 };
120 
121 /*******************************************************************************
122  * End of File
123  ******************************************************************************/
124 
125 } // namespace project
126 } // namespace librepcb
127 
128 #endif // LIBREPCB_PROJECT_BI_NETPOINT_H
The GraphicsLayer class represents a graphical layer used in schematics and boards.
Definition: graphicslayer.h:54
#define DECLARE_ERC_MSG_CLASS_NAME(msgOwnerClassName)
Definition: if_ercmsgprovider.h:44
QPainterPath getGrabAreaScenePx() const noexceptoverride
Definition: bi_netpoint.cpp:168
The BI_NetPoint class.
Definition: bi_netpoint.h:48
void init()
Definition: bi_netpoint.cpp:65
QScopedPointer< ErcMsg > mErcMsgDeadNetPoint
The ERC message for dead netpoints.
Definition: bi_netpoint.h:118
void addToBoard() override
Definition: bi_netpoint.cpp:114
BI_NetSegment & mNetSegment
Definition: bi_netpoint.h:109
QMetaObject::Connection mHighlightChangedConnection
Definition: bi_netpoint.h:106
Type_t
Definition: bi_base.h:57
The IF_ErcMsgProvider class.
Definition: if_ercmsgprovider.h:62
BI_NetPoint & operator=(const BI_NetPoint &rhs)=delete
bool operator!=(const BI_NetPoint &rhs) noexcept
Definition: bi_netpoint.h:99
NetSignal & getNetSignalOfNetSegment() const noexcept
Definition: bi_netpoint.cpp:87
void unregisterNetLine(BI_NetLine &netline) override
Definition: bi_netpoint.cpp:149
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:46
void setSelected(bool selected) noexceptoverride
Definition: bi_netpoint.cpp:176
const Uuid & getUuid() const noexcept
Definition: bi_netpoint.h:65
~BI_NetPoint() noexcept
Definition: bi_netpoint.cpp:79
The BI_NetSegment class.
Definition: bi_netsegment.h:59
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:81
GraphicsLayer * getLayerOfLines() const noexcept
Definition: bi_netpoint.cpp:91
BI_NetSegment & getNetSegment() const noexcept
Definition: bi_netpoint.h:66
The Board Item Base (BI_Base) class.
Definition: bi_base.h:52
librepcb::project::BI_NetPoint
bool isUsed() const noexcept
Definition: bi_netpoint.h:68
void removeFromBoard() override
Definition: bi_netpoint.cpp:126
QSet< BI_NetLine * > mRegisteredNetLines
all registered netlines
Definition: bi_netpoint.h:114
Definition: bi_netline.h:51
Uuid mUuid
Definition: bi_netpoint.h:110
Type_t getType() const noexceptoverride
Definition: bi_netpoint.h:83
QScopedPointer< BGI_NetPoint > mGraphicsItem
Definition: bi_netpoint.h:105
The NetSignal class.
Definition: netsignal.h:56
bool getIsMirrored() const noexceptoverride
Definition: bi_netpoint.h:85
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
bool isSelectable() const noexceptoverride
Definition: bi_netpoint.cpp:172
void setPosition(const Point &position) noexcept
Definition: bi_netpoint.cpp:101
const QSet< BI_NetLine * > & getNetLines() const noexceptoverride
Definition: bi_netpoint.h:92
The BI_NetLine class.
Definition: bi_netline.h:74
The SExpression class.
Definition: sexpression.h:60
void registerNetLine(BI_NetLine &netline) override
Definition: bi_netpoint.cpp:136
bool operator==(const BI_NetPoint &rhs) noexcept
Definition: bi_netpoint.h:98
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: bi_netpoint.cpp:159
Point mPosition
Definition: bi_netpoint.h:111
const Point & getPosition() const noexceptoverride
Definition: bi_netpoint.h:84