LibrePCB Developers Documentation
Loading...
Searching...
No Matches
via.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_VIA_H
21#define LIBREPCB_CORE_VIA_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../exceptions.h"
27#include "../serialization/serializableobjectlist.h"
28#include "../types/length.h"
29#include "../types/maskconfig.h"
30#include "../types/point.h"
31#include "path.h"
32
33#include <QtCore>
34
35#include <optional>
36
37/*******************************************************************************
38 * Namespace / Forward Declarations
39 ******************************************************************************/
40namespace librepcb {
41
42class BoundedUnsignedRatio;
43class Layer;
44
45/*******************************************************************************
46 * Class Via
47 ******************************************************************************/
48
55class Via final {
56 Q_DECLARE_TR_FUNCTIONS(Via)
57
58public:
59 // Signals
69
70 // Constructors / Destructor
71 Via() = delete;
72 Via(const Via& other) noexcept;
73 Via(const Uuid& uuid, const Via& other) noexcept;
74 Via(const Uuid& uuid, const Layer& startLayer, const Layer& endLayer,
75 const Point& position, const std::optional<PositiveLength>& drillDiameter,
76 const std::optional<PositiveLength>& size,
77 const MaskConfig& exposureConfig);
78 explicit Via(const SExpression& node);
79 ~Via() noexcept;
80
81 // Getters
82 const Uuid& getUuid() const noexcept { return mUuid; }
83 const Layer& getStartLayer() const noexcept { return *mStartLayer; }
84 const Layer& getEndLayer() const noexcept { return *mEndLayer; }
85 const Point& getPosition() const noexcept { return mPosition; }
86 const std::optional<PositiveLength>& getDrillDiameter() const noexcept {
87 return mDrillDiameter;
88 }
89 const std::optional<PositiveLength>& getSize() const noexcept {
90 return mSize;
91 }
92 const MaskConfig& getExposureConfig() const noexcept {
93 return mExposureConfig;
94 }
95 bool isThrough() const noexcept;
96 bool isBlind() const noexcept;
97 bool isBuried() const noexcept;
98 bool isOnLayer(const Layer& layer) const noexcept;
99 bool isOnAnyLayer(const QSet<const Layer*>& layers) const noexcept;
100
101 // Setters
102 bool setUuid(const Uuid& uuid) noexcept;
103 bool setLayers(const Layer& from, const Layer& to);
104 bool setPosition(const Point& position) noexcept;
105 bool setDrillAndSize(const std::optional<PositiveLength>& drill,
106 const std::optional<PositiveLength>& size);
107 bool setExposureConfig(const MaskConfig& config) noexcept;
108
109 // General Methods
110
116 void serialize(SExpression& root) const;
117
118 // Operator Overloadings
119 bool operator==(const Via& rhs) const noexcept;
120 bool operator!=(const Via& rhs) const noexcept { return !(*this == rhs); }
121 Via& operator=(const Via& rhs) noexcept;
122
123 // Static Methods
125 const PositiveLength& drill, const BoundedUnsignedRatio& ratio) noexcept;
126 static Path getOutline(const PositiveLength& size,
127 const Length& expansion = Length(0)) noexcept;
128 static bool isOnLayer(const Layer& layer, const Layer& from,
129 const Layer& to) noexcept;
130 static bool isOnAnyLayer(const QSet<const Layer*>& layers, const Layer& from,
131 const Layer& to) noexcept;
132 static QPainterPath toQPainterPathPx(
133 const PositiveLength& drillDiameter, const PositiveLength& size,
134 const Length& expansion = Length(0)) noexcept;
135
136private: // Data
141 // Invariant: If no drill is set, the size must not be set either.
145};
146
147/*******************************************************************************
148 * Class ViaList
149 ******************************************************************************/
150
152 static constexpr const char* tagname = "via";
153};
155
156/*******************************************************************************
157 * End of File
158 ******************************************************************************/
159
160} // namespace librepcb
161
162#endif
The BoundedUnsignedRatio class represents a ratio limited to a range specified by min/max values.
Definition boundedunsignedratio.h:46
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 MaskConfig class defines how to add automatic stop mask or solder paste.
Definition maskconfig.h:45
The Path class represents a list of vertices connected by straight lines or circular arc segments.
Definition path.h:59
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition point.h:78
The SExpression class.
Definition sexpression.h:69
The Signal class is used to emit signals on non-QObject derived classes.
Definition signalslot.h:65
The Slot class is used to receive signals from non-QObject derived classes.
Definition signalslot.h:170
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition uuid.h:56
The Via class represents a via of a board.
Definition via.h:55
std::optional< PositiveLength > mDrillDiameter
Guaranteed to be <= mSize.
Definition via.h:142
bool setExposureConfig(const MaskConfig &config) noexcept
Definition via.cpp:221
static Path getOutline(const PositiveLength &size, const Length &expansion=Length(0)) noexcept
Definition via.cpp:280
bool setPosition(const Point &position) noexcept
Definition via.cpp:190
Via & operator=(const Via &rhs) noexcept
Definition via.cpp:262
~Via() noexcept
Definition via.cpp:125
const Layer * mEndLayer
Definition via.h:139
const std::optional< PositiveLength > & getDrillDiameter() const noexcept
Definition via.h:86
bool isBlind() const noexcept
Definition via.cpp:137
const MaskConfig & getExposureConfig() const noexcept
Definition via.h:92
Uuid mUuid
Definition via.h:137
Event
Definition via.h:60
bool isThrough() const noexcept
Definition via.cpp:132
static PositiveLength calcSizeFromRules(const PositiveLength &drill, const BoundedUnsignedRatio &ratio) noexcept
Definition via.cpp:275
const Layer & getEndLayer() const noexcept
Definition via.h:84
bool isBuried() const noexcept
Definition via.cpp:144
const Layer & getStartLayer() const noexcept
Definition via.h:83
bool setLayers(const Layer &from, const Layer &to)
Definition via.cpp:171
bool setDrillAndSize(const std::optional< PositiveLength > &drill, const std::optional< PositiveLength > &size)
Definition via.cpp:200
Signal< Via, Event > onEdited
Definition via.h:67
Via()=delete
const std::optional< PositiveLength > & getSize() const noexcept
Definition via.h:89
std::optional< PositiveLength > mSize
Guaranteed to be >= mDrillDiameter.
Definition via.h:143
bool isOnLayer(const Layer &layer) const noexcept
Definition via.cpp:149
const Layer * mStartLayer
Definition via.h:138
const Point & getPosition() const noexcept
Definition via.h:85
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition via.cpp:235
const Uuid & getUuid() const noexcept
Definition via.h:82
MaskConfig mExposureConfig
Definition via.h:144
bool setUuid(const Uuid &uuid) noexcept
Definition via.cpp:161
bool isOnAnyLayer(const QSet< const Layer * > &layers) const noexcept
Definition via.cpp:153
Point mPosition
Definition via.h:140
static QPainterPath toQPainterPathPx(const PositiveLength &drillDiameter, const PositiveLength &size, const Length &expansion=Length(0)) noexcept
Definition via.cpp:305
Slot< Via, Event > OnEditedSlot
Definition via.h:68
Definition occmodel.cpp:77
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition length.h:810
Definition uuid.h:186
Definition via.h:151