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  private FootprintPadList::IF_Observer,
63  private PolygonList::IF_Observer,
64  private CircleList::IF_Observer,
65  private StrokeTextList::IF_Observer,
66  private HoleList::IF_Observer {
67  Q_DECLARE_TR_FUNCTIONS(Footprint)
68 
69 public:
70  // Constructors / Destructor
71  Footprint() = delete;
72  Footprint(const Footprint& other) noexcept;
73  Footprint(const Uuid& uuid, const ElementName& name_en_US,
74  const QString& description_en_US);
75  explicit Footprint(const SExpression& node);
76  ~Footprint() noexcept;
77 
78  // Getters: General
79  const Uuid& getUuid() const noexcept { return mUuid; }
80  LocalizedNameMap& getNames() noexcept { return mNames; }
81  const LocalizedNameMap& getNames() const noexcept { return mNames; }
83  const LocalizedDescriptionMap& getDescriptions() const noexcept {
84  return mDescriptions;
85  }
86 
87  // Getters: Geometry
88  const FootprintPadList& getPads() const noexcept { return mPads; }
89  FootprintPadList& getPads() noexcept { return mPads; }
90  const PolygonList& getPolygons() const noexcept { return mPolygons; }
91  PolygonList& getPolygons() noexcept { return mPolygons; }
92  const CircleList& getCircles() const noexcept { return mCircles; }
93  CircleList& getCircles() noexcept { return mCircles; }
94  const StrokeTextList& getStrokeTexts() const noexcept { return mStrokeTexts; }
95  StrokeTextList& getStrokeTexts() noexcept { return mStrokeTexts; }
96  const HoleList& getHoles() const noexcept { return mHoles; }
97  HoleList& getHoles() noexcept { return mHoles; }
98 
99  // General Methods
100  void setStrokeFontForAllTexts(const StrokeFont* font) noexcept;
101  void registerGraphicsItem(FootprintGraphicsItem& item) noexcept;
102  void unregisterGraphicsItem(FootprintGraphicsItem& item) noexcept;
103 
104  // General Methods
105 
107  void serialize(SExpression& root) const override;
108 
109  // Operator Overloadings
110  bool operator==(const Footprint& rhs) const noexcept;
111  bool operator!=(const Footprint& rhs) const noexcept {
112  return !(*this == rhs);
113  }
114  Footprint& operator=(const Footprint& rhs) noexcept;
115 
116 private: // Methods
117  void listObjectAdded(
118  const FootprintPadList& list, int newIndex,
119  const std::shared_ptr<FootprintPad>& ptr) noexcept override;
120  void listObjectAdded(const PolygonList& list, int newIndex,
121  const std::shared_ptr<Polygon>& ptr) noexcept override;
122  void listObjectAdded(const CircleList& list, int newIndex,
123  const std::shared_ptr<Circle>& ptr) noexcept override;
124  void listObjectAdded(
125  const StrokeTextList& list, int newIndex,
126  const std::shared_ptr<StrokeText>& ptr) noexcept override;
127  void listObjectAdded(const HoleList& list, int newIndex,
128  const std::shared_ptr<Hole>& ptr) noexcept override;
129  void listObjectRemoved(
130  const FootprintPadList& list, int oldIndex,
131  const std::shared_ptr<FootprintPad>& ptr) noexcept override;
132  void listObjectRemoved(const PolygonList& list, int oldIndex,
133  const std::shared_ptr<Polygon>& ptr) noexcept override;
134  void listObjectRemoved(const CircleList& list, int oldIndex,
135  const std::shared_ptr<Circle>& ptr) noexcept override;
136  void listObjectRemoved(
137  const StrokeTextList& list, int oldIndex,
138  const std::shared_ptr<StrokeText>& ptr) noexcept override;
139  void listObjectRemoved(const HoleList& list, int oldIndex,
140  const std::shared_ptr<Hole>& ptr) noexcept override;
141 
142 private: // Data
151 
154 };
155 
156 /*******************************************************************************
157  * Class FootprintList
158  ******************************************************************************/
159 
161  static constexpr const char* tagname = "footprint";
162 };
163 using FootprintList =
165 using CmdFootprintInsert =
167 using CmdFootprintRemove =
169 using CmdFootprintsSwap =
171 
172 /*******************************************************************************
173  * End of File
174  ******************************************************************************/
175 
176 } // namespace library
177 } // namespace librepcb
178 
179 #endif // LIBREPCB_LIBRARY_FOOTPRINT_H
void unregisterGraphicsItem(FootprintGraphicsItem &item) noexcept
Definition: footprint.cpp:108
void listObjectAdded(const FootprintPadList &list, int newIndex, const std::shared_ptr< FootprintPad > &ptr) noexceptoverride
Definition: footprint.cpp:156
const HoleList & getHoles() const noexcept
Definition: footprint.h:96
CircleList & getCircles() noexcept
Definition: footprint.h:93
The CmdListElementRemove class.
Definition: cmdlistelementremove.h:44
HoleList mHoles
Definition: footprint.h:150
LocalizedDescriptionMap & getDescriptions() noexcept
Definition: footprint.h:82
const LocalizedNameMap & getNames() const noexcept
Definition: footprint.h:81
const LocalizedDescriptionMap & getDescriptions() const noexcept
Definition: footprint.h:83
Footprint & operator=(const Footprint &rhs) noexcept
Definition: footprint.cpp:140
void registerGraphicsItem(FootprintGraphicsItem &item) noexcept
Definition: footprint.cpp:103
CircleList mCircles
Definition: footprint.h:148
const PolygonList & getPolygons() const noexcept
Definition: footprint.h:90
const Uuid & getUuid() const noexcept
Definition: footprint.h:79
~Footprint() noexcept
Definition: footprint.cpp:88
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:46
The CmdListElementsSwap class.
Definition: cmdlistelementsswap.h:44
Uuid mUuid
Definition: footprint.h:143
FootprintPadList & getPads() noexcept
Definition: footprint.h:89
const FootprintPadList & getPads() const noexcept
Definition: footprint.h:88
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: footprint.cpp:113
LocalizedNameMap mNames
Definition: footprint.h:144
HoleList & getHoles() noexcept
Definition: footprint.h:97
PolygonList mPolygons
Definition: footprint.h:147
bool operator==(const Footprint &rhs) const noexcept
Definition: footprint.cpp:128
void listObjectRemoved(const FootprintPadList &list, int oldIndex, const std::shared_ptr< FootprintPad > &ptr) noexceptoverride
Definition: footprint.cpp:194
The FootprintGraphicsItem class.
Definition: footprintgraphicsitem.h:63
PolygonList & getPolygons() noexcept
Definition: footprint.h:91
bool operator!=(const Footprint &rhs) const noexcept
Definition: footprint.h:111
void setStrokeFontForAllTexts(const StrokeFont *font) noexcept
Definition: footprint.cpp:96
The CmdListElementInsert class.
Definition: cmdlistelementinsert.h:44
StrokeTextList & getStrokeTexts() noexcept
Definition: footprint.h:95
const StrokeFont * mStrokeFont
Definition: footprint.h:152
FootprintGraphicsItem * mRegisteredGraphicsItem
Definition: footprint.h:153
StrokeTextList mStrokeTexts
Definition: footprint.h:149
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:161
LocalizedNameMap & getNames() noexcept
Definition: footprint.h:80
LocalizedDescriptionMap mDescriptions
Definition: footprint.h:145
The StrokeFont class.
Definition: strokefont.h:52
The SExpression class.
Definition: sexpression.h:60
The Footprint class represents one footprint variant of a package.
Definition: footprint.h:61
FootprintPadList mPads
Definition: footprint.h:146
const CircleList & getCircles() const noexcept
Definition: footprint.h:92
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition: elementname.h:92
const StrokeTextList & getStrokeTexts() const noexcept
Definition: footprint.h:94