LibrePCB Developers Documentation
Loading...
Searching...
No Matches
si_symbol.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_SYMBOL_H
21#define LIBREPCB_CORE_SI_SYMBOL_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../../geometry/text.h"
27#include "../../../types/angle.h"
28#include "../../../types/point.h"
29#include "../../../types/uuid.h"
30#include "../../../utils/signalslot.h"
31#include "si_base.h"
32
33#include <QtCore>
34
35/*******************************************************************************
36 * Namespace / Forward Declarations
37 ******************************************************************************/
38namespace librepcb {
39
40class ComponentInstance;
41class ComponentSymbolVariantItem;
42class SI_SymbolPin;
43class SI_Text;
44class Schematic;
45class Symbol;
46
47/*******************************************************************************
48 * Class SI_Symbol
49 ******************************************************************************/
50
54class SI_Symbol final : public SI_Base {
55 Q_OBJECT
56
57public:
58 // Signals
59 enum class Event {
63 };
66
67 // Constructors / Destructor
68 SI_Symbol() = delete;
69 SI_Symbol(const SI_Symbol& other) = delete;
70 SI_Symbol(Schematic& schematic, const Uuid& uuid,
71 ComponentInstance& cmpInstance, const Uuid& symbolItem,
72 const Point& position, const Angle& rotation, bool mirrored,
73 bool loadInitialTexts);
74 ~SI_Symbol() noexcept;
75
76 // Getters
77 const Uuid& getUuid() const noexcept { return mUuid; }
78 const Point& getPosition() const noexcept { return mPosition; }
79 const Angle& getRotation() const noexcept { return mRotation; }
80 bool getMirrored() const noexcept { return mMirrored; }
81 QString getName() const noexcept;
82 SI_SymbolPin* getPin(const Uuid& pinUuid) const noexcept {
83 return mPins.value(pinUuid);
84 }
85 const QHash<Uuid, SI_SymbolPin*>& getPins() const noexcept { return mPins; }
87 return mComponentInstance;
88 }
89 const Symbol& getLibSymbol() const noexcept { return *mSymbol; }
91 return *mSymbVarItem;
92 }
93
94 // Setters
95 void setPosition(const Point& newPos) noexcept;
96 void setRotation(const Angle& newRotation) noexcept;
97 void setMirrored(bool newMirrored) noexcept;
98
99 // Text Methods
100 TextList getDefaultTexts() const noexcept;
101 const QMap<Uuid, SI_Text*>& getTexts() const noexcept { return mTexts; }
102 void addText(SI_Text& text);
103 void removeText(SI_Text& text);
104
105 // General Methods
106 void addToSchematic() override;
107 void removeFromSchematic() override;
108
114 void serialize(SExpression& root) const;
115
116 // Operator Overloadings
117 SI_Symbol& operator=(const SI_Symbol& rhs) = delete;
118
119signals:
120 void textAdded(SI_Text& text);
121 void textRemoved(SI_Text& text);
123
124private:
125 bool checkAttributesValidity() const noexcept;
126
127 // General
133
134 // Attributes
139};
140
141/*******************************************************************************
142 * End of File
143 ******************************************************************************/
144
145} // namespace librepcb
146
147#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition angle.h:76
The ComponentInstance class.
Definition componentinstance.h:54
The ComponentSymbolVariantItem class represents one symbol of a component symbol variant.
Definition componentsymbolvariantitem.h:54
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_Symbol class.
Definition si_symbol.h:54
const QHash< Uuid, SI_SymbolPin * > & getPins() const noexcept
Definition si_symbol.h:85
bool getMirrored() const noexcept
Definition si_symbol.h:80
const Angle & getRotation() const noexcept
Definition si_symbol.h:79
ComponentInstance & getComponentInstance() const noexcept
Definition si_symbol.h:86
const ComponentSymbolVariantItem & getCompSymbVarItem() const noexcept
Definition si_symbol.h:90
void setMirrored(bool newMirrored) noexcept
Definition si_symbol.cpp:143
QHash< Uuid, SI_SymbolPin * > mPins
key: symbol pin UUID
Definition si_symbol.h:131
Slot< SI_Symbol, Event > OnEditedSlot
Definition si_symbol.h:65
void textAdded(SI_Text &text)
const QMap< Uuid, SI_Text * > & getTexts() const noexcept
Definition si_symbol.h:101
ComponentInstance & mComponentInstance
Definition si_symbol.h:128
Uuid mUuid
Definition si_symbol.h:135
QString getName() const noexcept
Definition si_symbol.cpp:117
Event
Definition si_symbol.h:59
TextList getDefaultTexts() const noexcept
Definition si_symbol.cpp:154
bool checkAttributesValidity() const noexcept
Definition si_symbol.cpp:265
SI_Symbol & operator=(const SI_Symbol &rhs)=delete
void removeFromSchematic() override
Definition si_symbol.cpp:222
void removeText(SI_Text &text)
Definition si_symbol.cpp:188
SI_SymbolPin * getPin(const Uuid &pinUuid) const noexcept
Definition si_symbol.h:82
void setRotation(const Angle &newRotation) noexcept
Definition si_symbol.cpp:136
void textRemoved(SI_Text &text)
void addText(SI_Text &text)
Definition si_symbol.cpp:170
void addToSchematic() override
Definition si_symbol.cpp:203
~SI_Symbol() noexcept
Definition si_symbol.cpp:106
Angle mRotation
Definition si_symbol.h:137
const Point & getPosition() const noexcept
Definition si_symbol.h:78
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition si_symbol.cpp:241
const Symbol & getLibSymbol() const noexcept
Definition si_symbol.h:89
const Uuid & getUuid() const noexcept
Definition si_symbol.h:77
void setPosition(const Point &newPos) noexcept
Definition si_symbol.cpp:129
QMap< Uuid, SI_Text * > mTexts
key: text UUID
Definition si_symbol.h:132
bool mMirrored
Definition si_symbol.h:138
const ComponentSymbolVariantItem * mSymbVarItem
Definition si_symbol.h:129
Point mPosition
Definition si_symbol.h:136
Signal< SI_Symbol, Event > onEdited
Definition si_symbol.h:64
SI_Symbol(const SI_Symbol &other)=delete
const Symbol * mSymbol
Definition si_symbol.h:130
The SI_SymbolPin class.
Definition si_symbolpin.h:52
The SI_Text class represents a text label in a schematic.
Definition si_text.h:48
The Schematic class represents one schematic page of a project and is always part of a circuit.
Definition schematic.h:74
The Signal class is used to emit signals on non-QObject derived classes.
Definition signalslot.h:65
The Slot class is used to receive signals from non-QObject derived classes.
Definition signalslot.h:170
The Symbol class represents the part of a component which is added to schematics.
Definition symbol.h:55
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition uuid.h:56
Definition occmodel.cpp:76