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 setDeltaToStartPos(const Point& deltaPos, bool immediate) noexcept;
66  void translate(const Point& delta, bool immediate) noexcept;
67  void setRotation(const Angle& angle, bool immediate) noexcept;
68  void rotate(const Angle& angle, const Point& center, bool immediate) noexcept;
69  void setMirrored(bool mirrored, bool immediate) noexcept;
70  void mirror(const Point& center, Qt::Orientation orientation,
71  bool immediate) noexcept;
72  void setAutoRotate(bool autoRotate, bool immediate) noexcept;
73 
74  // Operator Overloadings
75  CmdStrokeTextEdit& operator=(const CmdStrokeTextEdit& rhs) = delete;
76 
77 private:
78  // Private Methods
79 
81  bool performExecute() override;
82 
84  void performUndo() override;
85 
87  void performRedo() override;
88 
89  // Private Member Variables
90 
91  // Attributes from the constructor
93 
94  // General Attributes
97  QString mOldText;
98  QString mNewText;
117 };
118 
119 /*******************************************************************************
120  * End of File
121  ******************************************************************************/
122 
123 } // namespace librepcb
124 
125 #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:168
StrokeTextSpacing mNewLetterSpacing
Definition: cmdstroketextedit.h:108
void translate(const Point &delta, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:136
The Alignment class.
Definition: alignment.h:193
bool performExecute() override
Execute the command the first time.
Definition: cmdstroketextedit.cpp:188
GraphicsLayerName mOldLayerName
Definition: cmdstroketextedit.h:95
void setStrokeWidth(const UnsignedLength &strokeWidth, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:95
CmdStrokeTextEdit & operator=(const CmdStrokeTextEdit &rhs)=delete
bool mOldMirrored
Definition: cmdstroketextedit.h:113
void rotate(const Angle &angle, const Point &center, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:149
type_safe::constrained_type< QString, GraphicsLayerNameConstraint, GraphicsLayerNameVerifier > GraphicsLayerName
Definition: graphicslayername.h:78
The StrokeText class.
Definition: stroketext.h:153
Alignment mNewAlign
Definition: cmdstroketextedit.h:112
void setText(const QString &text, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:82
Alignment mOldAlign
Definition: cmdstroketextedit.h:111
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:81
PositiveLength mNewHeight
Definition: cmdstroketextedit.h:104
QString mNewText
Definition: cmdstroketextedit.h:98
The StrokeTextSpacing class.
Definition: stroketext.h:52
UnsignedLength mOldStrokeWidth
Definition: cmdstroketextedit.h:105
GraphicsLayerName mNewLayerName
Definition: cmdstroketextedit.h:96
UnsignedLength mNewStrokeWidth
Definition: cmdstroketextedit.h:106
void setDeltaToStartPos(const Point &deltaPos, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:129
void performRedo() override
Redo the command.
Definition: cmdstroketextedit.cpp:219
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:81
Point mOldPosition
Definition: cmdstroketextedit.h:99
StrokeTextSpacing mOldLetterSpacing
Definition: cmdstroketextedit.h:107
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:116
void setLayerName(const GraphicsLayerName &name, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:75
QString mOldText
Definition: cmdstroketextedit.h:97
Angle mOldRotation
Definition: cmdstroketextedit.h:101
The UndoCommand class represents a command which you can undo/redo.
Definition: undocommand.h:52
void setRotation(const Angle &angle, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:142
void performUndo() override
Undo the command.
Definition: cmdstroketextedit.cpp:205
Point mNewPosition
Definition: cmdstroketextedit.h:100
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:783
StrokeTextSpacing mNewLineSpacing
Definition: cmdstroketextedit.h:110
bool mOldAutoRotate
Definition: cmdstroketextedit.h:115
StrokeTextSpacing mOldLineSpacing
Definition: cmdstroketextedit.h:109
void setMirrored(bool mirrored, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:162
void setAutoRotate(bool autoRotate, bool immediate) noexcept
Definition: cmdstroketextedit.cpp:177
bool mNewMirrored
Definition: cmdstroketextedit.h:114
~CmdStrokeTextEdit() noexcept
Definition: cmdstroketextedit.cpp:65
StrokeText & mText
Definition: cmdstroketextedit.h:92
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:102
The CmdStrokeTextEdit class.
Definition: cmdstroketextedit.h:45
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:662
PositiveLength mOldHeight
Definition: cmdstroketextedit.h:103