LibrePCB Developers Documentation
Loading...
Searching...
No Matches
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 {
37
38class NetSignal;
39
40namespace editor {
41
42class GraphicsLayer;
43class GraphicsLayerList;
44class LineGraphicsItem;
45
46/*******************************************************************************
47 * Class SGI_NetLabel
48 ******************************************************************************/
49
53class SGI_NetLabel final : public QGraphicsItem {
54public:
55 // Constructors / Destructor
56 SGI_NetLabel() = delete;
57 SGI_NetLabel(const SGI_NetLabel& other) = delete;
58 SGI_NetLabel(SI_NetLabel& netlabel, const GraphicsLayerList& layers,
59 std::shared_ptr<const QSet<const NetSignal*>>
60 highlightedNetSignals) noexcept;
61 virtual ~SGI_NetLabel() noexcept;
62
63 // General Methods
64 SI_NetLabel& getNetLabel() noexcept { return mNetLabel; }
65
66 // Inherited from QGraphicsItem
67 QRectF boundingRect() const noexcept override { return mBoundingRect; }
68 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
69 QWidget* widget) noexcept override;
70
71 // Operator Overloadings
72 SGI_NetLabel& operator=(const SGI_NetLabel& rhs) = delete;
73
74private: // Methods
75 void netLabelEdited(const SI_NetLabel& obj,
76 SI_NetLabel::Event event) noexcept;
77 virtual QVariant itemChange(GraphicsItemChange change,
78 const QVariant& value) noexcept override;
79 void updatePosition() noexcept;
80 void updateRotation() noexcept;
81 void updateText() noexcept;
82 void updateAnchor() noexcept;
83
84private: // Data
86 std::shared_ptr<const QSet<const NetSignal*>> mHighlightedNetSignals;
88 std::shared_ptr<const GraphicsLayer> mNetLabelLayer;
90
91 // Cached Attributes
92 QStaticText mStaticText;
93 QVector<QLineF> mOverlines;
94 QFont mFont;
96 QPointF mTextOrigin;
98
99 // Slots
101
102 // Static Stuff
103 static QVector<QLineF> sOriginCrossLines;
104};
105
106/*******************************************************************************
107 * End of File
108 ******************************************************************************/
109
110} // namespace editor
111} // namespace librepcb
112
113#endif
The NetSignal class.
Definition netsignal.h:50
The SI_NetLabel class.
Definition si_netlabel.h:48
Event
Definition si_netlabel.h:53
The GraphicsLayer class represents a graphical layer used in schematics and boards.
Definition graphicslayer.h:53
The GraphicsLayerList class.
Definition graphicslayerlist.h:48
The LineGraphicsItem class.
Definition linegraphicsitem.h:50
The SGI_NetLabel class.
Definition sgi_netlabel.h:53
std::shared_ptr< const QSet< const NetSignal * > > mHighlightedNetSignals
Definition sgi_netlabel.h:86
QRectF boundingRect() const noexcept override
Definition sgi_netlabel.h:67
void updateText() noexcept
Definition sgi_netlabel.cpp:196
bool mRotate180
Definition sgi_netlabel.h:95
QVector< QLineF > mOverlines
Definition sgi_netlabel.h:93
void updatePosition() noexcept
Definition sgi_netlabel.cpp:188
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) noexcept override
Definition sgi_netlabel.cpp:143
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) noexcept override
Definition sgi_netlabel.cpp:100
SGI_NetLabel(const SGI_NetLabel &other)=delete
SI_NetLabel & getNetLabel() noexcept
Definition sgi_netlabel.h:64
void netLabelEdited(const SI_NetLabel &obj, SI_NetLabel::Event event) noexcept
Definition sgi_netlabel.cpp:162
void updateRotation() noexcept
Definition sgi_netlabel.cpp:192
QFont mFont
Definition sgi_netlabel.h:94
QScopedPointer< LineGraphicsItem > mAnchorGraphicsItem
Definition sgi_netlabel.h:89
QStaticText mStaticText
Definition sgi_netlabel.h:92
SGI_NetLabel & operator=(const SGI_NetLabel &rhs)=delete
std::shared_ptr< const GraphicsLayer > mNetLabelLayer
Definition sgi_netlabel.h:88
QRectF mBoundingRect
Definition sgi_netlabel.h:97
virtual ~SGI_NetLabel() noexcept
Definition sgi_netlabel.cpp:93
QPointF mTextOrigin
Definition sgi_netlabel.h:96
static QVector< QLineF > sOriginCrossLines
Definition sgi_netlabel.h:103
void updateAnchor() noexcept
Definition sgi_netlabel.cpp:239
std::shared_ptr< const GraphicsLayer > mOriginCrossLayer
Definition sgi_netlabel.h:87
SI_NetLabel::OnEditedSlot mOnEditedSlot
Definition sgi_netlabel.h:100
SI_NetLabel & mNetLabel
Definition sgi_netlabel.h:85
Definition occmodel.cpp:77
Definition uuid.h:186