LibrePCB Developers Documentation
Loading...
Searching...
No Matches
pad.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_PAD_H
21#define LIBREPCB_CORE_PAD_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../exceptions.h"
27#include "../types/angle.h"
28#include "../types/length.h"
29#include "../types/maskconfig.h"
30#include "../types/point.h"
31#include "../types/ratio.h"
32#include "../types/uuid.h"
33#include "padgeometry.h"
34#include "padhole.h"
35#include "path.h"
36
37#include <QtCore>
38
39/*******************************************************************************
40 * Namespace / Forward Declarations
41 ******************************************************************************/
42namespace librepcb {
43
44class Layer;
45
46/*******************************************************************************
47 * Class Pad
48 ******************************************************************************/
49
53class Pad {
54 Q_DECLARE_TR_FUNCTIONS(Pad)
55
56public:
57 // Types
58 enum class Shape {
61 Custom,
62 };
63
64 enum class ComponentSide {
65 Top,
66 Bottom,
67 };
68
81
82 // Constructors / Destructor
83 Pad() = delete;
84 Pad(const Pad& other) noexcept;
85 Pad(const Uuid& uuid, const Pad& other) noexcept;
86 Pad(const Uuid& uuid, const Point& pos, const Angle& rot, Shape shape,
87 const PositiveLength& width, const PositiveLength& height,
88 const UnsignedLimitedRatio& radius, const Path& customShapeOutline,
89 const MaskConfig& autoStopMask, const MaskConfig& autoSolderPaste,
90 const UnsignedLength& copperClearance, ComponentSide side,
91 Function function, const PadHoleList& holes) noexcept;
92 explicit Pad(const SExpression& node);
93 virtual ~Pad() noexcept;
94
95 // Getters
96 const Uuid& getUuid() const noexcept { return mUuid; }
97 const Point& getPosition() const noexcept { return mPosition; }
98 const Angle& getRotation() const noexcept { return mRotation; }
99 Shape getShape() const noexcept { return mShape; }
100 const PositiveLength& getWidth() const noexcept { return mWidth; }
101 const PositiveLength& getHeight() const noexcept { return mHeight; }
102 const UnsignedLimitedRatio& getRadius() const noexcept { return mRadius; }
103 const Path& getCustomShapeOutline() const noexcept {
104 return mCustomShapeOutline;
105 }
106 const MaskConfig& getStopMaskConfig() const noexcept {
107 return mStopMaskConfig;
108 }
109 const MaskConfig& getSolderPasteConfig() const noexcept {
110 return mSolderPasteConfig;
111 }
112 const UnsignedLength& getCopperClearance() const noexcept {
113 return mCopperClearance;
114 }
115 ComponentSide getComponentSide() const noexcept { return mComponentSide; }
116 Function getFunction() const noexcept { return mFunction; }
117 bool getFunctionIsFiducial() const noexcept;
118 bool getFunctionNeedsSoldering() const noexcept;
119 const PadHoleList& getHoles() const noexcept { return mHoles; }
120 bool isTht() const noexcept;
121 bool isOnLayer(const Layer& layer) const noexcept;
122 const Layer& getSmtLayer() const noexcept;
123 bool hasTopCopper() const noexcept;
124 bool hasBottomCopper() const noexcept;
125 bool hasAutoTopStopMask() const noexcept;
126 bool hasAutoBottomStopMask() const noexcept;
127 bool hasAutoTopSolderPaste() const noexcept;
128 bool hasAutoBottomSolderPaste() const noexcept;
129 PadGeometry getGeometry() const noexcept;
130 QHash<const Layer*, QList<PadGeometry>> buildPreviewGeometries()
131 const noexcept;
132
133 // Operator Overloadings
134 bool operator==(const Pad& rhs) const noexcept;
135 bool operator!=(const Pad& rhs) const noexcept { return !(*this == rhs); }
136
137 // Static Methods
139 const PositiveLength& width, const PositiveLength& height) noexcept;
140 static QString getFunctionDescriptionTr(Function function) noexcept;
141
142protected: // Data
157};
158
159/*******************************************************************************
160 * Non-Member Functions
161 ******************************************************************************/
162
163inline std::size_t qHash(const Pad::Function& key,
164 std::size_t seed = 0) noexcept {
165 return ::qHash(static_cast<int>(key), seed);
166}
167
168/*******************************************************************************
169 * End of File
170 ******************************************************************************/
171
172} // namespace librepcb
173
174Q_DECLARE_METATYPE(librepcb::Pad::Function)
175
176#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition angle.h:76
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
Base class for pads, extended in derived classes.
Definition pad.h:53
Function mFunction
Definition pad.h:155
QHash< const Layer *, QList< PadGeometry > > buildPreviewGeometries() const noexcept
Definition pad.cpp:311
Shape mShape
Definition pad.h:146
PadGeometry getGeometry() const noexcept
Definition pad.cpp:285
const Angle & getRotation() const noexcept
Definition pad.h:98
PadHoleList mHoles
If not empty, it's a THT pad.
Definition pad.h:156
const MaskConfig & getSolderPasteConfig() const noexcept
Definition pad.h:109
const PositiveLength & getWidth() const noexcept
Definition pad.h:100
bool getFunctionIsFiducial() const noexcept
Definition pad.cpp:220
Path mCustomShapeOutline
Empty if not needed; Implicitly closed.
Definition pad.h:150
Pad()=delete
const MaskConfig & getStopMaskConfig() const noexcept
Definition pad.h:106
bool hasBottomCopper() const noexcept
Definition pad.cpp:261
UnsignedLimitedRatio mRadius
Definition pad.h:149
ComponentSide
Definition pad.h:64
const Path & getCustomShapeOutline() const noexcept
Definition pad.h:103
bool isTht() const noexcept
Definition pad.cpp:237
bool getFunctionNeedsSoldering() const noexcept
Definition pad.cpp:225
const UnsignedLength & getCopperClearance() const noexcept
Definition pad.h:112
Uuid mUuid
Definition pad.h:143
Function
Definition pad.h:69
const PadHoleList & getHoles() const noexcept
Definition pad.h:119
Function getFunction() const noexcept
Definition pad.h:116
Shape
Definition pad.h:58
const Layer & getSmtLayer() const noexcept
Definition pad.cpp:249
bool hasTopCopper() const noexcept
Definition pad.cpp:257
const PositiveLength & getHeight() const noexcept
Definition pad.h:101
static UnsignedLimitedRatio getRecommendedRadius(const PositiveLength &width, const PositiveLength &height) noexcept
Definition pad.cpp:373
static QString getFunctionDescriptionTr(Function function) noexcept
Definition pad.cpp:384
ComponentSide getComponentSide() const noexcept
Definition pad.h:115
bool hasAutoTopStopMask() const noexcept
Definition pad.cpp:265
bool hasAutoBottomStopMask() const noexcept
Definition pad.cpp:270
MaskConfig mSolderPasteConfig
Definition pad.h:152
bool hasAutoBottomSolderPaste() const noexcept
Definition pad.cpp:280
Angle mRotation
Definition pad.h:145
bool isOnLayer(const Layer &layer) const noexcept
Definition pad.cpp:241
const Point & getPosition() const noexcept
Definition pad.h:97
MaskConfig mStopMaskConfig
Definition pad.h:151
virtual ~Pad() noexcept
Definition pad.cpp:213
PositiveLength mHeight
Definition pad.h:148
const Uuid & getUuid() const noexcept
Definition pad.h:96
UnsignedLength mCopperClearance
Definition pad.h:153
Point mPosition
Definition pad.h:144
PositiveLength mWidth
Definition pad.h:147
const UnsignedLimitedRatio & getRadius() const noexcept
Definition pad.h:102
Shape getShape() const noexcept
Definition pad.h:99
ComponentSide mComponentSide
Definition pad.h:154
bool hasAutoTopSolderPaste() const noexcept
Definition pad.cpp:275
The Path class represents a list of vertices connected by straight lines or circular arc segments.
Definition path.h:59
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
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition uuid.h:56
Definition occmodel.cpp:77
std::size_t qHash(const AttributeKey &key, std::size_t seed=0) noexcept
Definition attributekey.h:113
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