LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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_TEXT_H
21 #define LIBREPCB_TEXT_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../alignment.h"
27 #include "../fileio/cmd/cmdlistelementinsert.h"
28 #include "../fileio/cmd/cmdlistelementremove.h"
29 #include "../fileio/cmd/cmdlistelementsswap.h"
30 #include "../fileio/serializableobjectlist.h"
31 #include "../graphics/graphicslayername.h"
32 #include "../units/all_length_units.h"
33 
34 #include <QtCore>
35 
36 /*******************************************************************************
37  * Namespace / Forward Declarations
38  ******************************************************************************/
39 namespace librepcb {
40 
41 /*******************************************************************************
42  * Class Text
43  ******************************************************************************/
44 
48 class Text final : public SerializableObject {
49  Q_DECLARE_TR_FUNCTIONS(Text)
50 
51 public:
52  // Signals
53  enum class Event {
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 GraphicsLayerName& layerName,
70  const QString& text, const Point& pos, const Angle& rotation,
71  const PositiveLength& height, 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 GraphicsLayerName& getLayerName() const noexcept { return mLayerName; }
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 setLayerName(const GraphicsLayerName& name) 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 
93  void serialize(SExpression& root) const override;
94 
95  // Operator Overloadings
96  bool operator==(const Text& rhs) const noexcept;
97  bool operator!=(const Text& rhs) const noexcept { return !(*this == rhs); }
98  Text& operator=(const Text& rhs) noexcept;
99 
100 private: // Data
103  QString mText;
108 };
109 
110 /*******************************************************************************
111  * Class TextList
112  ******************************************************************************/
113 
115  static constexpr const char* tagname = "text";
116 };
117 using TextList =
119 using CmdTextInsert =
121 using CmdTextRemove =
123 using CmdTextsSwap =
125 
126 /*******************************************************************************
127  * End of File
128  ******************************************************************************/
129 
130 } // namespace librepcb
131 
132 #endif // LIBREPCB_TEXT_H
bool operator==(const Text &rhs) const noexcept
Definition: text.cpp:160
bool setAlign(const Alignment &align) noexcept
Definition: text.cpp:132
Alignment mAlign
Definition: text.h:107
Uuid mUuid
Definition: text.h:101
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: text.cpp:146
The CmdListElementRemove class.
Definition: cmdlistelementremove.h:44
The Alignment class.
Definition: alignment.h:184
PositiveLength mHeight
Definition: text.h:106
type_safe::constrained_type< QString, GraphicsLayerNameConstraint, GraphicsLayerNameVerifier > GraphicsLayerName
Definition: graphicslayername.h:78
const PositiveLength & getHeight() const noexcept
Definition: text.h:80
~Text() noexcept
Definition: text.cpp:75
bool setText(const QString &text) noexcept
Definition: text.cpp:92
bool setHeight(const PositiveLength &height) noexcept
Definition: text.cpp:122
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
GraphicsLayerName mLayerName
Definition: text.h:102
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:43
The CmdListElementsSwap class.
Definition: cmdlistelementsswap.h:44
bool setPosition(const Point &pos) noexcept
Definition: text.cpp:102
const Alignment & getAlign() const noexcept
Definition: text.h:81
const Point & getPosition() const noexcept
Definition: text.h:78
Event
Definition: text.h:53
const GraphicsLayerName & getLayerName() const noexcept
Definition: text.h:77
Text & operator=(const Text &rhs) noexcept
Definition: text.cpp:171
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
bool operator!=(const Text &rhs) const noexcept
Definition: text.h:97
Slot< Text, Event > OnEditedSlot
Definition: text.h:63
const QString & getText() const noexcept
Definition: text.h:82
static constexpr const char * tagname
Definition: text.h:115
Point mPosition
Definition: text.h:104
bool setRotation(const Angle &rotation) noexcept
Definition: text.cpp:112
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
const Uuid & getUuid() const noexcept
Definition: text.h:76
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:780
The CmdListElementInsert class.
Definition: cmdlistelementinsert.h:44
QString mText
Definition: text.h:103
const Angle & getRotation() const noexcept
Definition: text.h:79
The Text class.
Definition: text.h:48
bool setLayerName(const GraphicsLayerName &name) noexcept
Definition: text.cpp:82
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
Angle mRotation
Definition: text.h:105
The SExpression class.
Definition: sexpression.h:57
Definition: text.h:114
Signal< Text, Event > onEdited
Definition: text.h:62