LibrePCB Developers Documentation
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 {
61 PinsEdited,
62 PolygonsEdited,
63 CirclesEdited,
64 TextsEdited,
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 SymbolPinList& getPins() noexcept { return mPins; }
79 const SymbolPinList& getPins() const noexcept { return mPins; }
80 PolygonList& getPolygons() noexcept { return mPolygons; }
81 const PolygonList& getPolygons() const noexcept { return mPolygons; }
82 CircleList& getCircles() noexcept { return mCircles; }
83 const CircleList& getCircles() const noexcept { return mCircles; }
84 TextList& getTexts() noexcept { return mTexts; }
85 const TextList& getTexts() const noexcept { return mTexts; }
86
87 // General Methods
88 virtual RuleCheckMessageList runChecks() const override;
89
90 // Operator Overloadings
91 Symbol& operator=(const Symbol& rhs) = delete;
92
93 // Static Methods
94 static std::unique_ptr<Symbol> open(
95 std::unique_ptr<TransactionalDirectory> directory,
96 bool abortBeforeMigration = false);
97 static QString getShortElementName() noexcept {
98 return QStringLiteral("sym");
99 }
100 static QString getLongElementName() noexcept {
101 return QStringLiteral("symbol");
102 }
103
104protected: // Methods
105 virtual void serialize(SExpression& root) const override;
106
107private: // Methods
108 Symbol(std::unique_ptr<TransactionalDirectory> directory,
109 const SExpression& root);
110 void pinsEdited(const SymbolPinList& list, int index,
111 const std::shared_ptr<const SymbolPin>& pin,
112 SymbolPinList::Event event) noexcept;
113 void polygonsEdited(const PolygonList& list, int index,
114 const std::shared_ptr<const Polygon>& polygon,
115 PolygonList::Event event) noexcept;
116 void circlesEdited(const CircleList& list, int index,
117 const std::shared_ptr<const Circle>& circle,
118 CircleList::Event event) noexcept;
119 void textsEdited(const TextList& list, int index,
120 const std::shared_ptr<const Text>& text,
121 TextList::Event event) noexcept;
122
123private: // Data
128
129 // Slots
134};
135
136/*******************************************************************************
137 * End of File
138 ******************************************************************************/
139
140} // namespace librepcb
141
142#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
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
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:79
SymbolPinList mPins
Definition: symbol.h:124
TextList mTexts
Definition: symbol.h:127
~Symbol() noexcept
Definition: symbol.cpp:78
Signal< Symbol, Event > onEdited
Definition: symbol.h:66
virtual RuleCheckMessageList runChecks() const override
Definition: symbol.cpp:85
PolygonList & getPolygons() noexcept
Definition: symbol.h:80
CircleList mCircles
Definition: symbol.h:126
void circlesEdited(const CircleList &list, int index, const std::shared_ptr< const Circle > &circle, CircleList::Event event) noexcept
Definition: symbol.cpp:161
TextList & getTexts() noexcept
Definition: symbol.h:84
const PolygonList & getPolygons() const noexcept
Definition: symbol.h:81
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:141
const CircleList & getCircles() const noexcept
Definition: symbol.h:83
PolygonList::OnEditedSlot mPolygonsEditedSlot
Definition: symbol.h:131
const TextList & getTexts() const noexcept
Definition: symbol.h:85
SymbolPinList & getPins() noexcept
Definition: symbol.h:78
CircleList::OnEditedSlot mCirclesEditedSlot
Definition: symbol.h:132
SymbolPinList::OnEditedSlot mPinsEditedSlot
Definition: symbol.h:130
PolygonList mPolygons
Definition: symbol.h:125
void polygonsEdited(const PolygonList &list, int index, const std::shared_ptr< const Polygon > &polygon, PolygonList::Event event) noexcept
Definition: symbol.cpp:151
void textsEdited(const TextList &list, int index, const std::shared_ptr< const Text > &text, TextList::Event event) noexcept
Definition: symbol.cpp:171
CircleList & getCircles() noexcept
Definition: symbol.h:82
static QString getLongElementName() noexcept
Definition: symbol.h:100
TextList::OnEditedSlot mTextsEditedSlot
Definition: symbol.h:133
static std::unique_ptr< Symbol > open(std::unique_ptr< TransactionalDirectory > directory, bool abortBeforeMigration=false)
Definition: symbol.cpp:90
Symbol & operator=(const Symbol &rhs)=delete
virtual void serialize(SExpression &root) const override
Serialize into librepcb::SExpression node.
Definition: symbol.cpp:122
static QString getShortElementName() noexcept
Definition: symbol.h:97
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
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