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/image.h"
28#include "../../geometry/polygon.h"
29#include "../../geometry/text.h"
30#include "../libraryelement.h"
31#include "symbolpin.h"
32
33#include <QtCore>
34
35#include <memory>
36
37/*******************************************************************************
38 * Namespace / Forward Declarations
39 ******************************************************************************/
40namespace librepcb {
41
42/*******************************************************************************
43 * Class Symbol
44 ******************************************************************************/
45
56class Symbol final : public LibraryElement {
57 Q_OBJECT
58
59public:
60 // Signals
61 enum class Event {
67 };
70
71 // Constructors / Destructor
72 Symbol() = delete;
73 Symbol(const Symbol& other) = delete;
74 Symbol(const Uuid& uuid, const Version& version, const QString& author,
75 const ElementName& name_en_US, const QString& description_en_US,
76 const QString& keywords_en_US);
77 ~Symbol() noexcept;
78
79 // Getters: Attributes
80 const PositiveLength& getGridInterval() const noexcept {
81 return mGridInterval;
82 }
83
84 // Setters: Attributes
85 void setGridInterval(const PositiveLength& interval) noexcept {
86 mGridInterval = interval;
87 }
88
89 // Getters: Geometry
90 bool isEmpty() const noexcept;
91 SymbolPinList& getPins() noexcept { return mPins; }
92 const SymbolPinList& getPins() const noexcept { return mPins; }
93 PolygonList& getPolygons() noexcept { return mPolygons; }
94 const PolygonList& getPolygons() const noexcept { return mPolygons; }
95 CircleList& getCircles() noexcept { return mCircles; }
96 const CircleList& getCircles() const noexcept { return mCircles; }
97 TextList& getTexts() noexcept { return mTexts; }
98 const TextList& getTexts() const noexcept { return mTexts; }
99 ImageList& getImages() noexcept { return mImages; }
100 const ImageList& getImages() const noexcept { return mImages; }
101
102 // General Methods
103 virtual RuleCheckMessageList runChecks() const override;
104
105 // Operator Overloadings
106 Symbol& operator=(const Symbol& rhs) = delete;
107
108 // Static Methods
109 static std::unique_ptr<Symbol> open(
110 std::unique_ptr<TransactionalDirectory> directory,
111 bool abortBeforeMigration = false);
112 static QString getShortElementName() noexcept {
113 return QStringLiteral("sym");
114 }
115 static QString getLongElementName() noexcept {
116 return QStringLiteral("symbol");
117 }
118
119protected: // Methods
120 virtual void serialize(SExpression& root) const override;
121
122private: // Methods
123 Symbol(std::unique_ptr<TransactionalDirectory> directory,
124 const SExpression& root);
125 void pinsEdited(const SymbolPinList& list, int index,
126 const std::shared_ptr<const SymbolPin>& pin,
127 SymbolPinList::Event event) noexcept;
128 void polygonsEdited(const PolygonList& list, int index,
129 const std::shared_ptr<const Polygon>& polygon,
130 PolygonList::Event event) noexcept;
131 void circlesEdited(const CircleList& list, int index,
132 const std::shared_ptr<const Circle>& circle,
133 CircleList::Event event) noexcept;
134 void textsEdited(const TextList& list, int index,
135 const std::shared_ptr<const Text>& text,
136 TextList::Event event) noexcept;
137 void imagesEdited(const ImageList& list, int index,
138 const std::shared_ptr<const Image>& image,
139 ImageList::Event event) noexcept;
140
141private: // Data
143
149
150 // Slots
156};
157
158/*******************************************************************************
159 * End of File
160 ******************************************************************************/
161
162} // namespace librepcb
163
164#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:56
ImageList & getImages() noexcept
Definition symbol.h:99
Symbol(const Symbol &other)=delete
Slot< Symbol, Event > OnEditedSlot
Definition symbol.h:69
PositiveLength mGridInterval
Definition symbol.h:142
const SymbolPinList & getPins() const noexcept
Definition symbol.h:92
SymbolPinList mPins
Definition symbol.h:144
TextList mTexts
Definition symbol.h:147
~Symbol() noexcept
Definition symbol.cpp:87
Signal< Symbol, Event > onEdited
Definition symbol.h:68
const PositiveLength & getGridInterval() const noexcept
Definition symbol.h:80
virtual RuleCheckMessageList runChecks() const override
Definition symbol.cpp:99
ImageList mImages
Definition symbol.h:148
PolygonList & getPolygons() noexcept
Definition symbol.h:93
CircleList mCircles
Definition symbol.h:146
void circlesEdited(const CircleList &list, int index, const std::shared_ptr< const Circle > &circle, CircleList::Event event) noexcept
Definition symbol.cpp:179
TextList & getTexts() noexcept
Definition symbol.h:97
const ImageList & getImages() const noexcept
Definition symbol.h:100
const PolygonList & getPolygons() const noexcept
Definition symbol.h:94
Event
Definition symbol.h:61
void pinsEdited(const SymbolPinList &list, int index, const std::shared_ptr< const SymbolPin > &pin, SymbolPinList::Event event) noexcept
Definition symbol.cpp:159
const CircleList & getCircles() const noexcept
Definition symbol.h:96
ImageList::OnEditedSlot mImagesEditedSlot
Definition symbol.h:155
PolygonList::OnEditedSlot mPolygonsEditedSlot
Definition symbol.h:152
const TextList & getTexts() const noexcept
Definition symbol.h:98
SymbolPinList & getPins() noexcept
Definition symbol.h:91
CircleList::OnEditedSlot mCirclesEditedSlot
Definition symbol.h:153
SymbolPinList::OnEditedSlot mPinsEditedSlot
Definition symbol.h:151
PolygonList mPolygons
Definition symbol.h:145
void polygonsEdited(const PolygonList &list, int index, const std::shared_ptr< const Polygon > &polygon, PolygonList::Event event) noexcept
Definition symbol.cpp:169
void textsEdited(const TextList &list, int index, const std::shared_ptr< const Text > &text, TextList::Event event) noexcept
Definition symbol.cpp:189
CircleList & getCircles() noexcept
Definition symbol.h:95
static QString getLongElementName() noexcept
Definition symbol.h:115
TextList::OnEditedSlot mTextsEditedSlot
Definition symbol.h:154
static std::unique_ptr< Symbol > open(std::unique_ptr< TransactionalDirectory > directory, bool abortBeforeMigration=false)
Definition symbol.cpp:104
bool isEmpty() const noexcept
Definition symbol.cpp:94
Symbol & operator=(const Symbol &rhs)=delete
virtual void serialize(SExpression &root) const override
Serialize into librepcb::SExpression node.
Definition symbol.cpp:136
void imagesEdited(const ImageList &list, int index, const std::shared_ptr< const Image > &image, ImageList::Event event) noexcept
Definition symbol.cpp:199
void setGridInterval(const PositiveLength &interval) noexcept
Definition symbol.h:85
static QString getShortElementName() noexcept
Definition symbol.h:112
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
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition length.h:810
QVector< std::shared_ptr< const RuleCheckMessage > > RuleCheckMessageList
Definition rulecheckmessage.h:104
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition elementname.h:84