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 
29 
30 #include <QtCore>
31 #include <QtWidgets>
32 
33 /*******************************************************************************
34  * Namespace / Forward Declarations
35  ******************************************************************************/
36 namespace librepcb {
37 
38 class StrokeText;
39 class StrokeTextGraphicsItem;
40 class CmdStrokeTextEdit;
41 
42 namespace library {
43 
44 namespace editor {
45 
46 /*******************************************************************************
47  * Class PackageEditorState_DrawTextBase
48  ******************************************************************************/
49 
57  Q_OBJECT
58 
59 public:
60  // Types
61  enum class Mode { NAME, VALUE, TEXT };
62 
63  // Constructors / Destructor
66  const PackageEditorState_DrawTextBase& other) = delete;
67  explicit PackageEditorState_DrawTextBase(Context& context,
68  Mode mode) noexcept;
69  virtual ~PackageEditorState_DrawTextBase() noexcept;
70 
71  // General Methods
72  bool entry() noexcept override;
73  bool exit() noexcept override;
74 
75  // Event Handlers
77  QGraphicsSceneMouseEvent& e) noexcept override;
79  QGraphicsSceneMouseEvent& e) noexcept override;
81  QGraphicsSceneMouseEvent& e) noexcept override;
82  bool processRotateCw() noexcept override;
83  bool processRotateCcw() noexcept override;
84 
85  // Operator Overloadings
87  const PackageEditorState_DrawTextBase& rhs) = delete;
88 
89 private: // Methods
90  bool startAddText(const Point& pos) noexcept;
91  bool finishAddText(const Point& pos) noexcept;
92  bool abortAddText() noexcept;
93  void resetToDefaultParameters() noexcept;
94 
95  void layerComboBoxValueChanged(const QString& layerName) noexcept;
96  void heightSpinBoxValueChanged(double value) noexcept;
97  void textComboBoxValueChanged(const QString& value) noexcept;
98 
99 private: // Types / Data
102  QScopedPointer<CmdStrokeTextEdit> mEditCmd;
105 
106  // parameter memory
110  QString mLastText;
111 };
112 
113 /*******************************************************************************
114  * End of File
115  ******************************************************************************/
116 
117 } // namespace editor
118 } // namespace library
119 } // namespace librepcb
120 
121 #endif // LIBREPCB_LIBRARY_EDITOR_PACKAGEEDITORSTATE_DRAWTEXTBASE_H
void heightSpinBoxValueChanged(double value) noexcept
Definition: packageeditorstate_drawtextbase.cpp:283
bool processRotateCcw() noexceptoverride
Definition: packageeditorstate_drawtextbase.cpp:178
bool startAddText(const Point &pos) noexcept
Definition: packageeditorstate_drawtextbase.cpp:192
Point mStartPos
Definition: packageeditorstate_drawtextbase.h:101
bool exit() noexceptoverride
Definition: packageeditorstate_drawtextbase.cpp:123
type_safe::constrained_type< QString, GraphicsLayerNameConstraint, GraphicsLayerNameVerifier > GraphicsLayerName
Definition: graphicslayername.h:78
bool finishAddText(const Point &pos) noexcept
Definition: packageeditorstate_drawtextbase.cpp:219
virtual ~PackageEditorState_DrawTextBase() noexcept
Definition: packageeditorstate_drawtextbase.cpp:61
StrokeTextGraphicsItem * mCurrentGraphicsItem
Definition: packageeditorstate_drawtextbase.h:104
The StrokeText class.
Definition: stroketext.h:153
The PackageEditorState_DrawTextBase class.
Definition: packageeditorstate_drawtextbase.h:56
bool processGraphicsSceneRightMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexceptoverride
Definition: packageeditorstate_drawtextbase.cpp:163
bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent &e) noexceptoverride
Definition: packageeditorstate_drawtextbase.cpp:139
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:81
Angle mLastRotation
Definition: packageeditorstate_drawtextbase.h:108
QString mLastText
Definition: packageeditorstate_drawtextbase.h:110
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:81
bool abortAddText() noexcept
Definition: packageeditorstate_drawtextbase.cpp:238
GraphicsLayerName mLastLayerName
Definition: packageeditorstate_drawtextbase.h:107
PositiveLength mLastHeight
Definition: packageeditorstate_drawtextbase.h:109
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:48
StrokeText * mCurrentText
Definition: packageeditorstate_drawtextbase.h:103
void textComboBoxValueChanged(const QString &value) noexcept
Definition: packageeditorstate_drawtextbase.cpp:291
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:783
Mode
Definition: packageeditorstate_drawtextbase.h:61
void layerComboBoxValueChanged(const QString &layerName) noexcept
Definition: packageeditorstate_drawtextbase.cpp:272
Mode mMode
Definition: packageeditorstate_drawtextbase.h:100
bool processRotateCw() noexceptoverride
Definition: packageeditorstate_drawtextbase.cpp:168
bool entry() noexceptoverride
Definition: packageeditorstate_drawtextbase.cpp:71
bool processGraphicsSceneLeftMouseButtonPressed(QGraphicsSceneMouseEvent &e) noexceptoverride
Definition: packageeditorstate_drawtextbase.cpp:152
PackageEditorFsm::Context Context
Definition: packageeditorstate.h:56
void resetToDefaultParameters() noexcept
Definition: packageeditorstate_drawtextbase.cpp:252
QScopedPointer< CmdStrokeTextEdit > mEditCmd
Definition: packageeditorstate_drawtextbase.h:102
The CmdStrokeTextEdit class.
Definition: cmdstroketextedit.h:45