LibrePCB Developers Documentation
boardpainter.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_BOARDPAINTER_H
21 #define LIBREPCB_CORE_BOARDPAINTER_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../../export/graphicsexport.h"
27 #include "../../library/pkg/footprintpad.h"
28 #include "../../types/alignment.h"
29 #include "../../types/length.h"
30 #include "../../utils/transform.h"
31 
32 #include <QtCore>
33 #include <QtGui>
34 
35 /*******************************************************************************
36  * Namespace / Forward Declarations
37  ******************************************************************************/
38 namespace librepcb {
39 
40 class Board;
41 class Circle;
42 class Path;
43 class Via;
44 
45 /*******************************************************************************
46  * Class BoardPainter
47  ******************************************************************************/
48 
54 class BoardPainter final : public GraphicsPagePainter {
55  struct Trace {
56  const Layer* layer;
60  };
61 
62  struct ViaData {
66  const Layer* startLayer;
67  const Layer* endLayer;
68  tl::optional<PositiveLength> stopMaskDiameterTop;
69  tl::optional<PositiveLength> stopMaskDiameterBottom;
70  };
71 
72  struct Pad {
74  QList<std::pair<const Layer*, PadGeometry>> layerGeometries;
75  QList<PadHole> holes;
76  };
77 
78  struct PolygonData {
79  const Layer* layer;
82  bool filled;
83  bool grabArea;
84  };
85 
86  struct HoleData {
89  tl::optional<Length> stopMaskOffset;
90  };
91 
92  struct StrokeTextData {
94  const Layer* layer;
95  QVector<Path> paths;
98  QString text;
100  };
101 
102  struct TextData {
107  QString text;
108  };
109 
110  struct Footprint {
112  QList<Pad> pads;
113  QList<PolygonData> polygons;
114  QList<Circle> circles;
115  QList<HoleData> holes;
116  };
117 
118  struct Plane {
119  const Layer* layer;
120  QVector<Path> fragments;
121  };
122 
123  struct ColorContent {
124  QList<QPainterPath> areas;
125  QList<QPainterPath> thtPadAreas;
126  QList<QPainterPath> viaAreas;
127  QList<Trace> traces;
128  QList<PolygonData> polygons;
129  QList<Circle> circles;
130  QList<HoleData> holes;
131  QList<HoleData> padHoles;
132  QList<TextData> texts;
133  };
134 
135 public:
136  // Constructors / Destructor
137  BoardPainter() = delete;
138  explicit BoardPainter(const Board& board);
139  BoardPainter(const BoardPainter& other) = delete;
140  ~BoardPainter() noexcept;
141 
142  // General Methods
143  void paint(QPainter& painter,
144  const GraphicsExportSettings& settings) const noexcept override;
145 
146  // Operator Overloadings
147  BoardPainter& operator=(const BoardPainter& rhs) = delete;
148 
149 private: // Methods
150  void initContentByColor() const noexcept;
151 
152 private: // Data
154  QSet<const Layer*> mCopperLayers;
156  QList<ViaData> mVias;
157  QList<Trace> mTraces;
158  QList<Plane> mPlanes;
161  QList<HoleData> mHoles;
162 
163  mutable QMutex mMutex;
164  mutable QHash<QString, ColorContent> mContentByColor;
165 };
166 
167 /*******************************************************************************
168  * End of File
169  ******************************************************************************/
170 
171 } // namespace librepcb
172 
173 #endif
const Layer * layer
Definition: boardpainter.h:56
Alignment align
Definition: boardpainter.h:99
QList< QPainterPath > thtPadAreas
Drawn on Theme::Color::sBoardPads.
Definition: boardpainter.h:125
QList< PolygonData > polygons
Definition: boardpainter.h:113
Point position
Definition: boardpainter.h:63
QList< Trace > mTraces
Definition: boardpainter.h:157
Transform transform
Definition: boardpainter.h:93
Alignment align
Definition: boardpainter.h:106
tl::optional< PositiveLength > stopMaskDiameterTop
Definition: boardpainter.h:68
QList< Circle > circles
Definition: boardpainter.h:114
The Alignment class.
Definition: alignment.h:115
bool grabArea
Definition: boardpainter.h:83
tl::optional< Length > stopMaskOffset
Definition: boardpainter.h:89
Point endPosition
Definition: boardpainter.h:58
Definition: boardpainter.h:123
Definition: occmodel.cpp:77
The Layer class provides all supported geometry layers.
Definition: layer.h:40
Helper class to perform coordinate transformation with various types.
Definition: transform.h:59
Point startPosition
Definition: boardpainter.h:57
QVector< Path > fragments
Definition: boardpainter.h:120
type_safe::constrained_type< Path, NonEmptyPathConstraint, NonEmptyPathVerifier > NonEmptyPath
Definition: path.h:221
Definition: boardpainter.h:86
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
NonEmptyPath path
Definition: boardpainter.h:88
void paint(QPainter &painter, const GraphicsExportSettings &settings) const noexcept override
Draw page content on a QPainter.
Definition: boardpainter.cpp:141
PositiveLength height
Definition: boardpainter.h:105
QList< QPainterPath > areas
Definition: boardpainter.h:124
QList< HoleData > holes
Definition: boardpainter.h:115
Definition: boardpainter.h:118
Definition: boardpainter.h:102
Angle rotation
Definition: boardpainter.h:104
Definition: boardpainter.h:110
UnsignedLength strokeWidth
Definition: boardpainter.h:97
QSet< const Layer * > mCopperLayers
Definition: boardpainter.h:154
const Layer * endLayer
Definition: boardpainter.h:67
Definition: boardpainter.h:55
PositiveLength diameter
Definition: boardpainter.h:87
QHash< QString, ColorContent > mContentByColor
Definition: boardpainter.h:164
QFont mMonospaceFont
Definition: boardpainter.h:153
const Layer * layer
Definition: boardpainter.h:79
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:79
QList< Trace > traces
Definition: boardpainter.h:127
QList< HoleData > mHoles
Definition: boardpainter.h:161
QList< Plane > mPlanes
Definition: boardpainter.h:158
The Board class represents a PCB of a project and is always part of a circuit.
Definition: board.h:73
QList< HoleData > padHoles
Definition: boardpainter.h:131
Path path
Definition: boardpainter.h:80
Settings for librepcb::GraphicsExport.
Definition: graphicsexportsettings.h:51
const Layer * startLayer
Definition: boardpainter.h:66
const Layer * layer
Definition: boardpainter.h:94
QVector< Path > paths
Definition: boardpainter.h:95
Transform transform
Definition: boardpainter.h:111
Paints a librepcb::Board to a QPainter.
Definition: boardpainter.h:54
QMutex mMutex
Definition: boardpainter.h:163
QList< PolygonData > mPolygons
Definition: boardpainter.h:159
Transform transform
Definition: boardpainter.h:73
Definition: boardpainter.h:92
QList< Pad > pads
Definition: boardpainter.h:112
PositiveLength drill
Definition: boardpainter.h:65
Point position
Definition: boardpainter.h:103
The Path class represents a list of vertices connected by straight lines or circular arc segments...
Definition: path.h:58
QList< PadHole > holes
Definition: boardpainter.h:75
Definition: boardpainter.h:62
PositiveLength width
Definition: boardpainter.h:59
PositiveLength size
Definition: boardpainter.h:64
QString text
Definition: boardpainter.h:107
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:812
UnsignedLength lineWidth
Definition: boardpainter.h:81
QList< std::pair< const Layer *, PadGeometry > > layerGeometries
Definition: boardpainter.h:74
QList< HoleData > holes
Definition: boardpainter.h:130
tl::optional< PositiveLength > stopMaskDiameterBottom
Definition: boardpainter.h:69
QList< ViaData > mVias
Definition: boardpainter.h:156
QList< StrokeTextData > mStrokeTexts
Definition: boardpainter.h:160
QList< QPainterPath > viaAreas
Drawn on Theme::Color::sBoardVias.
Definition: boardpainter.h:126
QList< Circle > circles
Definition: boardpainter.h:129
~BoardPainter() noexcept
Definition: boardpainter.cpp:134
QList< TextData > texts
Definition: boardpainter.h:132
void initContentByColor() const noexcept
Definition: boardpainter.cpp:234
Base class for printing a page for librepcb::GraphicsExport.
Definition: graphicsexport.h:57
Definition: boardpainter.h:72
QString text
Definition: boardpainter.h:98
QList< Footprint > mFootprints
Definition: boardpainter.h:155
const Layer * layer
Definition: boardpainter.h:119
QList< PolygonData > polygons
Definition: boardpainter.h:128
PositiveLength height
Definition: boardpainter.h:96
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:696
Definition: boardpainter.h:78
bool filled
Definition: boardpainter.h:82