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  ******************************************************************************/
34 namespace librepcb {
35 namespace editor {
36 
37 class IF_GraphicsLayerProvider;
38 class OriginCrossGraphicsItem;
39 class PrimitivePathGraphicsItem;
40 
41 /*******************************************************************************
42  * Class StrokeTextGraphicsItem
43  ******************************************************************************/
44 
49 class StrokeTextGraphicsItem final : public QGraphicsItemGroup {
50 public:
51  // Constructors / Destructor
52  StrokeTextGraphicsItem() = delete;
53  StrokeTextGraphicsItem(const StrokeTextGraphicsItem& other) = delete;
55  const StrokeFont& font,
56  QGraphicsItem* parent = nullptr) noexcept;
57  virtual ~StrokeTextGraphicsItem() noexcept;
58 
59  // Getters
60  StrokeText& getText() 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
70 
71 private: // 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 
80 private: // Data
83  const StrokeFont& mFont;
84  tl::optional<QString> mTextOverride;
85  QScopedPointer<PrimitivePathGraphicsItem> mPathGraphicsItem;
86  QScopedPointer<OriginCrossGraphicsItem> mOriginCrossGraphicsItem;
87 
88  // Slots
90 };
91 
92 /*******************************************************************************
93  * End of File
94  ******************************************************************************/
95 
96 } // namespace editor
97 } // namespace librepcb
98 
99 #endif
void updateLayer(const Layer &layer) noexcept
Definition: stroketextgraphicsitem.cpp:141
QScopedPointer< PrimitivePathGraphicsItem > mPathGraphicsItem
Definition: stroketextgraphicsitem.h:85
Definition: occmodel.cpp:77
The Layer class provides all supported geometry layers.
Definition: layer.h:40
The StrokeText class.
Definition: stroketext.h:51
StrokeText & getText() noexcept
Definition: stroketextgraphicsitem.h:60
void updateTransform() noexcept
Definition: stroketextgraphicsitem.cpp:153
Event
Definition: stroketext.h:56
The StrokeTextGraphicsItem class is the graphical representation of a librepcb::StrokeText.
Definition: stroketextgraphicsitem.h:49
void strokeTextEdited(const StrokeText &text, StrokeText::Event event) noexcept
Definition: stroketextgraphicsitem.cpp:107
StrokeText & mText
Definition: stroketextgraphicsitem.h:81
The IF_GraphicsLayerProvider class defines an interface for classes which provide layers...
Definition: graphicslayer.h:111
QPainterPath shape() const noexcept override
Definition: stroketextgraphicsitem.cpp:88
QScopedPointer< OriginCrossGraphicsItem > mOriginCrossGraphicsItem
Definition: stroketextgraphicsitem.h:86
tl::optional< QString > mTextOverride
Definition: stroketextgraphicsitem.h:84
StrokeTextGraphicsItem & operator=(const StrokeTextGraphicsItem &rhs)=delete
StrokeText::OnEditedSlot mOnEditedSlot
Definition: stroketextgraphicsitem.h:89
void updateText() noexcept
Definition: stroketextgraphicsitem.cpp:147
const IF_GraphicsLayerProvider & mLayerProvider
Definition: stroketextgraphicsitem.h:82
virtual ~StrokeTextGraphicsItem() noexcept
Definition: stroketextgraphicsitem.cpp:69
void setTextOverride(const tl::optional< QString > &text) noexcept
Definition: stroketextgraphicsitem.cpp:76
const StrokeFont & mFont
Definition: stroketextgraphicsitem.h:83
The StrokeFont class.
Definition: strokefont.h:56
QVariant itemChange(GraphicsItemChange change, const QVariant &value) noexcept override
Definition: stroketextgraphicsitem.cpp:93