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, 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  BI_StrokeText(Board& board, const StrokeText& text);
66  ~BI_StrokeText() noexcept;
67 
68  // Getters
69  StrokeText& getText() noexcept { return *mText; }
70  const StrokeText& getText() const noexcept { return *mText; }
71  const Uuid& getUuid() const
72  noexcept; // convenience function, e.g. for template usage
73  bool isSelectable() const noexcept override;
74 
75  // General Methods
76  BI_Footprint* getFootprint() const noexcept { return mFootprint; }
77  void setFootprint(BI_Footprint* footprint) noexcept;
78  void updateGraphicsItems() noexcept;
79  void addToBoard() override;
80  void removeFromBoard() override;
81 
83  void serialize(SExpression& root) const override;
84 
85  // Inherited from BI_Base
86  Type_t getType() const noexcept override {
88  }
89  const Point& getPosition() const noexcept override;
90  bool getIsMirrored() const noexcept override { return false; }
91  QPainterPath getGrabAreaScenePx() const noexcept override;
92  void setSelected(bool selected) noexcept override;
93 
94  // Operator Overloadings
95  BI_StrokeText& operator=(const BI_StrokeText& rhs) = delete;
96 
97 private slots:
99 
100 private: // Methods
101  void init();
102  void updatePaths() noexcept;
103  void strokeTextEdited(const StrokeText& text,
104  StrokeText::Event event) noexcept;
105 
106 private: // Data
108  QScopedPointer<StrokeText> mText;
111 
112  // Slots
114 };
115 
116 /*******************************************************************************
117  * End of File
118  ******************************************************************************/
119 
120 } // namespace project
121 } // namespace librepcb
122 
123 #endif // LIBREPCB_PROJECT_BI_STROKETEXT_H
QScopedPointer< StrokeText > mText
Definition: bi_stroketext.h:108
void init()
Definition: bi_stroketext.cpp:72
~BI_StrokeText() noexcept
Definition: bi_stroketext.cpp:88
The BI_StrokeText class.
Definition: bi_stroketext.h:56
bool isSelectable() const noexceptoverride
Definition: bi_stroketext.cpp:158
The StrokeText class.
Definition: stroketext.h:119
const Uuid & getUuid() const noexcept
Definition: bi_stroketext.cpp:154
void setSelected(bool selected) noexceptoverride
Definition: bi_stroketext.cpp:164
void addToBoard() override
Definition: bi_stroketext.cpp:122
Type_t
Definition: bi_base.h:57
StrokeText & getText() noexcept
Definition: bi_stroketext.h:69
const StrokeText & getText() const noexcept
Definition: bi_stroketext.h:70
librepcb::project::BI_StrokeText
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: bi_stroketext.cpp:138
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:43
bool getIsMirrored() const noexceptoverride
Definition: bi_stroketext.h:90
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
The LineGraphicsItem class.
Definition: linegraphicsitem.h:44
void setFootprint(BI_Footprint *footprint) noexcept
Definition: bi_stroketext.cpp:95
const Point & getPosition() const noexceptoverride
Definition: bi_stroketext.cpp:146
StrokeText::OnEditedSlot mOnStrokeTextEditedSlot
Definition: bi_stroketext.h:113
QScopedPointer< LineGraphicsItem > mAnchorGraphicsItem
Definition: bi_stroketext.h:110
Type_t getType() const noexceptoverride
Definition: bi_stroketext.h:86
void boardAttributesChanged()
Definition: bi_stroketext.cpp:174
The Board Item Base (BI_Base) class.
Definition: bi_base.h:52
QScopedPointer< StrokeTextGraphicsItem > mGraphicsItem
Definition: bi_stroketext.h:109
The StrokeTextGraphicsItem class is the graphical representation of a librepcb::StrokeText.
Definition: stroketextgraphicsitem.h:48
void updateGraphicsItems() noexcept
Definition: bi_stroketext.cpp:100
void removeFromBoard() override
Definition: bi_stroketext.cpp:130
BI_Footprint * mFootprint
Definition: bi_stroketext.h:107
QPainterPath getGrabAreaScenePx() const noexceptoverride
Definition: bi_stroketext.cpp:150
The Board class represents a PCB of a project and is always part of a circuit.
Definition: board.h:82
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
The SExpression class.
Definition: sexpression.h:57
void strokeTextEdited(const StrokeText &text, StrokeText::Event event) noexcept
Definition: bi_stroketext.cpp:182
BI_Footprint * getFootprint() const noexcept
Definition: bi_stroketext.h:76