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  private SymbolPinList::IF_Observer,
59  private PolygonList::IF_Observer,
60  private CircleList::IF_Observer,
61  private TextList::IF_Observer {
62  Q_OBJECT
63 
64 public:
65  // Constructors / Destructor
66  Symbol() = delete;
67  Symbol(const Symbol& other) = delete;
68  Symbol(const Uuid& uuid, const Version& version, const QString& author,
69  const ElementName& name_en_US, const QString& description_en_US,
70  const QString& keywords_en_US);
71  explicit Symbol(const FilePath& elementDirectory, bool readOnly);
72  ~Symbol() noexcept;
73 
74  // Getters: Geometry
75  SymbolPinList& getPins() noexcept { return mPins; }
76  const SymbolPinList& getPins() const noexcept { return mPins; }
77  PolygonList& getPolygons() noexcept { return mPolygons; }
78  const PolygonList& getPolygons() const noexcept { return mPolygons; }
79  CircleList& getCircles() noexcept { return mCircles; }
80  const CircleList& getCircles() const noexcept { return mCircles; }
81  TextList& getTexts() noexcept { return mTexts; }
82  const TextList& getTexts() const noexcept { return mTexts; }
83 
84  // General Methods
85  virtual LibraryElementCheckMessageList runChecks() const override;
86  void registerGraphicsItem(SymbolGraphicsItem& item) noexcept;
87  void unregisterGraphicsItem(SymbolGraphicsItem& item) noexcept;
88 
89  // Operator Overloadings
90  Symbol& operator=(const Symbol& rhs) = delete;
91 
92  // Static Methods
93  static QString getShortElementName() noexcept {
94  return QStringLiteral("sym");
95  }
96  static QString getLongElementName() noexcept {
97  return QStringLiteral("symbol");
98  }
99 
100 private: // Methods
101  void listObjectAdded(const SymbolPinList& list, int newIndex,
102  const std::shared_ptr<SymbolPin>& ptr) noexcept override;
103  void listObjectAdded(const PolygonList& list, int newIndex,
104  const std::shared_ptr<Polygon>& ptr) noexcept override;
105  void listObjectAdded(const CircleList& list, int newIndex,
106  const std::shared_ptr<Circle>& ptr) noexcept override;
107  void listObjectAdded(const TextList& list, int newIndex,
108  const std::shared_ptr<Text>& ptr) noexcept override;
109  void listObjectRemoved(
110  const SymbolPinList& list, int oldIndex,
111  const std::shared_ptr<SymbolPin>& ptr) noexcept override;
112  void listObjectRemoved(const PolygonList& list, int oldIndex,
113  const std::shared_ptr<Polygon>& ptr) noexcept override;
114  void listObjectRemoved(const CircleList& list, int oldIndex,
115  const std::shared_ptr<Circle>& ptr) noexcept override;
116  void listObjectRemoved(const TextList& list, int oldIndex,
117  const std::shared_ptr<Text>& ptr) noexcept override;
119  void serialize(SExpression& root) const override;
120 
121 private: // Data
126 
128 };
129 
130 /*******************************************************************************
131  * End of File
132  ******************************************************************************/
133 
134 } // namespace library
135 } // namespace librepcb
136 
137 #endif // LIBREPCB_LIBRARY_SYMBOL_H
CircleList & getCircles() noexcept
Definition: symbol.h:79
PolygonList mPolygons
Definition: symbol.h:123
The Version class represents a version number in the format "1.42.7".
Definition: version.h:60
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:159
TextList & getTexts() noexcept
Definition: symbol.h:81
void unregisterGraphicsItem(SymbolGraphicsItem &item) noexcept
Definition: symbol.cpp:94
void listObjectRemoved(const SymbolPinList &list, int oldIndex, const std::shared_ptr< SymbolPin > &ptr) noexceptoverride
Definition: symbol.cpp:131
SymbolPinList mPins
Definition: symbol.h:122
void registerGraphicsItem(SymbolGraphicsItem &item) noexcept
Definition: symbol.cpp:89
SymbolPinList & getPins() noexcept
Definition: symbol.h:75
const CircleList & getCircles() const noexcept
Definition: symbol.h:80
const PolygonList & getPolygons() const noexcept
Definition: symbol.h:78
The Symbol class represents the part of a component which is added to schematics. ...
Definition: symbol.h:57
TextList mTexts
Definition: symbol.h:125
static QString getShortElementName() noexcept
Definition: symbol.h:93
virtual LibraryElementCheckMessageList runChecks() const override
Definition: symbol.cpp:84
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:130
void listObjectAdded(const SymbolPinList &list, int newIndex, const std::shared_ptr< SymbolPin > &ptr) noexceptoverride
Definition: symbol.cpp:103
~Symbol() noexcept
Definition: symbol.cpp:76
The LibraryElement class extends the LibraryBaseElement class with some attributes and methods which ...
Definition: libraryelement.h:45
const SymbolPinList & getPins() const noexcept
Definition: symbol.h:76
The SymbolGraphicsItem class.
Definition: symbolgraphicsitem.h:61
SymbolGraphicsItem * mRegisteredGraphicsItem
Definition: symbol.h:127
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:82
static QString getLongElementName() noexcept
Definition: symbol.h:96
CircleList mCircles
Definition: symbol.h:124
The SExpression class.
Definition: sexpression.h:60
PolygonList & getPolygons() noexcept
Definition: symbol.h:77
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition: elementname.h:92