LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
boarddesignrules.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_BOARDDESIGNRULES_H
21 #define LIBREPCB_BOARDDESIGNRULES_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "elementname.h"
27 #include "exceptions.h"
29 #include "units/all_length_units.h"
30 
31 #include <QtCore>
32 
33 /*******************************************************************************
34  * Namespace / Forward Declarations
35  ******************************************************************************/
36 namespace librepcb {
37 
38 /*******************************************************************************
39  * Class BoardDesignRules
40  ******************************************************************************/
41 
48 class BoardDesignRules final : public SerializableObject {
49  Q_DECLARE_TR_FUNCTIONS(BoardDesignRules)
50 
51 public:
52  // Constructors / Destructor
53  BoardDesignRules() noexcept;
54  BoardDesignRules(const BoardDesignRules& other);
55  explicit BoardDesignRules(const SExpression& node);
56  ~BoardDesignRules() noexcept;
57 
58  // Getters : General Attributes
59  const ElementName& getName() const noexcept { return mName; }
60  const QString& getDescription() const noexcept { return mDescription; }
61 
62  // Getters: Stop Mask
63  const UnsignedRatio& getStopMaskClearanceRatio() const noexcept {
65  }
66  const UnsignedLength& getStopMaskClearanceMin() const noexcept {
67  return mStopMaskClearanceMin;
68  }
69  const UnsignedLength& getStopMaskClearanceMax() const noexcept {
70  return mStopMaskClearanceMax;
71  }
72  const UnsignedLength& getStopMaskMaxViaDiameter() const noexcept {
74  }
75 
76  // Getters: Cream Mask
77  const UnsignedRatio& getCreamMaskClearanceRatio() const noexcept {
79  }
80  const UnsignedLength& getCreamMaskClearanceMin() const noexcept {
82  }
83  const UnsignedLength& getCreamMaskClearanceMax() const noexcept {
85  }
86 
87  // Getters: Restring
88  const UnsignedRatio& getRestringPadRatio() const noexcept {
89  return mRestringPadRatio;
90  }
91  const UnsignedLength& getRestringPadMin() const noexcept {
92  return mRestringPadMin;
93  }
94  const UnsignedLength& getRestringPadMax() const noexcept {
95  return mRestringPadMax;
96  }
97  const UnsignedRatio& getRestringViaRatio() const noexcept {
98  return mRestringViaRatio;
99  }
100  const UnsignedLength& getRestringViaMin() const noexcept {
101  return mRestringViaMin;
102  }
103  const UnsignedLength& getRestringViaMax() const noexcept {
104  return mRestringViaMax;
105  }
106 
107  // Setters: General Attributes
108  void setName(const ElementName& name) noexcept { mName = name; }
109  void setDescription(const QString& desc) noexcept { mDescription = desc; }
110 
111  // Setters: Stop Mask
112  void setStopMaskClearanceRatio(const UnsignedRatio& ratio) noexcept {
113  mStopMaskClearanceRatio = ratio;
114  }
116  const UnsignedLength& max);
117  void setStopMaskMaxViaDiameter(const UnsignedLength& dia) noexcept {
119  }
120 
121  // Setters: Clear Mask
122  void setCreamMaskClearanceRatio(const UnsignedRatio& ratio) noexcept {
123  mCreamMaskClearanceRatio = ratio;
124  }
126  const UnsignedLength& max);
127 
128  // Setters: Restring
129  void setRestringPadRatio(const UnsignedRatio& ratio) noexcept {
130  mRestringPadRatio = ratio;
131  }
132  void setRestringPadBounds(const UnsignedLength& min,
133  const UnsignedLength& max);
134  void setRestringViaRatio(const UnsignedRatio& ratio) noexcept {
135  mRestringViaRatio = ratio;
136  }
137  void setRestringViaBounds(const UnsignedLength& min,
138  const UnsignedLength& max);
139 
140  // General Methods
141  void restoreDefaults() noexcept;
142 
144  void serialize(SExpression& root) const override;
145 
146  // Helper Methods
147  bool doesViaRequireStopMask(const Length& drillDia) const noexcept;
148  UnsignedLength calcStopMaskClearance(const Length& padSize) const noexcept;
149  UnsignedLength calcCreamMaskClearance(const Length& padSize) const noexcept;
150  UnsignedLength calcPadRestring(const Length& drillDia) const noexcept;
151  UnsignedLength calcViaRestring(const Length& drillDia) const noexcept;
152 
153  // Operator Overloadings
154  BoardDesignRules& operator=(const BoardDesignRules& rhs) noexcept;
155 
156 private:
157  // General Attributes
159  QString mDescription;
160 
161  // Stop Mask
166 
167  // Cream Mask
171 
172  // Restring
179 };
180 
181 /*******************************************************************************
182  * End of File
183  ******************************************************************************/
184 
185 } // namespace librepcb
186 
187 #endif // LIBREPCB_BOARDDESIGNRULES_H
UnsignedLength calcStopMaskClearance(const Length &padSize) const noexcept
Definition: boarddesignrules.cpp:221
const UnsignedRatio & getRestringViaRatio() const noexcept
Definition: boarddesignrules.h:97
const UnsignedLength & getStopMaskMaxViaDiameter() const noexcept
Definition: boarddesignrules.h:72
void setCreamMaskClearanceBounds(const UnsignedLength &min, const UnsignedLength &max)
Definition: boarddesignrules.cpp:148
const UnsignedLength & getRestringPadMax() const noexcept
Definition: boarddesignrules.h:94
UnsignedLength mRestringViaMin
Definition: boarddesignrules.h:177
const QString & getDescription() const noexcept
Definition: boarddesignrules.h:60
const UnsignedRatio & getRestringPadRatio() const noexcept
Definition: boarddesignrules.h:88
void setRestringViaBounds(const UnsignedLength &min, const UnsignedLength &max)
Definition: boarddesignrules.cpp:170
void setStopMaskClearanceRatio(const UnsignedRatio &ratio) noexcept
Definition: boarddesignrules.h:112
UnsignedLength mRestringPadMin
Definition: boarddesignrules.h:174
UnsignedLength calcPadRestring(const Length &drillDia) const noexcept
Definition: boarddesignrules.cpp:237
UnsignedLength mRestringViaMax
Definition: boarddesignrules.h:178
The BoardDesignRules class.
Definition: boarddesignrules.h:48
UnsignedLength mCreamMaskClearanceMax
Definition: boarddesignrules.h:170
UnsignedLength calcCreamMaskClearance(const Length &padSize) const noexcept
Definition: boarddesignrules.cpp:229
const UnsignedLength & getCreamMaskClearanceMin() const noexcept
Definition: boarddesignrules.h:80
const ElementName & getName() const noexcept
Definition: boarddesignrules.h:59
void setDescription(const QString &desc) noexcept
Definition: boarddesignrules.h:109
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:46
const UnsignedRatio & getStopMaskClearanceRatio() const noexcept
Definition: boarddesignrules.h:63
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: boarddesignrules.cpp:189
UnsignedLength mStopMaskMaxViaDrillDiameter
Definition: boarddesignrules.h:165
void setRestringPadBounds(const UnsignedLength &min, const UnsignedLength &max)
Definition: boarddesignrules.cpp:159
type_safe::constrained_type< Ratio, UnsignedRatioConstraint, UnsignedRatioVerifier > UnsignedRatio
Definition: ratio.h:333
void setRestringPadRatio(const UnsignedRatio &ratio) noexcept
Definition: boarddesignrules.h:129
void setStopMaskClearanceBounds(const UnsignedLength &min, const UnsignedLength &max)
Definition: boarddesignrules.cpp:137
QString mDescription
Definition: boarddesignrules.h:159
UnsignedLength mCreamMaskClearanceMin
Definition: boarddesignrules.h:169
const UnsignedRatio & getCreamMaskClearanceRatio() const noexcept
Definition: boarddesignrules.h:77
UnsignedLength mStopMaskClearanceMax
Definition: boarddesignrules.h:164
UnsignedRatio mRestringPadRatio
Definition: boarddesignrules.h:173
const UnsignedLength & getRestringViaMax() const noexcept
Definition: boarddesignrules.h:103
void setName(const ElementName &name) noexcept
Definition: boarddesignrules.h:108
bool doesViaRequireStopMask(const Length &drillDia) const noexcept
Definition: boarddesignrules.cpp:216
~BoardDesignRules() noexcept
Definition: boarddesignrules.cpp:130
UnsignedLength mRestringPadMax
Definition: boarddesignrules.h:175
UnsignedLength calcViaRestring(const Length &drillDia) const noexcept
Definition: boarddesignrules.cpp:244
const UnsignedLength & getStopMaskClearanceMin() const noexcept
Definition: boarddesignrules.h:66
void restoreDefaults() noexcept
Definition: boarddesignrules.cpp:185
ElementName mName
Definition: boarddesignrules.h:158
const UnsignedLength & getStopMaskClearanceMax() const noexcept
Definition: boarddesignrules.h:69
UnsignedRatio mRestringViaRatio
Definition: boarddesignrules.h:176
const UnsignedLength & getRestringPadMin() const noexcept
Definition: boarddesignrules.h:91
void setCreamMaskClearanceRatio(const UnsignedRatio &ratio) noexcept
Definition: boarddesignrules.h:122
The Length class is used to represent a length (for example 12.75 millimeters)
Definition: length.h:85
void setRestringViaRatio(const UnsignedRatio &ratio) noexcept
Definition: boarddesignrules.h:134
void setStopMaskMaxViaDiameter(const UnsignedLength &dia) noexcept
Definition: boarddesignrules.h:117
UnsignedRatio mStopMaskClearanceRatio
Definition: boarddesignrules.h:162
const UnsignedLength & getRestringViaMin() const noexcept
Definition: boarddesignrules.h:100
The SExpression class.
Definition: sexpression.h:60
UnsignedLength mStopMaskClearanceMin
Definition: boarddesignrules.h:163
const UnsignedLength & getCreamMaskClearanceMax() const noexcept
Definition: boarddesignrules.h:83
UnsignedRatio mCreamMaskClearanceRatio
Definition: boarddesignrules.h:168
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:662
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition: elementname.h:92
BoardDesignRules() noexcept
Definition: boarddesignrules.cpp:36