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"
30 #include "componentpinsignalmap.h"
32 
33 #include <QtCore>
34 
35 /*******************************************************************************
36  * Namespace / Forward Declarations
37  ******************************************************************************/
38 namespace librepcb {
39 
40 /*******************************************************************************
41  * Class ComponentSymbolVariantItem
42  ******************************************************************************/
43 
55  Q_DECLARE_TR_FUNCTIONS(ComponentSymbolVariantItem)
56 
57 public:
58  // Signals
59  enum class Event {
67  };
70 
71  // Constructors / Destructor
72  ComponentSymbolVariantItem() = delete;
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);
79  ~ComponentSymbolVariantItem() noexcept;
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; }
87  const ComponentSymbolVariantItemSuffix& getSuffix() const noexcept {
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 
121 private: // Methods
122  void pinSignalMapEdited(
123  const ComponentPinSignalMap& map, int index,
124  const std::shared_ptr<const ComponentPinSignalMapItem>& item,
125  ComponentPinSignalMap::Event event) noexcept;
126 
127 private: // 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 
157 public:
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
bool operator==(const ComponentSymbolVariantItem &rhs) const noexcept
Definition: componentsymbolvariantitem.cpp:166
~ComponentSymbolVariantItem() noexcept
Definition: componentsymbolvariantitem.cpp:86
const Angle & getSymbolRotation() const noexcept
Definition: componentsymbolvariantitem.h:85
Uuid mUuid
Definition: componentsymbolvariantitem.h:128
bool setSymbolUuid(const Uuid &uuid) noexcept
Definition: componentsymbolvariantitem.cpp:93
Definition: occmodel.cpp:76
const Point & getSymbolPosition() const noexcept
Definition: componentsymbolvariantitem.h:84
void pinSignalMapEdited(const ComponentPinSignalMap &map, int index, const std::shared_ptr< const ComponentPinSignalMapItem > &item, ComponentPinSignalMap::Event event) noexcept
Definition: componentsymbolvariantitem.cpp:197
bool setSuffix(const ComponentSymbolVariantItemSuffix &suffix) noexcept
Definition: componentsymbolvariantitem.cpp:133
ComponentSymbolVariantItemSuffix mSuffix
Definition: componentsymbolvariantitem.h:133
Slot< ComponentSymbolVariantItem, Event > OnEditedSlot
Definition: componentsymbolvariantitem.h:69
const Uuid & getSymbolUuid() const noexcept
Definition: componentsymbolvariantitem.h:83
const ComponentPinSignalMap & getPinSignalMap() const noexcept
Definition: componentsymbolvariantitem.h:100
static QSet< Uuid > getAllSymbolUuids(const ComponentSymbolVariantItemList &list) noexcept
Definition: componentsymbolvariantitem.h:160
Point mSymbolPos
Definition: componentsymbolvariantitem.h:130
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:76
ComponentPinSignalMap::OnEditedSlot mOnPinSignalMapEditedSlot
Definition: componentsymbolvariantitem.h:137
ComponentSymbolVariantItem & operator=(const ComponentSymbolVariantItem &rhs) noexcept
Definition: componentsymbolvariantitem.cpp:178
Event
Definition: componentsymbolvariantitem.h:59
The ComponentSymbolVariantItem class represents one symbol of a component symbol variant.
Definition: componentsymbolvariantitem.h:54
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition: componentsymbolvariantitem.cpp:148
Definition: componentsymbolvariantitem.h:144
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
Definition: componentsymbolvariantitem.h:156
bool setSymbolPosition(const Point &pos) noexcept
Definition: componentsymbolvariantitem.cpp:103
bool setSymbolRotation(const Angle &rot) noexcept
Definition: componentsymbolvariantitem.cpp:113
bool setIsRequired(bool required) noexcept
Definition: componentsymbolvariantitem.cpp:123
const ComponentSymbolVariantItemSuffix & getSuffix() const noexcept
Definition: componentsymbolvariantitem.h:87
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
ComponentPinSignalMap & getPinSignalMap() noexcept
Definition: componentsymbolvariantitem.h:99
Angle mSymbolRot
Definition: componentsymbolvariantitem.h:131
const Uuid & getUuid() const noexcept
Definition: componentsymbolvariantitem.h:82
bool isRequired() const noexcept
Definition: componentsymbolvariantitem.h:86
bool mIsRequired
Definition: componentsymbolvariantitem.h:132
bool operator!=(const ComponentSymbolVariantItem &rhs) const noexcept
Definition: componentsymbolvariantitem.h:115
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:56
Uuid mSymbolUuid
Definition: componentsymbolvariantitem.h:129
type_safe::constrained_type< QString, ComponentSymbolVariantItemSuffixConstraint, ComponentSymbolVariantItemSuffixVerifier > ComponentSymbolVariantItemSuffix
Definition: componentsymbolvariantitemsuffix.h:88
ComponentPinSignalMap mPinSignalMap
Definition: componentsymbolvariantitem.h:134
The Slot class is used to receive signals from non-QObject derived classes.
Definition: signalslot.h:36
The SExpression class.
Definition: sexpression.h:66
Signal< ComponentSymbolVariantItem, Event > onEdited
Definition: componentsymbolvariantitem.h:68