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  ******************************************************************************/
35 namespace librepcb {
36 
37 class BI_Device;
38 class Board;
39 class Path;
40 class StrokeFont;
41 
42 /*******************************************************************************
43  * Class BI_StrokeText
44  ******************************************************************************/
45 
49 class BI_StrokeText final : public BI_Base {
50  Q_OBJECT
51 
52 public:
53  // Signals
54  enum class Event {
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 
102 private: // Methods
103  void updateText() noexcept;
104  void updatePaths() noexcept;
105  void invalidatePlanes(const Layer& layer) noexcept;
106 
107 private: // Data
111 
112  // Cached Attributes
114  QVector<Path> mPaths;
115 };
116 
117 /*******************************************************************************
118  * End of File
119  ******************************************************************************/
120 
121 } // namespace librepcb
122 
123 #endif
const QVector< Path > & getPaths() const noexcept
Definition: bi_stroketext.h:77
void removeFromBoard() override
Definition: bi_stroketext.cpp:216
The Alignment class.
Definition: alignment.h:115
Definition: occmodel.cpp:76
The BI_Device class.
Definition: bi_device.h:57
bool setHeight(const PositiveLength &height) noexcept
Definition: bi_stroketext.cpp:107
The Layer class provides all supported geometry layers.
Definition: layer.h:40
const BoardStrokeTextData & getData() const noexcept
Definition: bi_stroketext.h:72
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:76
bool setRotation(const Angle &rotation) noexcept
Definition: bi_stroketext.cpp:96
void updateText() noexcept
Definition: bi_stroketext.cpp:228
BI_StrokeText & operator=(const BI_StrokeText &rhs)=delete
Slot< BI_StrokeText, Event > OnEditedSlot
Definition: bi_stroketext.h:63
bool setMirrored(bool mirrored) noexcept
Definition: bi_stroketext.cpp:155
bool setText(const QString &text) noexcept
Definition: bi_stroketext.cpp:77
Represents the letter- or line spacing configuration of a stroke text.
Definition: stroketextspacing.h:44
BI_Device * getDevice() const noexcept
Definition: bi_stroketext.h:94
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
QVector< Path > mPaths
Without transformation (position/rotation/mirror)
Definition: bi_stroketext.h:114
The Board Item Base (BI_Base) class.
Definition: bi_base.h:45
bool setLocked(bool locked) noexcept
Definition: bi_stroketext.cpp:175
~BI_StrokeText() noexcept
Definition: bi_stroketext.cpp:58
The Board class represents a PCB of a project and is always part of a circuit.
Definition: board.h:73
bool setStrokeWidth(const UnsignedLength &strokeWidth) noexcept
Definition: bi_stroketext.cpp:116
BoardStrokeTextData mData
Definition: bi_stroketext.h:108
void setDevice(BI_Device *device) noexcept
Definition: bi_stroketext.cpp:187
The BI_StrokeText class.
Definition: bi_stroketext.h:49
const StrokeFont & mFont
Definition: bi_stroketext.h:109
bool setPosition(const Point &pos) noexcept
Definition: bi_stroketext.cpp:86
Signal< BI_StrokeText, Event > onEdited
Definition: bi_stroketext.h:62
void addToBoard() override
Definition: bi_stroketext.cpp:208
BI_Device * mDevice
Definition: bi_stroketext.h:110
void updatePaths() noexcept
Definition: bi_stroketext.cpp:239
const QString & getSubstitutedText() const noexcept
Definition: bi_stroketext.h:74
bool setLetterSpacing(const StrokeTextSpacing &spacing) noexcept
Definition: bi_stroketext.cpp:127
bool setAlign(const Alignment &align) noexcept
Definition: bi_stroketext.cpp:146
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:785
bool setLineSpacing(const StrokeTextSpacing &spacing) noexcept
Definition: bi_stroketext.cpp:137
bool setLayer(const Layer &layer) noexcept
Definition: bi_stroketext.cpp:65
QString mSubstitutedText
Definition: bi_stroketext.h:113
The StrokeFont class.
Definition: strokefont.h:54
The BoardStrokeTextData class.
Definition: boardstroketextdata.h:49
const StrokeFont & getFont() const noexcept
Definition: bi_stroketext.h:73
bool setAutoRotate(bool autoRotate) noexcept
Definition: bi_stroketext.cpp:166
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:670
void invalidatePlanes(const Layer &layer) noexcept
Definition: bi_stroketext.cpp:251
Event
Definition: bi_stroketext.h:54