LibrePCB Developers Documentation
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 "../../qtcompat.h"
31#include "../../serialization/serializableobjectlist.h"
32#include "../../types/angle.h"
33#include "../../types/length.h"
34#include "../../types/maskconfig.h"
35#include "../../types/point.h"
36#include "../../types/ratio.h"
37#include "../../types/uuid.h"
38
39#include <QtCore>
40
41/*******************************************************************************
42 * Namespace / Forward Declarations
43 ******************************************************************************/
44namespace librepcb {
45
46class Layer;
47
48/*******************************************************************************
49 * Class FootprintPad
50 ******************************************************************************/
51
55class FootprintPad final {
56 Q_DECLARE_TR_FUNCTIONS(FootprintPad)
57
58public:
59 // Types
60 enum class Shape {
61 RoundedRect,
62 RoundedOctagon,
63 Custom,
64 };
65
66 enum class ComponentSide {
67 Top,
68 Bottom,
69 };
70
71 enum class Function {
72 Unspecified = 0,
73 StandardPad,
74 PressFitPad,
75 ThermalPad,
76 BgaPad,
77 EdgeConnectorPad,
78 TestPad,
79 LocalFiducial,
80 GlobalFiducial,
81 _COUNT,
82 };
83
84 // Signals
85 enum class Event {
86 UuidChanged,
87 PackagePadUuidChanged,
88 PositionChanged,
89 RotationChanged,
90 ShapeChanged,
91 WidthChanged,
92 HeightChanged,
93 RadiusChanged,
94 CustomShapeOutlineChanged,
95 StopMaskConfigChanged,
96 SolderPasteConfigChanged,
97 CopperClearanceChanged,
98 ComponentSideChanged,
99 FunctionChanged,
100 HolesEdited,
101 };
104
105 // Constructors / Destructor
106 FootprintPad() = delete;
107 FootprintPad(const FootprintPad& other) noexcept;
108 FootprintPad(const Uuid& uuid, const tl::optional<Uuid>& pkgPadUuid,
109 const Point& pos, const Angle& rot, Shape shape,
110 const PositiveLength& width, const PositiveLength& height,
111 const UnsignedLimitedRatio& radius,
112 const Path& customShapeOutline, const MaskConfig& autoStopMask,
113 const MaskConfig& autoSolderPaste,
114 const UnsignedLength& copperClearance, ComponentSide side,
115 Function function, const PadHoleList& holes) noexcept;
116 explicit FootprintPad(const SExpression& node);
117 ~FootprintPad() noexcept;
118
119 // Getters
120 const Uuid& getUuid() const noexcept { return mUuid; }
121 const tl::optional<Uuid>& getPackagePadUuid() const noexcept {
122 return mPackagePadUuid;
123 }
124 const Point& getPosition() const noexcept { return mPosition; }
125 const Angle& getRotation() const noexcept { return mRotation; }
126 Shape getShape() const noexcept { return mShape; }
127 const PositiveLength& getWidth() const noexcept { return mWidth; }
128 const PositiveLength& getHeight() const noexcept { return mHeight; }
129 const UnsignedLimitedRatio& getRadius() const noexcept { return mRadius; }
130 const Path& getCustomShapeOutline() const noexcept {
131 return mCustomShapeOutline;
132 }
133 const MaskConfig& getStopMaskConfig() const noexcept {
134 return mStopMaskConfig;
135 }
136 const MaskConfig& getSolderPasteConfig() const noexcept {
137 return mSolderPasteConfig;
138 }
139 const UnsignedLength& getCopperClearance() const noexcept {
140 return mCopperClearance;
141 }
142 ComponentSide getComponentSide() const noexcept { return mComponentSide; }
143 Function getFunction() const noexcept { return mFunction; }
144 bool getFunctionIsFiducial() const noexcept;
145 bool getFunctionNeedsSoldering() const noexcept;
146 const PadHoleList& getHoles() const noexcept { return mHoles; }
147 PadHoleList& getHoles() noexcept { return mHoles; }
148 bool isTht() const noexcept;
149 bool isOnLayer(const Layer& layer) const noexcept;
150 const Layer& getSmtLayer() const noexcept;
151 bool hasTopCopper() const noexcept;
152 bool hasBottomCopper() const noexcept;
153 bool hasAutoTopStopMask() const noexcept;
154 bool hasAutoBottomStopMask() const noexcept;
155 bool hasAutoTopSolderPaste() const noexcept;
156 bool hasAutoBottomSolderPaste() const noexcept;
157 PadGeometry getGeometry() const noexcept;
158 QHash<const Layer*, QList<PadGeometry>> buildPreviewGeometries()
159 const noexcept;
160
161 // Setters
162 bool setPackagePadUuid(const tl::optional<Uuid>& pad) noexcept;
163 bool setPosition(const Point& pos) noexcept;
164 bool setRotation(const Angle& rot) noexcept;
165 bool setShape(Shape shape) noexcept;
166 bool setWidth(const PositiveLength& width) noexcept;
167 bool setHeight(const PositiveLength& height) noexcept;
168 bool setRadius(const UnsignedLimitedRatio& radius) noexcept;
169 bool setCustomShapeOutline(const Path& outline) noexcept;
170 bool setStopMaskConfig(const MaskConfig& config) noexcept;
171 bool setSolderPasteConfig(const MaskConfig& config) noexcept;
172 bool setCopperClearance(const UnsignedLength& clearance) noexcept;
173 bool setComponentSide(ComponentSide side) noexcept;
174 bool setFunction(Function function) noexcept;
175
176 // General Methods
177
183 void serialize(SExpression& root) const;
184
185 // Operator Overloadings
186 bool operator==(const FootprintPad& rhs) const noexcept;
187 bool operator!=(const FootprintPad& rhs) const noexcept {
188 return !(*this == rhs);
189 }
190 FootprintPad& operator=(const FootprintPad& rhs) noexcept;
191
192 // Static Methods
194 const PositiveLength& width, const PositiveLength& height) noexcept;
195 static QString getFunctionDescriptionTr(Function function) noexcept;
196
197private: // Methods
198 void holesEdited(const PadHoleList& list, int index,
199 const std::shared_ptr<const PadHole>& hole,
200 PadHoleList::Event event) noexcept;
201
202private: // Data
204
210 tl::optional<Uuid> mPackagePadUuid;
224
225 // Slots
227};
228
229/*******************************************************************************
230 * Non-Member Functions
231 ******************************************************************************/
232
234 QtCompat::Hash seed = 0) noexcept {
235 return ::qHash(static_cast<int>(key), seed);
236}
237
238/*******************************************************************************
239 * Class FootprintPadList
240 ******************************************************************************/
241
243 static constexpr const char* tagname = "pad";
244};
248
249/*******************************************************************************
250 * End of File
251 ******************************************************************************/
252
253} // namespace librepcb
254
255Q_DECLARE_METATYPE(librepcb::FootprintPad::Function)
256
257#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
The FootprintPad class represents a pad of a footprint.
Definition: footprintpad.h:55
Function mFunction
Definition: footprintpad.h:222
QHash< const Layer *, QList< PadGeometry > > buildPreviewGeometries() const noexcept
Definition: footprintpad.cpp:314
Shape mShape
Definition: footprintpad.h:213
bool setRotation(const Angle &rot) noexcept
Definition: footprintpad.cpp:374
PadGeometry getGeometry() const noexcept
Definition: footprintpad.cpp:298
const tl::optional< Uuid > & getPackagePadUuid() const noexcept
Definition: footprintpad.h:121
const Angle & getRotation() const noexcept
Definition: footprintpad.h:125
PadHoleList mHoles
If not empty, it's a THT pad.
Definition: footprintpad.h:223
const MaskConfig & getSolderPasteConfig() const noexcept
Definition: footprintpad.h:136
const PositiveLength & getWidth() const noexcept
Definition: footprintpad.h:127
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:217
const MaskConfig & getStopMaskConfig() const noexcept
Definition: footprintpad.h:133
bool hasBottomCopper() const noexcept
Definition: footprintpad.cpp:274
UnsignedLimitedRatio mRadius
Definition: footprintpad.h:216
ComponentSide
Definition: footprintpad.h:66
const Path & getCustomShapeOutline() const noexcept
Definition: footprintpad.h:130
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:139
Uuid mUuid
Definition: footprintpad.h:203
Function
Definition: footprintpad.h:71
const PadHoleList & getHoles() const noexcept
Definition: footprintpad.h:146
Function getFunction() const noexcept
Definition: footprintpad.h:143
Shape
Definition: footprintpad.h:60
Event
Definition: footprintpad.h:85
PadHoleList & getHoles() noexcept
Definition: footprintpad.h:147
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:128
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:142
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:226
MaskConfig mSolderPasteConfig
Definition: footprintpad.h:219
bool hasAutoBottomSolderPaste() const noexcept
Definition: footprintpad.cpp:293
bool setFunction(Function function) noexcept
Definition: footprintpad.cpp:475
Angle mRotation
Definition: footprintpad.h:212
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:124
bool setPackagePadUuid(const tl::optional< Uuid > &pad) noexcept
Definition: footprintpad.cpp:364
MaskConfig mStopMaskConfig
Definition: footprintpad.h:218
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition: footprintpad.cpp:489
PositiveLength mHeight
Definition: footprintpad.h:215
const Uuid & getUuid() const noexcept
Definition: footprintpad.h:120
tl::optional< Uuid > mPackagePadUuid
Definition: footprintpad.h:210
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:220
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:211
Signal< FootprintPad, Event > onEdited
Definition: footprintpad.h:102
PositiveLength mWidth
Definition: footprintpad.h:214
Slot< FootprintPad, Event > OnEditedSlot
Definition: footprintpad.h:103
const UnsignedLimitedRatio & getRadius() const noexcept
Definition: footprintpad.h:129
Shape getShape() const noexcept
Definition: footprintpad.h:126
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:221
bool hasAutoTopSolderPaste() const noexcept
Definition: footprintpad.cpp:288
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:58
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition: point.h:79
uint Hash
Return type of Qt's qHash() function.
Definition: qtcompat.h:58
The SExpression class.
Definition: sexpression.h:69
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
Definition: occmodel.cpp:77
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:812
QtCompat::Hash qHash(const AttributeKey &key, QtCompat::Hash seed=0) noexcept
Definition: attributekey.h:119
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:696
QtCompat::Hash qHash(const FootprintPad::Function &key, QtCompat::Hash seed=0) noexcept
Definition: footprintpad.h:233
type_safe::constrained_type< Ratio, UnsignedLimitedRatioConstraint, UnsignedLimitedRatioVerifier > UnsignedLimitedRatio
Definition: ratio.h:378
Definition: uuid.h:183
Definition: footprintpad.h:242
static constexpr const char * tagname
Definition: footprintpad.h:243