LibrePCB Developers Documentation
Loading...
Searching...
No Matches
si_bussegment.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_SI_BUSSEGMENT_H
21#define LIBREPCB_CORE_SI_BUSSEGMENT_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../../types/point.h"
27#include "../../../types/uuid.h"
28#include "si_base.h"
29
30#include <QtCore>
31
32/*******************************************************************************
33 * Namespace / Forward Declarations
34 ******************************************************************************/
35namespace librepcb {
36
37class Bus;
38class SI_BusJunction;
39class SI_BusLabel;
40class SI_BusLine;
41class SI_NetSegment;
42
43/*******************************************************************************
44 * Class SI_BusSegment
45 ******************************************************************************/
46
52class SI_BusSegment final : public SI_Base {
53 Q_OBJECT
54
55public:
56 // Constructors / Destructor
57 SI_BusSegment() = delete;
58 SI_BusSegment(const SI_BusSegment& other) = delete;
59 SI_BusSegment(Schematic& schematic, const Uuid& uuid, Bus& bus);
60 ~SI_BusSegment() noexcept;
61
62 // Getters
63 const Uuid& getUuid() const noexcept { return mUuid; }
64 Bus& getBus() const noexcept { return *mBus; }
65 bool isUsed() const noexcept;
66 Point calcNearestPoint(const Point& p) const noexcept;
67 QSet<SI_NetSegment*> getAttachedNetSegments() const noexcept;
68
69 // Setters
70 void setBus(Bus& bus);
71
72 // Element Getters
73 const QMap<Uuid, SI_BusJunction*>& getJunctions() const noexcept {
74 return mJunctions;
75 }
76 const QMap<Uuid, SI_BusLine*>& getLines() const noexcept { return mLines; }
77
78 // Junction/Line Methods
79 void addJunctionsAndLines(const QList<SI_BusJunction*>& junctions,
80 const QList<SI_BusLine*>& lines);
81 void removeJunctionsAndLines(const QList<SI_BusJunction*>& junctions,
82 const QList<SI_BusLine*>& lines);
83
84 // Label Methods
85 const QMap<Uuid, SI_BusLabel*>& getLabels() const noexcept { return mLabels; }
86 void addLabel(SI_BusLabel& label);
87 void removeLabel(SI_BusLabel& label);
88 void updateAllLabelAnchors() noexcept;
89
90 // General Methods
91 void addToSchematic() override;
92 void removeFromSchematic() override;
93
99 void serialize(SExpression& root) const;
100
101 // Operator Overloadings
102 SI_BusSegment& operator=(const SI_BusSegment& rhs) = delete;
103 bool operator==(const SI_BusSegment& rhs) noexcept { return (this == &rhs); }
104 bool operator!=(const SI_BusSegment& rhs) noexcept { return (this != &rhs); }
105
106signals:
107 void junctionsAndLinesAdded(const QList<SI_BusJunction*>& junctions,
108 const QList<SI_BusLine*>& lines);
109 void junctionsAndLinesRemoved(const QList<SI_BusJunction*>& junctions,
110 const QList<SI_BusLine*>& lines);
113
114private:
115 bool checkAttributesValidity() const noexcept;
116 bool areAllJunctionsConnectedTogether() const noexcept;
118 QSet<const SI_BusJunction*>& points,
119 QSet<const SI_BusLine*>& lines) const noexcept;
120
121 // Attributes
124
125 // Items
129};
130
131/*******************************************************************************
132 * End of File
133 ******************************************************************************/
134
135} // namespace librepcb
136
137#endif
The Bus class.
Definition bus.h:50
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 Schematic Item Base (SI_Base) class.
Definition si_base.h:45
The SI_BusJunction class.
Definition si_busjunction.h:45
The SI_BusLabel class.
Definition si_buslabel.h:48
The SI_BusLine class.
Definition si_busline.h:47
The SI_BusSegment class.
Definition si_bussegment.h:52
void updateAllLabelAnchors() noexcept
Definition si_bussegment.cpp:255
bool operator!=(const SI_BusSegment &rhs) noexcept
Definition si_bussegment.h:104
void labelAdded(SI_BusLabel &label)
Bus * mBus
Definition si_bussegment.h:123
const QMap< Uuid, SI_BusLabel * > & getLabels() const noexcept
Definition si_bussegment.h:85
const QMap< Uuid, SI_BusJunction * > & getJunctions() const noexcept
Definition si_bussegment.h:73
void addLabel(SI_BusLabel &label)
Definition si_bussegment.cpp:227
QMap< Uuid, SI_BusLabel * > mLabels
Definition si_bussegment.h:128
~SI_BusSegment() noexcept
Definition si_bussegment.cpp:50
SI_BusSegment(const SI_BusSegment &other)=delete
Uuid mUuid
Definition si_bussegment.h:122
bool isUsed() const noexcept
Definition si_bussegment.cpp:64
QMap< Uuid, SI_BusLine * > mLines
Definition si_bussegment.h:127
bool areAllJunctionsConnectedTogether() const noexcept
Definition si_bussegment.cpp:349
void removeLabel(SI_BusLabel &label)
Definition si_bussegment.cpp:244
void labelRemoved(SI_BusLabel &label)
QMap< Uuid, SI_BusJunction * > mJunctions
Definition si_bussegment.h:126
bool checkAttributesValidity() const noexcept
Definition si_bussegment.cpp:343
void removeJunctionsAndLines(const QList< SI_BusJunction * > &junctions, const QList< SI_BusLine * > &lines)
Definition si_bussegment.cpp:179
void removeFromSchematic() override
Definition si_bussegment.cpp:290
void junctionsAndLinesRemoved(const QList< SI_BusJunction * > &junctions, const QList< SI_BusLine * > &lines)
void addToSchematic() override
Definition si_bussegment.cpp:265
void addJunctionsAndLines(const QList< SI_BusJunction * > &junctions, const QList< SI_BusLine * > &lines)
Definition si_bussegment.cpp:119
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition si_bussegment.cpp:315
Bus & getBus() const noexcept
Definition si_bussegment.h:64
const Uuid & getUuid() const noexcept
Definition si_bussegment.h:63
void setBus(Bus &bus)
Definition si_bussegment.cpp:99
Point calcNearestPoint(const Point &p) const noexcept
Definition si_bussegment.cpp:69
void findAllConnectedJunctions(const SI_BusJunction &np, QSet< const SI_BusJunction * > &points, QSet< const SI_BusLine * > &lines) const noexcept
Definition si_bussegment.cpp:366
const QMap< Uuid, SI_BusLine * > & getLines() const noexcept
Definition si_bussegment.h:76
QSet< SI_NetSegment * > getAttachedNetSegments() const noexcept
Definition si_bussegment.cpp:85
void junctionsAndLinesAdded(const QList< SI_BusJunction * > &junctions, const QList< SI_BusLine * > &lines)
The SI_NetSegment class.
Definition si_netsegment.h:55
The Schematic class represents one schematic page of a project and is always part of a circuit.
Definition schematic.h:81
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition uuid.h:56
Definition occmodel.cpp:77