LibrePCB Developers Documentation
Loading...
Searching...
No Matches
stroketext.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_CORE_STROKETEXT_H
21#define LIBREPCB_CORE_STROKETEXT_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../geometry/path.h"
27#include "../serialization/serializableobjectlist.h"
28#include "../types/alignment.h"
29#include "../types/angle.h"
30#include "../types/length.h"
31#include "../types/point.h"
32#include "../types/stroketextspacing.h"
33
34#include <QtCore>
35
36/*******************************************************************************
37 * Namespace / Forward Declarations
38 ******************************************************************************/
39namespace librepcb {
40
41class Layer;
42class StrokeFont;
43
44/*******************************************************************************
45 * Class StrokeText
46 ******************************************************************************/
47
51class StrokeText final {
52 Q_DECLARE_TR_FUNCTIONS(StrokeText)
53
54public:
55 // Signals
73
74 // Constructors / Destructor
75 StrokeText() = delete;
76 StrokeText(const StrokeText& other) noexcept;
77 StrokeText(const Uuid& uuid, const StrokeText& other) noexcept;
78 StrokeText(const Uuid& uuid, const Layer& layer, const QString& text,
79 const Point& pos, const Angle& rotation,
80 const PositiveLength& height, const UnsignedLength& strokeWidth,
81 const StrokeTextSpacing& letterSpacing,
82 const StrokeTextSpacing& lineSpacing, const Alignment& align,
83 bool mirrored, bool autoRotate, bool locked) noexcept;
84 explicit StrokeText(const SExpression& node);
85 ~StrokeText() noexcept;
86
87 // Getters
88 const Uuid& getUuid() const noexcept { return mUuid; }
89 const Layer& getLayer() const noexcept { return *mLayer; }
90 const Point& getPosition() const noexcept { return mPosition; }
91 const Angle& getRotation() const noexcept { return mRotation; }
92 const PositiveLength& getHeight() const noexcept { return mHeight; }
93 const UnsignedLength& getStrokeWidth() const noexcept { return mStrokeWidth; }
94 const StrokeTextSpacing& getLetterSpacing() const noexcept {
95 return mLetterSpacing;
96 }
97 const StrokeTextSpacing& getLineSpacing() const noexcept {
98 return mLineSpacing;
99 }
100 const Alignment& getAlign() const noexcept { return mAlign; }
101 bool getMirrored() const noexcept { return mMirrored; }
102 bool getAutoRotate() const noexcept { return mAutoRotate; }
103 bool isLocked() const noexcept { return mLocked; }
104 const QString& getText() const noexcept { return mText; }
105 QVector<Path> generatePaths(const StrokeFont& font) const noexcept;
106 QVector<Path> generatePaths(const StrokeFont& font,
107 const QString& text) const noexcept;
108
109 // Setters
110 bool setLayer(const Layer& layer) noexcept;
111 bool setText(const QString& text) noexcept;
112 bool setPosition(const Point& pos) noexcept;
113 bool setRotation(const Angle& rotation) noexcept;
114 bool setHeight(const PositiveLength& height) noexcept;
115 bool setStrokeWidth(const UnsignedLength& strokeWidth) noexcept;
116 bool setLetterSpacing(const StrokeTextSpacing& spacing) noexcept;
117 bool setLineSpacing(const StrokeTextSpacing& spacing) noexcept;
118 bool setAlign(const Alignment& align) noexcept;
119 bool setMirrored(bool mirrored) noexcept;
120 bool setAutoRotate(bool autoRotate) noexcept;
121 bool setLocked(bool locked) noexcept;
122
123 // General Methods
124
130 void serialize(SExpression& root) const;
131
132 // Operator Overloadings
133 bool operator==(const StrokeText& rhs) const noexcept;
134 bool operator!=(const StrokeText& rhs) const noexcept {
135 return !(*this == rhs);
136 }
137 StrokeText& operator=(const StrokeText& rhs) noexcept;
138
139private: // Data
141 const Layer* mLayer;
142 QString mText;
153};
154
155/*******************************************************************************
156 * Class StrokeTextList
157 ******************************************************************************/
158
160 static constexpr const char* tagname = "stroke_text";
161};
165
166/*******************************************************************************
167 * End of File
168 ******************************************************************************/
169
170} // namespace librepcb
171
172#endif
The Alignment class.
Definition alignment.h:115
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition angle.h:76
The Layer class provides all supported geometry layers.
Definition layer.h:42
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition point.h:78
The SExpression class.
Definition sexpression.h:69
The Signal class is used to emit signals on non-QObject derived classes.
Definition signalslot.h:65
The Slot class is used to receive signals from non-QObject derived classes.
Definition signalslot.h:170
The StrokeFont class.
Definition strokefont.h:56
The StrokeText class.
Definition stroketext.h:51
bool mLocked
Definition stroketext.h:152
bool getMirrored() const noexcept
Definition stroketext.h:101
bool setText(const QString &text) noexcept
Definition stroketext.cpp:135
const Angle & getRotation() const noexcept
Definition stroketext.h:91
Slot< StrokeText, Event > OnEditedSlot
Definition stroketext.h:72
bool setPosition(const Point &pos) noexcept
Definition stroketext.cpp:145
bool setLineSpacing(const StrokeTextSpacing &spacing) noexcept
Definition stroketext.cpp:195
bool getAutoRotate() const noexcept
Definition stroketext.h:102
Uuid mUuid
Definition stroketext.h:140
StrokeText & operator=(const StrokeText &rhs) noexcept
Definition stroketext.cpp:290
Event
Definition stroketext.h:56
UnsignedLength mStrokeWidth
Definition stroketext.h:146
const PositiveLength & getHeight() const noexcept
Definition stroketext.h:92
QString mText
Definition stroketext.h:142
const Layer & getLayer() const noexcept
Definition stroketext.h:89
bool setLetterSpacing(const StrokeTextSpacing &spacing) noexcept
Definition stroketext.cpp:185
QVector< Path > generatePaths(const StrokeFont &font) const noexcept
Definition stroketext.cpp:110
bool isLocked() const noexcept
Definition stroketext.h:103
const Alignment & getAlign() const noexcept
Definition stroketext.h:100
const QString & getText() const noexcept
Definition stroketext.h:104
Signal< StrokeText, Event > onEdited
Definition stroketext.h:71
bool setStrokeWidth(const UnsignedLength &strokeWidth) noexcept
Definition stroketext.cpp:175
Angle mRotation
Definition stroketext.h:144
bool setLayer(const Layer &layer) noexcept
Definition stroketext.cpp:125
bool mAutoRotate
Definition stroketext.h:151
bool setHeight(const PositiveLength &height) noexcept
Definition stroketext.cpp:165
bool setMirrored(bool mirrored) noexcept
Definition stroketext.cpp:215
const Point & getPosition() const noexcept
Definition stroketext.h:90
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition stroketext.cpp:249
const StrokeTextSpacing & getLineSpacing() const noexcept
Definition stroketext.h:97
PositiveLength mHeight
Definition stroketext.h:145
const Uuid & getUuid() const noexcept
Definition stroketext.h:88
bool operator!=(const StrokeText &rhs) const noexcept
Definition stroketext.h:134
const StrokeTextSpacing & getLetterSpacing() const noexcept
Definition stroketext.h:94
Alignment mAlign
Definition stroketext.h:149
bool setRotation(const Angle &rotation) noexcept
Definition stroketext.cpp:155
const Layer * mLayer
Definition stroketext.h:141
StrokeTextSpacing mLineSpacing
Definition stroketext.h:148
const UnsignedLength & getStrokeWidth() const noexcept
Definition stroketext.h:93
~StrokeText() noexcept
Definition stroketext.cpp:103
bool setLocked(bool locked) noexcept
Definition stroketext.cpp:235
bool setAutoRotate(bool autoRotate) noexcept
Definition stroketext.cpp:225
bool mMirrored
Definition stroketext.h:150
bool operator==(const StrokeText &rhs) const noexcept
Definition stroketext.cpp:273
Point mPosition
Definition stroketext.h:143
bool setAlign(const Alignment &align) noexcept
Definition stroketext.cpp:205
StrokeTextSpacing mLetterSpacing
Definition stroketext.h:147
Represents the letter- or line spacing configuration of a stroke text.
Definition stroketextspacing.h:44
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition uuid.h:56
Definition occmodel.cpp:77
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition length.h:810
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition length.h:694
Definition stroketext.h:159
static constexpr const char * tagname
Definition stroketext.h:160