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" 28 #include "fileio/serializableobject.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 42 /** 43 * @brief The BoardDesignRules class 44 */ 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 BoardDesignRules(const SExpression& node, const Version& fileFormat); 53 ~BoardDesignRules() noexcept; 54 55 // Getters : General Attributes getName()56 const ElementName& getName() const noexcept { return mName; } getDescription()57 const QString& getDescription() const noexcept { return mDescription; } 58 59 // Getters: Stop Mask getStopMaskClearanceRatio()60 const UnsignedRatio& getStopMaskClearanceRatio() const noexcept { 61 return mStopMaskClearanceRatio; 62 } getStopMaskClearanceMin()63 const UnsignedLength& getStopMaskClearanceMin() const noexcept { 64 return mStopMaskClearanceMin; 65 } getStopMaskClearanceMax()66 const UnsignedLength& getStopMaskClearanceMax() const noexcept { 67 return mStopMaskClearanceMax; 68 } getStopMaskMaxViaDiameter()69 const UnsignedLength& getStopMaskMaxViaDiameter() const noexcept { 70 return mStopMaskMaxViaDrillDiameter; 71 } 72 73 // Getters: Cream Mask getCreamMaskClearanceRatio()74 const UnsignedRatio& getCreamMaskClearanceRatio() const noexcept { 75 return mCreamMaskClearanceRatio; 76 } getCreamMaskClearanceMin()77 const UnsignedLength& getCreamMaskClearanceMin() const noexcept { 78 return mCreamMaskClearanceMin; 79 } getCreamMaskClearanceMax()80 const UnsignedLength& getCreamMaskClearanceMax() const noexcept { 81 return mCreamMaskClearanceMax; 82 } 83 84 // Getters: Restring getRestringPadRatio()85 const UnsignedRatio& getRestringPadRatio() const noexcept { 86 return mRestringPadRatio; 87 } getRestringPadMin()88 const UnsignedLength& getRestringPadMin() const noexcept { 89 return mRestringPadMin; 90 } getRestringPadMax()91 const UnsignedLength& getRestringPadMax() const noexcept { 92 return mRestringPadMax; 93 } getRestringViaRatio()94 const UnsignedRatio& getRestringViaRatio() const noexcept { 95 return mRestringViaRatio; 96 } getRestringViaMin()97 const UnsignedLength& getRestringViaMin() const noexcept { 98 return mRestringViaMin; 99 } getRestringViaMax()100 const UnsignedLength& getRestringViaMax() const noexcept { 101 return mRestringViaMax; 102 } 103 104 // Setters: General Attributes setName(const ElementName & name)105 void setName(const ElementName& name) noexcept { mName = name; } setDescription(const QString & desc)106 void setDescription(const QString& desc) noexcept { mDescription = desc; } 107 108 // Setters: Stop Mask setStopMaskClearanceRatio(const UnsignedRatio & ratio)109 void setStopMaskClearanceRatio(const UnsignedRatio& ratio) noexcept { 110 mStopMaskClearanceRatio = ratio; 111 } 112 void setStopMaskClearanceBounds(const UnsignedLength& min, 113 const UnsignedLength& max); setStopMaskMaxViaDiameter(const UnsignedLength & dia)114 void setStopMaskMaxViaDiameter(const UnsignedLength& dia) noexcept { 115 mStopMaskMaxViaDrillDiameter = dia; 116 } 117 118 // Setters: Clear Mask setCreamMaskClearanceRatio(const UnsignedRatio & ratio)119 void setCreamMaskClearanceRatio(const UnsignedRatio& ratio) noexcept { 120 mCreamMaskClearanceRatio = ratio; 121 } 122 void setCreamMaskClearanceBounds(const UnsignedLength& min, 123 const UnsignedLength& max); 124 125 // Setters: Restring setRestringPadRatio(const UnsignedRatio & ratio)126 void setRestringPadRatio(const UnsignedRatio& ratio) noexcept { 127 mRestringPadRatio = ratio; 128 } 129 void setRestringPadBounds(const UnsignedLength& min, 130 const UnsignedLength& max); setRestringViaRatio(const UnsignedRatio & ratio)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 140 /// @copydoc librepcb::SerializableObject::serialize() 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 155 ElementName mName; 156 QString mDescription; 157 158 // Stop Mask 159 UnsignedRatio mStopMaskClearanceRatio; 160 UnsignedLength mStopMaskClearanceMin; 161 UnsignedLength mStopMaskClearanceMax; 162 UnsignedLength mStopMaskMaxViaDrillDiameter; 163 164 // Cream Mask 165 UnsignedRatio mCreamMaskClearanceRatio; 166 UnsignedLength mCreamMaskClearanceMin; 167 UnsignedLength mCreamMaskClearanceMax; 168 169 // Restring 170 UnsignedRatio mRestringPadRatio; 171 UnsignedLength mRestringPadMin; 172 UnsignedLength mRestringPadMax; 173 UnsignedRatio mRestringViaRatio; 174 UnsignedLength mRestringViaMin; 175 UnsignedLength mRestringViaMax; 176 }; 177 178 /******************************************************************************* 179 * End of File 180 ******************************************************************************/ 181 182 } // namespace librepcb 183 184 #endif // LIBREPCB_BOARDDESIGNRULES_H 185