LibrePCB Developers Documentation
Loading...
Searching...
No Matches
symbolpingraphicsitem.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_EDITOR_SYMBOLPINGRAPHICSITEM_H
21#define LIBREPCB_EDITOR_SYMBOLPINGRAPHICSITEM_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
27
28#include <QtCore>
29#include <QtWidgets>
30
31/*******************************************************************************
32 * Namespace / Forward Declarations
33 ******************************************************************************/
34namespace librepcb {
35
36class Component;
37class ComponentSymbolVariantItem;
38
39namespace editor {
40
41class IF_GraphicsLayerProvider;
42class LineGraphicsItem;
43class PrimitiveCircleGraphicsItem;
44class PrimitiveTextGraphicsItem;
45
46/*******************************************************************************
47 * Class SymbolPinGraphicsItem
48 ******************************************************************************/
49
53class SymbolPinGraphicsItem final : public QGraphicsItemGroup {
54public:
55 // Constructors / Destructor
59 std::shared_ptr<SymbolPin> pin, const IF_GraphicsLayerProvider& lp,
60 std::shared_ptr<const Component> cmp = nullptr,
61 std::shared_ptr<const ComponentSymbolVariantItem> cmpItem = nullptr,
62 QGraphicsItem* parent = nullptr) noexcept;
63 ~SymbolPinGraphicsItem() noexcept;
64
65 // Getters
66 SymbolPin& getObj() noexcept { return *mPin; }
67 const std::shared_ptr<SymbolPin>& getPtr() noexcept { return mPin; }
68
69 // General Methods
70 void updateText() noexcept;
71
72 // Inherited from QGraphicsItem
73 QPainterPath shape() const noexcept override;
74
75 // Operator Overloadings
76 SymbolPinGraphicsItem& operator=(const SymbolPinGraphicsItem& rhs) = delete;
77
78private: // Methods
79 void pinEdited(const SymbolPin& pin, SymbolPin::Event event) noexcept;
80 virtual QVariant itemChange(GraphicsItemChange change,
81 const QVariant& value) noexcept override;
82 void setLength(const UnsignedLength& length) noexcept;
83 void updateNamePosition() noexcept;
84 void updateNumbersTransform() noexcept;
85
86private: // Data
87 std::shared_ptr<SymbolPin> mPin;
89 std::shared_ptr<const Component> mComponent; // Can be nullptr.
90 std::shared_ptr<const ComponentSymbolVariantItem> mItem; // Can be nullptr.
95
96 // Slots
97 SymbolPin::OnEditedSlot mOnEditedSlot;
98};
99
100/*******************************************************************************
101 * End of File
102 ******************************************************************************/
103
104} // namespace editor
105} // namespace librepcb
106
107#endif
The Component class represents a "generic" device in the library.
Definition component.h:73
The ComponentSymbolVariantItem class represents one symbol of a component symbol variant.
Definition componentsymbolvariantitem.h:54
The SymbolPin class represents one pin of a symbol.
Definition symbolpin.h:51
The IF_GraphicsLayerProvider class defines an interface for classes which provide layers.
Definition graphicslayer.h:111
The LineGraphicsItem class.
Definition linegraphicsitem.h:50
The PrimitiveCircleGraphicsItem class.
Definition primitivecirclegraphicsitem.h:49
The PrimitiveTextGraphicsItem class is the graphical representation of a text.
Definition primitivetextgraphicsitem.h:52
The SymbolPinGraphicsItem class.
Definition symbolpingraphicsitem.h:53
QScopedPointer< PrimitiveTextGraphicsItem > mNumbersGraphicsItem
Definition symbolpingraphicsitem.h:94
void updateText() noexcept
Definition symbolpingraphicsitem.cpp:115
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) noexcept override
Definition symbolpingraphicsitem.cpp:168
const std::shared_ptr< SymbolPin > & getPtr() noexcept
Definition symbolpingraphicsitem.h:67
std::shared_ptr< const ComponentSymbolVariantItem > mItem
Definition symbolpingraphicsitem.h:90
QScopedPointer< PrimitiveCircleGraphicsItem > mCircleGraphicsItem
Definition symbolpingraphicsitem.h:91
SymbolPinGraphicsItem(const SymbolPinGraphicsItem &other)=delete
std::shared_ptr< SymbolPin > mPin
Definition symbolpingraphicsitem.h:87
std::shared_ptr< const Component > mComponent
Definition symbolpingraphicsitem.h:89
QPainterPath shape() const noexcept override
Definition symbolpingraphicsitem.cpp:163
void setLength(const UnsignedLength &length) noexcept
Definition symbolpingraphicsitem.cpp:226
void pinEdited(const SymbolPin &pin, SymbolPin::Event event) noexcept
Definition symbolpingraphicsitem.cpp:184
const IF_GraphicsLayerProvider & mLayerProvider
Definition symbolpingraphicsitem.h:88
QScopedPointer< LineGraphicsItem > mLineGraphicsItem
Definition symbolpingraphicsitem.h:92
void updateNamePosition() noexcept
Definition symbolpingraphicsitem.cpp:230
SymbolPin::OnEditedSlot mOnEditedSlot
Definition symbolpingraphicsitem.h:97
SymbolPin & getObj() noexcept
Definition symbolpingraphicsitem.h:66
void updateNumbersTransform() noexcept
Definition symbolpingraphicsitem.cpp:235
QScopedPointer< PrimitiveTextGraphicsItem > mNameGraphicsItem
Definition symbolpingraphicsitem.h:93
Definition occmodel.cpp:76
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition length.h:694
Definition uuid.h:186