LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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_CMDSTROKETEXTEDIT_H
21 #define LIBREPCB_CMDSTROKETEXTEDIT_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../../undocommand.h"
27 #include "../stroketext.h"
28 
29 #include <QtCore>
30 
31 /*******************************************************************************
32  * Namespace / Forward Declarations
33  ******************************************************************************/
34 namespace librepcb {
35 
36 class StrokeText;
37 
38 /*******************************************************************************
39  * Class CmdStrokeTextEdit
40  ******************************************************************************/
41 
45 class CmdStrokeTextEdit final : public UndoCommand {
46 public:
47  // Constructors / Destructor
48  CmdStrokeTextEdit() = delete;
49  CmdStrokeTextEdit(const CmdStrokeTextEdit& other) = delete;
50  explicit CmdStrokeTextEdit(StrokeText& text) noexcept;
51  ~CmdStrokeTextEdit() noexcept;
52 
53  // Setters
54  void setLayerName(const GraphicsLayerName& name, bool immediate) noexcept;
55  void setText(const QString& text, bool immediate) noexcept;
56  void setHeight(const PositiveLength& height, bool immediate) noexcept;
57  void setStrokeWidth(const UnsignedLength& strokeWidth,
58  bool immediate) noexcept;
59  void setLetterSpacing(const StrokeTextSpacing& spacing,
60  bool immediate) noexcept;
61  void setLineSpacing(const StrokeTextSpacing& spacing,
62  bool immediate) noexcept;
63  void setAlignment(const Alignment& align, bool immediate) noexcept;
64  void setPosition(const Point& pos, bool immediate) noexcept;
65  void translate(const Point& delta, bool immediate) noexcept;
66  void setRotation(const Angle& angle, bool immediate) noexcept;
67  void rotate(const Angle& angle, const Point& center, bool immediate) noexcept;
68  void setMirrored(bool mirrored, bool immediate) noexcept;
69  void mirror(const Point& center, Qt::Orientation orientation,
70  bool immediate) noexcept;
71  void setAutoRotate(bool autoRotate, bool immediate) noexcept;
72 
73  // Operator Overloadings
74  CmdStrokeTextEdit& operator=(const CmdStrokeTextEdit& rhs) = delete;
75 
76 private:
77  // Private Methods
78 
80  bool performExecute() override;
81 
83  void performUndo() override;
84 
86  void performRedo() override;
87 
88  // Private Member Variables
89 
90  // Attributes from the constructor
92 
93  // General Attributes
96  QString mOldText;
97  QString mNewText;
116 };
117 
118 /*******************************************************************************
119  * End of File
120  ******************************************************************************/
121 
122 } // namespace librepcb
123 
124 #endif // LIBREPCB_CMDSTROKETEXTEDIT_H
void setLineSpacing(const StrokeTextSpacing &spacing, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:109
void mirror(const Point &center, Qt::Orientation orientation, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:161
StrokeTextSpacing mNewLetterSpacing
Definition: cmdstroketextedit.h:107
void translate(const Point &delta, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:129
The Alignment class.
Definition: alignment.h:184
bool performExecute() override
Execute the command the first time.
Definition: cmdstroketextedit.cpp:181
GraphicsLayerName mOldLayerName
Definition: cmdstroketextedit.h:94
void setStrokeWidth(const UnsignedLength &strokeWidth, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:95
CmdStrokeTextEdit & operator=(const CmdStrokeTextEdit &rhs)=delete
bool mOldMirrored
Definition: cmdstroketextedit.h:112
void rotate(const Angle &angle, const Point &center, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:142
type_safe::constrained_type< QString, GraphicsLayerNameConstraint, GraphicsLayerNameVerifier > GraphicsLayerName
Definition: graphicslayername.h:78
The StrokeText class.
Definition: stroketext.h:119
Alignment mNewAlign
Definition: cmdstroketextedit.h:111
void setText(const QString &text, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:82
Alignment mOldAlign
Definition: cmdstroketextedit.h:110
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
PositiveLength mNewHeight
Definition: cmdstroketextedit.h:103
QString mNewText
Definition: cmdstroketextedit.h:97
The StrokeTextSpacing class.
Definition: stroketext.h:52
UnsignedLength mOldStrokeWidth
Definition: cmdstroketextedit.h:104
GraphicsLayerName mNewLayerName
Definition: cmdstroketextedit.h:95
UnsignedLength mNewStrokeWidth
Definition: cmdstroketextedit.h:105
void performRedo() override
Redo the command.
Definition: cmdstroketextedit.cpp:212
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
Point mOldPosition
Definition: cmdstroketextedit.h:98
StrokeTextSpacing mOldLetterSpacing
Definition: cmdstroketextedit.h:106
void setPosition(const Point &pos, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:123
void setAlignment(const Alignment &align, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:116
bool mNewAutoRotate
Definition: cmdstroketextedit.h:115
void setLayerName(const GraphicsLayerName &name, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:75
QString mOldText
Definition: cmdstroketextedit.h:96
Angle mOldRotation
Definition: cmdstroketextedit.h:100
The UndoCommand class represents a command which you can undo/redo.
Definition: undocommand.h:47
void setRotation(const Angle &angle, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:135
void performUndo() override
Undo the command.
Definition: cmdstroketextedit.cpp:198
Point mNewPosition
Definition: cmdstroketextedit.h:99
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:780
StrokeTextSpacing mNewLineSpacing
Definition: cmdstroketextedit.h:109
bool mOldAutoRotate
Definition: cmdstroketextedit.h:114
StrokeTextSpacing mOldLineSpacing
Definition: cmdstroketextedit.h:108
void setMirrored(bool mirrored, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:155
void setAutoRotate(bool autoRotate, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:170
bool mNewMirrored
Definition: cmdstroketextedit.h:113
~CmdStrokeTextEdit() noexcept
Definition: cmdstroketextedit.cpp:65
StrokeText & mText
Definition: cmdstroketextedit.h:91
void setLetterSpacing(const StrokeTextSpacing &spacing, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:102
void setHeight(const PositiveLength &height, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:88
Angle mNewRotation
Definition: cmdstroketextedit.h:101
The CmdStrokeTextEdit class.
Definition: cmdstroketextedit.h:45
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:659
PositiveLength mOldHeight
Definition: cmdstroketextedit.h:102