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  ******************************************************************************/
41 namespace librepcb {
42 
43 class Layer;
44 class StrokeText;
45 
46 namespace editor {
47 
48 class CmdStrokeTextEdit;
49 class HAlignActionGroup;
50 class LayerComboBox;
51 class StrokeTextGraphicsItem;
52 class VAlignActionGroup;
53 
54 /*******************************************************************************
55  * Class PackageEditorState_DrawTextBase
56  ******************************************************************************/
57 
62  Q_OBJECT
63 
64 public:
65  // Types
66  enum class Mode { NAME, VALUE, TEXT };
67 
68  // Constructors / Destructor
71  const PackageEditorState_DrawTextBase& other) = delete;
72  explicit PackageEditorState_DrawTextBase(Context& context,
73  Mode mode) noexcept;
74  virtual ~PackageEditorState_DrawTextBase() noexcept;
75 
76  // General Methods
77  bool entry() noexcept override;
78  bool exit() noexcept override;
79  QSet<EditorWidgetBase::Feature> getAvailableFeatures()
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 
97 private: // 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 
109 private: // Types / Data
112  QScopedPointer<CmdStrokeTextEdit> mEditCmd;
113  std::shared_ptr<StrokeText> mCurrentText;
114  std::shared_ptr<StrokeTextGraphicsItem> mCurrentGraphicsItem;
115  QPointer<LayerComboBox> mLayerComboBox;
116  QPointer<HAlignActionGroup> mHAlignActionGroup;
117  QPointer<VAlignActionGroup> mVAlignActionGroup;
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
Definition: packageeditorfsm.h:89
bool processGraphicsSceneLeftMouseButtonPressed(QGraphicsSceneMouseEvent &e) noexcept override
Definition: packageeditorstate_drawtextbase.cpp:215
bool mLastMirrored
Definition: packageeditorstate_drawtextbase.h:126
void resetToDefaultParameters() noexcept
Definition: packageeditorstate_drawtextbase.cpp:347
std::shared_ptr< StrokeText > mCurrentText
Definition: packageeditorstate_drawtextbase.h:113
The Alignment class.
Definition: alignment.h:115
Mode
Definition: packageeditorstate_drawtextbase.h:66
bool entry() noexcept override
Definition: packageeditorstate_drawtextbase.cpp:76
Definition: occmodel.cpp:77
void layerComboBoxValueChanged(const Layer &layer) noexcept
Definition: packageeditorstate_drawtextbase.cpp:378
The Layer class provides all supported geometry layers.
Definition: layer.h:40
PackageEditorState_DrawTextBase & operator=(const PackageEditorState_DrawTextBase &rhs)=delete
void strokeWidthEditValueChanged(const UnsignedLength &value) noexcept
Definition: packageeditorstate_drawtextbase.cpp:394
void heightEditValueChanged(const PositiveLength &value) noexcept
Definition: packageeditorstate_drawtextbase.cpp:386
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
QSet< EditorWidgetBase::Feature > getAvailableFeatures() const noexcept override
Definition: packageeditorstate_drawtextbase.cpp:189
bool processFlip(Qt::Orientation orientation) noexcept override
Definition: packageeditorstate_drawtextbase.cpp:261
void hAlignActionGroupValueChanged(const HAlign &value) noexcept
Definition: packageeditorstate_drawtextbase.cpp:410
void textComboBoxValueChanged(const QString &value) noexcept
Definition: packageeditorstate_drawtextbase.cpp:402
virtual ~PackageEditorState_DrawTextBase() noexcept
Definition: packageeditorstate_drawtextbase.cpp:68
QString mLastText
Definition: packageeditorstate_drawtextbase.h:125
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:79
The VAlign class.
Definition: alignment.h:79
bool processRotate(const Angle &rotation) noexcept override
Definition: packageeditorstate_drawtextbase.cpp:232
The HAlign class.
Definition: alignment.h:43
bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent &e) noexcept override
Definition: packageeditorstate_drawtextbase.cpp:202
Mode mMode
Definition: packageeditorstate_drawtextbase.h:110
const Layer * mLastLayer
Definition: packageeditorstate_drawtextbase.h:120
bool startAddText(const Point &pos) noexcept
Definition: packageeditorstate_drawtextbase.cpp:289
The PackageEditorState_DrawTextBase class.
Definition: packageeditorstate_drawtextbase.h:61
bool processMirror(Qt::Orientation orientation) noexcept override
Definition: packageeditorstate_drawtextbase.cpp:243
Alignment mLastAlignment
Definition: packageeditorstate_drawtextbase.h:124
QScopedPointer< CmdStrokeTextEdit > mEditCmd
Definition: packageeditorstate_drawtextbase.h:112
Angle mLastRotation
Definition: packageeditorstate_drawtextbase.h:121
Point mStartPos
Definition: packageeditorstate_drawtextbase.h:111
std::shared_ptr< StrokeTextGraphicsItem > mCurrentGraphicsItem
Definition: packageeditorstate_drawtextbase.h:114
PositiveLength mLastHeight
Definition: packageeditorstate_drawtextbase.h:122
QPointer< LayerComboBox > mLayerComboBox
Definition: packageeditorstate_drawtextbase.h:115
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:812
UnsignedLength mLastStrokeWidth
Definition: packageeditorstate_drawtextbase.h:123
void vAlignActionGroupValueChanged(const VAlign &value) noexcept
Definition: packageeditorstate_drawtextbase.cpp:418
QPointer< HAlignActionGroup > mHAlignActionGroup
Definition: packageeditorstate_drawtextbase.h:116
bool abortAddText() noexcept
Definition: packageeditorstate_drawtextbase.cpp:333
bool processGraphicsSceneRightMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexcept override
Definition: packageeditorstate_drawtextbase.cpp:226
The PackageEditorState class is the base class of all package editor FSM states.
Definition: packageeditorstate.h:52
bool finishAddText(const Point &pos) noexcept
Definition: packageeditorstate_drawtextbase.cpp:314
QPointer< VAlignActionGroup > mVAlignActionGroup
Definition: packageeditorstate_drawtextbase.h:117
bool exit() noexcept override
Definition: packageeditorstate_drawtextbase.cpp:176
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:696