LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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_LIBRARY_SYMBOL_H
21 #define LIBREPCB_LIBRARY_SYMBOL_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../libraryelement.h"
27 #include "symbolpin.h"
28 
32 
33 #include <QtCore>
34 
35 /*******************************************************************************
36  * Namespace / Forward Declarations
37  ******************************************************************************/
38 namespace librepcb {
39 namespace library {
40 
41 class SymbolGraphicsItem;
42 
43 /*******************************************************************************
44  * Class Symbol
45  ******************************************************************************/
46 
57 class Symbol final : public LibraryElement {
58  Q_OBJECT
59 
60 public:
61  // Signals
62  enum class Event {
63  PinsEdited,
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  explicit Symbol(std::unique_ptr<TransactionalDirectory> directory);
78  ~Symbol() noexcept;
79 
80  // Getters: Geometry
81  SymbolPinList& getPins() noexcept { return mPins; }
82  const SymbolPinList& getPins() const noexcept { return mPins; }
83  PolygonList& getPolygons() noexcept { return mPolygons; }
84  const PolygonList& getPolygons() const noexcept { return mPolygons; }
85  CircleList& getCircles() noexcept { return mCircles; }
86  const CircleList& getCircles() const noexcept { return mCircles; }
87  TextList& getTexts() noexcept { return mTexts; }
88  const TextList& getTexts() const noexcept { return mTexts; }
89 
90  // General Methods
91  virtual LibraryElementCheckMessageList runChecks() const override;
92  void registerGraphicsItem(SymbolGraphicsItem& item) noexcept;
93  void unregisterGraphicsItem(SymbolGraphicsItem& item) noexcept;
94 
95  // Operator Overloadings
96  Symbol& operator=(const Symbol& rhs) = delete;
97 
98  // Static Methods
99  static QString getShortElementName() noexcept {
100  return QStringLiteral("sym");
101  }
102  static QString getLongElementName() noexcept {
103  return QStringLiteral("symbol");
104  }
105 
106 private: // Methods
107  void pinsEdited(const SymbolPinList& list, int index,
108  const std::shared_ptr<const SymbolPin>& pin,
109  SymbolPinList::Event event) noexcept;
110  void polygonsEdited(const PolygonList& list, int index,
111  const std::shared_ptr<const Polygon>& polygon,
112  PolygonList::Event event) noexcept;
113  void circlesEdited(const CircleList& list, int index,
114  const std::shared_ptr<const Circle>& circle,
115  CircleList::Event event) noexcept;
116  void textsEdited(const TextList& list, int index,
117  const std::shared_ptr<const Text>& text,
118  TextList::Event event) noexcept;
120  void serialize(SExpression& root) const override;
121 
122 private: // Data
127 
129 
130  // Slots
135 };
136 
137 /*******************************************************************************
138  * End of File
139  ******************************************************************************/
140 
141 } // namespace library
142 } // namespace librepcb
143 
144 #endif // LIBREPCB_LIBRARY_SYMBOL_H
CircleList & getCircles() noexcept
Definition: symbol.h:85
PolygonList mPolygons
Definition: symbol.h:124
TextList::OnEditedSlot mTextsEditedSlot
Definition: symbol.h:134
The Version class represents a version number in the format "1.42.7".
Definition: version.h:60
Slot< SerializableObjectList< Polygon, PolygonListNameProvider, OnEditedArgs...>, int, const std::shared_ptr< const Polygon > &, Event > OnEditedSlot
Definition: serializableobjectlist.h:133
QVector< std::shared_ptr< const LibraryElementCheckMessage > > LibraryElementCheckMessageList
Definition: libraryelementcheckmessage.h:96
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: symbol.cpp:198
CircleList::OnEditedSlot mCirclesEditedSlot
Definition: symbol.h:133
TextList & getTexts() noexcept
Definition: symbol.h:87
void unregisterGraphicsItem(SymbolGraphicsItem &item) noexcept
Definition: symbol.cpp:101
SymbolPinList mPins
Definition: symbol.h:123
void registerGraphicsItem(SymbolGraphicsItem &item) noexcept
Definition: symbol.cpp:96
SymbolPinList & getPins() noexcept
Definition: symbol.h:81
const CircleList & getCircles() const noexcept
Definition: symbol.h:86
void polygonsEdited(const PolygonList &list, int index, const std::shared_ptr< const Polygon > &polygon, PolygonList::Event event) noexcept
Definition: symbol.cpp:132
const PolygonList & getPolygons() const noexcept
Definition: symbol.h:84
The Symbol class represents the part of a component which is added to schematics. ...
Definition: symbol.h:57
Signal< Symbol, Event > onEdited
Definition: symbol.h:68
TextList mTexts
Definition: symbol.h:126
static QString getShortElementName() noexcept
Definition: symbol.h:99
Slot< Symbol, Event > OnEditedSlot
Definition: symbol.h:69
void pinsEdited(const SymbolPinList &list, int index, const std::shared_ptr< const SymbolPin > &pin, SymbolPinList::Event event) noexcept
Definition: symbol.cpp:110
virtual LibraryElementCheckMessageList runChecks() const override
Definition: symbol.cpp:91
Event
Definition: symbol.h:62
~Symbol() noexcept
Definition: symbol.cpp:83
void circlesEdited(const CircleList &list, int index, const std::shared_ptr< const Circle > &circle, CircleList::Event event) noexcept
Definition: symbol.cpp:154
The LibraryElement class extends the LibraryBaseElement class with some attributes and methods which ...
Definition: libraryelement.h:45
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
const SymbolPinList & getPins() const noexcept
Definition: symbol.h:82
PolygonList::OnEditedSlot mPolygonsEditedSlot
Definition: symbol.h:132
The SymbolGraphicsItem class.
Definition: symbolgraphicsitem.h:58
SymbolGraphicsItem * mRegisteredGraphicsItem
Definition: symbol.h:128
Symbol & operator=(const Symbol &rhs)=delete
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
const TextList & getTexts() const noexcept
Definition: symbol.h:88
static QString getLongElementName() noexcept
Definition: symbol.h:102
SymbolPinList::OnEditedSlot mPinsEditedSlot
Definition: symbol.h:131
CircleList mCircles
Definition: symbol.h:125
void textsEdited(const TextList &list, int index, const std::shared_ptr< const Text > &text, TextList::Event event) noexcept
Definition: symbol.cpp:176
The Slot class is used to receive signals from non-QObject derived classes.
Definition: signalslot.h:36
The SExpression class.
Definition: sexpression.h:57
PolygonList & getPolygons() noexcept
Definition: symbol.h:83
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition: elementname.h:92