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 
58  Q_OBJECT
59 
60 public:
61  // Types
62  enum class Mode { NAME, VALUE, TEXT };
63 
64  // Constructors / Destructor
67  delete;
68  explicit SymbolEditorState_DrawTextBase(const Context& context,
69  Mode mode) noexcept;
70  virtual ~SymbolEditorState_DrawTextBase() noexcept;
71 
72  // General Methods
73  bool entry() noexcept override;
74  bool exit() noexcept override;
75 
76  // Event Handlers
78  QGraphicsSceneMouseEvent& e) noexcept override;
80  QGraphicsSceneMouseEvent& e) noexcept override;
82  QGraphicsSceneMouseEvent& e) noexcept override;
83  bool processRotateCw() noexcept override;
84  bool processRotateCcw() noexcept override;
85 
86  // Operator Overloadings
88  const SymbolEditorState_DrawTextBase& rhs) = delete;
89 
90 private: // Methods
91  bool startAddText(const Point& pos) noexcept;
92  bool finishAddText(const Point& pos) noexcept;
93  bool abortAddText() noexcept;
94  void resetToDefaultParameters() noexcept;
95  Alignment getAlignment() const noexcept;
96 
97  void layerComboBoxValueChanged(const QString& layerName) noexcept;
98  void heightSpinBoxValueChanged(double value) noexcept;
99  void textComboBoxValueChanged(const QString& value) noexcept;
100 
101 private: // Types / Data
104  QScopedPointer<CmdTextEdit> mEditCmd;
107 
108  // parameter memory
112  QString mLastText;
113 };
114 
115 /*******************************************************************************
116  * End of File
117  ******************************************************************************/
118 
119 } // namespace editor
120 } // namespace library
121 } // namespace librepcb
122 
123 #endif // LIBREPCB_LIBRARY_EDITOR_SYMBOLEDITORSTATE_DRAWTEXTBASE_H
virtual ~SymbolEditorState_DrawTextBase() noexcept
Definition: symboleditorstate_drawtextbase.cpp:61
Text * mCurrentText
Definition: symboleditorstate_drawtextbase.h:105
PositiveLength mLastHeight
Definition: symboleditorstate_drawtextbase.h:111
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:52
void resetToDefaultParameters() noexcept
Definition: symboleditorstate_drawtextbase.cpp:249
Mode
Definition: symboleditorstate_drawtextbase.h:62
The Alignment class.
Definition: alignment.h:193
The SymbolEditorState_DrawTextBase class.
Definition: symboleditorstate_drawtextbase.h:57
Mode mMode
Definition: symboleditorstate_drawtextbase.h:102
type_safe::constrained_type< QString, GraphicsLayerNameConstraint, GraphicsLayerNameVerifier > GraphicsLayerName
Definition: graphicslayername.h:78
GraphicsLayerName mLastLayerName
Definition: symboleditorstate_drawtextbase.h:109
QString mLastText
Definition: symboleditorstate_drawtextbase.h:112
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:81
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:56
TextGraphicsItem * mCurrentGraphicsItem
Definition: symboleditorstate_drawtextbase.h:106
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:81
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:783
bool entry() noexceptoverride
Definition: symboleditorstate_drawtextbase.cpp:71
The Text class.
Definition: text.h:75
QScopedPointer< CmdTextEdit > mEditCmd
Definition: symboleditorstate_drawtextbase.h:104
bool exit() noexceptoverride
Definition: symboleditorstate_drawtextbase.cpp:124
The TextGraphicsItem class is the graphical representation of a librepcb::Text.
Definition: textgraphicsitem.h:51
Angle mLastRotation
Definition: symboleditorstate_drawtextbase.h:110
The CmdTextEdit class.
Definition: cmdtextedit.h:43
Point mStartPos
Definition: symboleditorstate_drawtextbase.h:103
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