LibrePCB Developers Documentation
Loading...
Searching...
No Matches
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
65
66 // Constructors / Destructor
67 Text() = delete;
68 Text(const Text& other) noexcept;
69 Text(const Uuid& uuid, const Text& other) noexcept;
70 Text(const Uuid& uuid, const Layer& layer, const QString& text,
71 const Point& pos, const Angle& rotation, const PositiveLength& height,
72 const Alignment& align, bool locked) noexcept;
73 explicit Text(const SExpression& node);
74 ~Text() noexcept;
75
76 // Getters
77 const Uuid& getUuid() const noexcept { return mUuid; }
78 const Layer& getLayer() const noexcept { return *mLayer; }
79 const QString& getText() const noexcept { return mText; }
80 const Point& getPosition() const noexcept { return mPosition; }
81 const Angle& getRotation() const noexcept { return mRotation; }
82 const PositiveLength& getHeight() const noexcept { return mHeight; }
83 const Alignment& getAlign() const noexcept { return mAlign; }
84 bool isLocked() const noexcept { return mLocked; }
85
86 // Setters
87 bool setLayer(const Layer& layer) noexcept;
88 bool setText(const QString& text) noexcept;
89 bool setPosition(const Point& pos) noexcept;
90 bool setRotation(const Angle& rotation) noexcept;
91 bool setHeight(const PositiveLength& height) noexcept;
92 bool setAlign(const Alignment& align) noexcept;
93 bool setLocked(bool locked) noexcept;
94
95 // General Methods
96
102 void serialize(SExpression& root) const;
103
104 // Operator Overloadings
105 bool operator==(const Text& rhs) const noexcept;
106 bool operator!=(const Text& rhs) const noexcept { return !(*this == rhs); }
107 Text& operator=(const Text& rhs) noexcept;
108
109private: // Data
111 const Layer* mLayer;
112 QString mText;
118};
119
120/*******************************************************************************
121 * Class TextList
122 ******************************************************************************/
123
125 static constexpr const char* tagname = "text";
126};
127using TextList =
129
130/*******************************************************************************
131 * End of File
132 ******************************************************************************/
133
134} // namespace librepcb
135
136#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 Text class.
Definition text.h:48
bool mLocked
Definition text.h:117
bool setText(const QString &text) noexcept
Definition text.cpp:96
const Angle & getRotation() const noexcept
Definition text.h:81
bool setPosition(const Point &pos) noexcept
Definition text.cpp:106
~Text() noexcept
Definition text.cpp:79
bool operator==(const Text &rhs) const noexcept
Definition text.cpp:178
Signal< Text, Event > onEdited
Definition text.h:63
Uuid mUuid
Definition text.h:110
Event
Definition text.h:53
const PositiveLength & getHeight() const noexcept
Definition text.h:82
QString mText
Definition text.h:112
const Layer & getLayer() const noexcept
Definition text.h:78
Text & operator=(const Text &rhs) noexcept
Definition text.cpp:190
bool isLocked() const noexcept
Definition text.h:84
const Alignment & getAlign() const noexcept
Definition text.h:83
const QString & getText() const noexcept
Definition text.h:79
Angle mRotation
Definition text.h:114
bool setLayer(const Layer &layer) noexcept
Definition text.cpp:86
bool setHeight(const PositiveLength &height) noexcept
Definition text.cpp:126
const Point & getPosition() const noexcept
Definition text.h:80
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition text.cpp:160
PositiveLength mHeight
Definition text.h:115
const Uuid & getUuid() const noexcept
Definition text.h:77
bool operator!=(const Text &rhs) const noexcept
Definition text.h:106
Alignment mAlign
Definition text.h:116
bool setRotation(const Angle &rotation) noexcept
Definition text.cpp:116
const Layer * mLayer
Definition text.h:111
Slot< Text, Event > OnEditedSlot
Definition text.h:64
bool setLocked(bool locked) noexcept
Definition text.cpp:146
Point mPosition
Definition text.h:113
bool setAlign(const Alignment &align) noexcept
Definition text.cpp:136
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
Definition text.h:124
static constexpr const char * tagname
Definition text.h:125