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_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, public SerializableObject {
57  Q_OBJECT
58 
59 public:
60  // Constructors / Destructor
61  BI_StrokeText() = delete;
62  BI_StrokeText(const BI_StrokeText& other) = delete;
63  BI_StrokeText(Board& board, const BI_StrokeText& other);
64  BI_StrokeText(Board& board, const SExpression& node,
65  const Version& fileFormat);
66  BI_StrokeText(Board& board, const StrokeText& text);
67  ~BI_StrokeText() noexcept;
68 
69  // Getters
70  StrokeText& getText() noexcept { return *mText; }
71  const StrokeText& getText() const noexcept { return *mText; }
72  const Uuid& getUuid() const
73  noexcept; // convenience function, e.g. for template usage
74  bool isSelectable() const noexcept override;
75 
76  // General Methods
77  BI_Footprint* getFootprint() const noexcept { return mFootprint; }
78  void setFootprint(BI_Footprint* footprint) noexcept;
79  void updateGraphicsItems() noexcept;
80  void addToBoard() override;
81  void removeFromBoard() override;
82 
84  void serialize(SExpression& root) const override;
85 
86  // Inherited from BI_Base
87  Type_t getType() const noexcept override {
89  }
90  const Point& getPosition() const noexcept override;
91  bool getIsMirrored() const noexcept override { return false; }
92  QPainterPath getGrabAreaScenePx() const noexcept override;
93  void setSelected(bool selected) noexcept override;
94 
95  // Operator Overloadings
96  BI_StrokeText& operator=(const BI_StrokeText& rhs) = delete;
97 
98 private slots:
100 
101 private: // Methods
102  void init();
103  void updatePaths() noexcept;
104  void strokeTextEdited(const StrokeText& text,
105  StrokeText::Event event) noexcept;
106 
107 private: // Data
109  QScopedPointer<StrokeText> mText;
110  QScopedPointer<StrokeTextGraphicsItem> mGraphicsItem;
111  QScopedPointer<LineGraphicsItem> mAnchorGraphicsItem;
112 
113  // Slots
115 };
116 
117 /*******************************************************************************
118  * End of File
119  ******************************************************************************/
120 
121 } // namespace project
122 } // namespace librepcb
123 
124 #endif // LIBREPCB_PROJECT_BI_STROKETEXT_H
The Version class represents a version number in the format "1.42.7".
Definition: version.h:60
QScopedPointer< StrokeText > mText
Definition: bi_stroketext.h:109
void init()
Definition: bi_stroketext.cpp:73
~BI_StrokeText() noexcept
Definition: bi_stroketext.cpp:89
The BI_StrokeText class.
Definition: bi_stroketext.h:56
bool getIsMirrored() const noexcept override
Definition: bi_stroketext.h:91
Definition: airwiresbuilder.cpp:32
QPainterPath getGrabAreaScenePx() const noexcept override
Definition: bi_stroketext.cpp:162
The StrokeText class.
Definition: stroketext.h:118
const Uuid & getUuid() const noexcept
Definition: bi_stroketext.cpp:166
void addToBoard() override
Definition: bi_stroketext.cpp:134
Type_t
Definition: bi_base.h:57
StrokeText & getText() noexcept
Definition: bi_stroketext.h:70
Event
Definition: stroketext.h:123
const StrokeText & getText() const noexcept
Definition: bi_stroketext.h:71
librepcb::project::BI_StrokeText
void setSelected(bool selected) noexcept override
Definition: bi_stroketext.cpp:176
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: bi_stroketext.cpp:150
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:43
BI_StrokeText & operator=(const BI_StrokeText &rhs)=delete
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
The BI_Footprint class.
Definition: bi_footprint.h:57
const Point & getPosition() const noexcept override
Definition: bi_stroketext.cpp:158
void setFootprint(BI_Footprint *footprint) noexcept
Definition: bi_stroketext.cpp:96
StrokeText::OnEditedSlot mOnStrokeTextEditedSlot
Definition: bi_stroketext.h:114
QScopedPointer< LineGraphicsItem > mAnchorGraphicsItem
Definition: bi_stroketext.h:111
The Board Item Base (BI_Base) class.
Definition: bi_base.h:52
QScopedPointer< StrokeTextGraphicsItem > mGraphicsItem
Definition: bi_stroketext.h:110
void updateGraphicsItems() noexcept
Definition: bi_stroketext.cpp:112
void removeFromBoard() override
Definition: bi_stroketext.cpp:142
BI_Footprint * mFootprint
Definition: bi_stroketext.h:108
Type_t getType() const noexcept override
Definition: bi_stroketext.h:87
The Board class represents a PCB of a project and is always part of a circuit.
Definition: board.h:83
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
bool isSelectable() const noexcept override
Definition: bi_stroketext.cpp:170
The SExpression class.
Definition: sexpression.h:72
void strokeTextEdited(const StrokeText &text, StrokeText::Event event) noexcept
Definition: bi_stroketext.cpp:194
void boardOrFootprintAttributesChanged()
Definition: bi_stroketext.cpp:186
BI_Footprint * getFootprint() const noexcept
Definition: bi_stroketext.h:77