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  ******************************************************************************/
36 namespace librepcb {
37 
38 class SI_Symbol;
39 class Schematic;
40 
41 /*******************************************************************************
42  * Class SI_Text
43  ******************************************************************************/
44 
48 class SI_Text final : public SI_Base {
49  Q_OBJECT
50 
51 public:
52  // Signals
53  enum class Event {
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 
84 private: // Methods
85  void textEdited(const Text& text, Text::Event event) noexcept;
86  void updateText() noexcept;
87 
88 private: // 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
Text::OnEditedSlot mOnTextEditedSlot
Definition: si_text.h:96
The SI_Text class represents a text label in a schematic.
Definition: si_text.h:48
void setSymbol(SI_Symbol *symbol) noexcept
Definition: si_text.cpp:67
const Point & getPosition() const noexcept
Definition: si_text.h:69
Text & getTextObj() noexcept
Definition: si_text.h:72
Definition: occmodel.cpp:76
~SI_Text() noexcept
Definition: si_text.cpp:60
The Schematic Item Base (SI_Base) class.
Definition: si_base.h:45
const QString & getText() const noexcept
Definition: si_text.h:71
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:76
Slot< SI_Text, Event > OnEditedSlot
Definition: si_text.h:59
const Uuid & getUuid() const noexcept
Definition: si_text.h:68
const Point & getPosition() const noexcept
Definition: text.h:78
Event
Definition: text.h:53
The Schematic class represents one schematic page of a project and is always part of a circuit...
Definition: schematic.h:74
Text mTextObj
Definition: si_text.h:90
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
void textEdited(const Text &text, Text::Event event) noexcept
Definition: si_text.cpp:105
const Text & getTextObj() const noexcept
Definition: si_text.h:73
const Angle & getRotation() const noexcept
Definition: si_text.h:70
QString mText
Definition: si_text.h:93
SI_Text & operator=(const SI_Text &rhs)=delete
void removeFromSchematic() override
Definition: si_text.cpp:94
QPointer< SI_Symbol > mSymbol
Definition: si_text.h:89
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
The SI_Symbol class.
Definition: si_symbol.h:54
const Uuid & getUuid() const noexcept
Definition: text.h:76
Signal< SI_Text, Event > onEdited
Definition: si_text.h:58
SI_Symbol * getSymbol() const noexcept
Definition: si_text.h:76
const Angle & getRotation() const noexcept
Definition: text.h:79
The Text class.
Definition: text.h:48
void updateText() noexcept
Definition: si_text.cpp:125
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:56
Event
Definition: si_text.h:53
void addToSchematic() override
Definition: si_text.cpp:87