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