LibrePCB Developers Documentation
Loading...
Searching...
No Matches
symbol.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_SYMBOL_H
21#define LIBREPCB_CORE_SYMBOL_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../geometry/circle.h"
27#include "../../geometry/polygon.h"
28#include "../../geometry/text.h"
29#include "../libraryelement.h"
30#include "symbolpin.h"
31
32#include <QtCore>
33
34#include <memory>
35
36/*******************************************************************************
37 * Namespace / Forward Declarations
38 ******************************************************************************/
39namespace librepcb {
40
41/*******************************************************************************
42 * Class Symbol
43 ******************************************************************************/
44
55class Symbol final : public LibraryElement {
56 Q_OBJECT
57
58public:
59 // Signals
60 enum class Event {
65 };
68
69 // Constructors / Destructor
70 Symbol() = delete;
71 Symbol(const Symbol& other) = delete;
72 Symbol(const Uuid& uuid, const Version& version, const QString& author,
73 const ElementName& name_en_US, const QString& description_en_US,
74 const QString& keywords_en_US);
75 ~Symbol() noexcept;
76
77 // Getters: Geometry
78 bool isEmpty() const noexcept;
79 SymbolPinList& getPins() noexcept { return mPins; }
80 const SymbolPinList& getPins() const noexcept { return mPins; }
81 PolygonList& getPolygons() noexcept { return mPolygons; }
82 const PolygonList& getPolygons() const noexcept { return mPolygons; }
83 CircleList& getCircles() noexcept { return mCircles; }
84 const CircleList& getCircles() const noexcept { return mCircles; }
85 TextList& getTexts() noexcept { return mTexts; }
86 const TextList& getTexts() const noexcept { return mTexts; }
87
88 // General Methods
89 virtual RuleCheckMessageList runChecks() const override;
90
91 // Operator Overloadings
92 Symbol& operator=(const Symbol& rhs) = delete;
93
94 // Static Methods
95 static std::unique_ptr<Symbol> open(
96 std::unique_ptr<TransactionalDirectory> directory,
97 bool abortBeforeMigration = false);
98 static QString getShortElementName() noexcept {
99 return QStringLiteral("sym");
100 }
101 static QString getLongElementName() noexcept {
102 return QStringLiteral("symbol");
103 }
104
105protected: // Methods
106 virtual void serialize(SExpression& root) const override;
107
108private: // Methods
109 Symbol(std::unique_ptr<TransactionalDirectory> directory,
110 const SExpression& root);
111 void pinsEdited(const SymbolPinList& list, int index,
112 const std::shared_ptr<const SymbolPin>& pin,
113 SymbolPinList::Event event) noexcept;
114 void polygonsEdited(const PolygonList& list, int index,
115 const std::shared_ptr<const Polygon>& polygon,
116 PolygonList::Event event) noexcept;
117 void circlesEdited(const CircleList& list, int index,
118 const std::shared_ptr<const Circle>& circle,
119 CircleList::Event event) noexcept;
120 void textsEdited(const TextList& list, int index,
121 const std::shared_ptr<const Text>& text,
122 TextList::Event event) noexcept;
123
124private: // Data
129
130 // Slots
135};
136
137/*******************************************************************************
138 * End of File
139 ******************************************************************************/
140
141} // namespace librepcb
142
143#endif
The LibraryElement class extends the LibraryBaseElement class with some attributes and methods which ...
Definition libraryelement.h:45
The SExpression class.
Definition sexpression.h:69
Slot< SerializableObjectList< SymbolPin, SymbolPinListNameProvider, OnEditedArgs... >, int, const std::shared_ptr< const SymbolPin > &, Event > OnEditedSlot
Definition serializableobjectlist.h:136
The Signal class is used to emit signals on non-QObject derived classes.
Definition signalslot.h:65
The Slot class is used to receive signals from non-QObject derived classes.
Definition signalslot.h:170
The Symbol class represents the part of a component which is added to schematics.
Definition symbol.h:55
Symbol(const Symbol &other)=delete
Slot< Symbol, Event > OnEditedSlot
Definition symbol.h:67
const SymbolPinList & getPins() const noexcept
Definition symbol.h:80
SymbolPinList mPins
Definition symbol.h:125
TextList mTexts
Definition symbol.h:128
~Symbol() noexcept
Definition symbol.cpp:78
Signal< Symbol, Event > onEdited
Definition symbol.h:66
virtual RuleCheckMessageList runChecks() const override
Definition symbol.cpp:90
PolygonList & getPolygons() noexcept
Definition symbol.h:81
CircleList mCircles
Definition symbol.h:127
void circlesEdited(const CircleList &list, int index, const std::shared_ptr< const Circle > &circle, CircleList::Event event) noexcept
Definition symbol.cpp:166
TextList & getTexts() noexcept
Definition symbol.h:85
const PolygonList & getPolygons() const noexcept
Definition symbol.h:82
Event
Definition symbol.h:60
void pinsEdited(const SymbolPinList &list, int index, const std::shared_ptr< const SymbolPin > &pin, SymbolPinList::Event event) noexcept
Definition symbol.cpp:146
const CircleList & getCircles() const noexcept
Definition symbol.h:84
PolygonList::OnEditedSlot mPolygonsEditedSlot
Definition symbol.h:132
const TextList & getTexts() const noexcept
Definition symbol.h:86
SymbolPinList & getPins() noexcept
Definition symbol.h:79
CircleList::OnEditedSlot mCirclesEditedSlot
Definition symbol.h:133
SymbolPinList::OnEditedSlot mPinsEditedSlot
Definition symbol.h:131
PolygonList mPolygons
Definition symbol.h:126
void polygonsEdited(const PolygonList &list, int index, const std::shared_ptr< const Polygon > &polygon, PolygonList::Event event) noexcept
Definition symbol.cpp:156
void textsEdited(const TextList &list, int index, const std::shared_ptr< const Text > &text, TextList::Event event) noexcept
Definition symbol.cpp:176
CircleList & getCircles() noexcept
Definition symbol.h:83
static QString getLongElementName() noexcept
Definition symbol.h:101
TextList::OnEditedSlot mTextsEditedSlot
Definition symbol.h:134
static std::unique_ptr< Symbol > open(std::unique_ptr< TransactionalDirectory > directory, bool abortBeforeMigration=false)
Definition symbol.cpp:95
bool isEmpty() const noexcept
Definition symbol.cpp:85
Symbol & operator=(const Symbol &rhs)=delete
virtual void serialize(SExpression &root) const override
Serialize into librepcb::SExpression node.
Definition symbol.cpp:127
static QString getShortElementName() noexcept
Definition symbol.h:98
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition uuid.h:56
The Version class represents a version number in the format "1.42.7".
Definition version.h:58
Definition occmodel.cpp:77
QVector< std::shared_ptr< const RuleCheckMessage > > RuleCheckMessageList
Definition rulecheckmessage.h:104
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition elementname.h:84