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 "../../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  ******************************************************************************/
43 namespace librepcb {
44 
45 class Layer;
46 
47 /*******************************************************************************
48  * Class FootprintPad
49  ******************************************************************************/
50 
54 class FootprintPad final {
55  Q_DECLARE_TR_FUNCTIONS(FootprintPad)
56 
57 public:
58  // Types
59  enum class Shape {
62  Custom,
63  };
64 
65  enum class ComponentSide {
66  Top,
67  Bottom,
68  };
69 
70  enum class Function {
71  Unspecified = 0,
72  StandardPad,
73  PressFitPad,
74  ThermalPad,
75  BgaPad,
76  EdgeConnectorPad,
77  TestPad,
78  LocalFiducial,
79  GlobalFiducial,
80  _COUNT,
81  };
82 
83  // Signals
84  enum class Event {
85  UuidChanged,
86  PackagePadUuidChanged,
87  PositionChanged,
88  RotationChanged,
89  ShapeChanged,
90  WidthChanged,
91  HeightChanged,
92  RadiusChanged,
93  CustomShapeOutlineChanged,
94  StopMaskConfigChanged,
95  SolderPasteConfigChanged,
96  CopperClearanceChanged,
97  ComponentSideChanged,
98  FunctionChanged,
99  HolesEdited,
100  };
103 
104  // Constructors / Destructor
105  FootprintPad() = delete;
106  FootprintPad(const FootprintPad& other) noexcept;
107  FootprintPad(const Uuid& uuid, const tl::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 tl::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() const
158  noexcept;
159 
160  // Setters
161  bool setPackagePadUuid(const tl::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 
196 private: // Methods
197  void holesEdited(const PadHoleList& list, int index,
198  const std::shared_ptr<const PadHole>& hole,
199  PadHoleList::Event event) noexcept;
200 
201 private: // Data
203 
209  tl::optional<Uuid> mPackagePadUuid;
223 
224  // Slots
226 };
227 
228 /*******************************************************************************
229  * Non-Member Functions
230  ******************************************************************************/
231 
232 inline uint qHash(const FootprintPad::Function& key, uint seed = 0) noexcept {
233  return ::qHash(static_cast<int>(key), seed);
234 }
235 
236 /*******************************************************************************
237  * Class FootprintPadList
238  ******************************************************************************/
239 
241  static constexpr const char* tagname = "pad";
242 };
243 using FootprintPadList =
246 
247 /*******************************************************************************
248  * End of File
249  ******************************************************************************/
250 
251 } // namespace librepcb
252 
253 Q_DECLARE_METATYPE(librepcb::FootprintPad::Function)
254 
255 #endif
Function getFunction() const noexcept
Definition: footprintpad.h:142
bool setPosition(const Point &pos) noexcept
Definition: footprintpad.cpp:351
const Uuid & getUuid() const noexcept
Definition: footprintpad.h:119
bool hasAutoTopStopMask() const noexcept
Definition: footprintpad.cpp:275
const Point & getPosition() const noexcept
Definition: footprintpad.h:123
bool setRotation(const Angle &rot) noexcept
Definition: footprintpad.cpp:371
const Layer & getSmtLayer() const noexcept
Definition: footprintpad.cpp:259
bool setWidth(const PositiveLength &width) noexcept
Definition: footprintpad.cpp:391
Shape
Definition: footprintpad.h:59
bool setSolderPasteConfig(const MaskConfig &config) noexcept
Definition: footprintpad.cpp:441
bool getFunctionIsFiducial() const noexcept
Definition: footprintpad.cpp:230
The MaskConfig class defines how to add automatic stop mask or solder paste.
Definition: maskconfig.h:45
const PositiveLength & getWidth() const noexcept
Definition: footprintpad.h:126
Definition: footprintpad.h:240
UnsignedLength mCopperClearance
Definition: footprintpad.h:219
bool isTht() const noexcept
Definition: footprintpad.cpp:247
Definition: occmodel.cpp:76
The Layer class provides all supported geometry layers.
Definition: layer.h:40
bool hasAutoBottomSolderPaste() const noexcept
Definition: footprintpad.cpp:290
PadHoleList::OnEditedSlot mHolesEditedSlot
Definition: footprintpad.h:225
bool setPackagePadUuid(const tl::optional< Uuid > &pad) noexcept
Definition: footprintpad.cpp:361
Slot< FootprintPad, Event > OnEditedSlot
Definition: footprintpad.h:102
Angle mRotation
Definition: footprintpad.h:211
The PadGeometry class describes the shape of a pad.
Definition: padgeometry.h:46
bool hasTopCopper() const noexcept
Definition: footprintpad.cpp:267
bool isOnLayer(const Layer &layer) const noexcept
Definition: footprintpad.cpp:251
The FootprintPad class represents a pad of a footprint.
Definition: footprintpad.h:54
bool setRadius(const UnsignedLimitedRatio &radius) noexcept
Definition: footprintpad.cpp:411
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:76
PadHoleList & getHoles() noexcept
Definition: footprintpad.h:146
Shape mShape
Definition: footprintpad.h:212
Uuid mUuid
Definition: footprintpad.h:202
PadGeometry getGeometry() const noexcept
Definition: footprintpad.cpp:295
Point mPosition
Definition: footprintpad.h:210
bool setCopperClearance(const UnsignedLength &clearance) noexcept
Definition: footprintpad.cpp:451
bool setHeight(const PositiveLength &height) noexcept
Definition: footprintpad.cpp:401
ComponentSide
Definition: footprintpad.h:65
FootprintPad & operator=(const FootprintPad &rhs) noexcept
Definition: footprintpad.cpp:532
const PositiveLength & getHeight() const noexcept
Definition: footprintpad.h:127
const tl::optional< Uuid > & getPackagePadUuid() const noexcept
Definition: footprintpad.h:120
Shape getShape() const noexcept
Definition: footprintpad.h:125
bool hasAutoBottomStopMask() const noexcept
Definition: footprintpad.cpp:280
PositiveLength mHeight
Definition: footprintpad.h:214
bool setStopMaskConfig(const MaskConfig &config) noexcept
Definition: footprintpad.cpp:431
bool operator==(const FootprintPad &rhs) const noexcept
Definition: footprintpad.cpp:513
void holesEdited(const PadHoleList &list, int index, const std::shared_ptr< const PadHole > &hole, PadHoleList::Event event) noexcept
Definition: footprintpad.cpp:601
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
Signal< FootprintPad, Event > onEdited
Definition: footprintpad.h:101
tl::optional< Uuid > mPackagePadUuid
Definition: footprintpad.h:209
const PadHoleList & getHoles() const noexcept
Definition: footprintpad.h:145
ComponentSide mComponentSide
Definition: footprintpad.h:220
static QString getFunctionDescriptionTr(Function function) noexcept
Definition: footprintpad.cpp:569
bool hasBottomCopper() const noexcept
Definition: footprintpad.cpp:271
Function
Definition: footprintpad.h:70
const MaskConfig & getStopMaskConfig() const noexcept
Definition: footprintpad.h:132
Event
Definition: footprintpad.h:84
MaskConfig mStopMaskConfig
Definition: footprintpad.h:217
static UnsignedLimitedRatio getRecommendedRadius(const PositiveLength &width, const PositiveLength &height) noexcept
Definition: footprintpad.cpp:558
bool operator!=(const FootprintPad &rhs) const noexcept
Definition: footprintpad.h:186
PadHoleList mHoles
If not empty, it&#39;s a THT pad.
Definition: footprintpad.h:222
const Angle & getRotation() const noexcept
Definition: footprintpad.h:124
~FootprintPad() noexcept
Definition: footprintpad.cpp:223
UnsignedLimitedRatio mRadius
Definition: footprintpad.h:215
Path mCustomShapeOutline
Empty if not needed; Implicitly closed.
Definition: footprintpad.h:216
const MaskConfig & getSolderPasteConfig() const noexcept
Definition: footprintpad.h:135
bool getFunctionNeedsSoldering() const noexcept
Definition: footprintpad.cpp:235
The Path class represents a list of vertices connected by straight lines or circular arc segments...
Definition: path.h:57
ComponentSide getComponentSide() const noexcept
Definition: footprintpad.h:141
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
const UnsignedLength & getCopperClearance() const noexcept
Definition: footprintpad.h:138
type_safe::constrained_type< Ratio, UnsignedLimitedRatioConstraint, UnsignedLimitedRatioVerifier > UnsignedLimitedRatio
Definition: ratio.h:368
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:785
const Path & getCustomShapeOutline() const noexcept
Definition: footprintpad.h:129
QHash< const Layer *, QList< PadGeometry > > buildPreviewGeometries() const noexcept
Definition: footprintpad.cpp:311
bool setCustomShapeOutline(const Path &outline) noexcept
Definition: footprintpad.cpp:421
Function mFunction
Definition: footprintpad.h:221
bool setComponentSide(ComponentSide side) noexcept
Definition: footprintpad.cpp:462
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:56
uint qHash(const FootprintPad::Function &key, uint seed=0) noexcept
Definition: footprintpad.h:232
PositiveLength mWidth
Definition: footprintpad.h:213
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition: footprintpad.cpp:486
bool hasAutoTopSolderPaste() const noexcept
Definition: footprintpad.cpp:285
const UnsignedLimitedRatio & getRadius() const noexcept
Definition: footprintpad.h:128
The SExpression class.
Definition: sexpression.h:66
bool setShape(Shape shape) noexcept
Definition: footprintpad.cpp:381
uint qHash(const AttributeKey &key, uint seed=0) noexcept
Definition: attributekey.h:118
bool setFunction(Function function) noexcept
Definition: footprintpad.cpp:472
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:670
MaskConfig mSolderPasteConfig
Definition: footprintpad.h:218