LibrePCB Developers Documentation
si_netlabel.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_NETLABEL_H
21#define LIBREPCB_CORE_SI_NETLABEL_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../../geometry/netlabel.h"
27#include "../../../utils/signalslot.h"
28#include "si_base.h"
29
30#include <QtCore>
31
32/*******************************************************************************
33 * Namespace / Forward Declarations
34 ******************************************************************************/
35namespace librepcb {
36
37class Circuit;
38class NetSignal;
39class SI_NetSegment;
40class Schematic;
41
42/*******************************************************************************
43 * Class SI_NetLabel
44 ******************************************************************************/
45
49class SI_NetLabel final : public SI_Base {
50 Q_OBJECT
51
52public:
53 // Signals
54 enum class Event {
55 PositionChanged,
56 RotationChanged,
57 MirroredChanged,
58 NetNameChanged,
59 AnchorPositionChanged,
60 };
63
64 // Constructors / Destructor
65 SI_NetLabel() = delete;
66 SI_NetLabel(const SI_NetLabel& other) = delete;
67 explicit SI_NetLabel(SI_NetSegment& segment, const NetLabel& label);
68 ~SI_NetLabel() noexcept;
69
70 // Getters
71 const Uuid& getUuid() const noexcept { return mNetLabel.getUuid(); }
72 const Point& getPosition() const noexcept { return mNetLabel.getPosition(); }
73 const Angle& getRotation() const noexcept { return mNetLabel.getRotation(); }
74 bool getMirrored() const noexcept { return mNetLabel.getMirrored(); }
75 const Point& getAnchorPosition() const noexcept { return mAnchorPosition; }
76 const NetLabel& getNetLabel() const noexcept { return mNetLabel; }
77 SI_NetSegment& getNetSegment() const noexcept { return mNetSegment; }
78 NetSignal& getNetSignalOfNetSegment() const noexcept;
79 Length getApproximateWidth() noexcept;
80
81 // Setters
82 void setPosition(const Point& position) noexcept;
83 void setRotation(const Angle& rotation) noexcept;
84 void setMirrored(const bool mirrored) noexcept;
85
86 // General Methods
87 void addToSchematic() override;
88 void removeFromSchematic() override;
89 void updateAnchor() noexcept;
90
91 // Operator Overloadings
92 SI_NetLabel& operator=(const SI_NetLabel& rhs) = delete;
93
94private:
95 // General
96 QMetaObject::Connection mNameChangedConnection;
97
98 // Attributes
101
102 // Cached Attributes
104};
105
106/*******************************************************************************
107 * End of File
108 ******************************************************************************/
109
110} // namespace librepcb
111
112#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
The Length class is used to represent a length (for example 12.75 millimeters)
Definition: length.h:83
The NetLabel class represents a net text label of a schematic.
Definition: netlabel.h:47
bool getMirrored() const noexcept
Definition: netlabel.h:74
const Angle & getRotation() const noexcept
Definition: netlabel.h:73
const Point & getPosition() const noexcept
Definition: netlabel.h:72
const Uuid & getUuid() const noexcept
Definition: netlabel.h:71
The NetSignal class.
Definition: netsignal.h:50
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition: point.h:79
The Schematic Item Base (SI_Base) class.
Definition: si_base.h:45
The SI_NetLabel class.
Definition: si_netlabel.h:49
bool getMirrored() const noexcept
Definition: si_netlabel.h:74
const Angle & getRotation() const noexcept
Definition: si_netlabel.h:73
SI_NetLabel(const SI_NetLabel &other)=delete
Signal< SI_NetLabel, Event > onEdited
Definition: si_netlabel.h:61
void setMirrored(const bool mirrored) noexcept
Definition: si_netlabel.cpp:84
NetSignal & getNetSignalOfNetSegment() const noexcept
Definition: si_netlabel.cpp:59
Point mAnchorPosition
Definition: si_netlabel.h:103
NetLabel mNetLabel
Definition: si_netlabel.h:100
Event
Definition: si_netlabel.h:54
QMetaObject::Connection mNameChangedConnection
Definition: si_netlabel.h:96
void removeFromSchematic() override
Definition: si_netlabel.cpp:104
SI_NetSegment & mNetSegment
Definition: si_netlabel.h:99
void addToSchematic() override
Definition: si_netlabel.cpp:94
const NetLabel & getNetLabel() const noexcept
Definition: si_netlabel.h:76
const Point & getPosition() const noexcept
Definition: si_netlabel.h:72
Slot< SI_NetLabel, Event > OnEditedSlot
Definition: si_netlabel.h:62
void setRotation(const Angle &rotation) noexcept
Definition: si_netlabel.cpp:78
const Uuid & getUuid() const noexcept
Definition: si_netlabel.h:71
const Point & getAnchorPosition() const noexcept
Definition: si_netlabel.h:75
void updateAnchor() noexcept
Definition: si_netlabel.cpp:112
~SI_NetLabel() noexcept
Definition: si_netlabel.cpp:52
SI_NetSegment & getNetSegment() const noexcept
Definition: si_netlabel.h:77
void setPosition(const Point &position) noexcept
Definition: si_netlabel.cpp:71
Length getApproximateWidth() noexcept
Definition: si_netlabel.cpp:63
The SI_NetSegment class.
Definition: si_netsegment.h:53
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
Definition: occmodel.cpp:77