LibrePCB Developers Documentation
Loading...
Searching...
No Matches
footprintpad.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_FOOTPRINTPAD_H
21#define LIBREPCB_CORE_FOOTPRINTPAD_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../exceptions.h"
27#include "../../geometry/padgeometry.h"
28#include "../../geometry/padhole.h"
29#include "../../geometry/path.h"
30#include "../../serialization/serializableobjectlist.h"
31#include "../../types/angle.h"
32#include "../../types/length.h"
33#include "../../types/maskconfig.h"
34#include "../../types/point.h"
35#include "../../types/ratio.h"
36#include "../../types/uuid.h"
37
38#include <QtCore>
39
40/*******************************************************************************
41 * Namespace / Forward Declarations
42 ******************************************************************************/
43namespace librepcb {
44
45class Layer;
46
47/*******************************************************************************
48 * Class FootprintPad
49 ******************************************************************************/
50
54class FootprintPad final {
55 Q_DECLARE_TR_FUNCTIONS(FootprintPad)
56
57public:
58 // Types
59 enum class Shape {
62 Custom,
63 };
64
65 enum class ComponentSide {
66 Top,
67 Bottom,
68 };
69
82
83 // Signals
103
104 // Constructors / Destructor
105 FootprintPad() = delete;
106 FootprintPad(const FootprintPad& other) noexcept;
107 FootprintPad(const Uuid& uuid, const std::optional<Uuid>& pkgPadUuid,
108 const Point& pos, const Angle& rot, Shape shape,
109 const PositiveLength& width, const PositiveLength& height,
110 const UnsignedLimitedRatio& radius,
111 const Path& customShapeOutline, const MaskConfig& autoStopMask,
112 const MaskConfig& autoSolderPaste,
113 const UnsignedLength& copperClearance, ComponentSide side,
114 Function function, const PadHoleList& holes) noexcept;
115 explicit FootprintPad(const SExpression& node);
116 ~FootprintPad() noexcept;
117
118 // Getters
119 const Uuid& getUuid() const noexcept { return mUuid; }
120 const std::optional<Uuid>& getPackagePadUuid() const noexcept {
121 return mPackagePadUuid;
122 }
123 const Point& getPosition() const noexcept { return mPosition; }
124 const Angle& getRotation() const noexcept { return mRotation; }
125 Shape getShape() const noexcept { return mShape; }
126 const PositiveLength& getWidth() const noexcept { return mWidth; }
127 const PositiveLength& getHeight() const noexcept { return mHeight; }
128 const UnsignedLimitedRatio& getRadius() const noexcept { return mRadius; }
129 const Path& getCustomShapeOutline() const noexcept {
130 return mCustomShapeOutline;
131 }
132 const MaskConfig& getStopMaskConfig() const noexcept {
133 return mStopMaskConfig;
134 }
135 const MaskConfig& getSolderPasteConfig() const noexcept {
136 return mSolderPasteConfig;
137 }
138 const UnsignedLength& getCopperClearance() const noexcept {
139 return mCopperClearance;
140 }
141 ComponentSide getComponentSide() const noexcept { return mComponentSide; }
142 Function getFunction() const noexcept { return mFunction; }
143 bool getFunctionIsFiducial() const noexcept;
144 bool getFunctionNeedsSoldering() const noexcept;
145 const PadHoleList& getHoles() const noexcept { return mHoles; }
146 PadHoleList& getHoles() noexcept { return mHoles; }
147 bool isTht() const noexcept;
148 bool isOnLayer(const Layer& layer) const noexcept;
149 const Layer& getSmtLayer() const noexcept;
150 bool hasTopCopper() const noexcept;
151 bool hasBottomCopper() const noexcept;
152 bool hasAutoTopStopMask() const noexcept;
153 bool hasAutoBottomStopMask() const noexcept;
154 bool hasAutoTopSolderPaste() const noexcept;
155 bool hasAutoBottomSolderPaste() const noexcept;
156 PadGeometry getGeometry() const noexcept;
157 QHash<const Layer*, QList<PadGeometry>> buildPreviewGeometries()
158 const noexcept;
159
160 // Setters
161 bool setPackagePadUuid(const std::optional<Uuid>& pad) noexcept;
162 bool setPosition(const Point& pos) noexcept;
163 bool setRotation(const Angle& rot) noexcept;
164 bool setShape(Shape shape) noexcept;
165 bool setWidth(const PositiveLength& width) noexcept;
166 bool setHeight(const PositiveLength& height) noexcept;
167 bool setRadius(const UnsignedLimitedRatio& radius) noexcept;
168 bool setCustomShapeOutline(const Path& outline) noexcept;
169 bool setStopMaskConfig(const MaskConfig& config) noexcept;
170 bool setSolderPasteConfig(const MaskConfig& config) noexcept;
171 bool setCopperClearance(const UnsignedLength& clearance) noexcept;
172 bool setComponentSide(ComponentSide side) noexcept;
173 bool setFunction(Function function) noexcept;
174
175 // General Methods
176
182 void serialize(SExpression& root) const;
183
184 // Operator Overloadings
185 bool operator==(const FootprintPad& rhs) const noexcept;
186 bool operator!=(const FootprintPad& rhs) const noexcept {
187 return !(*this == rhs);
188 }
189 FootprintPad& operator=(const FootprintPad& rhs) noexcept;
190
191 // Static Methods
193 const PositiveLength& width, const PositiveLength& height) noexcept;
194 static QString getFunctionDescriptionTr(Function function) noexcept;
195
196private: // Methods
197 void holesEdited(const PadHoleList& list, int index,
198 const std::shared_ptr<const PadHole>& hole,
199 PadHoleList::Event event) noexcept;
200
201private: // Data
203
209 std::optional<Uuid> mPackagePadUuid;
223
224 // Slots
226};
227
228/*******************************************************************************
229 * Non-Member Functions
230 ******************************************************************************/
231
232inline std::size_t qHash(const FootprintPad::Function& key,
233 std::size_t seed = 0) noexcept {
234 return ::qHash(static_cast<int>(key), seed);
235}
236
237/*******************************************************************************
238 * Class FootprintPadList
239 ******************************************************************************/
240
242 static constexpr const char* tagname = "pad";
243};
247
248/*******************************************************************************
249 * End of File
250 ******************************************************************************/
251
252} // namespace librepcb
253
254Q_DECLARE_METATYPE(librepcb::FootprintPad::Function)
255
256#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition angle.h:76
The FootprintPad class represents a pad of a footprint.
Definition footprintpad.h:54
Function mFunction
Definition footprintpad.h:221
QHash< const Layer *, QList< PadGeometry > > buildPreviewGeometries() const noexcept
Definition footprintpad.cpp:314
Shape mShape
Definition footprintpad.h:212
bool setRotation(const Angle &rot) noexcept
Definition footprintpad.cpp:374
PadGeometry getGeometry() const noexcept
Definition footprintpad.cpp:298
const Angle & getRotation() const noexcept
Definition footprintpad.h:124
PadHoleList mHoles
If not empty, it's a THT pad.
Definition footprintpad.h:222
const MaskConfig & getSolderPasteConfig() const noexcept
Definition footprintpad.h:135
const PositiveLength & getWidth() const noexcept
Definition footprintpad.h:126
bool setPosition(const Point &pos) noexcept
Definition footprintpad.cpp:354
bool setComponentSide(ComponentSide side) noexcept
Definition footprintpad.cpp:465
bool getFunctionIsFiducial() const noexcept
Definition footprintpad.cpp:233
bool setShape(Shape shape) noexcept
Definition footprintpad.cpp:384
~FootprintPad() noexcept
Definition footprintpad.cpp:226
Path mCustomShapeOutline
Empty if not needed; Implicitly closed.
Definition footprintpad.h:216
std::optional< Uuid > mPackagePadUuid
Definition footprintpad.h:209
const MaskConfig & getStopMaskConfig() const noexcept
Definition footprintpad.h:132
bool hasBottomCopper() const noexcept
Definition footprintpad.cpp:274
UnsignedLimitedRatio mRadius
Definition footprintpad.h:215
ComponentSide
Definition footprintpad.h:65
const Path & getCustomShapeOutline() const noexcept
Definition footprintpad.h:129
bool setStopMaskConfig(const MaskConfig &config) noexcept
Definition footprintpad.cpp:434
bool setCopperClearance(const UnsignedLength &clearance) noexcept
Definition footprintpad.cpp:454
bool isTht() const noexcept
Definition footprintpad.cpp:250
bool getFunctionNeedsSoldering() const noexcept
Definition footprintpad.cpp:238
const UnsignedLength & getCopperClearance() const noexcept
Definition footprintpad.h:138
Uuid mUuid
Definition footprintpad.h:202
const std::optional< Uuid > & getPackagePadUuid() const noexcept
Definition footprintpad.h:120
Function
Definition footprintpad.h:70
const PadHoleList & getHoles() const noexcept
Definition footprintpad.h:145
Function getFunction() const noexcept
Definition footprintpad.h:142
Shape
Definition footprintpad.h:59
Event
Definition footprintpad.h:84
PadHoleList & getHoles() noexcept
Definition footprintpad.h:146
const Layer & getSmtLayer() const noexcept
Definition footprintpad.cpp:262
bool hasTopCopper() const noexcept
Definition footprintpad.cpp:270
const PositiveLength & getHeight() const noexcept
Definition footprintpad.h:127
static UnsignedLimitedRatio getRecommendedRadius(const PositiveLength &width, const PositiveLength &height) noexcept
Definition footprintpad.cpp:561
static QString getFunctionDescriptionTr(Function function) noexcept
Definition footprintpad.cpp:572
ComponentSide getComponentSide() const noexcept
Definition footprintpad.h:141
bool hasAutoTopStopMask() const noexcept
Definition footprintpad.cpp:278
bool setSolderPasteConfig(const MaskConfig &config) noexcept
Definition footprintpad.cpp:444
bool hasAutoBottomStopMask() const noexcept
Definition footprintpad.cpp:283
PadHoleList::OnEditedSlot mHolesEditedSlot
Definition footprintpad.h:225
MaskConfig mSolderPasteConfig
Definition footprintpad.h:218
bool hasAutoBottomSolderPaste() const noexcept
Definition footprintpad.cpp:293
bool setFunction(Function function) noexcept
Definition footprintpad.cpp:475
Angle mRotation
Definition footprintpad.h:211
bool setHeight(const PositiveLength &height) noexcept
Definition footprintpad.cpp:404
bool isOnLayer(const Layer &layer) const noexcept
Definition footprintpad.cpp:254
const Point & getPosition() const noexcept
Definition footprintpad.h:123
MaskConfig mStopMaskConfig
Definition footprintpad.h:217
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition footprintpad.cpp:489
PositiveLength mHeight
Definition footprintpad.h:214
const Uuid & getUuid() const noexcept
Definition footprintpad.h:119
bool setWidth(const PositiveLength &width) noexcept
Definition footprintpad.cpp:394
bool setRadius(const UnsignedLimitedRatio &radius) noexcept
Definition footprintpad.cpp:414
UnsignedLength mCopperClearance
Definition footprintpad.h:219
bool setCustomShapeOutline(const Path &outline) noexcept
Definition footprintpad.cpp:424
FootprintPad & operator=(const FootprintPad &rhs) noexcept
Definition footprintpad.cpp:535
Point mPosition
Definition footprintpad.h:210
Signal< FootprintPad, Event > onEdited
Definition footprintpad.h:101
PositiveLength mWidth
Definition footprintpad.h:213
Slot< FootprintPad, Event > OnEditedSlot
Definition footprintpad.h:102
const UnsignedLimitedRatio & getRadius() const noexcept
Definition footprintpad.h:128
Shape getShape() const noexcept
Definition footprintpad.h:125
void holesEdited(const PadHoleList &list, int index, const std::shared_ptr< const PadHole > &hole, PadHoleList::Event event) noexcept
Definition footprintpad.cpp:604
ComponentSide mComponentSide
Definition footprintpad.h:220
bool hasAutoTopSolderPaste() const noexcept
Definition footprintpad.cpp:288
bool setPackagePadUuid(const std::optional< Uuid > &pad) noexcept
Definition footprintpad.cpp:364
The Layer class provides all supported geometry layers.
Definition layer.h:42
The MaskConfig class defines how to add automatic stop mask or solder paste.
Definition maskconfig.h:45
The PadGeometry class describes the shape of a pad.
Definition padgeometry.h:46
The Path class represents a list of vertices connected by straight lines or circular arc segments.
Definition path.h:57
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition point.h:78
The SExpression class.
Definition sexpression.h:69
Slot< SerializableObjectList< PadHole, PadHoleListNameProvider, OnEditedArgs... >, int, const std::shared_ptr< const PadHole > &, 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:76
std::size_t qHash(const AttributeKey &key, std::size_t seed=0) noexcept
Definition attributekey.h:118
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition length.h:810
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition length.h:694
type_safe::constrained_type< Ratio, UnsignedLimitedRatioConstraint, UnsignedLimitedRatioVerifier > UnsignedLimitedRatio
Definition ratio.h:376
Definition uuid.h:186
Definition footprintpad.h:241
static constexpr const char * tagname
Definition footprintpad.h:242