LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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_PROJECT_SI_NETLABEL_H
21 #define LIBREPCB_PROJECT_SI_NETLABEL_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../graphicsitems/sgi_netlabel.h"
27 #include "si_base.h"
28 
30 
31 #include <QtCore>
32 
33 /*******************************************************************************
34  * Namespace / Forward Declarations
35  ******************************************************************************/
36 namespace librepcb {
37 namespace project {
38 
39 class Circuit;
40 class Schematic;
41 class NetSignal;
42 class SI_NetSegment;
43 
44 /*******************************************************************************
45  * Class SI_NetLabel
46  ******************************************************************************/
47 
51 class SI_NetLabel final : public SI_Base, public SerializableObject {
52  Q_OBJECT
53 
54 public:
55  // Constructors / Destructor
56  SI_NetLabel() = delete;
57  SI_NetLabel(const SI_NetLabel& other) = delete;
58  explicit SI_NetLabel(SI_NetSegment& segment, const SExpression& node);
59  explicit SI_NetLabel(SI_NetSegment& segment, const Point& position,
60  const Angle& rotation);
61  ~SI_NetLabel() noexcept;
62 
63  // Getters
64  const Uuid& getUuid() const noexcept { return mUuid; }
65  const Angle& getRotation() const noexcept { return mRotation; }
66  SI_NetSegment& getNetSegment() const noexcept { return mNetSegment; }
67  NetSignal& getNetSignalOfNetSegment() const noexcept;
68 
69  // Setters
70  void setPosition(const Point& position) noexcept;
71  void setRotation(const Angle& rotation) noexcept;
72 
73  // General Methods
74  void updateAnchor() noexcept;
75  void addToSchematic() override;
76  void removeFromSchematic() override;
77 
79  void serialize(SExpression& root) const override;
80 
81  // Inherited from SI_Base
82  Type_t getType() const noexcept override { return SI_Base::Type_t::NetLabel; }
83  const Point& getPosition() const noexcept override { return mPosition; }
84  QPainterPath getGrabAreaScenePx() const noexcept override;
85  void setSelected(bool selected) noexcept override;
86 
87  // Operator Overloadings
88  SI_NetLabel& operator=(const SI_NetLabel& rhs) = delete;
89 
90 private:
91  void init();
92 
93  // General
94  QScopedPointer<SGI_NetLabel> mGraphicsItem;
95  QMetaObject::Connection mNameChangedConnection;
96  QMetaObject::Connection mHighlightChangedConnection;
97 
98  // Attributes
103 };
104 
105 /*******************************************************************************
106  * End of File
107  ******************************************************************************/
108 
109 } // namespace project
110 } // namespace librepcb
111 
112 #endif // LIBREPCB_PROJECT_SI_NETLABEL_H
QMetaObject::Connection mNameChangedConnection
Definition: si_netlabel.h:95
Type_t getType() const noexceptoverride
Definition: si_netlabel.h:82
SI_NetSegment & mNetSegment
Definition: si_netlabel.h:99
QScopedPointer< SGI_NetLabel > mGraphicsItem
Definition: si_netlabel.h:94
NetSignal & getNetSignalOfNetSegment() const noexcept
Definition: si_netlabel.cpp:93
void addToSchematic() override
Definition: si_netlabel.cpp:126
The SGI_NetLabel class.
Definition: sgi_netlabel.h:50
const Angle & getRotation() const noexcept
Definition: si_netlabel.h:65
void setRotation(const Angle &rotation) noexcept
Definition: si_netlabel.cpp:109
The Schematic Item Base (SI_Base) class.
Definition: si_base.h:52
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:81
const Point & getPosition() const noexceptoverride
Definition: si_netlabel.h:83
void updateAnchor() noexcept
Definition: si_netlabel.cpp:122
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:46
librepcb::project::SI_NetLabel
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:81
QMetaObject::Connection mHighlightChangedConnection
Definition: si_netlabel.h:96
void removeFromSchematic() override
Definition: si_netlabel.cpp:141
The SI_NetSegment class.
Definition: si_netsegment.h:55
Angle mRotation
Definition: si_netlabel.h:102
Type_t
Definition: si_base.h:57
SI_NetSegment & getNetSegment() const noexcept
Definition: si_netlabel.h:66
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: si_netlabel.cpp:150
The NetSignal class.
Definition: netsignal.h:56
Uuid mUuid
Definition: si_netlabel.h:100
~SI_NetLabel() noexcept
Definition: si_netlabel.cpp:85
The SI_NetLabel class.
Definition: si_netlabel.h:51
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
void setPosition(const Point &position) noexcept
Definition: si_netlabel.cpp:101
Point mPosition
Definition: si_netlabel.h:101
void setSelected(bool selected) noexceptoverride
Definition: si_netlabel.cpp:164
The SExpression class.
Definition: sexpression.h:60
const Uuid & getUuid() const noexcept
Definition: si_netlabel.h:64
QPainterPath getGrabAreaScenePx() const noexceptoverride
Definition: si_netlabel.cpp:160
void init()
Definition: si_netlabel.cpp:78