LibrePCB Developers Documentation
si_text.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_SI_TEXT_H
21#define LIBREPCB_CORE_SI_TEXT_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../../geometry/text.h"
27#include "../../../utils/signalslot.h"
28#include "si_base.h"
29#include "si_symbol.h"
30
31#include <QtCore>
32
33/*******************************************************************************
34 * Namespace / Forward Declarations
35 ******************************************************************************/
36namespace librepcb {
37
38class SI_Symbol;
39class Schematic;
40
41/*******************************************************************************
42 * Class SI_Text
43 ******************************************************************************/
44
48class SI_Text final : public SI_Base {
49 Q_OBJECT
50
51public:
52 // Signals
53 enum class Event {
54 PositionChanged,
55 LayerNameChanged,
56 TextChanged,
57 };
60
61 // Constructors / Destructor
62 SI_Text() = delete;
63 SI_Text(const SI_Text& other) = delete;
64 SI_Text(Schematic& schematic, const Text& text);
65 ~SI_Text() noexcept;
66
67 // Getters
68 const Uuid& getUuid() const noexcept { return mTextObj.getUuid(); }
69 const Point& getPosition() const noexcept { return mTextObj.getPosition(); }
70 const Angle& getRotation() const noexcept { return mTextObj.getRotation(); }
71 const QString& getText() const noexcept { return mText; }
72 Text& getTextObj() noexcept { return mTextObj; }
73 const Text& getTextObj() const noexcept { return mTextObj; }
74
75 // General Methods
76 SI_Symbol* getSymbol() const noexcept { return mSymbol; }
77 void setSymbol(SI_Symbol* symbol) noexcept;
78 void addToSchematic() override;
79 void removeFromSchematic() override;
80
81 // Operator Overloadings
82 SI_Text& operator=(const SI_Text& rhs) = delete;
83
84private: // Methods
85 void textEdited(const Text& text, Text::Event event) noexcept;
86 void updateText() noexcept;
87
88private: // Attributes
89 QPointer<SI_Symbol> mSymbol;
91
92 // Cached Attributes
93 QString mText;
94
95 // Slots
97};
98
99/*******************************************************************************
100 * End of File
101 ******************************************************************************/
102
103} // namespace librepcb
104
105#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition: point.h:79
The Schematic Item Base (SI_Base) class.
Definition: si_base.h:45
The SI_Symbol class.
Definition: si_symbol.h:54
The SI_Text class represents a text label in a schematic.
Definition: si_text.h:48
const Angle & getRotation() const noexcept
Definition: si_text.h:70
void updateText() noexcept
Definition: si_text.cpp:125
void textEdited(const Text &text, Text::Event event) noexcept
Definition: si_text.cpp:105
Text & getTextObj() noexcept
Definition: si_text.h:72
Signal< SI_Text, Event > onEdited
Definition: si_text.h:58
Event
Definition: si_text.h:53
Slot< SI_Text, Event > OnEditedSlot
Definition: si_text.h:59
void setSymbol(SI_Symbol *symbol) noexcept
Definition: si_text.cpp:67
QString mText
Definition: si_text.h:93
void removeFromSchematic() override
Definition: si_text.cpp:94
SI_Text & operator=(const SI_Text &rhs)=delete
SI_Symbol * getSymbol() const noexcept
Definition: si_text.h:76
void addToSchematic() override
Definition: si_text.cpp:87
const QString & getText() const noexcept
Definition: si_text.h:71
QPointer< SI_Symbol > mSymbol
Definition: si_text.h:89
Text::OnEditedSlot mOnTextEditedSlot
Definition: si_text.h:96
const Point & getPosition() const noexcept
Definition: si_text.h:69
~SI_Text() noexcept
Definition: si_text.cpp:60
const Uuid & getUuid() const noexcept
Definition: si_text.h:68
Text mTextObj
Definition: si_text.h:90
const Text & getTextObj() const noexcept
Definition: si_text.h:73
SI_Text(const SI_Text &other)=delete
The Schematic class represents one schematic page of a project and is always part of a circuit.
Definition: schematic.h:74
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
The Text class.
Definition: text.h:48
const Angle & getRotation() const noexcept
Definition: text.h:79
Event
Definition: text.h:53
const Point & getPosition() const noexcept
Definition: text.h:78
const Uuid & getUuid() const noexcept
Definition: text.h:76
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
Definition: occmodel.cpp:77