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/*******************************************************************************
36 * Namespace / Forward Declarations
37 ******************************************************************************/
38namespace librepcb {
39
40class Layer;
41
42/*******************************************************************************
43 * Class Via
44 ******************************************************************************/
45
52class Via final {
53 Q_DECLARE_TR_FUNCTIONS(Via)
54
55public:
56 // Signals
67
68 // Constructors / Destructor
69 Via() = delete;
70 Via(const Via& other) noexcept;
71 Via(const Uuid& uuid, const Via& other) noexcept;
72 Via(const Uuid& uuid, const Layer& startLayer, const Layer& endLayer,
73 const Point& position, const PositiveLength& size,
74 const PositiveLength& drillDiameter,
75 const MaskConfig& exposureConfig) noexcept;
76 explicit Via(const SExpression& node);
77 ~Via() noexcept;
78
79 // Getters
80 const Uuid& getUuid() const noexcept { return mUuid; }
81 const Layer& getStartLayer() const noexcept { return *mStartLayer; }
82 const Layer& getEndLayer() const noexcept { return *mEndLayer; }
83 const Point& getPosition() const noexcept { return mPosition; }
84 const PositiveLength& getSize() const noexcept { return mSize; }
85 const PositiveLength& getDrillDiameter() const noexcept {
86 return mDrillDiameter;
87 }
88 const MaskConfig& getExposureConfig() const noexcept {
89 return mExposureConfig;
90 }
91 Path getOutline(const Length& expansion = Length(0)) const noexcept;
92 Path getSceneOutline(const Length& expansion = Length(0)) const noexcept;
93 bool isThrough() const noexcept;
94 bool isBlind() const noexcept;
95 bool isBuried() const noexcept;
96 bool isOnLayer(const Layer& layer) const noexcept;
97 bool isOnAnyLayer(const QSet<const Layer*>& layers) const noexcept;
98 QPainterPath toQPainterPathPx(
99 const Length& expansion = Length(0)) 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 setSize(const PositiveLength& size) noexcept;
106 bool setDrillDiameter(const PositiveLength& diameter) noexcept;
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
124 static Path getOutline(const PositiveLength& size,
125 const Length& expansion = Length(0)) noexcept;
126 static bool isOnLayer(const Layer& layer, const Layer& from,
127 const Layer& to) noexcept;
128 static bool isOnAnyLayer(const QSet<const Layer*>& layers, const Layer& from,
129 const Layer& to) noexcept;
130 static QPainterPath toQPainterPathPx(
131 const PositiveLength& size, const PositiveLength& drillDiameter,
132 const Length& expansion = Length(0)) noexcept;
133
134private: // Data
142};
143
144/*******************************************************************************
145 * Class ViaList
146 ******************************************************************************/
147
149 static constexpr const char* tagname = "via";
150};
152
153/*******************************************************************************
154 * End of File
155 ******************************************************************************/
156
157} // namespace librepcb
158
159#endif
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:57
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:52
PositiveLength mDrillDiameter
Definition via.h:140
bool setExposureConfig(const MaskConfig &config) noexcept
Definition via.cpp:189
QPainterPath toQPainterPathPx(const Length &expansion=Length(0)) const noexcept
Definition via.cpp:122
bool setPosition(const Point &position) noexcept
Definition via.cpp:159
bool setSize(const PositiveLength &size) noexcept
Definition via.cpp:169
Via & operator=(const Via &rhs) noexcept
Definition via.cpp:230
~Via() noexcept
Definition via.cpp:82
const Layer * mEndLayer
Definition via.h:137
bool isBlind() const noexcept
Definition via.cpp:102
const MaskConfig & getExposureConfig() const noexcept
Definition via.h:88
Uuid mUuid
Definition via.h:135
PositiveLength mSize
Definition via.h:139
Event
Definition via.h:57
const PositiveLength & getDrillDiameter() const noexcept
Definition via.h:85
bool isThrough() const noexcept
Definition via.cpp:97
const PositiveLength & getSize() const noexcept
Definition via.h:84
const Layer & getEndLayer() const noexcept
Definition via.h:82
bool isBuried() const noexcept
Definition via.cpp:109
const Layer & getStartLayer() const noexcept
Definition via.h:81
bool setLayers(const Layer &from, const Layer &to)
Definition via.cpp:140
Signal< Via, Event > onEdited
Definition via.h:65
Via()=delete
bool setDrillDiameter(const PositiveLength &diameter) noexcept
Definition via.cpp:179
bool isOnLayer(const Layer &layer) const noexcept
Definition via.cpp:114
const Layer * mStartLayer
Definition via.h:136
const Point & getPosition() const noexcept
Definition via.h:83
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition via.cpp:203
const Uuid & getUuid() const noexcept
Definition via.h:80
Path getOutline(const Length &expansion=Length(0)) const noexcept
Definition via.cpp:89
Path getSceneOutline(const Length &expansion=Length(0)) const noexcept
Definition via.cpp:93
MaskConfig mExposureConfig
Definition via.h:141
bool setUuid(const Uuid &uuid) noexcept
Definition via.cpp:130
bool isOnAnyLayer(const QSet< const Layer * > &layers) const noexcept
Definition via.cpp:118
Point mPosition
Definition via.h:138
Slot< Via, Event > OnEditedSlot
Definition via.h:66
Definition occmodel.cpp:76
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition length.h:810
Definition via.h:148