LibrePCB Developers Documentation
Loading...
Searching...
No Matches
sgi_buslabel.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_BUSLABEL_H
21#define LIBREPCB_EDITOR_SGI_BUSLABEL_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 GraphicsLayerList;
41class LineGraphicsItem;
42
43/*******************************************************************************
44 * Class SGI_BusLabel
45 ******************************************************************************/
46
50class SGI_BusLabel final : public QGraphicsItem {
51public:
52 // Constructors / Destructor
53 SGI_BusLabel() = delete;
54 SGI_BusLabel(const SGI_BusLabel& other) = delete;
55 SGI_BusLabel(SI_BusLabel& label, const GraphicsLayerList& layers) noexcept;
56 virtual ~SGI_BusLabel() noexcept;
57
58 // General Methods
59 SI_BusLabel& getBusLabel() noexcept { return mBusLabel; }
60
61 // Inherited from QGraphicsItem
62 QRectF boundingRect() const noexcept override { return mBoundingRect; }
63 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
64 QWidget* widget) noexcept override;
65
66 // Operator Overloadings
67 SGI_BusLabel& operator=(const SGI_BusLabel& rhs) = delete;
68
69private: // Methods
70 void busLabelEdited(const SI_BusLabel& obj,
71 SI_BusLabel::Event event) noexcept;
72 virtual QVariant itemChange(GraphicsItemChange change,
73 const QVariant& value) noexcept override;
74 void updatePosition() noexcept;
75 void updateRotation() noexcept;
76 void updateText() noexcept;
77 void updateAnchor() noexcept;
78
79private: // Data
82 std::shared_ptr<const GraphicsLayer> mBusLabelLayer;
84
85 // Cached Attributes
86 QStaticText mStaticText;
87 QVector<QLineF> mOverlines;
88 QFont mFont;
90 QPointF mTextOrigin;
92
93 // Slots
95
96 // Static Stuff
97 static QVector<QLineF> sOriginCrossLines;
98};
99
100/*******************************************************************************
101 * End of File
102 ******************************************************************************/
103
104} // namespace editor
105} // namespace librepcb
106
107#endif
The SI_BusLabel class.
Definition si_buslabel.h:48
Event
Definition si_buslabel.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_BusLabel class.
Definition sgi_buslabel.h:50
SGI_BusLabel & operator=(const SGI_BusLabel &rhs)=delete
void busLabelEdited(const SI_BusLabel &obj, SI_BusLabel::Event event) noexcept
Definition sgi_buslabel.cpp:157
QRectF boundingRect() const noexcept override
Definition sgi_buslabel.h:62
void updateText() noexcept
Definition sgi_buslabel.cpp:191
bool mRotate180
Definition sgi_buslabel.h:89
QVector< QLineF > mOverlines
Definition sgi_buslabel.h:87
void updatePosition() noexcept
Definition sgi_buslabel.cpp:183
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) noexcept override
Definition sgi_buslabel.cpp:138
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) noexcept override
Definition sgi_buslabel.cpp:97
SI_BusLabel & mBusLabel
Definition sgi_buslabel.h:80
void updateRotation() noexcept
Definition sgi_buslabel.cpp:187
QFont mFont
Definition sgi_buslabel.h:88
QScopedPointer< LineGraphicsItem > mAnchorGraphicsItem
Definition sgi_buslabel.h:83
QStaticText mStaticText
Definition sgi_buslabel.h:86
std::shared_ptr< const GraphicsLayer > mBusLabelLayer
Definition sgi_buslabel.h:82
virtual ~SGI_BusLabel() noexcept
Definition sgi_buslabel.cpp:90
QRectF mBoundingRect
Definition sgi_buslabel.h:91
SGI_BusLabel(const SGI_BusLabel &other)=delete
QPointF mTextOrigin
Definition sgi_buslabel.h:90
static QVector< QLineF > sOriginCrossLines
Definition sgi_buslabel.h:97
void updateAnchor() noexcept
Definition sgi_buslabel.cpp:234
std::shared_ptr< const GraphicsLayer > mOriginCrossLayer
Definition sgi_buslabel.h:81
SI_BusLabel::OnEditedSlot mOnEditedSlot
Definition sgi_buslabel.h:94
SI_BusLabel & getBusLabel() noexcept
Definition sgi_buslabel.h:59
Definition occmodel.cpp:77
Definition uuid.h:186