LibrePCB Developers Documentation
bi_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_BI_STROKETEXT_H
21#define LIBREPCB_CORE_BI_STROKETEXT_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../../utils/signalslot.h"
27#include "../boardstroketextdata.h"
28#include "bi_base.h"
29
30#include <QtCore>
31
32/*******************************************************************************
33 * Namespace / Forward Declarations
34 ******************************************************************************/
35namespace librepcb {
36
37class BI_Device;
38class Board;
39class Path;
40class StrokeFont;
41
42/*******************************************************************************
43 * Class BI_StrokeText
44 ******************************************************************************/
45
49class BI_StrokeText final : public BI_Base {
50 Q_OBJECT
51
52public:
53 // Signals
54 enum class Event {
55 LayerChanged,
56 PositionChanged,
57 RotationChanged,
58 MirroredChanged,
59 StrokeWidthChanged,
60 PathsChanged,
61 };
64
65 // Constructors / Destructor
66 BI_StrokeText() = delete;
67 BI_StrokeText(const BI_StrokeText& other) = delete;
68 BI_StrokeText(Board& board, const BoardStrokeTextData& data);
69 ~BI_StrokeText() noexcept;
70
71 // Getters
72 const BoardStrokeTextData& getData() const noexcept { return mData; }
73 const StrokeFont& getFont() const noexcept { return mFont; }
74 const QString& getSubstitutedText() const noexcept {
75 return mSubstitutedText;
76 }
77 const QVector<Path>& getPaths() const noexcept { return mPaths; }
78
79 // Setters
80 bool setLayer(const Layer& layer) noexcept;
81 bool setText(const QString& text) noexcept;
82 bool setPosition(const Point& pos) noexcept;
83 bool setRotation(const Angle& rotation) noexcept;
84 bool setHeight(const PositiveLength& height) noexcept;
85 bool setStrokeWidth(const UnsignedLength& strokeWidth) noexcept;
86 bool setLetterSpacing(const StrokeTextSpacing& spacing) noexcept;
87 bool setLineSpacing(const StrokeTextSpacing& spacing) noexcept;
88 bool setAlign(const Alignment& align) noexcept;
89 bool setMirrored(bool mirrored) noexcept;
90 bool setAutoRotate(bool autoRotate) noexcept;
91 bool setLocked(bool locked) noexcept;
92
93 // General Methods
94 BI_Device* getDevice() const noexcept { return mDevice; }
95 void setDevice(BI_Device* device) noexcept;
96 void addToBoard() override;
97 void removeFromBoard() override;
98
99 // Operator Overloadings
100 BI_StrokeText& operator=(const BI_StrokeText& rhs) = delete;
101
102private: // Methods
103 void updateText() noexcept;
104 void updatePaths() noexcept;
105 void invalidatePlanes(const Layer& layer) noexcept;
106
107private: // Data
111
112 // Cached Attributes
114 QVector<Path> mPaths;
115};
116
117/*******************************************************************************
118 * End of File
119 ******************************************************************************/
120
121} // namespace librepcb
122
123#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 Board Item Base (BI_Base) class.
Definition: bi_base.h:45
The BI_Device class.
Definition: bi_device.h:57
The BI_StrokeText class.
Definition: bi_stroketext.h:49
BoardStrokeTextData mData
Definition: bi_stroketext.h:108
const BoardStrokeTextData & getData() const noexcept
Definition: bi_stroketext.h:72
bool setText(const QString &text) noexcept
Definition: bi_stroketext.cpp:77
const QString & getSubstitutedText() const noexcept
Definition: bi_stroketext.h:74
void updateText() noexcept
Definition: bi_stroketext.cpp:228
bool setPosition(const Point &pos) noexcept
Definition: bi_stroketext.cpp:86
void updatePaths() noexcept
Definition: bi_stroketext.cpp:240
bool setLineSpacing(const StrokeTextSpacing &spacing) noexcept
Definition: bi_stroketext.cpp:137
void removeFromBoard() override
Definition: bi_stroketext.cpp:216
BI_Device * mDevice
Definition: bi_stroketext.h:110
Event
Definition: bi_stroketext.h:54
bool setLetterSpacing(const StrokeTextSpacing &spacing) noexcept
Definition: bi_stroketext.cpp:127
const QVector< Path > & getPaths() const noexcept
Definition: bi_stroketext.h:77
~BI_StrokeText() noexcept
Definition: bi_stroketext.cpp:58
void setDevice(BI_Device *device) noexcept
Definition: bi_stroketext.cpp:187
bool setStrokeWidth(const UnsignedLength &strokeWidth) noexcept
Definition: bi_stroketext.cpp:116
Slot< BI_StrokeText, Event > OnEditedSlot
Definition: bi_stroketext.h:63
bool setLayer(const Layer &layer) noexcept
Definition: bi_stroketext.cpp:65
bool setHeight(const PositiveLength &height) noexcept
Definition: bi_stroketext.cpp:107
bool setMirrored(bool mirrored) noexcept
Definition: bi_stroketext.cpp:155
const StrokeFont & getFont() const noexcept
Definition: bi_stroketext.h:73
BI_StrokeText & operator=(const BI_StrokeText &rhs)=delete
const StrokeFont & mFont
Definition: bi_stroketext.h:109
bool setRotation(const Angle &rotation) noexcept
Definition: bi_stroketext.cpp:96
void addToBoard() override
Definition: bi_stroketext.cpp:208
BI_StrokeText(const BI_StrokeText &other)=delete
Signal< BI_StrokeText, Event > onEdited
Definition: bi_stroketext.h:62
BI_Device * getDevice() const noexcept
Definition: bi_stroketext.h:94
bool setLocked(bool locked) noexcept
Definition: bi_stroketext.cpp:175
QVector< Path > mPaths
Without transformation (position/rotation/mirror)
Definition: bi_stroketext.h:114
bool setAutoRotate(bool autoRotate) noexcept
Definition: bi_stroketext.cpp:166
QString mSubstitutedText
Definition: bi_stroketext.h:113
bool setAlign(const Alignment &align) noexcept
Definition: bi_stroketext.cpp:146
void invalidatePlanes(const Layer &layer) noexcept
Definition: bi_stroketext.cpp:252
The Board class represents a PCB of a project and is always part of a circuit.
Definition: board.h:73
The BoardStrokeTextData class.
Definition: boardstroketextdata.h:49
The Layer class provides all supported geometry layers.
Definition: layer.h:42
The Path class represents a list of vertices connected by straight lines or circular arc segments.
Definition: path.h:58
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition: point.h:79
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
The StrokeFont class.
Definition: strokefont.h:56
Represents the letter- or line spacing configuration of a stroke text.
Definition: stroketextspacing.h:44
Definition: occmodel.cpp:77
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:812
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:696