LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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_LIBRARY_EDITOR_PACKAGEEDITORSTATE_DRAWTEXTBASE_H
21 #define LIBREPCB_LIBRARY_EDITOR_PACKAGEEDITORSTATE_DRAWTEXTBASE_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "packageeditorstate.h"
27 
30 
31 #include <QtCore>
32 #include <QtWidgets>
33 
34 /*******************************************************************************
35  * Namespace / Forward Declarations
36  ******************************************************************************/
37 namespace librepcb {
38 
39 class StrokeText;
40 class StrokeTextGraphicsItem;
41 class CmdStrokeTextEdit;
42 
43 namespace library {
44 
45 namespace editor {
46 
47 /*******************************************************************************
48  * Class PackageEditorState_DrawTextBase
49  ******************************************************************************/
50 
55  Q_OBJECT
56 
57 public:
58  // Types
59  enum class Mode { NAME, VALUE, TEXT };
60 
61  // Constructors / Destructor
64  const PackageEditorState_DrawTextBase& other) = delete;
65  explicit PackageEditorState_DrawTextBase(Context& context,
66  Mode mode) noexcept;
67  virtual ~PackageEditorState_DrawTextBase() noexcept;
68 
69  // General Methods
70  bool entry() noexcept override;
71  bool exit() noexcept override;
72 
73  // Event Handlers
75  QGraphicsSceneMouseEvent& e) noexcept override;
77  QGraphicsSceneMouseEvent& e) noexcept override;
79  QGraphicsSceneMouseEvent& e) noexcept override;
80  bool processRotateCw() noexcept override;
81  bool processRotateCcw() noexcept override;
82 
83  // Operator Overloadings
85  const PackageEditorState_DrawTextBase& rhs) = delete;
86 
87 private: // Methods
88  bool startAddText(const Point& pos) noexcept;
89  bool finishAddText(const Point& pos) noexcept;
90  bool abortAddText() noexcept;
91  void resetToDefaultParameters() noexcept;
92 
93  void layerComboBoxValueChanged(const GraphicsLayerName& layerName) noexcept;
94  void heightEditValueChanged(const PositiveLength& value) noexcept;
95  void strokeWidthEditValueChanged(const UnsignedLength& value) noexcept;
96  void textComboBoxValueChanged(const QString& value) noexcept;
97  void hAlignActionGroupValueChanged(const HAlign& value) noexcept;
98  void vAlignActionGroupValueChanged(const VAlign& value) noexcept;
99 
100 private: // Types / Data
103  QScopedPointer<CmdStrokeTextEdit> mEditCmd;
106 
107  // parameter memory
113  QString mLastText;
114 };
115 
116 /*******************************************************************************
117  * End of File
118  ******************************************************************************/
119 
120 } // namespace editor
121 } // namespace library
122 } // namespace librepcb
123 
124 #endif // LIBREPCB_LIBRARY_EDITOR_PACKAGEEDITORSTATE_DRAWTEXTBASE_H
bool processRotateCcw() noexceptoverride
Definition: packageeditorstate_drawtextbase.cpp:211
The Alignment class.
Definition: alignment.h:184
bool startAddText(const Point &pos) noexcept
Definition: packageeditorstate_drawtextbase.cpp:225
void strokeWidthEditValueChanged(const UnsignedLength &value) noexcept
Definition: packageeditorstate_drawtextbase.cpp:329
Point mStartPos
Definition: packageeditorstate_drawtextbase.h:102
bool exit() noexceptoverride
Definition: packageeditorstate_drawtextbase.cpp:156
type_safe::constrained_type< QString, GraphicsLayerNameConstraint, GraphicsLayerNameVerifier > GraphicsLayerName
Definition: graphicslayername.h:78
bool finishAddText(const Point &pos) noexcept
Definition: packageeditorstate_drawtextbase.cpp:251
virtual ~PackageEditorState_DrawTextBase() noexcept
Definition: packageeditorstate_drawtextbase.cpp:68
StrokeTextGraphicsItem * mCurrentGraphicsItem
Definition: packageeditorstate_drawtextbase.h:105
The StrokeText class.
Definition: stroketext.h:119
The PackageEditorState_DrawTextBase class.
Definition: packageeditorstate_drawtextbase.h:54
bool processGraphicsSceneRightMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexceptoverride
Definition: packageeditorstate_drawtextbase.cpp:196
void vAlignActionGroupValueChanged(const VAlign &value) noexcept
Definition: packageeditorstate_drawtextbase.cpp:353
bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent &e) noexceptoverride
Definition: packageeditorstate_drawtextbase.cpp:172
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
Angle mLastRotation
Definition: packageeditorstate_drawtextbase.h:109
QString mLastText
Definition: packageeditorstate_drawtextbase.h:113
Alignment mLastAlignment
Definition: packageeditorstate_drawtextbase.h:112
void hAlignActionGroupValueChanged(const HAlign &value) noexcept
Definition: packageeditorstate_drawtextbase.cpp:345
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
bool abortAddText() noexcept
Definition: packageeditorstate_drawtextbase.cpp:270
The VAlign class.
Definition: alignment.h:113
The HAlign class.
Definition: alignment.h:42
UnsignedLength mLastStrokeWidth
Definition: packageeditorstate_drawtextbase.h:111
GraphicsLayerName mLastLayerName
Definition: packageeditorstate_drawtextbase.h:108
PositiveLength mLastHeight
Definition: packageeditorstate_drawtextbase.h:110
The PackageEditorState class is the base class of all package editor FSM states.
Definition: packageeditorstate.h:49
The StrokeTextGraphicsItem class is the graphical representation of a librepcb::StrokeText.
Definition: stroketextgraphicsitem.h:48
StrokeText * mCurrentText
Definition: packageeditorstate_drawtextbase.h:104
void textComboBoxValueChanged(const QString &value) noexcept
Definition: packageeditorstate_drawtextbase.cpp:337
void layerComboBoxValueChanged(const GraphicsLayerName &layerName) noexcept
Definition: packageeditorstate_drawtextbase.cpp:313
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:780
Mode
Definition: packageeditorstate_drawtextbase.h:59
Mode mMode
Definition: packageeditorstate_drawtextbase.h:101
bool processRotateCw() noexceptoverride
Definition: packageeditorstate_drawtextbase.cpp:201
bool entry() noexceptoverride
Definition: packageeditorstate_drawtextbase.cpp:78
bool processGraphicsSceneLeftMouseButtonPressed(QGraphicsSceneMouseEvent &e) noexceptoverride
Definition: packageeditorstate_drawtextbase.cpp:185
void heightEditValueChanged(const PositiveLength &value) noexcept
Definition: packageeditorstate_drawtextbase.cpp:321
PackageEditorFsm::Context Context
Definition: packageeditorstate.h:53
void resetToDefaultParameters() noexcept
Definition: packageeditorstate_drawtextbase.cpp:284
QScopedPointer< CmdStrokeTextEdit > mEditCmd
Definition: packageeditorstate_drawtextbase.h:103
The CmdStrokeTextEdit class.
Definition: cmdstroketextedit.h:45
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:659