LibrePCB Developers Documentation
Loading...
Searching...
No Matches
symboleditorstate_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_SYMBOLEDITORSTATE_DRAWTEXTBASE_H
21#define LIBREPCB_EDITOR_SYMBOLEDITORSTATE_DRAWTEXTBASE_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "symboleditorstate.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 Text;
45
46namespace editor {
47
48class CmdTextEdit;
49class HAlignActionGroup;
50class TextGraphicsItem;
51class VAlignActionGroup;
52
53/*******************************************************************************
54 * Class SymbolEditorState_DrawTextBase
55 ******************************************************************************/
56
61 Q_OBJECT
62
63public:
64 // Types
65 enum class Mode { NAME, VALUE, TEXT };
66
67 // Constructors / Destructor
70 delete;
71 explicit SymbolEditorState_DrawTextBase(const Context& context,
72 Mode mode) noexcept;
73 virtual ~SymbolEditorState_DrawTextBase() noexcept;
74
75 // General Methods
76 bool entry() noexcept override;
77 bool exit() noexcept override;
79 const noexcept override;
80
81 // Event Handlers
83 QGraphicsSceneMouseEvent& e) noexcept override;
85 QGraphicsSceneMouseEvent& e) noexcept override;
87 QGraphicsSceneMouseEvent& e) noexcept override;
88 bool processRotate(const Angle& rotation) noexcept override;
89 bool processMirror(Qt::Orientation orientation) noexcept override;
90
91 // Operator Overloadings
93 const SymbolEditorState_DrawTextBase& rhs) = delete;
94
95private: // Methods
96 bool startAddText(const Point& pos) noexcept;
97 bool finishAddText(const Point& pos) noexcept;
98 bool abortAddText() noexcept;
99 void resetToDefaultParameters() noexcept;
100 void layerComboBoxValueChanged(const Layer& layer) noexcept;
101 void heightEditValueChanged(const PositiveLength& value) noexcept;
102 void textComboBoxValueChanged(const QString& value) noexcept;
103 void hAlignActionGroupValueChanged(const HAlign& value) noexcept;
104 void vAlignActionGroupValueChanged(const VAlign& value) noexcept;
105
106private: // Types / Data
110 std::shared_ptr<Text> mCurrentText;
114
115 // parameter memory
120 QString mLastText;
121};
122
123/*******************************************************************************
124 * End of File
125 ******************************************************************************/
126
127} // namespace editor
128} // namespace librepcb
129
130#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:76
The HAlign class.
Definition alignment.h:43
The Layer class provides all supported geometry layers.
Definition layer.h:42
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition point.h:78
The Text class.
Definition text.h:48
The VAlign class.
Definition alignment.h:79
The CmdTextEdit class.
Definition cmdtextedit.h:51
The EditorWidgetBase class.
Definition editorwidgetbase.h:61
The HAlignActionGroup class is a helper to add librepcb::HAlign chooser toolbuttons to a toolbar.
Definition halignactiongroup.h:47
The SymbolEditorState_DrawTextBase class.
Definition symboleditorstate_drawtextbase.h:60
bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent &e) noexcept override
Definition symboleditorstate_drawtextbase.cpp:181
PositiveLength mLastHeight
Definition symboleditorstate_drawtextbase.h:118
void vAlignActionGroupValueChanged(const VAlign &value) noexcept
Definition symboleditorstate_drawtextbase.cpp:359
void hAlignActionGroupValueChanged(const HAlign &value) noexcept
Definition symboleditorstate_drawtextbase.cpp:351
SymbolEditorState_DrawTextBase(const SymbolEditorState_DrawTextBase &other)=delete
bool abortAddText() noexcept
Definition symboleditorstate_drawtextbase.cpp:286
const Layer * mLastLayer
Definition symboleditorstate_drawtextbase.h:116
QPointer< HAlignActionGroup > mHAlignActionGroup
Definition symboleditorstate_drawtextbase.h:112
QString mLastText
Definition symboleditorstate_drawtextbase.h:120
Mode
Definition symboleditorstate_drawtextbase.h:65
void heightEditValueChanged(const PositiveLength &value) noexcept
Definition symboleditorstate_drawtextbase.cpp:335
Mode mMode
Definition symboleditorstate_drawtextbase.h:107
std::shared_ptr< Text > mCurrentText
Definition symboleditorstate_drawtextbase.h:110
bool finishAddText(const Point &pos) noexcept
Definition symboleditorstate_drawtextbase.cpp:267
std::shared_ptr< TextGraphicsItem > mCurrentGraphicsItem
Definition symboleditorstate_drawtextbase.h:111
bool processRotate(const Angle &rotation) noexcept override
Definition symboleditorstate_drawtextbase.cpp:210
void textComboBoxValueChanged(const QString &value) noexcept
Definition symboleditorstate_drawtextbase.cpp:343
std::unique_ptr< CmdTextEdit > mEditCmd
Definition symboleditorstate_drawtextbase.h:109
QPointer< VAlignActionGroup > mVAlignActionGroup
Definition symboleditorstate_drawtextbase.h:113
Angle mLastRotation
Definition symboleditorstate_drawtextbase.h:117
void layerComboBoxValueChanged(const Layer &layer) noexcept
Definition symboleditorstate_drawtextbase.cpp:327
void resetToDefaultParameters() noexcept
Definition symboleditorstate_drawtextbase.cpp:300
bool exit() noexcept override
Definition symboleditorstate_drawtextbase.cpp:156
bool processGraphicsSceneRightMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexcept override
Definition symboleditorstate_drawtextbase.cpp:204
virtual ~SymbolEditorState_DrawTextBase() noexcept
Definition symboleditorstate_drawtextbase.cpp:65
Alignment mLastAlignment
Definition symboleditorstate_drawtextbase.h:119
Point mStartPos
Definition symboleditorstate_drawtextbase.h:108
bool processMirror(Qt::Orientation orientation) noexcept override
Definition symboleditorstate_drawtextbase.cpp:221
QSet< EditorWidgetBase::Feature > getAvailableFeatures() const noexcept override
Definition symboleditorstate_drawtextbase.cpp:169
bool processGraphicsSceneLeftMouseButtonPressed(QGraphicsSceneMouseEvent &e) noexcept override
Definition symboleditorstate_drawtextbase.cpp:193
bool startAddText(const Point &pos) noexcept
Definition symboleditorstate_drawtextbase.cpp:243
bool entry() noexcept override
Definition symboleditorstate_drawtextbase.cpp:73
The SymbolEditorState class is the base class of all symbol editor FSM states.
Definition symboleditorstate.h:54
The TextGraphicsItem class is the graphical representation of a librepcb::Text.
Definition textgraphicsitem.h:49
The VAlignActionGroup class is a helper to add librepcb::VAlign chooser toolbuttons to a toolbar.
Definition valignactiongroup.h:47
Definition occmodel.cpp:76
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition length.h:810
Definition uuid.h:186
Definition symboleditorfsm.h:76