LibrePCB Developers Documentation
scenedata3d.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_SCENEDATA3D_H
21#define LIBREPCB_CORE_SCENEDATA3D_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../geometry/circle.h"
27#include "../geometry/path.h"
28#include "../geometry/polygon.h"
29#include "../utils/transform.h"
30
31#include <optional/tl/optional.hpp>
32
33#include <QtCore>
34
35#include <memory>
36
37/*******************************************************************************
38 * Namespace / Forward Declarations
39 ******************************************************************************/
40namespace librepcb {
41
42class FileSystem;
43class Layer;
44class PcbColor;
45
46/*******************************************************************************
47 * Class SceneData3D
48 ******************************************************************************/
49
53class SceneData3D final {
54 Q_DECLARE_TR_FUNCTIONS(SceneData3D)
55
56public:
57 // Types
58 struct DeviceData {
61 QString stepFile;
64 QString name;
65 };
66
67 struct PolygonData {
70 };
71
72 struct CircleData {
75 };
76
77 struct StrokeData {
78 const Layer* layer;
79 QVector<Path> paths;
82 };
83
84 struct ViaData {
90 tl::optional<PositiveLength> stopMaskDiameterTop;
91 tl::optional<PositiveLength> stopMaskDiameterBottom;
92 };
93
94 struct HoleData {
97 bool plated;
98 bool via;
101 };
102
103 struct AreaData {
104 const Layer* layer;
107 };
108
109 // Constructors / Destructor
110 explicit SceneData3D(std::shared_ptr<FileSystem> fs = nullptr,
111 bool autoBoardOutline = false) noexcept;
112 SceneData3D(const SceneData3D& other) = delete;
113 ~SceneData3D() noexcept;
114
115 // Getters
116 const std::shared_ptr<FileSystem>& getFileSystem() const noexcept {
117 return mFileSystem;
118 }
119 const PositiveLength& getThickness() const noexcept { return mThickness; }
120 const PcbColor* getSolderResist() const noexcept { return mSolderResist; }
121 const PcbColor* getSilkscreen() const noexcept { return mSilkscreen; }
122 const QSet<const Layer*>& getSilkscreenLayersTop() const noexcept {
124 }
125 const QSet<const Layer*>& getSilkscreenLayersBot() const noexcept {
127 }
128 bool getAutoBoardOutline() const noexcept { return mAutoBoardOutline; }
129 qreal getStepAlphaValue() const noexcept { return mStepAlphaValue; }
130 const QString& getProjectName() const noexcept { return mProjectName; }
131 const QList<DeviceData>& getDevices() const noexcept { return mDevices; }
132 const QList<PolygonData>& getPolygons() const noexcept { return mPolygons; }
133 const QList<CircleData>& getCircles() const noexcept { return mCircles; }
134 const QList<StrokeData>& getStrokes() const noexcept { return mStrokes; }
135 const QList<ViaData>& getVias() const noexcept { return mVias; }
136 const QList<HoleData>& getHoles() const noexcept { return mHoles; }
137 const QList<AreaData>& getAreas() const noexcept { return mAreas; }
138
139 // Setters
140 void setThickness(const PositiveLength& value) noexcept {
141 mThickness = value;
142 }
143 void setSolderResist(const PcbColor* value) noexcept {
144 mSolderResist = value;
145 }
146 void setSilkscreen(const PcbColor* value) noexcept { mSilkscreen = value; }
147 void setSilkscreenLayersTop(const QSet<const Layer*>& value) noexcept {
148 mSilkscreenLayersTop = value;
149 }
150 void setSilkscreenLayersBot(const QSet<const Layer*>& value) noexcept {
151 mSilkscreenLayersBot = value;
152 }
153 void setAutoBoardOutline(bool value) noexcept { mAutoBoardOutline = value; }
154 void setStepAlphaValue(qreal value) noexcept { mStepAlphaValue = value; }
155 void setProjectName(const QString& value) noexcept { mProjectName = value; }
156
157 // General Methods
158 void addDevice(const Uuid& uuid, const Transform& transform,
159 const QString& stepFile, const Point3D& stepPosition,
160 const Angle3D& stepRotation, const QString& name) noexcept;
161 void addPolygon(const Polygon& polygon, const Transform& transform) noexcept;
162 void addCircle(const Circle& circle, const Transform& transform) noexcept;
163 void addStroke(const Layer& layer, const QVector<Path>& paths,
164 const Length& width, const Transform& transform) noexcept;
165 void addVia(
166 const Point& position, const PositiveLength& size,
167 const PositiveLength& drillDiameter, const Layer& startLayer,
168 const Layer& endLayer,
169 const tl::optional<PositiveLength>& stopMaskDiameterTop,
170 const tl::optional<PositiveLength>& stopMaskDiameterBottom) noexcept;
171 void addHole(const NonEmptyPath& path, const PositiveLength& diameter,
172 bool plated, bool via, const Transform& transform) noexcept;
173 void addArea(const Layer& layer, const Path& outline,
174 const Transform& transform) noexcept;
175 void preprocess(bool center, bool sortDevices = false,
176 Length* width = nullptr, Length* height = nullptr);
177
178 // Operator Overloadings
179 SceneData3D& operator=(const SceneData3D& rhs) = delete;
180
181private: // Data
182 std::shared_ptr<FileSystem> mFileSystem;
186 QSet<const Layer*> mSilkscreenLayersTop;
187 QSet<const Layer*> mSilkscreenLayersBot;
191
192 QList<DeviceData> mDevices;
193 QList<PolygonData> mPolygons;
194 QList<CircleData> mCircles;
195 QList<StrokeData> mStrokes;
196 QList<ViaData> mVias;
197 QList<HoleData> mHoles;
198 QList<AreaData> mAreas;
199};
200
201/*******************************************************************************
202 * End of File
203 ******************************************************************************/
204
205} // namespace librepcb
206
207#endif
The Circle class.
Definition: circle.h:46
Base class / interface for all file system implementations.
Definition: filesystem.h:45
The Layer class provides all supported geometry layers.
Definition: layer.h:42
The Length class is used to represent a length (for example 12.75 millimeters)
Definition: length.h:83
The Path class represents a list of vertices connected by straight lines or circular arc segments.
Definition: path.h:58
Predefined colors relevant for PCB fabrication.
Definition: pcbcolor.h:41
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition: point.h:79
The Polygon class.
Definition: polygon.h:45
3D scene data representing a board with package models
Definition: scenedata3d.h:53
QList< HoleData > mHoles
Cleared by preprocess().
Definition: scenedata3d.h:197
const QSet< const Layer * > & getSilkscreenLayersBot() const noexcept
Definition: scenedata3d.h:125
std::shared_ptr< FileSystem > mFileSystem
Definition: scenedata3d.h:182
const QList< CircleData > & getCircles() const noexcept
Definition: scenedata3d.h:133
const QList< AreaData > & getAreas() const noexcept
Definition: scenedata3d.h:137
bool mAutoBoardOutline
Definition: scenedata3d.h:188
const PcbColor * getSilkscreen() const noexcept
Definition: scenedata3d.h:121
void addPolygon(const Polygon &polygon, const Transform &transform) noexcept
Definition: scenedata3d.cpp:70
QSet< const Layer * > mSilkscreenLayersBot
Definition: scenedata3d.h:187
void setStepAlphaValue(qreal value) noexcept
Definition: scenedata3d.h:154
qreal getStepAlphaValue() const noexcept
Definition: scenedata3d.h:129
void setThickness(const PositiveLength &value) noexcept
Definition: scenedata3d.h:140
void setSolderResist(const PcbColor *value) noexcept
Definition: scenedata3d.h:143
void setProjectName(const QString &value) noexcept
Definition: scenedata3d.h:155
const QList< PolygonData > & getPolygons() const noexcept
Definition: scenedata3d.h:132
void setAutoBoardOutline(bool value) noexcept
Definition: scenedata3d.h:153
void addDevice(const Uuid &uuid, const Transform &transform, const QString &stepFile, const Point3D &stepPosition, const Angle3D &stepRotation, const QString &name) noexcept
Definition: scenedata3d.cpp:61
void setSilkscreen(const PcbColor *value) noexcept
Definition: scenedata3d.h:146
QList< DeviceData > mDevices
Definition: scenedata3d.h:192
bool getAutoBoardOutline() const noexcept
Definition: scenedata3d.h:128
const QString & getProjectName() const noexcept
Definition: scenedata3d.h:130
void addStroke(const Layer &layer, const QVector< Path > &paths, const Length &width, const Transform &transform) noexcept
Definition: scenedata3d.cpp:80
void addArea(const Layer &layer, const Path &outline, const Transform &transform) noexcept
Definition: scenedata3d.cpp:102
void preprocess(bool center, bool sortDevices=false, Length *width=nullptr, Length *height=nullptr)
Definition: scenedata3d.cpp:107
QList< AreaData > mAreas
Definition: scenedata3d.h:198
QList< StrokeData > mStrokes
Cleared by preprocess().
Definition: scenedata3d.h:195
PositiveLength mThickness
Definition: scenedata3d.h:183
const std::shared_ptr< FileSystem > & getFileSystem() const noexcept
Definition: scenedata3d.h:116
void setSilkscreenLayersBot(const QSet< const Layer * > &value) noexcept
Definition: scenedata3d.h:150
QList< PolygonData > mPolygons
Cleared by preprocess().
Definition: scenedata3d.h:193
qreal mStepAlphaValue
Definition: scenedata3d.h:189
QList< CircleData > mCircles
Cleared by preprocess().
Definition: scenedata3d.h:194
void addHole(const NonEmptyPath &path, const PositiveLength &diameter, bool plated, bool via, const Transform &transform) noexcept
Definition: scenedata3d.cpp:96
const PositiveLength & getThickness() const noexcept
Definition: scenedata3d.h:119
SceneData3D & operator=(const SceneData3D &rhs)=delete
const QList< ViaData > & getVias() const noexcept
Definition: scenedata3d.h:135
void setSilkscreenLayersTop(const QSet< const Layer * > &value) noexcept
Definition: scenedata3d.h:147
const QSet< const Layer * > & getSilkscreenLayersTop() const noexcept
Definition: scenedata3d.h:122
const QList< StrokeData > & getStrokes() const noexcept
Definition: scenedata3d.h:134
QList< ViaData > mVias
Definition: scenedata3d.h:196
const QList< HoleData > & getHoles() const noexcept
Definition: scenedata3d.h:136
void addCircle(const Circle &circle, const Transform &transform) noexcept
Definition: scenedata3d.cpp:75
const PcbColor * mSolderResist
Definition: scenedata3d.h:184
const QList< DeviceData > & getDevices() const noexcept
Definition: scenedata3d.h:131
const PcbColor * mSilkscreen
Definition: scenedata3d.h:185
const PcbColor * getSolderResist() const noexcept
Definition: scenedata3d.h:120
SceneData3D(std::shared_ptr< FileSystem > fs=nullptr, bool autoBoardOutline=false) noexcept
Definition: scenedata3d.cpp:41
void addVia(const Point &position, const PositiveLength &size, const PositiveLength &drillDiameter, const Layer &startLayer, const Layer &endLayer, const tl::optional< PositiveLength > &stopMaskDiameterTop, const tl::optional< PositiveLength > &stopMaskDiameterBottom) noexcept
Definition: scenedata3d.cpp:86
QSet< const Layer * > mSilkscreenLayersTop
Definition: scenedata3d.h:186
QString mProjectName
Definition: scenedata3d.h:190
Helper class to perform coordinate transformation with various types.
Definition: transform.h:59
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
Definition: occmodel.cpp:77
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:812
type_safe::constrained_type< Path, NonEmptyPathConstraint, NonEmptyPathVerifier > NonEmptyPath
Definition: path.h:222
std::tuple< Length, Length, Length > Point3D
Definition: length.h:989
std::tuple< Angle, Angle, Angle > Angle3D
Definition: angle.h:461
Definition: scenedata3d.h:103
Transform transform
Reset by preprocess().
Definition: scenedata3d.h:106
Path outline
Definition: scenedata3d.h:105
const Layer * layer
Definition: scenedata3d.h:104
Definition: scenedata3d.h:72
Transform transform
Definition: scenedata3d.h:74
Circle circle
Definition: scenedata3d.h:73
Definition: scenedata3d.h:58
Transform transform
Definition: scenedata3d.h:60
Uuid uuid
Definition: scenedata3d.h:59
Angle3D stepRotation
Definition: scenedata3d.h:63
QString name
Definition: scenedata3d.h:64
QString stepFile
Definition: scenedata3d.h:61
Point3D stepPosition
Definition: scenedata3d.h:62
Definition: scenedata3d.h:94
const Layer * copperLayer
nullptr for through-hole.
Definition: scenedata3d.h:99
bool plated
Definition: scenedata3d.h:97
bool via
Definition: scenedata3d.h:98
Transform transform
Reset by preprocess().
Definition: scenedata3d.h:100
PositiveLength diameter
Definition: scenedata3d.h:96
NonEmptyPath path
Definition: scenedata3d.h:95
Definition: scenedata3d.h:67
Transform transform
Definition: scenedata3d.h:69
Polygon polygon
Definition: scenedata3d.h:68
Definition: scenedata3d.h:77
Transform transform
Definition: scenedata3d.h:81
QVector< Path > paths
Definition: scenedata3d.h:79
Length width
Definition: scenedata3d.h:80
const Layer * layer
Definition: scenedata3d.h:78
Definition: scenedata3d.h:84
PositiveLength size
Definition: scenedata3d.h:86
tl::optional< PositiveLength > stopMaskDiameterTop
Definition: scenedata3d.h:90
const Layer * endLayer
Definition: scenedata3d.h:89
const Layer * startLayer
Definition: scenedata3d.h:88
tl::optional< PositiveLength > stopMaskDiameterBottom
Definition: scenedata3d.h:91
Point position
Definition: scenedata3d.h:85
PositiveLength drillDiameter
Definition: scenedata3d.h:87