LibrePCB Developers Documentation
packageeditorstate_drawtextbase.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_PACKAGEEDITORSTATE_DRAWTEXTBASE_H
21#define LIBREPCB_EDITOR_PACKAGEEDITORSTATE_DRAWTEXTBASE_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "packageeditorstate.h"
27
32
33#include <QtCore>
34#include <QtWidgets>
35
36#include <memory>
37
38/*******************************************************************************
39 * Namespace / Forward Declarations
40 ******************************************************************************/
41namespace librepcb {
42
43class Layer;
44class StrokeText;
45
46namespace editor {
47
48class CmdStrokeTextEdit;
49class HAlignActionGroup;
50class LayerComboBox;
51class StrokeTextGraphicsItem;
52class VAlignActionGroup;
53
54/*******************************************************************************
55 * Class PackageEditorState_DrawTextBase
56 ******************************************************************************/
57
62 Q_OBJECT
63
64public:
65 // Types
66 enum class Mode { NAME, VALUE, TEXT };
67
68 // Constructors / Destructor
71 const PackageEditorState_DrawTextBase& other) = delete;
73 Mode mode) noexcept;
74 virtual ~PackageEditorState_DrawTextBase() noexcept;
75
76 // General Methods
77 bool entry() noexcept override;
78 bool exit() noexcept override;
80 const noexcept override;
81
82 // Event Handlers
84 QGraphicsSceneMouseEvent& e) noexcept override;
86 QGraphicsSceneMouseEvent& e) noexcept override;
88 QGraphicsSceneMouseEvent& e) noexcept override;
89 bool processRotate(const Angle& rotation) noexcept override;
90 bool processMirror(Qt::Orientation orientation) noexcept override;
91 bool processFlip(Qt::Orientation orientation) noexcept override;
92
93 // Operator Overloadings
95 const PackageEditorState_DrawTextBase& rhs) = delete;
96
97private: // Methods
98 bool startAddText(const Point& pos) noexcept;
99 bool finishAddText(const Point& pos) noexcept;
100 bool abortAddText() noexcept;
101 void resetToDefaultParameters() noexcept;
102 void layerComboBoxValueChanged(const Layer& layer) noexcept;
103 void heightEditValueChanged(const PositiveLength& value) noexcept;
104 void strokeWidthEditValueChanged(const UnsignedLength& value) noexcept;
105 void textComboBoxValueChanged(const QString& value) noexcept;
106 void hAlignActionGroupValueChanged(const HAlign& value) noexcept;
107 void vAlignActionGroupValueChanged(const VAlign& value) noexcept;
108
109private: // Types / Data
113 std::shared_ptr<StrokeText> mCurrentText;
118
119 // parameter memory
125 QString mLastText;
127};
128
129/*******************************************************************************
130 * End of File
131 ******************************************************************************/
132
133} // namespace editor
134} // namespace librepcb
135
136#endif
The Alignment class.
Definition: alignment.h:115
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
The HAlign class.
Definition: alignment.h:43
The Layer class provides all supported geometry layers.
Definition: layer.h:40
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition: point.h:79
The StrokeText class.
Definition: stroketext.h:51
The VAlign class.
Definition: alignment.h:79
The CmdStrokeTextEdit class.
Definition: cmdstroketextedit.h:51
The EditorWidgetBase class.
Definition: editorwidgetbase.h:62
The HAlignActionGroup class is a helper to add librepcb::HAlign chooser toolbuttons to a toolbar.
Definition: halignactiongroup.h:47
The LayerComboBox class.
Definition: layercombobox.h:47
The PackageEditorState_DrawTextBase class.
Definition: packageeditorstate_drawtextbase.h:61
bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent &e) noexcept override
Definition: packageeditorstate_drawtextbase.cpp:202
PositiveLength mLastHeight
Definition: packageeditorstate_drawtextbase.h:122
QScopedPointer< CmdStrokeTextEdit > mEditCmd
Definition: packageeditorstate_drawtextbase.h:112
void vAlignActionGroupValueChanged(const VAlign &value) noexcept
Definition: packageeditorstate_drawtextbase.cpp:418
void hAlignActionGroupValueChanged(const HAlign &value) noexcept
Definition: packageeditorstate_drawtextbase.cpp:410
bool abortAddText() noexcept
Definition: packageeditorstate_drawtextbase.cpp:333
const Layer * mLastLayer
Definition: packageeditorstate_drawtextbase.h:120
QPointer< HAlignActionGroup > mHAlignActionGroup
Definition: packageeditorstate_drawtextbase.h:116
QString mLastText
Definition: packageeditorstate_drawtextbase.h:125
Mode
Definition: packageeditorstate_drawtextbase.h:66
void heightEditValueChanged(const PositiveLength &value) noexcept
Definition: packageeditorstate_drawtextbase.cpp:386
Mode mMode
Definition: packageeditorstate_drawtextbase.h:110
UnsignedLength mLastStrokeWidth
Definition: packageeditorstate_drawtextbase.h:123
bool finishAddText(const Point &pos) noexcept
Definition: packageeditorstate_drawtextbase.cpp:314
virtual ~PackageEditorState_DrawTextBase() noexcept
Definition: packageeditorstate_drawtextbase.cpp:68
PackageEditorState_DrawTextBase(const PackageEditorState_DrawTextBase &other)=delete
bool mLastMirrored
Definition: packageeditorstate_drawtextbase.h:126
void strokeWidthEditValueChanged(const UnsignedLength &value) noexcept
Definition: packageeditorstate_drawtextbase.cpp:394
bool processRotate(const Angle &rotation) noexcept override
Definition: packageeditorstate_drawtextbase.cpp:232
void textComboBoxValueChanged(const QString &value) noexcept
Definition: packageeditorstate_drawtextbase.cpp:402
std::shared_ptr< StrokeText > mCurrentText
Definition: packageeditorstate_drawtextbase.h:113
QPointer< VAlignActionGroup > mVAlignActionGroup
Definition: packageeditorstate_drawtextbase.h:117
std::shared_ptr< StrokeTextGraphicsItem > mCurrentGraphicsItem
Definition: packageeditorstate_drawtextbase.h:114
Angle mLastRotation
Definition: packageeditorstate_drawtextbase.h:121
void layerComboBoxValueChanged(const Layer &layer) noexcept
Definition: packageeditorstate_drawtextbase.cpp:378
void resetToDefaultParameters() noexcept
Definition: packageeditorstate_drawtextbase.cpp:347
bool exit() noexcept override
Definition: packageeditorstate_drawtextbase.cpp:176
QPointer< LayerComboBox > mLayerComboBox
Definition: packageeditorstate_drawtextbase.h:115
bool processGraphicsSceneRightMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexcept override
Definition: packageeditorstate_drawtextbase.cpp:226
Alignment mLastAlignment
Definition: packageeditorstate_drawtextbase.h:124
Point mStartPos
Definition: packageeditorstate_drawtextbase.h:111
bool processFlip(Qt::Orientation orientation) noexcept override
Definition: packageeditorstate_drawtextbase.cpp:261
bool processMirror(Qt::Orientation orientation) noexcept override
Definition: packageeditorstate_drawtextbase.cpp:243
QSet< EditorWidgetBase::Feature > getAvailableFeatures() const noexcept override
Definition: packageeditorstate_drawtextbase.cpp:189
bool processGraphicsSceneLeftMouseButtonPressed(QGraphicsSceneMouseEvent &e) noexcept override
Definition: packageeditorstate_drawtextbase.cpp:215
bool startAddText(const Point &pos) noexcept
Definition: packageeditorstate_drawtextbase.cpp:289
bool entry() noexcept override
Definition: packageeditorstate_drawtextbase.cpp:76
The PackageEditorState class is the base class of all package editor FSM states.
Definition: packageeditorstate.h:52
The StrokeTextGraphicsItem class is the graphical representation of a librepcb::StrokeText.
Definition: stroketextgraphicsitem.h:49
The VAlignActionGroup class is a helper to add librepcb::VAlign chooser toolbuttons to a toolbar.
Definition: valignactiongroup.h:47
Definition: occmodel.cpp:77
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:812
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:696
Definition: packageeditorfsm.h:89