LibrePCB Developers Documentation
text.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_TEXT_H
21#define LIBREPCB_CORE_TEXT_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../serialization/serializableobjectlist.h"
27#include "../types/alignment.h"
28#include "../types/angle.h"
29#include "../types/length.h"
30#include "../types/point.h"
31
32#include <QtCore>
33
34/*******************************************************************************
35 * Namespace / Forward Declarations
36 ******************************************************************************/
37namespace librepcb {
38
39class Layer;
40
41/*******************************************************************************
42 * Class Text
43 ******************************************************************************/
44
48class Text final {
49 Q_DECLARE_TR_FUNCTIONS(Text)
50
51public:
52 // Signals
53 enum class Event {
54 UuidChanged,
55 LayerChanged,
56 TextChanged,
57 PositionChanged,
58 RotationChanged,
59 HeightChanged,
60 AlignChanged,
61 };
64
65 // Constructors / Destructor
66 Text() = delete;
67 Text(const Text& other) noexcept;
68 Text(const Uuid& uuid, const Text& other) noexcept;
69 Text(const Uuid& uuid, const Layer& layer, const QString& text,
70 const Point& pos, const Angle& rotation, const PositiveLength& height,
71 const Alignment& align) noexcept;
72 explicit Text(const SExpression& node);
73 ~Text() noexcept;
74
75 // Getters
76 const Uuid& getUuid() const noexcept { return mUuid; }
77 const Layer& getLayer() const noexcept { return *mLayer; }
78 const Point& getPosition() const noexcept { return mPosition; }
79 const Angle& getRotation() const noexcept { return mRotation; }
80 const PositiveLength& getHeight() const noexcept { return mHeight; }
81 const Alignment& getAlign() const noexcept { return mAlign; }
82 const QString& getText() const noexcept { return mText; }
83
84 // Setters
85 bool setLayer(const Layer& layer) noexcept;
86 bool setText(const QString& text) noexcept;
87 bool setPosition(const Point& pos) noexcept;
88 bool setRotation(const Angle& rotation) noexcept;
89 bool setHeight(const PositiveLength& height) noexcept;
90 bool setAlign(const Alignment& align) noexcept;
91
92 // General Methods
93
99 void serialize(SExpression& root) const;
100
101 // Operator Overloadings
102 bool operator==(const Text& rhs) const noexcept;
103 bool operator!=(const Text& rhs) const noexcept { return !(*this == rhs); }
104 Text& operator=(const Text& rhs) noexcept;
105
106private: // Data
108 const Layer* mLayer;
109 QString mText;
114};
115
116/*******************************************************************************
117 * Class TextList
118 ******************************************************************************/
119
121 static constexpr const char* tagname = "text";
122};
123using TextList =
125
126/*******************************************************************************
127 * End of File
128 ******************************************************************************/
129
130} // namespace librepcb
131
132#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:78
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:79
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 Text class.
Definition: text.h:48
bool setText(const QString &text) noexcept
Definition: text.cpp:92
const Angle & getRotation() const noexcept
Definition: text.h:79
bool setPosition(const Point &pos) noexcept
Definition: text.cpp:102
~Text() noexcept
Definition: text.cpp:75
bool operator==(const Text &rhs) const noexcept
Definition: text.cpp:162
Signal< Text, Event > onEdited
Definition: text.h:62
Uuid mUuid
Definition: text.h:107
Event
Definition: text.h:53
const PositiveLength & getHeight() const noexcept
Definition: text.h:80
QString mText
Definition: text.h:109
const Layer & getLayer() const noexcept
Definition: text.h:77
Text & operator=(const Text &rhs) noexcept
Definition: text.cpp:173
const Alignment & getAlign() const noexcept
Definition: text.h:81
const QString & getText() const noexcept
Definition: text.h:82
Angle mRotation
Definition: text.h:111
bool setLayer(const Layer &layer) noexcept
Definition: text.cpp:82
bool setHeight(const PositiveLength &height) noexcept
Definition: text.cpp:122
const Point & getPosition() const noexcept
Definition: text.h:78
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition: text.cpp:146
PositiveLength mHeight
Definition: text.h:112
const Uuid & getUuid() const noexcept
Definition: text.h:76
bool operator!=(const Text &rhs) const noexcept
Definition: text.h:103
Alignment mAlign
Definition: text.h:113
bool setRotation(const Angle &rotation) noexcept
Definition: text.cpp:112
const Layer * mLayer
Definition: text.h:108
Slot< Text, Event > OnEditedSlot
Definition: text.h:63
Point mPosition
Definition: text.h:110
bool setAlign(const Alignment &align) noexcept
Definition: text.cpp:132
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
Definition: occmodel.cpp:77
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:812
Definition: text.h:120
static constexpr const char * tagname
Definition: text.h:121