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 
54  Q_OBJECT
55 
56 public:
57  // Types
58  enum class Mode { NAME, VALUE, TEXT };
59 
60  // Constructors / Destructor
63  const PackageEditorState_DrawTextBase& other) = delete;
64  explicit PackageEditorState_DrawTextBase(Context& context,
65  Mode mode) noexcept;
66  virtual ~PackageEditorState_DrawTextBase() noexcept;
67 
68  // General Methods
69  bool entry() noexcept override;
70  bool exit() noexcept override;
71 
72  // Event Handlers
74  QGraphicsSceneMouseEvent& e) noexcept override;
76  QGraphicsSceneMouseEvent& e) noexcept override;
78  QGraphicsSceneMouseEvent& e) noexcept override;
79  bool processRotateCw() noexcept override;
80  bool processRotateCcw() noexcept override;
81 
82  // Operator Overloadings
84  const PackageEditorState_DrawTextBase& rhs) = delete;
85 
86 private: // Methods
87  bool startAddText(const Point& pos) noexcept;
88  bool finishAddText(const Point& pos) noexcept;
89  bool abortAddText() noexcept;
90  void resetToDefaultParameters() noexcept;
91 
92  void layerComboBoxValueChanged(const QString& layerName) noexcept;
93  void heightSpinBoxValueChanged(double value) noexcept;
94  void textComboBoxValueChanged(const QString& value) noexcept;
95 
96 private: // Types / Data
99  QScopedPointer<CmdStrokeTextEdit> mEditCmd;
102 
103  // parameter memory
107  QString mLastText;
108 };
109 
110 /*******************************************************************************
111  * End of File
112  ******************************************************************************/
113 
114 } // namespace editor
115 } // namespace library
116 } // namespace librepcb
117 
118 #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:98
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:101
The StrokeText class.
Definition: stroketext.h:119
The PackageEditorState_DrawTextBase class.
Definition: packageeditorstate_drawtextbase.h:53
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:78
Angle mLastRotation
Definition: packageeditorstate_drawtextbase.h:105
QString mLastText
Definition: packageeditorstate_drawtextbase.h:107
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:238
GraphicsLayerName mLastLayerName
Definition: packageeditorstate_drawtextbase.h:104
PositiveLength mLastHeight
Definition: packageeditorstate_drawtextbase.h:106
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:100
void textComboBoxValueChanged(const QString &value) noexcept
Definition: packageeditorstate_drawtextbase.cpp:291
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:780
Mode
Definition: packageeditorstate_drawtextbase.h:58
void layerComboBoxValueChanged(const QString &layerName) noexcept
Definition: packageeditorstate_drawtextbase.cpp:272
Mode mMode
Definition: packageeditorstate_drawtextbase.h:97
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:53
void resetToDefaultParameters() noexcept
Definition: packageeditorstate_drawtextbase.cpp:252
QScopedPointer< CmdStrokeTextEdit > mEditCmd
Definition: packageeditorstate_drawtextbase.h:99
The CmdStrokeTextEdit class.
Definition: cmdstroketextedit.h:45