LibrePCB Developers Documentation
Loading...
Searching...
No Matches
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 "../../types/tag.h"
34#include "footprintpad.h"
35
36#include <QtCore>
37
38/*******************************************************************************
39 * Namespace / Forward Declarations
40 ******************************************************************************/
41namespace librepcb {
42
43/*******************************************************************************
44 * Class Footprint
45 ******************************************************************************/
46
56class Footprint final {
57 Q_DECLARE_TR_FUNCTIONS(Footprint)
58
59public:
60 // Signals
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 const QSet<Tag>& getTags() const noexcept { return mTags; }
96 const Point3D& getModelPosition() const noexcept { return mModelPosition; }
97 const Angle3D& getModelRotation() const noexcept { return mModelRotation; }
98 const QSet<Uuid>& getModels() const noexcept { return mModels; }
99
100 // Getters: Geometry
101 const FootprintPadList& getPads() const noexcept { return mPads; }
102 FootprintPadList& getPads() noexcept { return mPads; }
103 const PolygonList& getPolygons() const noexcept { return mPolygons; }
104 PolygonList& getPolygons() noexcept { return mPolygons; }
105 const CircleList& getCircles() const noexcept { return mCircles; }
106 CircleList& getCircles() noexcept { return mCircles; }
107 const StrokeTextList& getStrokeTexts() const noexcept { return mStrokeTexts; }
109 const ZoneList& getZones() const noexcept { return mZones; }
110 ZoneList& getZones() noexcept { return mZones; }
111 const HoleList& getHoles() const noexcept { return mHoles; }
112 HoleList& getHoles() noexcept { return mHoles; }
113 std::pair<Point, Point> calculateBoundingRect(
114 bool withCourtyard) const noexcept;
115
116 // Setters: General
117 bool setTags(const QSet<Tag>& tags) noexcept;
118 bool setModelPosition(const Point3D& position) noexcept;
119 bool setModelRotation(const Angle3D& rotation) noexcept;
120 bool setModels(const QSet<Uuid>& models) noexcept;
121
122 // General Methods
123
129 void serialize(SExpression& root) const;
130
131 // Operator Overloadings
132 bool operator==(const Footprint& rhs) const noexcept;
133 bool operator!=(const Footprint& rhs) const noexcept {
134 return !(*this == rhs);
135 }
136 Footprint& operator=(const Footprint& rhs) noexcept;
137
138private: // Methods
139 void namesEdited(const LocalizedNameMap& names, const QString& key,
140 LocalizedNameMap::Event event) noexcept;
142 const QString& key,
143 LocalizedDescriptionMap::Event event) noexcept;
144 void padsEdited(const FootprintPadList& list, int index,
145 const std::shared_ptr<const FootprintPad>& pad,
146 FootprintPadList::Event event) noexcept;
147 void polygonsEdited(const PolygonList& list, int index,
148 const std::shared_ptr<const Polygon>& polygon,
149 PolygonList::Event event) noexcept;
150 void circlesEdited(const CircleList& list, int index,
151 const std::shared_ptr<const Circle>& circle,
152 CircleList::Event event) noexcept;
153 void strokeTextsEdited(const StrokeTextList& list, int index,
154 const std::shared_ptr<const StrokeText>& text,
155 StrokeTextList::Event event) noexcept;
156 void zonesEdited(const ZoneList& list, int index,
157 const std::shared_ptr<const Zone>& zone,
158 ZoneList::Event event) noexcept;
159 void holesEdited(const HoleList& list, int index,
160 const std::shared_ptr<const Hole>& hole,
161 HoleList::Event event) noexcept;
162
163private: // Data
167 QSet<Tag> mTags;
170 QSet<Uuid> mModels;
177
178 // Slots
187};
188
189/*******************************************************************************
190 * Class FootprintList
191 ******************************************************************************/
192
194 static constexpr const char* tagname = "footprint";
195};
199
200/*******************************************************************************
201 * End of File
202 ******************************************************************************/
203
204} // namespace librepcb
205
206#endif
The Footprint class represents one footprint variant of a package.
Definition footprint.h:56
std::pair< Point, Point > calculateBoundingRect(bool withCourtyard) const noexcept
Definition footprint.cpp:236
LocalizedNameMap::OnEditedSlot mNamesEditedSlot
Definition footprint.h:179
HoleList & getHoles() noexcept
Definition footprint.h:112
const LocalizedNameMap & getNames() const noexcept
Definition footprint.h:90
bool setModelPosition(const Point3D &position) noexcept
Definition footprint.cpp:160
const FootprintPadList & getPads() const noexcept
Definition footprint.h:101
FootprintPadList & getPads() noexcept
Definition footprint.h:102
Point3D mModelPosition
Definition footprint.h:168
const Angle3D & getModelRotation() const noexcept
Definition footprint.h:97
ZoneList & getZones() noexcept
Definition footprint.h:110
PolygonList & getPolygons() noexcept
Definition footprint.h:104
CircleList mCircles
Definition footprint.h:173
bool setModelRotation(const Angle3D &rotation) noexcept
Definition footprint.cpp:170
void circlesEdited(const CircleList &list, int index, const std::shared_ptr< const Circle > &circle, CircleList::Event event) noexcept
Definition footprint.cpp:367
FootprintPadList::OnEditedSlot mPadsEditedSlot
Definition footprint.h:181
const Point3D & getModelPosition() const noexcept
Definition footprint.h:96
StrokeTextList::OnEditedSlot mStrokeTextsEditedSlot
Definition footprint.h:184
QSet< Tag > mTags
Definition footprint.h:167
bool operator!=(const Footprint &rhs) const noexcept
Definition footprint.h:133
Uuid mUuid
Definition footprint.h:164
const PolygonList & getPolygons() const noexcept
Definition footprint.h:103
Event
Definition footprint.h:61
bool operator==(const Footprint &rhs) const noexcept
Definition footprint.cpp:289
ZoneList::OnEditedSlot mZonesEditedSlot
Definition footprint.h:185
const HoleList & getHoles() const noexcept
Definition footprint.h:111
const ZoneList & getZones() const noexcept
Definition footprint.h:109
ZoneList mZones
Definition footprint.h:175
void holesEdited(const HoleList &list, int index, const std::shared_ptr< const Hole > &hole, HoleList::Event event) noexcept
Definition footprint.cpp:397
LocalizedDescriptionMap mDescriptions
Definition footprint.h:166
void zonesEdited(const ZoneList &list, int index, const std::shared_ptr< const Zone > &zone, ZoneList::Event event) noexcept
Definition footprint.cpp:387
const CircleList & getCircles() const noexcept
Definition footprint.h:105
QSet< Uuid > mModels
Definition footprint.h:170
Slot< Footprint, Event > OnEditedSlot
Definition footprint.h:77
LocalizedDescriptionMap::OnEditedSlot mDescriptionsEditedSlot
Definition footprint.h:180
const QSet< Tag > & getTags() const noexcept
Definition footprint.h:95
const QSet< Uuid > & getModels() const noexcept
Definition footprint.h:98
PolygonList::OnEditedSlot mPolygonsEditedSlot
Definition footprint.h:182
CircleList::OnEditedSlot mCirclesEditedSlot
Definition footprint.h:183
Footprint & operator=(const Footprint &rhs) noexcept
Definition footprint.cpp:306
Signal< Footprint, Event > onEdited
Definition footprint.h:76
LocalizedNameMap mNames
Definition footprint.h:165
PolygonList mPolygons
Definition footprint.h:172
void polygonsEdited(const PolygonList &list, int index, const std::shared_ptr< const Polygon > &polygon, PolygonList::Event event) noexcept
Definition footprint.cpp:357
FootprintPadList mPads
Definition footprint.h:171
StrokeTextList & getStrokeTexts() noexcept
Definition footprint.h:108
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition footprint.cpp:194
~Footprint() noexcept
Definition footprint.cpp:143
CircleList & getCircles() noexcept
Definition footprint.h:106
const LocalizedDescriptionMap & getDescriptions() const noexcept
Definition footprint.h:92
const StrokeTextList & getStrokeTexts() const noexcept
Definition footprint.h:107
void descriptionsEdited(const LocalizedDescriptionMap &names, const QString &key, LocalizedDescriptionMap::Event event) noexcept
Definition footprint.cpp:338
const Uuid & getUuid() const noexcept
Definition footprint.h:88
HoleList mHoles
Definition footprint.h:176
void namesEdited(const LocalizedNameMap &names, const QString &key, LocalizedNameMap::Event event) noexcept
Definition footprint.cpp:330
bool setTags(const QSet< Tag > &tags) noexcept
Definition footprint.cpp:150
LocalizedDescriptionMap & getDescriptions() noexcept
Definition footprint.h:91
bool setModels(const QSet< Uuid > &models) noexcept
Definition footprint.cpp:180
void strokeTextsEdited(const StrokeTextList &list, int index, const std::shared_ptr< const StrokeText > &text, StrokeTextList::Event event) noexcept
Definition footprint.cpp:377
HoleList::OnEditedSlot mHolesEditedSlot
Definition footprint.h:186
LocalizedNameMap & getNames() noexcept
Definition footprint.h:89
void padsEdited(const FootprintPadList &list, int index, const std::shared_ptr< const FootprintPad > &pad, FootprintPadList::Event event) noexcept
Definition footprint.cpp:347
StrokeTextList mStrokeTexts
Definition footprint.h:174
Angle3D mModelRotation
Definition footprint.h:169
The SExpression class.
Definition sexpression.h:69
Slot< SerializableKeyValueMap< LocalizedNameMapPolicy >, const QString &, Event > OnEditedSlot
Definition serializablekeyvaluemap.h:67
Event
Definition serializablekeyvaluemap.h:61
Slot< SerializableObjectList< FootprintPad, FootprintPadListNameProvider, OnEditedArgs... >, int, const std::shared_ptr< const FootprintPad > &, Event > OnEditedSlot
Definition serializableobjectlist.h:136
The Signal class is used to emit signals on non-QObject derived classes.
Definition signalslot.h:65
The Slot class is used to receive signals from non-QObject derived classes.
Definition signalslot.h:170
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition uuid.h:56
Definition occmodel.cpp:77
std::tuple< Length, Length, Length > Point3D
Definition length.h:987
std::tuple< Angle, Angle, Angle > Angle3D
Definition angle.h:458
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition elementname.h:84
Definition footprint.h:193
static constexpr const char * tagname
Definition footprint.h:194