LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
boarddesignrulecheck.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_PROJECT_BOARDDESIGNRULECHECK_H
21 #define LIBREPCB_PROJECT_BOARDDESIGNRULECHECK_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
27 
28 #include <clipper/clipper.hpp>
29 
30 #include <QtCore>
31 
32 /*******************************************************************************
33  * Namespace / Forward Declarations
34  ******************************************************************************/
35 namespace librepcb {
36 
37 class GraphicsLayer;
38 
39 namespace project {
40 
41 class Board;
42 class BI_Device;
43 class NetSignal;
44 
45 /*******************************************************************************
46  * Class BoardDesignRuleCheck
47  ******************************************************************************/
48 
53 class BoardDesignRuleCheck final : public QObject {
54  Q_OBJECT
55 
56 public:
57  struct Options {
66 
68  : minCopperWidth(200000), // 200um
69  minCopperCopperClearance(200000), // 200um
70  minCopperBoardClearance(300000), // 300um
71  minCopperNpthClearance(200000), // 200um
72  minPthRestring(150000), // 150um
73  minNpthDrillDiameter(250000), // 250um
74  minPthDrillDiameter(250000), // 250um
75  courtyardOffset(0) // 0um
76  {}
77  };
78 
79  // Constructors / Destructor
80  explicit BoardDesignRuleCheck(Board& board, const Options& options,
81  QObject* parent = nullptr) noexcept;
82  ~BoardDesignRuleCheck() noexcept;
83 
84  // Getters
85  const QList<BoardDesignRuleCheckMessage>& getMessages() const noexcept {
86  return mMessages;
87  }
88 
89  // General Methods
90  void execute();
91 
92 signals:
93  void started();
94  void progressPercent(int percent);
95  void progressStatus(const QString& msg);
96  void progressMessage(const QString& msg);
97  void finished();
98 
99 private: // Methods
100  void rebuildPlanes(int progressStart, int progressEnd);
101  void checkForMissingConnections(int progressStart, int progressEnd);
102  void checkCopperBoardClearances(int progressStart, int progressEnd);
103  void checkCopperCopperClearances(int progressStart, int progressEnd);
104  void checkCourtyardClearances(int progressStart, int progressEnd);
105  void checkMinimumCopperWidth(int progressStart, int progressEnd);
106  void checkMinimumPthRestring(int progressStart, int progressEnd);
107  void checkMinimumPthDrillDiameter(int progressStart, int progressEnd);
108  void checkMinimumNpthDrillDiameter(int progressStart, int progressEnd);
109  const ClipperLib::Paths& getCopperPaths(const GraphicsLayer* layer,
110  const NetSignal* netsignal);
111  ClipperLib::Paths getDeviceCourtyardPaths(const BI_Device& device,
112  const GraphicsLayer* layer);
113  void addMessage(const BoardDesignRuleCheckMessage& msg) noexcept;
114  QString formatLength(const Length& length) const noexcept;
115 
119  static PositiveLength maxArcTolerance() noexcept {
120  return PositiveLength(5000);
121  }
122 
123 private: // Data
126  QList<BoardDesignRuleCheckMessage> mMessages;
127  QHash<const GraphicsLayer*, QHash<const NetSignal*, ClipperLib::Paths>>
129 };
130 
131 /*******************************************************************************
132  * End of File
133  ******************************************************************************/
134 
135 } // namespace project
136 } // namespace librepcb
137 
138 #endif // LIBREPCB_PROJECT_BOARDDESIGNRULECHECK_H
Options()
Definition: boarddesignrulecheck.h:67
The GraphicsLayer class represents a graphical layer used in schematics and boards.
Definition: graphicslayer.h:50
Definition: boarddesignrulecheck.h:57
ClipperLib::Paths getDeviceCourtyardPaths(const BI_Device &device, const GraphicsLayer *layer)
Definition: boarddesignrulecheck.cpp:517
void checkCourtyardClearances(int progressStart, int progressEnd)
Definition: boarddesignrulecheck.cpp:232
void execute()
Definition: boarddesignrulecheck.cpp:74
void checkMinimumPthDrillDiameter(int progressStart, int progressEnd)
Definition: boarddesignrulecheck.cpp:428
void checkForMissingConnections(int progressStart, int progressEnd)
Definition: boarddesignrulecheck.cpp:108
void checkCopperBoardClearances(int progressStart, int progressEnd)
Definition: boarddesignrulecheck.cpp:128
UnsignedLength minPthDrillDiameter
Definition: boarddesignrulecheck.h:64
void checkMinimumCopperWidth(int progressStart, int progressEnd)
Definition: boarddesignrulecheck.cpp:278
UnsignedLength minNpthDrillDiameter
Definition: boarddesignrulecheck.h:63
BoardDesignRuleCheck(Board &board, const Options &options, QObject *parent=nullptr) noexcept
Definition: boarddesignrulecheck.cpp:62
void checkMinimumPthRestring(int progressStart, int progressEnd)
Definition: boarddesignrulecheck.cpp:377
UnsignedLength minPthRestring
Definition: boarddesignrulecheck.h:62
QList< BoardDesignRuleCheckMessage > mMessages
Definition: boarddesignrulecheck.h:126
UnsignedLength minCopperWidth
Definition: boarddesignrulecheck.h:58
const ClipperLib::Paths & getCopperPaths(const GraphicsLayer *layer, const NetSignal *netsignal)
Definition: boarddesignrulecheck.cpp:507
const QList< BoardDesignRuleCheckMessage > & getMessages() const noexcept
Definition: boarddesignrulecheck.h:85
The BoardDesignRuleCheckMessage class represents a message produced by the design rule check (DRC) ...
Definition: boarddesignrulecheckmessage.h:44
static PositiveLength maxArcTolerance() noexcept
Definition: boarddesignrulecheck.h:119
UnsignedLength minCopperBoardClearance
Definition: boarddesignrulecheck.h:60
void checkMinimumNpthDrillDiameter(int progressStart, int progressEnd)
Definition: boarddesignrulecheck.cpp:473
UnsignedLength minCopperCopperClearance
Definition: boarddesignrulecheck.h:59
Board & mBoard
Definition: boarddesignrulecheck.h:124
The BI_Device class.
Definition: bi_device.h:62
QString formatLength(const Length &length) const noexcept
Definition: boarddesignrulecheck.cpp:560
UnsignedLength minCopperNpthClearance
Definition: boarddesignrulecheck.h:61
void progressStatus(const QString &msg)
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:780
The NetSignal class.
Definition: netsignal.h:56
QHash< const GraphicsLayer *, QHash< const NetSignal *, ClipperLib::Paths > > mCachedPaths
Definition: boarddesignrulecheck.h:128
void progressMessage(const QString &msg)
void rebuildPlanes(int progressStart, int progressEnd)
Definition: boarddesignrulecheck.cpp:101
The Board class represents a PCB of a project and is always part of a circuit.
Definition: board.h:83
Options mOptions
Definition: boarddesignrulecheck.h:125
The Length class is used to represent a length (for example 12.75 millimeters)
Definition: length.h:82
Length courtyardOffset
Definition: boarddesignrulecheck.h:65
void checkCopperCopperClearances(int progressStart, int progressEnd)
Definition: boarddesignrulecheck.cpp:185
The BoardDesignRuleCheck class checks a librepcb::project::Board for design rule violations.
Definition: boarddesignrulecheck.h:53
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:659
void addMessage(const BoardDesignRuleCheckMessage &msg) noexcept
Definition: boarddesignrulecheck.cpp:554