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