LibrePCB Developers Documentation
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  ******************************************************************************/
38 namespace librepcb {
39 
40 class Layer;
41 
42 /*******************************************************************************
43  * Class Via
44  ******************************************************************************/
45 
52 class Via final {
53  Q_DECLARE_TR_FUNCTIONS(Via)
54 
55 public:
56  // Signals
57  enum class Event {
64  };
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 QPainterPath toQPainterPathPx(
129  const PositiveLength& size, const PositiveLength& drillDiameter,
130  const Length& expansion = Length(0)) noexcept;
131 
132 private: // Data
135  const Layer* mEndLayer;
140 };
141 
142 /*******************************************************************************
143  * Class ViaList
144  ******************************************************************************/
145 
147  static constexpr const char* tagname = "via";
148 };
150 
151 /*******************************************************************************
152  * End of File
153  ******************************************************************************/
154 
155 } // namespace librepcb
156 
157 #endif
Path getOutline(const Length &expansion=Length(0)) const noexcept
Definition: via.cpp:89
QPainterPath toQPainterPathPx(const Length &expansion=Length(0)) const noexcept
Definition: via.cpp:127
const MaskConfig & getExposureConfig() const noexcept
Definition: via.h:88
const Point & getPosition() const noexcept
Definition: via.h:83
The Via class represents a via of a board.
Definition: via.h:52
The MaskConfig class defines how to add automatic stop mask or solder paste.
Definition: maskconfig.h:45
const Layer & getEndLayer() const noexcept
Definition: via.h:82
Definition: occmodel.cpp:77
Via & operator=(const Via &rhs) noexcept
Definition: via.cpp:235
The Layer class provides all supported geometry layers.
Definition: layer.h:40
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition: via.cpp:208
const PositiveLength & getDrillDiameter() const noexcept
Definition: via.h:85
bool setPosition(const Point &position) noexcept
Definition: via.cpp:164
Uuid mUuid
Definition: via.h:133
Point mPosition
Definition: via.h:136
MaskConfig mExposureConfig
Definition: via.h:139
bool isOnLayer(const Layer &layer) const noexcept
Definition: via.cpp:114
const PositiveLength & getSize() const noexcept
Definition: via.h:84
bool isThrough() const noexcept
Definition: via.cpp:97
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:79
bool isOnAnyLayer(const QSet< const Layer *> &layers) const noexcept
Definition: via.cpp:118
const Layer & getStartLayer() const noexcept
Definition: via.h:81
bool isBuried() const noexcept
Definition: via.cpp:109
const Layer * mStartLayer
Definition: via.h:134
bool isBlind() const noexcept
Definition: via.cpp:102
Signal< Via, Event > onEdited
Definition: via.h:65
bool operator!=(const Via &rhs) const noexcept
Definition: via.h:120
PositiveLength mDrillDiameter
Definition: via.h:138
Via()=delete
~Via() noexcept
Definition: via.cpp:82
The Path class represents a list of vertices connected by straight lines or circular arc segments...
Definition: path.h:58
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
bool setUuid(const Uuid &uuid) noexcept
Definition: via.cpp:135
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:812
Slot< Via, Event > OnEditedSlot
Definition: via.h:66
bool setExposureConfig(const MaskConfig &config) noexcept
Definition: via.cpp:194
bool setDrillDiameter(const PositiveLength &diameter) noexcept
Definition: via.cpp:184
Path getSceneOutline(const Length &expansion=Length(0)) const noexcept
Definition: via.cpp:93
Event
Definition: via.h:57
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
The Length class is used to represent a length (for example 12.75 millimeters)
Definition: length.h:83
PositiveLength mSize
Definition: via.h:137
Definition: via.h:146
bool setSize(const PositiveLength &size) noexcept
Definition: via.cpp:174
bool operator==(const Via &rhs) const noexcept
Definition: via.cpp:224
const Uuid & getUuid() const noexcept
Definition: via.h:80
The Slot class is used to receive signals from non-QObject derived classes.
Definition: signalslot.h:36
The SExpression class.
Definition: sexpression.h:69
const Layer * mEndLayer
Definition: via.h:135
bool setLayers(const Layer &from, const Layer &to)
Definition: via.cpp:145