LibrePCB Developers Documentation
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_CORE_FOOTPRINT_H
21 #define LIBREPCB_CORE_FOOTPRINT_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../../geometry/circle.h"
27 #include "../../geometry/hole.h"
28 #include "../../geometry/polygon.h"
29 #include "../../geometry/stroketext.h"
30 #include "../../geometry/zone.h"
31 #include "../../serialization/serializablekeyvaluemap.h"
32 #include "../../serialization/serializableobjectlist.h"
33 #include "footprintpad.h"
34 
35 #include <QtCore>
36 
37 /*******************************************************************************
38  * Namespace / Forward Declarations
39  ******************************************************************************/
40 namespace librepcb {
41 
42 /*******************************************************************************
43  * Class Footprint
44  ******************************************************************************/
45 
55 class Footprint final {
56  Q_DECLARE_TR_FUNCTIONS(Footprint)
57 
58 public:
59  // Signals
60  enum class Event {
67  PadsEdited,
73  };
76 
77  // Constructors / Destructor
78  Footprint() = delete;
79  Footprint(const Footprint& other) noexcept;
80  Footprint(const Uuid& uuid, const ElementName& name_en_US,
81  const QString& description_en_US);
82  explicit Footprint(const SExpression& node);
83  ~Footprint() noexcept;
84 
85  // Getters: General
86  const Uuid& getUuid() const noexcept { return mUuid; }
87  LocalizedNameMap& getNames() noexcept { return mNames; }
88  const LocalizedNameMap& getNames() const noexcept { return mNames; }
90  const LocalizedDescriptionMap& getDescriptions() const noexcept {
91  return mDescriptions;
92  }
93  const Point3D& getModelPosition() const noexcept { return mModelPosition; }
94  const Angle3D& getModelRotation() const noexcept { return mModelRotation; }
95  const QSet<Uuid>& getModels() const noexcept { return mModels; }
96 
97  // Getters: Geometry
98  const FootprintPadList& getPads() const noexcept { return mPads; }
99  FootprintPadList& getPads() noexcept { return mPads; }
100  const PolygonList& getPolygons() const noexcept { return mPolygons; }
101  PolygonList& getPolygons() noexcept { return mPolygons; }
102  const CircleList& getCircles() const noexcept { return mCircles; }
103  CircleList& getCircles() noexcept { return mCircles; }
104  const StrokeTextList& getStrokeTexts() const noexcept { return mStrokeTexts; }
106  const ZoneList& getZones() const noexcept { return mZones; }
107  ZoneList& getZones() noexcept { return mZones; }
108  const HoleList& getHoles() const noexcept { return mHoles; }
109  HoleList& getHoles() noexcept { return mHoles; }
110 
111  // Setters: General
112  bool setModelPosition(const Point3D& position) noexcept;
113  bool setModelRotation(const Angle3D& rotation) noexcept;
114  bool setModels(const QSet<Uuid>& models) noexcept;
115 
116  // General Methods
117 
123  void serialize(SExpression& root) const;
124 
125  // Operator Overloadings
126  bool operator==(const Footprint& rhs) const noexcept;
127  bool operator!=(const Footprint& rhs) const noexcept {
128  return !(*this == rhs);
129  }
130  Footprint& operator=(const Footprint& rhs) noexcept;
131 
132 private: // Methods
133  void namesEdited(const LocalizedNameMap& names, const QString& key,
134  LocalizedNameMap::Event event) noexcept;
136  const QString& key,
137  LocalizedDescriptionMap::Event event) noexcept;
138  void padsEdited(const FootprintPadList& list, int index,
139  const std::shared_ptr<const FootprintPad>& pad,
140  FootprintPadList::Event event) noexcept;
141  void polygonsEdited(const PolygonList& list, int index,
142  const std::shared_ptr<const Polygon>& polygon,
143  PolygonList::Event event) noexcept;
144  void circlesEdited(const CircleList& list, int index,
145  const std::shared_ptr<const Circle>& circle,
146  CircleList::Event event) noexcept;
147  void strokeTextsEdited(const StrokeTextList& list, int index,
148  const std::shared_ptr<const StrokeText>& text,
149  StrokeTextList::Event event) noexcept;
150  void zonesEdited(const ZoneList& list, int index,
151  const std::shared_ptr<const Zone>& zone,
152  ZoneList::Event event) noexcept;
153  void holesEdited(const HoleList& list, int index,
154  const std::shared_ptr<const Hole>& hole,
155  HoleList::Event event) noexcept;
156 
157 private: // Data
163  QSet<Uuid> mModels;
170 
171  // Slots
180 };
181 
182 /*******************************************************************************
183  * Class FootprintList
184  ******************************************************************************/
185 
187  static constexpr const char* tagname = "footprint";
188 };
189 using FootprintList =
192 
193 /*******************************************************************************
194  * End of File
195  ******************************************************************************/
196 
197 } // namespace librepcb
198 
199 #endif
Slot< SerializableKeyValueMap< LocalizedNameMapPolicy >, const QString &, Event > OnEditedSlot
Definition: serializablekeyvaluemap.h:67
PolygonList & getPolygons() noexcept
Definition: footprint.h:101
StrokeTextList & getStrokeTexts() noexcept
Definition: footprint.h:105
Slot< SerializableObjectList< FootprintPad, FootprintPadListNameProvider, OnEditedArgs... >, int, const std::shared_ptr< const FootprintPad > &, Event > OnEditedSlot
Definition: serializableobjectlist.h:136
PolygonList mPolygons
Definition: footprint.h:165
const Point3D & getModelPosition() const noexcept
Definition: footprint.h:93
bool setModels(const QSet< Uuid > &models) noexcept
Definition: footprint.cpp:165
LocalizedNameMap::OnEditedSlot mNamesEditedSlot
Definition: footprint.h:172
CircleList & getCircles() noexcept
Definition: footprint.h:103
const StrokeTextList & getStrokeTexts() const noexcept
Definition: footprint.h:104
bool setModelRotation(const Angle3D &rotation) noexcept
Definition: footprint.cpp:155
const CircleList & getCircles() const noexcept
Definition: footprint.h:102
void descriptionsEdited(const LocalizedDescriptionMap &names, const QString &key, LocalizedDescriptionMap::Event event) noexcept
Definition: footprint.cpp:268
Definition: occmodel.cpp:77
Signal< Footprint, Event > onEdited
Definition: footprint.h:74
Event
Definition: serializablekeyvaluemap.h:61
Footprint & operator=(const Footprint &rhs) noexcept
Definition: footprint.cpp:237
CircleList mCircles
Definition: footprint.h:166
const HoleList & getHoles() const noexcept
Definition: footprint.h:108
LocalizedNameMap & getNames() noexcept
Definition: footprint.h:87
LocalizedDescriptionMap::OnEditedSlot mDescriptionsEditedSlot
Definition: footprint.h:173
PolygonList::OnEditedSlot mPolygonsEditedSlot
Definition: footprint.h:175
const Angle3D & getModelRotation() const noexcept
Definition: footprint.h:94
StrokeTextList mStrokeTexts
Definition: footprint.h:167
LocalizedNameMap mNames
Definition: footprint.h:159
void namesEdited(const LocalizedNameMap &names, const QString &key, LocalizedNameMap::Event event) noexcept
Definition: footprint.cpp:260
void strokeTextsEdited(const StrokeTextList &list, int index, const std::shared_ptr< const StrokeText > &text, StrokeTextList::Event event) noexcept
Definition: footprint.cpp:307
bool operator==(const Footprint &rhs) const noexcept
Definition: footprint.cpp:221
The Footprint class represents one footprint variant of a package.
Definition: footprint.h:55
~Footprint() noexcept
Definition: footprint.cpp:138
const QSet< Uuid > & getModels() const noexcept
Definition: footprint.h:95
void zonesEdited(const ZoneList &list, int index, const std::shared_ptr< const Zone > &zone, ZoneList::Event event) noexcept
Definition: footprint.cpp:317
ZoneList & getZones() noexcept
Definition: footprint.h:107
const LocalizedNameMap & getNames() const noexcept
Definition: footprint.h:88
const LocalizedDescriptionMap & getDescriptions() const noexcept
Definition: footprint.h:90
QSet< Uuid > mModels
Definition: footprint.h:163
FootprintPadList & getPads() noexcept
Definition: footprint.h:99
void polygonsEdited(const PolygonList &list, int index, const std::shared_ptr< const Polygon > &polygon, PolygonList::Event event) noexcept
Definition: footprint.cpp:287
bool operator!=(const Footprint &rhs) const noexcept
Definition: footprint.h:127
Definition: footprint.h:186
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition: footprint.cpp:179
Event
Definition: footprint.h:60
HoleList mHoles
Definition: footprint.h:169
HoleList & getHoles() noexcept
Definition: footprint.h:109
void holesEdited(const HoleList &list, int index, const std::shared_ptr< const Hole > &hole, HoleList::Event event) noexcept
Definition: footprint.cpp:327
CircleList::OnEditedSlot mCirclesEditedSlot
Definition: footprint.h:176
HoleList::OnEditedSlot mHolesEditedSlot
Definition: footprint.h:179
LocalizedDescriptionMap mDescriptions
Definition: footprint.h:160
Angle3D mModelRotation
Definition: footprint.h:162
ZoneList::OnEditedSlot mZonesEditedSlot
Definition: footprint.h:178
const PolygonList & getPolygons() const noexcept
Definition: footprint.h:100
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
Point3D mModelPosition
Definition: footprint.h:161
ZoneList mZones
Definition: footprint.h:168
const ZoneList & getZones() const noexcept
Definition: footprint.h:106
FootprintPadList::OnEditedSlot mPadsEditedSlot
Definition: footprint.h:174
void circlesEdited(const CircleList &list, int index, const std::shared_ptr< const Circle > &circle, CircleList::Event event) noexcept
Definition: footprint.cpp:297
std::tuple< Length, Length, Length > Point3D
Definition: length.h:989
Uuid mUuid
Definition: footprint.h:158
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
StrokeTextList::OnEditedSlot mStrokeTextsEditedSlot
Definition: footprint.h:177
const Uuid & getUuid() const noexcept
Definition: footprint.h:86
std::tuple< Angle, Angle, Angle > Angle3D
Definition: angle.h:461
FootprintPadList mPads
Definition: footprint.h:164
void padsEdited(const FootprintPadList &list, int index, const std::shared_ptr< const FootprintPad > &pad, FootprintPadList::Event event) noexcept
Definition: footprint.cpp:277
bool setModelPosition(const Point3D &position) noexcept
Definition: footprint.cpp:145
The SExpression class.
Definition: sexpression.h:69
LocalizedDescriptionMap & getDescriptions() noexcept
Definition: footprint.h:89
Slot< Footprint, Event > OnEditedSlot
Definition: footprint.h:75
const FootprintPadList & getPads() const noexcept
Definition: footprint.h:98
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition: elementname.h:84