LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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_LIBRARY_COMPONENTSYMBOLVARIANTITEM_H
21 #define LIBREPCB_LIBRARY_COMPONENTSYMBOLVARIANTITEM_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "componentpinsignalmap.h"
28 
34 #include <librepcb/common/uuid.h>
35 
36 #include <QtCore>
37 
38 /*******************************************************************************
39  * Namespace / Forward Declarations
40  ******************************************************************************/
41 namespace librepcb {
42 namespace library {
43 
44 /*******************************************************************************
45  * Class ComponentSymbolVariantItem
46  ******************************************************************************/
47 
59  Q_DECLARE_TR_FUNCTIONS(ComponentSymbolVariantItem)
60 
61 public:
62  // Signals
63  enum class Event {
71  };
74 
75  // Constructors / Destructor
76  ComponentSymbolVariantItem() = delete;
79  const Uuid& uuid, const Uuid& symbolUuid, const Point& symbolPos,
80  const Angle& symbolRotation, bool isRequired,
81  const ComponentSymbolVariantItemSuffix& suffix) noexcept;
82  explicit ComponentSymbolVariantItem(const SExpression& node);
83  ~ComponentSymbolVariantItem() noexcept;
84 
85  // Getters: Attributes
86  const Uuid& getUuid() const noexcept { return mUuid; }
87  const Uuid& getSymbolUuid() const noexcept { return mSymbolUuid; }
88  const Point& getSymbolPosition() const noexcept { return mSymbolPos; }
89  const Angle& getSymbolRotation() const noexcept { return mSymbolRot; }
90  bool isRequired() const noexcept { return mIsRequired; }
91  const ComponentSymbolVariantItemSuffix& getSuffix() const noexcept {
92  return mSuffix;
93  }
94 
95  // Setters: Attributes
96  bool setSymbolUuid(const Uuid& uuid) noexcept;
97  bool setSymbolPosition(const Point& pos) noexcept;
98  bool setSymbolRotation(const Angle& rot) noexcept;
99  bool setIsRequired(bool required) noexcept;
100  bool setSuffix(const ComponentSymbolVariantItemSuffix& suffix) noexcept;
101 
102  // Pin-Signal-Map Methods
104  const ComponentPinSignalMap& getPinSignalMap() const noexcept {
105  return mPinSignalMap;
106  }
107 
109  void serialize(SExpression& root) const override;
110 
111  // Operator Overloadings
112  bool operator==(const ComponentSymbolVariantItem& rhs) const noexcept;
113  bool operator!=(const ComponentSymbolVariantItem& rhs) const noexcept {
114  return !(*this == rhs);
115  }
117  const ComponentSymbolVariantItem& rhs) noexcept;
118 
119 private: // Methods
120  void pinSignalMapEdited(
121  const ComponentPinSignalMap& map, int index,
122  const std::shared_ptr<const ComponentPinSignalMapItem>& item,
123  ComponentPinSignalMap::Event event) noexcept;
124 
125 private: // Data
133 
134  // Slots
136 };
137 
138 /*******************************************************************************
139  * Class ComponentSymbolVariantItemList
140  ******************************************************************************/
141 
143  static constexpr const char* tagname = "gate";
144 };
161 
162 /*******************************************************************************
163  * Class ComponentSymbolVariantItemListHelpers
164  ******************************************************************************/
165 
167 public:
168  ComponentSymbolVariantItemListHelpers() = delete; // disable instantiation
169 
170  static QSet<Uuid> getAllSymbolUuids(
171  const ComponentSymbolVariantItemList& list) noexcept {
172  QSet<Uuid> set;
173  for (const auto& item : list) {
174  set.insert(item.getSymbolUuid());
175  }
176  return set;
177  }
178 };
179 
180 /*******************************************************************************
181  * End of File
182  ******************************************************************************/
183 
184 } // namespace library
185 } // namespace librepcb
186 
187 #endif // LIBREPCB_LIBRARY_COMPONENTSYMBOLVARIANTITEM_H
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: componentsymbolvariantitem.cpp:148
const Uuid & getSymbolUuid() const noexcept
Definition: componentsymbolvariantitem.h:87
Uuid mSymbolUuid
Definition: componentsymbolvariantitem.h:127
ComponentPinSignalMap mPinSignalMap
Definition: componentsymbolvariantitem.h:132
type_safe::constrained_type< QString, ComponentSymbolVariantItemSuffixConstraint, ComponentSymbolVariantItemSuffixVerifier > ComponentSymbolVariantItemSuffix
Definition: componentsymbolvariantitemsuffix.h:79
The CmdListElementRemove class.
Definition: cmdlistelementremove.h:44
const Angle & getSymbolRotation() const noexcept
Definition: componentsymbolvariantitem.h:89
ComponentSymbolVariantItem & operator=(const ComponentSymbolVariantItem &rhs) noexcept
Definition: componentsymbolvariantitem.cpp:174
const Point & getSymbolPosition() const noexcept
Definition: componentsymbolvariantitem.h:88
Uuid mUuid
Definition: componentsymbolvariantitem.h:126
Event
Definition: componentsymbolvariantitem.h:63
Point mSymbolPos
Definition: componentsymbolvariantitem.h:128
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
~ComponentSymbolVariantItem() noexcept
Definition: componentsymbolvariantitem.cpp:86
Definition: componentsymbolvariantitem.h:142
Angle mSymbolRot
Definition: componentsymbolvariantitem.h:129
const ComponentPinSignalMap & getPinSignalMap() const noexcept
Definition: componentsymbolvariantitem.h:104
static QSet< Uuid > getAllSymbolUuids(const ComponentSymbolVariantItemList &list) noexcept
Definition: componentsymbolvariantitem.h:170
const Uuid & getUuid() const noexcept
Definition: componentsymbolvariantitem.h:86
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:43
The CmdListElementsSwap class.
Definition: cmdlistelementsswap.h:44
void pinSignalMapEdited(const ComponentPinSignalMap &map, int index, const std::shared_ptr< const ComponentPinSignalMapItem > &item, ComponentPinSignalMap::Event event) noexcept
Definition: componentsymbolvariantitem.cpp:193
ComponentPinSignalMap & getPinSignalMap() noexcept
Definition: componentsymbolvariantitem.h:103
bool operator==(const ComponentSymbolVariantItem &rhs) const noexcept
Definition: componentsymbolvariantitem.cpp:162
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
bool isRequired() const noexcept
Definition: componentsymbolvariantitem.h:90
const ComponentSymbolVariantItemSuffix & getSuffix() const noexcept
Definition: componentsymbolvariantitem.h:91
static constexpr const char * tagname
Definition: componentsymbolvariantitem.h:143
bool setSuffix(const ComponentSymbolVariantItemSuffix &suffix) noexcept
Definition: componentsymbolvariantitem.cpp:133
bool mIsRequired
Definition: componentsymbolvariantitem.h:130
bool setSymbolPosition(const Point &pos) noexcept
Definition: componentsymbolvariantitem.cpp:103
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
bool setIsRequired(bool required) noexcept
Definition: componentsymbolvariantitem.cpp:123
The CmdListElementInsert class.
Definition: cmdlistelementinsert.h:44
Definition: componentsymbolvariantitem.h:166
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
The ComponentSymbolVariantItem class represents one symbol of a component symbol variant.
Definition: componentsymbolvariantitem.h:58
Signal< ComponentSymbolVariantItem, Event > onEdited
Definition: componentsymbolvariantitem.h:72
ComponentSymbolVariantItemSuffix mSuffix
Definition: componentsymbolvariantitem.h:131
ComponentPinSignalMap::OnEditedSlot mOnPinSignalMapEditedSlot
Definition: componentsymbolvariantitem.h:135
The Slot class is used to receive signals from non-QObject derived classes.
Definition: signalslot.h:36
bool setSymbolUuid(const Uuid &uuid) noexcept
Definition: componentsymbolvariantitem.cpp:93
The SExpression class.
Definition: sexpression.h:57
bool setSymbolRotation(const Angle &rot) noexcept
Definition: componentsymbolvariantitem.cpp:113
Slot< ComponentSymbolVariantItem, Event > OnEditedSlot
Definition: componentsymbolvariantitem.h:73
bool operator!=(const ComponentSymbolVariantItem &rhs) const noexcept
Definition: componentsymbolvariantitem.h:113