LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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_LIBRARY_EDITOR_SYMBOLEDITORSTATE_DRAWTEXTBASE_H
21 #define LIBREPCB_LIBRARY_EDITOR_SYMBOLEDITORSTATE_DRAWTEXTBASE_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "symboleditorstate.h"
27 
30 
31 #include <QtCore>
32 #include <QtWidgets>
33 
34 /*******************************************************************************
35  * Namespace / Forward Declarations
36  ******************************************************************************/
37 namespace librepcb {
38 
39 class Text;
40 class TextGraphicsItem;
41 class CmdTextEdit;
42 
43 namespace library {
44 
45 namespace editor {
46 
47 /*******************************************************************************
48  * Class SymbolEditorState_DrawTextBase
49  ******************************************************************************/
50 
55  Q_OBJECT
56 
57 public:
58  // Types
59  enum class Mode { NAME, VALUE, TEXT };
60 
61  // Constructors / Destructor
64  delete;
65  explicit SymbolEditorState_DrawTextBase(const Context& context,
66  Mode mode) noexcept;
67  virtual ~SymbolEditorState_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 SymbolEditorState_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  Alignment getAlignment() const noexcept;
93 
94  void layerComboBoxValueChanged(const QString& layerName) noexcept;
95  void heightSpinBoxValueChanged(double value) noexcept;
96  void textComboBoxValueChanged(const QString& value) noexcept;
97 
98 private: // Types / Data
101  QScopedPointer<CmdTextEdit> mEditCmd;
104 
105  // parameter memory
109  QString mLastText;
110 };
111 
112 /*******************************************************************************
113  * End of File
114  ******************************************************************************/
115 
116 } // namespace editor
117 } // namespace library
118 } // namespace librepcb
119 
120 #endif // LIBREPCB_LIBRARY_EDITOR_SYMBOLEDITORSTATE_DRAWTEXTBASE_H
virtual ~SymbolEditorState_DrawTextBase() noexcept
Definition: symboleditorstate_drawtextbase.cpp:61
Text * mCurrentText
Definition: symboleditorstate_drawtextbase.h:102
PositiveLength mLastHeight
Definition: symboleditorstate_drawtextbase.h:108
void heightSpinBoxValueChanged(double value) noexcept
Definition: symboleditorstate_drawtextbase.cpp:288
The SymbolEditorState class is the base class of all symbol editor FSM states.
Definition: symboleditorstate.h:49
void resetToDefaultParameters() noexcept
Definition: symboleditorstate_drawtextbase.cpp:249
Mode
Definition: symboleditorstate_drawtextbase.h:59
The Alignment class.
Definition: alignment.h:184
The SymbolEditorState_DrawTextBase class.
Definition: symboleditorstate_drawtextbase.h:54
Mode mMode
Definition: symboleditorstate_drawtextbase.h:99
type_safe::constrained_type< QString, GraphicsLayerNameConstraint, GraphicsLayerNameVerifier > GraphicsLayerName
Definition: graphicslayername.h:78
GraphicsLayerName mLastLayerName
Definition: symboleditorstate_drawtextbase.h:106
QString mLastText
Definition: symboleditorstate_drawtextbase.h:109
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
bool finishAddText(const Point &pos) noexcept
Definition: symboleditorstate_drawtextbase.cpp:216
Alignment getAlignment() const noexcept
Definition: symboleditorstate_drawtextbase.cpp:269
SymbolEditorFsm::Context Context
Definition: symboleditorstate.h:53
TextGraphicsItem * mCurrentGraphicsItem
Definition: symboleditorstate_drawtextbase.h:103
bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent &e) noexceptoverride
Definition: symboleditorstate_drawtextbase.cpp:140
void layerComboBoxValueChanged(const QString &layerName) noexcept
Definition: symboleditorstate_drawtextbase.cpp:277
bool processGraphicsSceneLeftMouseButtonPressed(QGraphicsSceneMouseEvent &e) noexceptoverride
Definition: symboleditorstate_drawtextbase.cpp:152
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
bool processGraphicsSceneRightMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexceptoverride
Definition: symboleditorstate_drawtextbase.cpp:163
bool processRotateCcw() noexceptoverride
Definition: symboleditorstate_drawtextbase.cpp:179
bool startAddText(const Point &pos) noexcept
Definition: symboleditorstate_drawtextbase.cpp:193
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:780
bool entry() noexceptoverride
Definition: symboleditorstate_drawtextbase.cpp:71
The Text class.
Definition: text.h:48
QScopedPointer< CmdTextEdit > mEditCmd
Definition: symboleditorstate_drawtextbase.h:101
bool exit() noexceptoverride
Definition: symboleditorstate_drawtextbase.cpp:124
The TextGraphicsItem class is the graphical representation of a librepcb::Text.
Definition: textgraphicsitem.h:48
Angle mLastRotation
Definition: symboleditorstate_drawtextbase.h:107
The CmdTextEdit class.
Definition: cmdtextedit.h:43
Point mStartPos
Definition: symboleditorstate_drawtextbase.h:100
bool processRotateCw() noexceptoverride
Definition: symboleditorstate_drawtextbase.cpp:169
bool abortAddText() noexcept
Definition: symboleditorstate_drawtextbase.cpp:235
void textComboBoxValueChanged(const QString &value) noexcept
Definition: symboleditorstate_drawtextbase.cpp:296