LibrePCB Developers Documentation
sgi_netlabel.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_EDITOR_SGI_NETLABEL_H
21#define LIBREPCB_EDITOR_SGI_NETLABEL_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
27
28#include <QtCore>
29#include <QtWidgets>
30
31#include <memory>
32
33/*******************************************************************************
34 * Namespace / Forward Declarations
35 ******************************************************************************/
36namespace librepcb {
37namespace editor {
38
39class GraphicsLayer;
40class IF_GraphicsLayerProvider;
41class LineGraphicsItem;
42
43/*******************************************************************************
44 * Class SGI_NetLabel
45 ******************************************************************************/
46
50class SGI_NetLabel final : public QGraphicsItem {
51public:
52 // Constructors / Destructor
53 SGI_NetLabel() = delete;
54 SGI_NetLabel(const SGI_NetLabel& other) = delete;
56 std::shared_ptr<const QSet<const NetSignal*>>
57 highlightedNetSignals) noexcept;
58 virtual ~SGI_NetLabel() noexcept;
59
60 // General Methods
61 SI_NetLabel& getNetLabel() noexcept { return mNetLabel; }
62
63 // Inherited from QGraphicsItem
64 QRectF boundingRect() const noexcept override { return mBoundingRect; }
65 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
66 QWidget* widget) noexcept override;
67
68 // Operator Overloadings
69 SGI_NetLabel& operator=(const SGI_NetLabel& rhs) = delete;
70
71private: // Methods
72 void netLabelEdited(const SI_NetLabel& obj,
73 SI_NetLabel::Event event) noexcept;
74 virtual QVariant itemChange(GraphicsItemChange change,
75 const QVariant& value) noexcept override;
76 void updatePosition() noexcept;
77 void updateRotation() noexcept;
78 void updateText() noexcept;
79 void updateAnchor() noexcept;
80
81private: // Data
83 std::shared_ptr<const QSet<const NetSignal*>> mHighlightedNetSignals;
85 std::shared_ptr<GraphicsLayer> mNetLabelLayer;
87
88 // Cached Attributes
89 QStaticText mStaticText;
90 QVector<QLineF> mOverlines;
91 QFont mFont;
93 QPointF mTextOrigin;
95
96 // Slots
98
99 // Static Stuff
100 static QVector<QLineF> sOriginCrossLines;
101};
102
103/*******************************************************************************
104 * End of File
105 ******************************************************************************/
106
107} // namespace editor
108} // namespace librepcb
109
110#endif
The NetSignal class.
Definition: netsignal.h:50
The SI_NetLabel class.
Definition: si_netlabel.h:49
Event
Definition: si_netlabel.h:54
The GraphicsLayer class represents a graphical layer used in schematics and boards.
Definition: graphicslayer.h:53
The IF_GraphicsLayerProvider class defines an interface for classes which provide layers.
Definition: graphicslayer.h:111
The LineGraphicsItem class.
Definition: linegraphicsitem.h:50
The SGI_NetLabel class.
Definition: sgi_netlabel.h:50
std::shared_ptr< const QSet< const NetSignal * > > mHighlightedNetSignals
Definition: sgi_netlabel.h:83
QRectF boundingRect() const noexcept override
Definition: sgi_netlabel.h:64
void updateText() noexcept
Definition: sgi_netlabel.cpp:192
bool mRotate180
Definition: sgi_netlabel.h:92
QVector< QLineF > mOverlines
Definition: sgi_netlabel.h:90
void updatePosition() noexcept
Definition: sgi_netlabel.cpp:184
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) noexcept override
Definition: sgi_netlabel.cpp:141
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) noexcept override
Definition: sgi_netlabel.cpp:99
SGI_NetLabel(const SGI_NetLabel &other)=delete
SI_NetLabel & getNetLabel() noexcept
Definition: sgi_netlabel.h:61
void netLabelEdited(const SI_NetLabel &obj, SI_NetLabel::Event event) noexcept
Definition: sgi_netlabel.cpp:158
void updateRotation() noexcept
Definition: sgi_netlabel.cpp:188
QFont mFont
Definition: sgi_netlabel.h:91
QScopedPointer< LineGraphicsItem > mAnchorGraphicsItem
Definition: sgi_netlabel.h:86
QStaticText mStaticText
Definition: sgi_netlabel.h:89
SGI_NetLabel & operator=(const SGI_NetLabel &rhs)=delete
std::shared_ptr< GraphicsLayer > mOriginCrossLayer
Definition: sgi_netlabel.h:84
QRectF mBoundingRect
Definition: sgi_netlabel.h:94
virtual ~SGI_NetLabel() noexcept
Definition: sgi_netlabel.cpp:92
std::shared_ptr< GraphicsLayer > mNetLabelLayer
Definition: sgi_netlabel.h:85
QPointF mTextOrigin
Definition: sgi_netlabel.h:93
static QVector< QLineF > sOriginCrossLines
Definition: sgi_netlabel.h:100
void updateAnchor() noexcept
Definition: sgi_netlabel.cpp:235
SI_NetLabel::OnEditedSlot mOnEditedSlot
Definition: sgi_netlabel.h:97
SI_NetLabel & mNetLabel
Definition: sgi_netlabel.h:82
Definition: occmodel.cpp:77