LibrePCB Developers Documentation
cmdstroketextedit.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_CMDSTROKETEXTEDIT_H
21 #define LIBREPCB_EDITOR_CMDSTROKETEXTEDIT_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../undocommand.h"
27 #include "cmdlistelementinsert.h"
28 #include "cmdlistelementremove.h"
29 #include "cmdlistelementsswap.h"
30 
32 
33 #include <QtCore>
34 
35 /*******************************************************************************
36  * Namespace / Forward Declarations
37  ******************************************************************************/
38 namespace librepcb {
39 
40 class Layer;
41 
42 namespace editor {
43 
44 /*******************************************************************************
45  * Class CmdStrokeTextEdit
46  ******************************************************************************/
47 
51 class CmdStrokeTextEdit final : public UndoCommand {
52 public:
53  // Constructors / Destructor
54  CmdStrokeTextEdit() = delete;
55  CmdStrokeTextEdit(const CmdStrokeTextEdit& other) = delete;
56  explicit CmdStrokeTextEdit(StrokeText& text) noexcept;
57  ~CmdStrokeTextEdit() noexcept;
58 
59  // Setters
60  void setLayer(const Layer& layer, bool immediate) noexcept;
61  void setText(const QString& text, bool immediate) noexcept;
62  void setHeight(const PositiveLength& height, bool immediate) noexcept;
63  void setStrokeWidth(const UnsignedLength& strokeWidth,
64  bool immediate) noexcept;
65  void setLetterSpacing(const StrokeTextSpacing& spacing,
66  bool immediate) noexcept;
67  void setLineSpacing(const StrokeTextSpacing& spacing,
68  bool immediate) noexcept;
69  void setAlignment(const Alignment& align, bool immediate) noexcept;
70  void setPosition(const Point& pos, bool immediate) noexcept;
71  void translate(const Point& delta, bool immediate) noexcept;
72  void snapToGrid(const PositiveLength& gridInterval, bool immediate) noexcept;
73  void setRotation(const Angle& angle, bool immediate) noexcept;
74  void rotate(const Angle& angle, const Point& center, bool immediate) noexcept;
75  void setMirrored(bool mirrored, bool immediate) noexcept;
76  void mirrorGeometry(Qt::Orientation orientation, const Point& center,
77  bool immediate) noexcept;
78  void mirrorLayer(bool immediate) noexcept;
79  void setAutoRotate(bool autoRotate, bool immediate) noexcept;
80 
81  // Operator Overloadings
82  CmdStrokeTextEdit& operator=(const CmdStrokeTextEdit& rhs) = delete;
83 
84 private:
85  // Private Methods
86 
88  bool performExecute() override;
89 
91  void performUndo() override;
92 
94  void performRedo() override;
95 
96  // Private Member Variables
97 
98  // Attributes from the constructor
100 
101  // General Attributes
102  const Layer* mOldLayer;
103  const Layer* mNewLayer;
104  QString mOldText;
105  QString mNewText;
124 };
125 
126 /*******************************************************************************
127  * Undo Commands
128  ******************************************************************************/
129 
130 using CmdStrokeTextInsert =
133 using CmdStrokeTextRemove =
134  CmdListElementRemove<StrokeText, StrokeTextListNameProvider,
136 using CmdStrokeTextsSwap =
137  CmdListElementsSwap<StrokeText, StrokeTextListNameProvider,
139 
140 /*******************************************************************************
141  * End of File
142  ******************************************************************************/
143 
144 } // namespace editor
145 } // namespace librepcb
146 
147 #endif
bool mOldAutoRotate
Definition: cmdstroketextedit.h:122
PositiveLength mNewHeight
Definition: cmdstroketextedit.h:111
StrokeTextSpacing mNewLetterSpacing
Definition: cmdstroketextedit.h:115
void snapToGrid(const PositiveLength &gridInterval, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:135
bool mNewMirrored
Definition: cmdstroketextedit.h:121
PositiveLength mOldHeight
Definition: cmdstroketextedit.h:110
Angle mOldRotation
Definition: cmdstroketextedit.h:108
void setAutoRotate(bool autoRotate, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:177
void setLayer(const Layer &layer, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:76
The CmdListElementRemove class.
Definition: cmdlistelementremove.h:46
void mirrorGeometry(Qt::Orientation orientation, const Point &center, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:159
Alignment mOldAlign
Definition: cmdstroketextedit.h:118
The Alignment class.
Definition: alignment.h:115
void setRotation(const Angle &angle, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:140
Point mNewPosition
Definition: cmdstroketextedit.h:107
Definition: occmodel.cpp:77
Definition: stroketext.h:155
UnsignedLength mOldStrokeWidth
Definition: cmdstroketextedit.h:112
The Layer class provides all supported geometry layers.
Definition: layer.h:40
const Layer * mNewLayer
Definition: cmdstroketextedit.h:103
The StrokeText class.
Definition: stroketext.h:51
CmdStrokeTextEdit & operator=(const CmdStrokeTextEdit &rhs)=delete
~CmdStrokeTextEdit() noexcept
Definition: cmdstroketextedit.cpp:66
void setHeight(const PositiveLength &height, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:88
void setText(const QString &text, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:82
void setStrokeWidth(const UnsignedLength &strokeWidth, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:95
StrokeTextSpacing mNewLineSpacing
Definition: cmdstroketextedit.h:117
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
Event
Definition: stroketext.h:56
void rotate(const Angle &angle, const Point &center, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:147
void mirrorLayer(bool immediate) noexcept
Definition: cmdstroketextedit.cpp:171
Represents the letter- or line spacing configuration of a stroke text.
Definition: stroketextspacing.h:44
UnsignedLength mNewStrokeWidth
Definition: cmdstroketextedit.h:113
bool mOldMirrored
Definition: cmdstroketextedit.h:120
void setMirrored(bool mirrored, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:153
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:79
The CmdListElementInsert class.
Definition: cmdlistelementinsert.h:46
The UndoCommand class represents a command which you can undo/redo.
Definition: undocommand.h:46
bool mNewAutoRotate
Definition: cmdstroketextedit.h:123
void setPosition(const Point &pos, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:123
StrokeTextSpacing mOldLetterSpacing
Definition: cmdstroketextedit.h:114
Point mOldPosition
Definition: cmdstroketextedit.h:106
void performUndo() override
Undo the command.
Definition: cmdstroketextedit.cpp:205
void setAlignment(const Alignment &align, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:116
bool performExecute() override
Execute the command the first time.
Definition: cmdstroketextedit.cpp:188
Alignment mNewAlign
Definition: cmdstroketextedit.h:119
const Layer * mOldLayer
Definition: cmdstroketextedit.h:102
The CmdListElementsSwap class.
Definition: cmdlistelementsswap.h:46
QString mNewText
Definition: cmdstroketextedit.h:105
void performRedo() override
Redo the command.
Definition: cmdstroketextedit.cpp:219
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:812
void setLetterSpacing(const StrokeTextSpacing &spacing, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:102
The CmdStrokeTextEdit class.
Definition: cmdstroketextedit.h:51
Angle mNewRotation
Definition: cmdstroketextedit.h:109
StrokeText & mText
Definition: cmdstroketextedit.h:99
StrokeTextSpacing mOldLineSpacing
Definition: cmdstroketextedit.h:116
void setLineSpacing(const StrokeTextSpacing &spacing, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:109
void translate(const Point &delta, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:129
QString mOldText
Definition: cmdstroketextedit.h:104
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:696