LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
footprint.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_FOOTPRINT_H
21 #define LIBREPCB_LIBRARY_FOOTPRINT_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "footprintpad.h"
27 
37 
38 #include <QtCore>
39 
40 /*******************************************************************************
41  * Namespace / Forward Declarations
42  ******************************************************************************/
43 namespace librepcb {
44 namespace library {
45 
46 class FootprintGraphicsItem;
47 
48 /*******************************************************************************
49  * Class Footprint
50  ******************************************************************************/
51 
61 class Footprint final : public SerializableObject {
62  Q_DECLARE_TR_FUNCTIONS(Footprint)
63 
64 public:
65  // Signals
66  enum class Event {
70  PadsEdited,
75  };
78 
79  // Constructors / Destructor
80  Footprint() = delete;
81  Footprint(const Footprint& other) noexcept;
82  Footprint(const Uuid& uuid, const ElementName& name_en_US,
83  const QString& description_en_US);
84  explicit Footprint(const SExpression& node);
85  ~Footprint() noexcept;
86 
87  // Getters: General
88  const Uuid& getUuid() const noexcept { return mUuid; }
89  LocalizedNameMap& getNames() noexcept { return mNames; }
90  const LocalizedNameMap& getNames() const noexcept { return mNames; }
92  const LocalizedDescriptionMap& getDescriptions() const noexcept {
93  return mDescriptions;
94  }
95 
96  // Getters: Geometry
97  const FootprintPadList& getPads() const noexcept { return mPads; }
98  FootprintPadList& getPads() noexcept { return mPads; }
99  const PolygonList& getPolygons() const noexcept { return mPolygons; }
100  PolygonList& getPolygons() noexcept { return mPolygons; }
101  const CircleList& getCircles() const noexcept { return mCircles; }
102  CircleList& getCircles() noexcept { return mCircles; }
103  const StrokeTextList& getStrokeTexts() const noexcept { return mStrokeTexts; }
105  const HoleList& getHoles() const noexcept { return mHoles; }
106  HoleList& getHoles() noexcept { return mHoles; }
107 
108  // General Methods
109  void setStrokeFontForAllTexts(const StrokeFont* font) noexcept;
110  void registerGraphicsItem(FootprintGraphicsItem& item) noexcept;
111  void unregisterGraphicsItem(FootprintGraphicsItem& item) noexcept;
112 
113  // General Methods
114 
116  void serialize(SExpression& root) const override;
117 
118  // Operator Overloadings
119  bool operator==(const Footprint& rhs) const noexcept;
120  bool operator!=(const Footprint& rhs) const noexcept {
121  return !(*this == rhs);
122  }
123  Footprint& operator=(const Footprint& rhs) noexcept;
124 
125 private: // Methods
126  void namesEdited(const LocalizedNameMap& names, const QString& key,
127  LocalizedNameMap::Event event) noexcept;
129  const QString& key,
130  LocalizedDescriptionMap::Event event) noexcept;
131  void padsEdited(const FootprintPadList& list, int index,
132  const std::shared_ptr<const FootprintPad>& pad,
133  FootprintPadList::Event event) noexcept;
134  void polygonsEdited(const PolygonList& list, int index,
135  const std::shared_ptr<const Polygon>& polygon,
136  PolygonList::Event event) noexcept;
137  void circlesEdited(const CircleList& list, int index,
138  const std::shared_ptr<const Circle>& circle,
139  CircleList::Event event) noexcept;
140  void strokeTextsEdited(const StrokeTextList& list, int index,
141  const std::shared_ptr<const StrokeText>& text,
142  StrokeTextList::Event event) noexcept;
143  void holesEdited(const HoleList& list, int index,
144  const std::shared_ptr<const Hole>& hole,
145  HoleList::Event event) noexcept;
146 
147 private: // Data
156 
159 
160  // Slots
168 };
169 
170 /*******************************************************************************
171  * Class FootprintList
172  ******************************************************************************/
173 
175  static constexpr const char* tagname = "footprint";
176 };
177 using FootprintList =
180 using CmdFootprintInsert =
183 using CmdFootprintRemove =
186 using CmdFootprintsSwap =
188 
189 /*******************************************************************************
190  * End of File
191  ******************************************************************************/
192 
193 } // namespace library
194 } // namespace librepcb
195 
196 #endif // LIBREPCB_LIBRARY_FOOTPRINT_H
Slot< SerializableKeyValueMap< LocalizedNameMapPolicy >, const QString &, Event > OnEditedSlot
Definition: serializablekeyvaluemap.h:66
CircleList::OnEditedSlot mCirclesEditedSlot
Definition: footprint.h:165
void unregisterGraphicsItem(FootprintGraphicsItem &item) noexcept
Definition: footprint.cpp:145
Slot< SerializableObjectList< FootprintPad, FootprintPadListNameProvider, OnEditedArgs...>, int, const std::shared_ptr< const FootprintPad > &, Event > OnEditedSlot
Definition: serializableobjectlist.h:133
const HoleList & getHoles() const noexcept
Definition: footprint.h:105
CircleList & getCircles() noexcept
Definition: footprint.h:102
The CmdListElementRemove class.
Definition: cmdlistelementremove.h:44
HoleList mHoles
Definition: footprint.h:155
LocalizedDescriptionMap & getDescriptions() noexcept
Definition: footprint.h:91
FootprintPadList::OnEditedSlot mPadsEditedSlot
Definition: footprint.h:163
Event
Definition: serializablekeyvaluemap.h:60
const LocalizedNameMap & getNames() const noexcept
Definition: footprint.h:90
const LocalizedDescriptionMap & getDescriptions() const noexcept
Definition: footprint.h:92
void holesEdited(const HoleList &list, int index, const std::shared_ptr< const Hole > &hole, HoleList::Event event) noexcept
Definition: footprint.cpp:303
Footprint & operator=(const Footprint &rhs) noexcept
Definition: footprint.cpp:177
LocalizedDescriptionMap::OnEditedSlot mDescriptionsEditedSlot
Definition: footprint.h:162
void registerGraphicsItem(FootprintGraphicsItem &item) noexcept
Definition: footprint.cpp:140
CircleList mCircles
Definition: footprint.h:153
const PolygonList & getPolygons() const noexcept
Definition: footprint.h:99
const Uuid & getUuid() const noexcept
Definition: footprint.h:88
~Footprint() noexcept
Definition: footprint.cpp:125
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:43
StrokeTextList::OnEditedSlot mStrokeTextsEditedSlot
Definition: footprint.h:166
The CmdListElementsSwap class.
Definition: cmdlistelementsswap.h:44
Uuid mUuid
Definition: footprint.h:148
FootprintPadList & getPads() noexcept
Definition: footprint.h:98
LocalizedNameMap::OnEditedSlot mNamesEditedSlot
Definition: footprint.h:161
const FootprintPadList & getPads() const noexcept
Definition: footprint.h:97
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: footprint.cpp:150
LocalizedNameMap mNames
Definition: footprint.h:149
HoleList & getHoles() noexcept
Definition: footprint.h:106
PolygonList mPolygons
Definition: footprint.h:152
Slot< Footprint, Event > OnEditedSlot
Definition: footprint.h:77
bool operator==(const Footprint &rhs) const noexcept
Definition: footprint.cpp:165
The FootprintGraphicsItem class.
Definition: footprintgraphicsitem.h:62
void circlesEdited(const CircleList &list, int index, const std::shared_ptr< const Circle > &circle, CircleList::Event event) noexcept
Definition: footprint.cpp:257
void namesEdited(const LocalizedNameMap &names, const QString &key, LocalizedNameMap::Event event) noexcept
Definition: footprint.cpp:196
PolygonList::OnEditedSlot mPolygonsEditedSlot
Definition: footprint.h:164
void polygonsEdited(const PolygonList &list, int index, const std::shared_ptr< const Polygon > &polygon, PolygonList::Event event) noexcept
Definition: footprint.cpp:235
PolygonList & getPolygons() noexcept
Definition: footprint.h:100
bool operator!=(const Footprint &rhs) const noexcept
Definition: footprint.h:120
void setStrokeFontForAllTexts(const StrokeFont *font) noexcept
Definition: footprint.cpp:133
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
void strokeTextsEdited(const StrokeTextList &list, int index, const std::shared_ptr< const StrokeText > &text, StrokeTextList::Event event) noexcept
Definition: footprint.cpp:279
HoleList::OnEditedSlot mHolesEditedSlot
Definition: footprint.h:167
The CmdListElementInsert class.
Definition: cmdlistelementinsert.h:44
StrokeTextList & getStrokeTexts() noexcept
Definition: footprint.h:104
const StrokeFont * mStrokeFont
Definition: footprint.h:157
FootprintGraphicsItem * mRegisteredGraphicsItem
Definition: footprint.h:158
StrokeTextList mStrokeTexts
Definition: footprint.h:154
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
static constexpr const char * tagname
Definition: footprint.h:175
LocalizedNameMap & getNames() noexcept
Definition: footprint.h:89
Signal< Footprint, Event > onEdited
Definition: footprint.h:76
LocalizedDescriptionMap mDescriptions
Definition: footprint.h:150
void padsEdited(const FootprintPadList &list, int index, const std::shared_ptr< const FootprintPad > &pad, FootprintPadList::Event event) noexcept
Definition: footprint.cpp:213
Event
Definition: footprint.h:66
The StrokeFont class.
Definition: strokefont.h:52
The Slot class is used to receive signals from non-QObject derived classes.
Definition: signalslot.h:36
The SExpression class.
Definition: sexpression.h:57
The Footprint class represents one footprint variant of a package.
Definition: footprint.h:61
FootprintPadList mPads
Definition: footprint.h:151
const CircleList & getCircles() const noexcept
Definition: footprint.h:101
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition: elementname.h:92
void descriptionsEdited(const LocalizedDescriptionMap &names, const QString &key, LocalizedDescriptionMap::Event event) noexcept
Definition: footprint.cpp:204
const StrokeTextList & getStrokeTexts() const noexcept
Definition: footprint.h:103