LibrePCB Developers Documentation
boardeditorstate_addstroketext.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_EDITOR_BOARDEDITORSTATE_ADDSTROKETEXT_H
21 #define LIBREPCB_EDITOR_BOARDEDITORSTATE_ADDSTROKETEXT_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "boardeditorstate.h"
27 
29 
30 #include <QtCore>
31 
32 /*******************************************************************************
33  * Namespace / Forward Declarations
34  ******************************************************************************/
35 namespace librepcb {
36 
37 class Board;
38 class Layer;
39 
40 namespace editor {
41 
42 class CmdBoardStrokeTextEdit;
43 class LayerComboBox;
44 class PositiveLengthEdit;
45 
46 /*******************************************************************************
47  * Class BoardEditorState_AddStrokeText
48  ******************************************************************************/
49 
54  Q_OBJECT
55 
56 public:
57  // Constructors / Destructor
60  delete;
61  explicit BoardEditorState_AddStrokeText(const Context& context) noexcept;
62  virtual ~BoardEditorState_AddStrokeText() noexcept;
63 
64  // General Methods
65  virtual bool entry() noexcept override;
66  virtual bool exit() noexcept override;
67 
68  // Event Handlers
69  virtual bool processRotate(const Angle& rotation) noexcept override;
70  virtual bool processFlip(Qt::Orientation orientation) noexcept override;
71  virtual bool processGraphicsSceneMouseMoved(
72  QGraphicsSceneMouseEvent& e) noexcept override;
74  QGraphicsSceneMouseEvent& e) noexcept override;
76  QGraphicsSceneMouseEvent& e) noexcept override;
78  QGraphicsSceneMouseEvent& e) noexcept override;
79 
80  // Operator Overloadings
82  const BoardEditorState_AddStrokeText& rhs) = delete;
83 
84 private: // Methods
85  bool addText(const Point& pos) noexcept;
86  bool rotateText(const Angle& angle) noexcept;
87  bool flipText(Qt::Orientation orientation) noexcept;
88  bool updatePosition(const Point& pos) noexcept;
89  bool fixPosition(const Point& pos) noexcept;
90  bool abortCommand(bool showErrMsgBox) noexcept;
91  void layerComboBoxLayerChanged(const Layer& layer) noexcept;
92  void textComboBoxValueChanged(const QString& value) noexcept;
93  void heightEditValueChanged(const PositiveLength& value) noexcept;
94  void mirrorCheckBoxToggled(bool checked) noexcept;
95 
96 private: // Data
97  // State
99 
100  // Parameter memory
106  QString mLastText;
108 
109  // Information about the current text to place. Only valid if
110  // mIsUndoCmdActive == true.
112  QScopedPointer<CmdBoardStrokeTextEdit> mCurrentTextEditCmd;
113 
114  // Widgets for the command toolbar
115  QPointer<LayerComboBox> mLayerComboBox;
116  QPointer<QCheckBox> mMirrorCheckBox;
117 };
118 
119 /*******************************************************************************
120  * End of File
121  ******************************************************************************/
122 
123 } // namespace editor
124 } // namespace librepcb
125 
126 #endif
Angle mLastRotation
Definition: boardeditorstate_addstroketext.h:102
FSM Context.
Definition: boardeditorfsm.h:88
void textComboBoxValueChanged(const QString &value) noexcept
Definition: boardeditorstate_addstroketext.cpp:319
bool flipText(Qt::Orientation orientation) noexcept
Definition: boardeditorstate_addstroketext.cpp:242
The Alignment class.
Definition: alignment.h:115
Definition: occmodel.cpp:77
bool updatePosition(const Point &pos) noexcept
Definition: boardeditorstate_addstroketext.cpp:260
The Layer class provides all supported geometry layers.
Definition: layer.h:40
virtual bool exit() noexcept override
Definition: boardeditorstate_addstroketext.cpp:141
Alignment mLastAlignment
Definition: boardeditorstate_addstroketext.h:105
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
virtual bool processGraphicsSceneLeftMouseButtonPressed(QGraphicsSceneMouseEvent &e) noexcept override
Definition: boardeditorstate_addstroketext.cpp:172
bool mIsUndoCmdActive
Definition: boardeditorstate_addstroketext.h:98
bool fixPosition(const Point &pos) noexcept
Definition: boardeditorstate_addstroketext.cpp:269
PositiveLength mLastHeight
Definition: boardeditorstate_addstroketext.h:103
QString mLastText
Definition: boardeditorstate_addstroketext.h:106
virtual bool processRotate(const Angle &rotation) noexcept override
Definition: boardeditorstate_addstroketext.cpp:156
bool addText(const Point &pos) noexcept
Definition: boardeditorstate_addstroketext.cpp:203
BoardEditorState_AddStrokeText & operator=(const BoardEditorState_AddStrokeText &rhs)=delete
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:79
bool mLastMirrored
Definition: boardeditorstate_addstroketext.h:107
bool abortCommand(bool showErrMsgBox) noexcept
Definition: boardeditorstate_addstroketext.cpp:288
virtual bool processGraphicsSceneRightMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexcept override
Definition: boardeditorstate_addstroketext.cpp:187
UnsignedLength mLastStrokeWidth
Definition: boardeditorstate_addstroketext.h:104
The BI_StrokeText class.
Definition: bi_stroketext.h:49
virtual bool processGraphicsSceneLeftMouseButtonDoubleClicked(QGraphicsSceneMouseEvent &e) noexcept override
Definition: boardeditorstate_addstroketext.cpp:181
QPointer< QCheckBox > mMirrorCheckBox
Definition: boardeditorstate_addstroketext.h:116
void mirrorCheckBoxToggled(bool checked) noexcept
Definition: boardeditorstate_addstroketext.cpp:335
void heightEditValueChanged(const PositiveLength &value) noexcept
Definition: boardeditorstate_addstroketext.cpp:327
virtual ~BoardEditorState_AddStrokeText() noexcept
Definition: boardeditorstate_addstroketext.cpp:66
void layerComboBoxLayerChanged(const Layer &layer) noexcept
Definition: boardeditorstate_addstroketext.cpp:310
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:812
virtual bool entry() noexcept override
Definition: boardeditorstate_addstroketext.cpp:73
QPointer< LayerComboBox > mLayerComboBox
Definition: boardeditorstate_addstroketext.h:115
The "add stroke text" state/tool of the board editor.
Definition: boardeditorstate_addstroketext.h:53
The board editor state base class.
Definition: boardeditorstate.h:59
bool rotateText(const Angle &angle) noexcept
Definition: boardeditorstate_addstroketext.cpp:232
virtual bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent &e) noexcept override
Definition: boardeditorstate_addstroketext.cpp:166
QScopedPointer< CmdBoardStrokeTextEdit > mCurrentTextEditCmd
Definition: boardeditorstate_addstroketext.h:112
BI_StrokeText * mCurrentTextToPlace
Definition: boardeditorstate_addstroketext.h:111
virtual bool processFlip(Qt::Orientation orientation) noexcept override
Definition: boardeditorstate_addstroketext.cpp:161
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:696
const Layer * mLastLayer
Definition: boardeditorstate_addstroketext.h:101