LibrePCB Developers Documentation
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 const std::shared_ptr<SymbolPin>& getPin() noexcept { return mPin; }
67
68 // General Methods
69 void updateText() noexcept;
70
71 // Inherited from QGraphicsItem
72 QPainterPath shape() const noexcept override;
73
74 // Operator Overloadings
75 SymbolPinGraphicsItem& operator=(const SymbolPinGraphicsItem& rhs) = delete;
76
77private: // Methods
78 void pinEdited(const SymbolPin& pin, SymbolPin::Event event) noexcept;
79 virtual QVariant itemChange(GraphicsItemChange change,
80 const QVariant& value) noexcept override;
81 void setLength(const UnsignedLength& length) noexcept;
82 void updateNamePosition() noexcept;
83 void updateNumbersTransform() noexcept;
84
85private: // Data
86 std::shared_ptr<SymbolPin> mPin;
88 std::shared_ptr<const Component> mComponent; // Can be nullptr.
89 std::shared_ptr<const ComponentSymbolVariantItem> mItem; // Can be nullptr.
94
95 // Slots
96 SymbolPin::OnEditedSlot mOnEditedSlot;
97};
98
99/*******************************************************************************
100 * End of File
101 ******************************************************************************/
102
103} // namespace editor
104} // namespace librepcb
105
106#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:93
void updateText() noexcept
Definition: symbolpingraphicsitem.cpp:115
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) noexcept override
Definition: symbolpingraphicsitem.cpp:168
std::shared_ptr< const ComponentSymbolVariantItem > mItem
Definition: symbolpingraphicsitem.h:89
QScopedPointer< PrimitiveCircleGraphicsItem > mCircleGraphicsItem
Definition: symbolpingraphicsitem.h:90
SymbolPinGraphicsItem(const SymbolPinGraphicsItem &other)=delete
std::shared_ptr< SymbolPin > mPin
Definition: symbolpingraphicsitem.h:86
std::shared_ptr< const Component > mComponent
Definition: symbolpingraphicsitem.h:88
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:87
QScopedPointer< LineGraphicsItem > mLineGraphicsItem
Definition: symbolpingraphicsitem.h:91
void updateNamePosition() noexcept
Definition: symbolpingraphicsitem.cpp:230
SymbolPin::OnEditedSlot mOnEditedSlot
Definition: symbolpingraphicsitem.h:96
const std::shared_ptr< SymbolPin > & getPin() noexcept
Definition: symbolpingraphicsitem.h:66
void updateNumbersTransform() noexcept
Definition: symbolpingraphicsitem.cpp:235
QScopedPointer< PrimitiveTextGraphicsItem > mNameGraphicsItem
Definition: symbolpingraphicsitem.h:92
Definition: occmodel.cpp:77
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:696