LibrePCB Developers Documentation
stroketextgraphicsitem.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_STROKETEXTGRAPHICSITEM_H
21#define LIBREPCB_EDITOR_STROKETEXTGRAPHICSITEM_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
27
28#include <QtCore>
29#include <QtWidgets>
30
31/*******************************************************************************
32 * Namespace / Forward Declarations
33 ******************************************************************************/
34namespace librepcb {
35namespace editor {
36
37class IF_GraphicsLayerProvider;
38class OriginCrossGraphicsItem;
39class PrimitivePathGraphicsItem;
40
41/*******************************************************************************
42 * Class StrokeTextGraphicsItem
43 ******************************************************************************/
44
49class StrokeTextGraphicsItem final : public QGraphicsItemGroup {
50public:
51 // Constructors / Destructor
55 const StrokeFont& font,
56 QGraphicsItem* parent = nullptr) noexcept;
57 virtual ~StrokeTextGraphicsItem() noexcept;
58
59 // Getters
60 StrokeText& getObj() noexcept { return mText; }
61
62 // General Methods
63 void setTextOverride(const tl::optional<QString>& text) noexcept;
64
65 // Inherited from QGraphicsItem
66 QPainterPath shape() const noexcept override;
67
68 // Operator Overloadings
69 StrokeTextGraphicsItem& operator=(const StrokeTextGraphicsItem& rhs) = delete;
70
71private: // Methods
72 void strokeTextEdited(const StrokeText& text,
73 StrokeText::Event event) noexcept;
74 QVariant itemChange(GraphicsItemChange change,
75 const QVariant& value) noexcept override;
76 void updateLayer(const Layer& layer) noexcept;
77 void updateText() noexcept;
78 void updateTransform() noexcept;
79
80private: // Data
84 tl::optional<QString> mTextOverride;
87
88 // Slots
90};
91
92/*******************************************************************************
93 * End of File
94 ******************************************************************************/
95
96} // namespace editor
97} // namespace librepcb
98
99#endif
The Layer class provides all supported geometry layers.
Definition: layer.h:42
The StrokeFont class.
Definition: strokefont.h:56
The StrokeText class.
Definition: stroketext.h:51
The IF_GraphicsLayerProvider class defines an interface for classes which provide layers.
Definition: graphicslayer.h:111
The OriginCrossGraphicsItem class.
Definition: origincrossgraphicsitem.h:50
The PrimitivePathGraphicsItem class.
Definition: primitivepathgraphicsitem.h:50
The StrokeTextGraphicsItem class is the graphical representation of a librepcb::StrokeText.
Definition: stroketextgraphicsitem.h:49
QScopedPointer< PrimitivePathGraphicsItem > mPathGraphicsItem
Definition: stroketextgraphicsitem.h:85
void updateLayer(const Layer &layer) noexcept
Definition: stroketextgraphicsitem.cpp:141
QScopedPointer< OriginCrossGraphicsItem > mOriginCrossGraphicsItem
Definition: stroketextgraphicsitem.h:86
void updateText() noexcept
Definition: stroketextgraphicsitem.cpp:147
QVariant itemChange(GraphicsItemChange change, const QVariant &value) noexcept override
Definition: stroketextgraphicsitem.cpp:93
StrokeTextGraphicsItem(const StrokeTextGraphicsItem &other)=delete
QPainterPath shape() const noexcept override
Definition: stroketextgraphicsitem.cpp:88
void setTextOverride(const tl::optional< QString > &text) noexcept
Definition: stroketextgraphicsitem.cpp:76
const IF_GraphicsLayerProvider & mLayerProvider
Definition: stroketextgraphicsitem.h:82
StrokeText & getObj() noexcept
Definition: stroketextgraphicsitem.h:60
void updateTransform() noexcept
Definition: stroketextgraphicsitem.cpp:153
tl::optional< QString > mTextOverride
Definition: stroketextgraphicsitem.h:84
const StrokeFont & mFont
Definition: stroketextgraphicsitem.h:83
void strokeTextEdited(const StrokeText &text, StrokeText::Event event) noexcept
Definition: stroketextgraphicsitem.cpp:107
StrokeText::OnEditedSlot mOnEditedSlot
Definition: stroketextgraphicsitem.h:89
StrokeText & mText
Definition: stroketextgraphicsitem.h:81
Definition: occmodel.cpp:77
Definition: uuid.h:183