LibrePCB Developers Documentation
bi_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_PROJECT_BI_VIA_H
21 #define LIBREPCB_PROJECT_BI_VIA_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../graphicsitems/bgi_via.h"
27 #include "./bi_netline.h"
28 #include "bi_base.h"
29 
33 
34 #include <QtCore>
35 
36 /*******************************************************************************
37  * Namespace / Forward Declarations
38  ******************************************************************************/
39 namespace librepcb {
40 namespace project {
41 
42 /*******************************************************************************
43  * Class BI_Via
44  ******************************************************************************/
45 
49 class BI_Via final : public BI_Base,
50  public BI_NetLineAnchor,
51  public SerializableObject {
52  Q_OBJECT
53 
54 public:
55  // Constructors / Destructor
56  BI_Via() = delete;
57  BI_Via(const BI_Via& other) = delete;
58  BI_Via(BI_NetSegment& netsegment, const BI_Via& other);
59  BI_Via(BI_NetSegment& netsegment, const Via& via);
60  BI_Via(BI_NetSegment& netsegment, const SExpression& node);
61  ~BI_Via() noexcept;
62 
63  // Getters
64  BI_NetSegment& getNetSegment() const noexcept { return mNetSegment; }
65  NetSignal& getNetSignalOfNetSegment() const noexcept;
66  const Via& getVia() const noexcept { return mVia; }
67  const Uuid& getUuid() const noexcept { return mVia.getUuid(); }
68  Via::Shape getShape() const noexcept { return mVia.getShape(); }
69  const PositiveLength& getDrillDiameter() const noexcept {
70  return mVia.getDrillDiameter();
71  }
72  const PositiveLength& getSize() const noexcept { return mVia.getSize(); }
73  bool isUsed() const noexcept { return (mRegisteredNetLines.count() > 0); }
74  bool isOnLayer(const QString& layerName) const noexcept;
75  bool isSelectable() const noexcept override;
76  TraceAnchor toTraceAnchor() const noexcept override;
77 
78  // Setters
79  void setPosition(const Point& position) noexcept;
80  void setShape(Via::Shape shape) noexcept;
81  void setSize(const PositiveLength& size) noexcept;
82  void setDrillDiameter(const PositiveLength& diameter) noexcept;
83 
84  // General Methods
85  void addToBoard() override;
86  void removeFromBoard() override;
87 
89  void serialize(SExpression& root) const override;
90 
91  // Inherited from BI_Base
92  Type_t getType() const noexcept override { return BI_Base::Type_t::Via; }
93  const Point& getPosition() const noexcept override {
94  return mVia.getPosition();
95  }
96  bool getIsMirrored() const noexcept override { return false; }
97  QPainterPath getGrabAreaScenePx() const noexcept override;
98  void setSelected(bool selected) noexcept override;
99 
100  // Inherited from BI_NetLineAnchor
101  void registerNetLine(BI_NetLine& netline) override;
102  void unregisterNetLine(BI_NetLine& netline) override;
103  const QSet<BI_NetLine*>& getNetLines() const noexcept override {
104  return mRegisteredNetLines;
105  }
106 
107  // Operator Overloadings
108  BI_Via& operator=(const BI_Via& rhs) = delete;
109  bool operator==(const BI_Via& rhs) noexcept { return (this == &rhs); }
110  bool operator!=(const BI_Via& rhs) noexcept { return (this != &rhs); }
111 
112 private:
113  void init();
115 
116  // General
119  QScopedPointer<BGI_Via> mGraphicsItem;
120  QMetaObject::Connection mHighlightChangedConnection;
121 
122  // Registered Elements
123  QSet<BI_NetLine*> mRegisteredNetLines;
124 };
125 
126 /*******************************************************************************
127  * End of File
128  ******************************************************************************/
129 
130 } // namespace project
131 } // namespace librepcb
132 
133 #endif // LIBREPCB_PROJECT_BI_VIA_H
Shape getShape() const noexcept
Definition: via.h:80
void setSelected(bool selected) noexcept override
Definition: bi_via.cpp:184
Via mVia
Definition: bi_via.h:117
const Point & getPosition() const noexcept
Definition: via.h:79
The Via class represents a via of a board.
Definition: via.h:50
void init()
Definition: bi_via.cpp:58
~BI_Via() noexcept
Definition: bi_via.cpp:73
void boardOrNetAttributesChanged()
Definition: bi_via.cpp:193
Definition: airwiresbuilder.cpp:32
QSet< BI_NetLine * > mRegisteredNetLines
Definition: bi_via.h:123
The TraceAnchor class.
Definition: trace.h:47
void unregisterNetLine(BI_NetLine &netline) override
Definition: bi_via.cpp:159
const QSet< BI_NetLine * > & getNetLines() const noexcept override
Definition: bi_via.h:103
QScopedPointer< BGI_Via > mGraphicsItem
Definition: bi_via.h:119
void setShape(Via::Shape shape) noexcept
Definition: bi_via.cpp:107
Type_t
Definition: bi_base.h:57
librepcb::project::BI_Via
void setDrillDiameter(const PositiveLength &diameter) noexcept
Definition: bi_via.cpp:119
const PositiveLength & getDrillDiameter() const noexcept
Definition: via.h:82
void setPosition(const Point &position) noexcept
Definition: bi_via.cpp:97
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:43
const Point & getPosition() const noexcept override
Definition: bi_via.h:93
bool operator!=(const BI_Via &rhs) noexcept
Definition: bi_via.h:110
const PositiveLength & getSize() const noexcept
Definition: via.h:81
void registerNetLine(BI_NetLine &netline) override
Definition: bi_via.cpp:149
const Via & getVia() const noexcept
Definition: bi_via.h:66
The BI_NetSegment class.
Definition: bi_netsegment.h:57
BI_NetSegment & mNetSegment
Definition: bi_via.h:118
const Uuid & getUuid() const noexcept
Definition: bi_via.h:67
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
void addToBoard() override
Definition: bi_via.cpp:129
bool isSelectable() const noexcept override
Definition: bi_via.cpp:180
bool getIsMirrored() const noexcept override
Definition: bi_via.h:96
bool operator==(const BI_Via &rhs) noexcept
Definition: bi_via.h:109
Shape
Definition: via.h:66
const PositiveLength & getSize() const noexcept
Definition: bi_via.h:72
The Board Item Base (BI_Base) class.
Definition: bi_base.h:52
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: bi_via.cpp:168
bool isOnLayer(const QString &layerName) const noexcept
Definition: bi_via.cpp:85
BI_Via & operator=(const BI_Via &rhs)=delete
bool isUsed() const noexcept
Definition: bi_via.h:73
Definition: bi_netline.h:51
Via::Shape getShape() const noexcept
Definition: bi_via.h:68
void removeFromBoard() override
Definition: bi_via.cpp:140
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:794
NetSignal & getNetSignalOfNetSegment() const noexcept
Definition: bi_via.cpp:81
The NetSignal class.
Definition: netsignal.h:56
BI_NetSegment & getNetSegment() const noexcept
Definition: bi_via.h:64
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
QMetaObject::Connection mHighlightChangedConnection
Definition: bi_via.h:120
Type_t getType() const noexcept override
Definition: bi_via.h:92
const PositiveLength & getDrillDiameter() const noexcept
Definition: bi_via.h:69
const Uuid & getUuid() const noexcept
Definition: via.h:78
TraceAnchor toTraceAnchor() const noexcept override
Definition: bi_via.cpp:89
The BI_NetLine class.
Definition: bi_netline.h:76
The SExpression class.
Definition: sexpression.h:57
The BI_Via class.
Definition: bi_via.h:49
QPainterPath getGrabAreaScenePx() const noexcept override
Definition: bi_via.cpp:176
void setSize(const PositiveLength &size) noexcept
Definition: bi_via.cpp:113