LibrePCB Developers Documentation
componentsymbolvariantitem.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_COMPONENTSYMBOLVARIANTITEM_H
21#define LIBREPCB_CORE_COMPONENTSYMBOLVARIANTITEM_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../serialization/serializableobjectlist.h"
27#include "../../types/angle.h"
28#include "../../types/point.h"
29#include "../../types/uuid.h"
32
33#include <QtCore>
34
35/*******************************************************************************
36 * Namespace / Forward Declarations
37 ******************************************************************************/
38namespace librepcb {
39
40/*******************************************************************************
41 * Class ComponentSymbolVariantItem
42 ******************************************************************************/
43
55 Q_DECLARE_TR_FUNCTIONS(ComponentSymbolVariantItem)
56
57public:
58 // Signals
59 enum class Event {
60 UuidChanged,
61 SymbolUuidChanged,
62 SymbolPositionChanged,
63 SymbolRotationChanged,
64 IsRequiredChanged,
65 SuffixChanged,
66 PinSignalMapEdited,
67 };
70
71 // Constructors / Destructor
75 const Uuid& uuid, const Uuid& symbolUuid, const Point& symbolPos,
76 const Angle& symbolRotation, bool isRequired,
77 const ComponentSymbolVariantItemSuffix& suffix) noexcept;
78 explicit ComponentSymbolVariantItem(const SExpression& node);
80
81 // Getters: Attributes
82 const Uuid& getUuid() const noexcept { return mUuid; }
83 const Uuid& getSymbolUuid() const noexcept { return mSymbolUuid; }
84 const Point& getSymbolPosition() const noexcept { return mSymbolPos; }
85 const Angle& getSymbolRotation() const noexcept { return mSymbolRot; }
86 bool isRequired() const noexcept { return mIsRequired; }
88 return mSuffix;
89 }
90
91 // Setters: Attributes
92 bool setSymbolUuid(const Uuid& uuid) noexcept;
93 bool setSymbolPosition(const Point& pos) noexcept;
94 bool setSymbolRotation(const Angle& rot) noexcept;
95 bool setIsRequired(bool required) noexcept;
96 bool setSuffix(const ComponentSymbolVariantItemSuffix& suffix) noexcept;
97
98 // Pin-Signal-Map Methods
100 const ComponentPinSignalMap& getPinSignalMap() const noexcept {
101 return mPinSignalMap;
102 }
103
104 // General Methods
105
111 void serialize(SExpression& root) const;
112
113 // Operator Overloadings
114 bool operator==(const ComponentSymbolVariantItem& rhs) const noexcept;
115 bool operator!=(const ComponentSymbolVariantItem& rhs) const noexcept {
116 return !(*this == rhs);
117 }
119 const ComponentSymbolVariantItem& rhs) noexcept;
120
121private: // Methods
123 const ComponentPinSignalMap& map, int index,
124 const std::shared_ptr<const ComponentPinSignalMapItem>& item,
125 ComponentPinSignalMap::Event event) noexcept;
126
127private: // Data
135
136 // Slots
138};
139
140/*******************************************************************************
141 * Class ComponentSymbolVariantItemList
142 ******************************************************************************/
143
145 static constexpr const char* tagname = "gate";
146};
151
152/*******************************************************************************
153 * Class ComponentSymbolVariantItemListHelpers
154 ******************************************************************************/
155
157public:
158 ComponentSymbolVariantItemListHelpers() = delete; // disable instantiation
159
160 static QSet<Uuid> getAllSymbolUuids(
161 const ComponentSymbolVariantItemList& list) noexcept {
162 QSet<Uuid> set;
163 for (const auto& item : list) {
164 set.insert(item.getSymbolUuid());
165 }
166 return set;
167 }
168};
169
170/*******************************************************************************
171 * End of File
172 ******************************************************************************/
173
174} // namespace librepcb
175
176#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
The ComponentSymbolVariantItem class represents one symbol of a component symbol variant.
Definition: componentsymbolvariantitem.h:54
~ComponentSymbolVariantItem() noexcept
Definition: componentsymbolvariantitem.cpp:86
ComponentSymbolVariantItemSuffix mSuffix
Definition: componentsymbolvariantitem.h:133
const ComponentSymbolVariantItemSuffix & getSuffix() const noexcept
Definition: componentsymbolvariantitem.h:87
bool setSymbolUuid(const Uuid &uuid) noexcept
Definition: componentsymbolvariantitem.cpp:93
Slot< ComponentSymbolVariantItem, Event > OnEditedSlot
Definition: componentsymbolvariantitem.h:69
Point mSymbolPos
Definition: componentsymbolvariantitem.h:130
bool setSuffix(const ComponentSymbolVariantItemSuffix &suffix) noexcept
Definition: componentsymbolvariantitem.cpp:133
bool setIsRequired(bool required) noexcept
Definition: componentsymbolvariantitem.cpp:123
ComponentSymbolVariantItem & operator=(const ComponentSymbolVariantItem &rhs) noexcept
Definition: componentsymbolvariantitem.cpp:178
bool operator!=(const ComponentSymbolVariantItem &rhs) const noexcept
Definition: componentsymbolvariantitem.h:115
Signal< ComponentSymbolVariantItem, Event > onEdited
Definition: componentsymbolvariantitem.h:68
Uuid mUuid
Definition: componentsymbolvariantitem.h:128
Event
Definition: componentsymbolvariantitem.h:59
bool setSymbolRotation(const Angle &rot) noexcept
Definition: componentsymbolvariantitem.cpp:113
const Point & getSymbolPosition() const noexcept
Definition: componentsymbolvariantitem.h:84
Uuid mSymbolUuid
Definition: componentsymbolvariantitem.h:129
bool mIsRequired
Definition: componentsymbolvariantitem.h:132
ComponentPinSignalMap & getPinSignalMap() noexcept
Definition: componentsymbolvariantitem.h:99
bool isRequired() const noexcept
Definition: componentsymbolvariantitem.h:86
const ComponentPinSignalMap & getPinSignalMap() const noexcept
Definition: componentsymbolvariantitem.h:100
Angle mSymbolRot
Definition: componentsymbolvariantitem.h:131
bool operator==(const ComponentSymbolVariantItem &rhs) const noexcept
Definition: componentsymbolvariantitem.cpp:166
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition: componentsymbolvariantitem.cpp:148
ComponentPinSignalMap mPinSignalMap
Definition: componentsymbolvariantitem.h:134
const Uuid & getUuid() const noexcept
Definition: componentsymbolvariantitem.h:82
const Uuid & getSymbolUuid() const noexcept
Definition: componentsymbolvariantitem.h:83
const Angle & getSymbolRotation() const noexcept
Definition: componentsymbolvariantitem.h:85
bool setSymbolPosition(const Point &pos) noexcept
Definition: componentsymbolvariantitem.cpp:103
void pinSignalMapEdited(const ComponentPinSignalMap &map, int index, const std::shared_ptr< const ComponentPinSignalMapItem > &item, ComponentPinSignalMap::Event event) noexcept
Definition: componentsymbolvariantitem.cpp:197
ComponentPinSignalMap::OnEditedSlot mOnPinSignalMapEditedSlot
Definition: componentsymbolvariantitem.h:137
Definition: componentsymbolvariantitem.h:156
static QSet< Uuid > getAllSymbolUuids(const ComponentSymbolVariantItemList &list) noexcept
Definition: componentsymbolvariantitem.h:160
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition: point.h:79
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 Slot class is used to receive signals from non-QObject derived classes.
Definition: signalslot.h:170
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
Definition: occmodel.cpp:77
type_safe::constrained_type< QString, ComponentSymbolVariantItemSuffixConstraint, ComponentSymbolVariantItemSuffixVerifier > ComponentSymbolVariantItemSuffix
Definition: componentsymbolvariantitemsuffix.h:89
Definition: componentsymbolvariantitem.h:144
static constexpr const char * tagname
Definition: componentsymbolvariantitem.h:145