LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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_PROJECT_BI_STROKETEXT_H
21 #define LIBREPCB_PROJECT_BI_STROKETEXT_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "bi_base.h"
27 
31 #include <librepcb/common/uuid.h>
32 
33 #include <QtCore>
34 
35 /*******************************************************************************
36  * Namespace / Forward Declarations
37  ******************************************************************************/
38 namespace librepcb {
39 
40 class StrokeTextGraphicsItem;
41 class LineGraphicsItem;
42 
43 namespace project {
44 
45 class Project;
46 class Board;
47 class BI_Footprint;
48 
49 /*******************************************************************************
50  * Class BI_StrokeText
51  ******************************************************************************/
52 
56 class BI_StrokeText final : public BI_Base,
57  public SerializableObject,
58  public IF_StrokeTextObserver {
59  Q_OBJECT
60 
61 public:
62  // Constructors / Destructor
63  BI_StrokeText() = delete;
64  BI_StrokeText(const BI_StrokeText& other) = delete;
65  BI_StrokeText(Board& board, const BI_StrokeText& other);
66  BI_StrokeText(Board& board, const SExpression& node);
67  BI_StrokeText(Board& board, const StrokeText& text);
68  ~BI_StrokeText() noexcept;
69 
70  // Getters
71  StrokeText& getText() noexcept { return *mText; }
72  const StrokeText& getText() const noexcept { return *mText; }
73  const Uuid& getUuid() const
74  noexcept; // convenience function, e.g. for template usage
75  bool isSelectable() const noexcept override;
76 
77  // General Methods
78  BI_Footprint* getFootprint() const noexcept { return mFootprint; }
79  void setFootprint(BI_Footprint* footprint) noexcept;
80  void updateGraphicsItems() noexcept;
81  void addToBoard() override;
82  void removeFromBoard() override;
83 
85  void serialize(SExpression& root) const override;
86 
87  // Inherited from BI_Base
88  Type_t getType() const noexcept override {
90  }
91  const Point& getPosition() const noexcept override;
92  bool getIsMirrored() const noexcept override { return false; }
93  QPainterPath getGrabAreaScenePx() const noexcept override;
94  void setSelected(bool selected) noexcept override;
95 
96  // Operator Overloadings
97  BI_StrokeText& operator=(const BI_StrokeText& rhs) = delete;
98 
99 private slots:
100  void boardAttributesChanged();
101 
102 private: // Methods
103  void init();
104  void updatePaths() noexcept;
106  const GraphicsLayerName& newLayerName) noexcept override {
107  Q_UNUSED(newLayerName);
109  }
110  void strokeTextTextChanged(const QString& newText) noexcept override {
111  Q_UNUSED(newText);
112  }
113  void strokeTextPositionChanged(const Point& newPos) noexcept override {
114  Q_UNUSED(newPos);
116  }
117  void strokeTextRotationChanged(const Angle& newRot) noexcept override {
118  Q_UNUSED(newRot);
119  }
121  const PositiveLength& newHeight) noexcept override {
122  Q_UNUSED(newHeight);
123  }
125  const UnsignedLength& newStrokeWidth) noexcept override {
126  Q_UNUSED(newStrokeWidth);
127  }
129  const StrokeTextSpacing& spacing) noexcept override {
130  Q_UNUSED(spacing);
131  }
133  const StrokeTextSpacing& spacing) noexcept override {
134  Q_UNUSED(spacing);
135  }
136  void strokeTextAlignChanged(const Alignment& newAlign) noexcept override {
137  Q_UNUSED(newAlign);
138  }
139  void strokeTextMirroredChanged(bool mirrored) noexcept override {
140  Q_UNUSED(mirrored);
141  }
142  void strokeTextAutoRotateChanged(bool newAutoRotate) noexcept override {
143  Q_UNUSED(newAutoRotate);
144  }
145  void strokeTextPathsChanged(const QVector<Path>& paths) noexcept override {
146  Q_UNUSED(paths);
147  }
148 
149 private: // Data
151  QScopedPointer<StrokeText> mText;
152  QScopedPointer<StrokeTextGraphicsItem> mGraphicsItem;
153  QScopedPointer<LineGraphicsItem> mAnchorGraphicsItem;
154 };
155 
156 /*******************************************************************************
157  * End of File
158  ******************************************************************************/
159 
160 } // namespace project
161 } // namespace librepcb
162 
163 #endif // LIBREPCB_PROJECT_BI_STROKETEXT_H
void strokeTextPathsChanged(const QVector< Path > &paths) noexceptoverride
Definition: bi_stroketext.h:145
void strokeTextTextChanged(const QString &newText) noexceptoverride
Definition: bi_stroketext.h:110
QScopedPointer< StrokeText > mText
Definition: bi_stroketext.h:151
void strokeTextLayerNameChanged(const GraphicsLayerName &newLayerName) noexceptoverride
Definition: bi_stroketext.h:105
void init()
Definition: bi_stroketext.cpp:66
~BI_StrokeText() noexcept
Definition: bi_stroketext.cpp:82
void strokeTextMirroredChanged(bool mirrored) noexceptoverride
Definition: bi_stroketext.h:139
The Alignment class.
Definition: alignment.h:193
void strokeTextStrokeWidthChanged(const UnsignedLength &newStrokeWidth) noexceptoverride
Definition: bi_stroketext.h:124
The BI_StrokeText class.
Definition: bi_stroketext.h:56
bool isSelectable() const noexceptoverride
Definition: bi_stroketext.cpp:156
type_safe::constrained_type< QString, GraphicsLayerNameConstraint, GraphicsLayerNameVerifier > GraphicsLayerName
Definition: graphicslayername.h:78
The StrokeText class.
Definition: stroketext.h:153
const Uuid & getUuid() const noexcept
Definition: bi_stroketext.cpp:152
void setSelected(bool selected) noexceptoverride
Definition: bi_stroketext.cpp:162
void addToBoard() override
Definition: bi_stroketext.cpp:120
Type_t
Definition: bi_base.h:57
StrokeText & getText() noexcept
Definition: bi_stroketext.h:71
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:81
const StrokeText & getText() const noexcept
Definition: bi_stroketext.h:72
librepcb::project::BI_StrokeText
void strokeTextAutoRotateChanged(bool newAutoRotate) noexceptoverride
Definition: bi_stroketext.h:142
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: bi_stroketext.cpp:136
The StrokeTextSpacing class.
Definition: stroketext.h:52
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:46
The IF_StrokeTextObserver class.
Definition: stroketext.h:119
bool getIsMirrored() const noexceptoverride
Definition: bi_stroketext.h:92
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:81
The BI_Footprint class.
Definition: bi_footprint.h:60
void strokeTextLetterSpacingChanged(const StrokeTextSpacing &spacing) noexceptoverride
Definition: bi_stroketext.h:128
void setFootprint(BI_Footprint *footprint) noexcept
Definition: bi_stroketext.cpp:93
const Point & getPosition() const noexceptoverride
Definition: bi_stroketext.cpp:144
void strokeTextPositionChanged(const Point &newPos) noexceptoverride
Definition: bi_stroketext.h:113
QScopedPointer< LineGraphicsItem > mAnchorGraphicsItem
Definition: bi_stroketext.h:153
Type_t getType() const noexceptoverride
Definition: bi_stroketext.h:88
void boardAttributesChanged()
Definition: bi_stroketext.cpp:172
The Board Item Base (BI_Base) class.
Definition: bi_base.h:52
QScopedPointer< StrokeTextGraphicsItem > mGraphicsItem
Definition: bi_stroketext.h:152
void strokeTextHeightChanged(const PositiveLength &newHeight) noexceptoverride
Definition: bi_stroketext.h:120
void updateGraphicsItems() noexcept
Definition: bi_stroketext.cpp:98
void removeFromBoard() override
Definition: bi_stroketext.cpp:128
void strokeTextLineSpacingChanged(const StrokeTextSpacing &spacing) noexceptoverride
Definition: bi_stroketext.h:132
BI_Footprint * mFootprint
Definition: bi_stroketext.h:150
QPainterPath getGrabAreaScenePx() const noexceptoverride
Definition: bi_stroketext.cpp:148
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:783
The Board class represents a PCB of a project and is always part of a circuit.
Definition: board.h:82
void strokeTextAlignChanged(const Alignment &newAlign) noexceptoverride
Definition: bi_stroketext.h:136
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
void strokeTextRotationChanged(const Angle &newRot) noexceptoverride
Definition: bi_stroketext.h:117
The SExpression class.
Definition: sexpression.h:60
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:662
BI_Footprint * getFootprint() const noexcept
Definition: bi_stroketext.h:78