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 ******************************************************************************/
28
29#include <QtCore>
30#include <QtWidgets>
31
32/*******************************************************************************
33 * Namespace / Forward Declarations
34 ******************************************************************************/
35namespace librepcb {
36namespace editor {
37
38class GraphicsLayerList;
39class LineGraphicsItem;
40class PrimitiveCircleGraphicsItem;
41class PrimitiveTextGraphicsItem;
42
43/*******************************************************************************
44 * Class SymbolPinGraphicsItem
45 ******************************************************************************/
46
50class SymbolPinGraphicsItem final : public QGraphicsItemGroup {
51public:
52 // Constructors / Destructor
56 std::shared_ptr<SymbolPin> pin, const GraphicsLayerList& layers,
57 QPointer<const Component> cmp,
58 std::shared_ptr<const ComponentSymbolVariantItem> cmpItem,
59 bool hideIfUnused, QGraphicsItem* parent = nullptr) noexcept;
60 ~SymbolPinGraphicsItem() noexcept;
61
62 // Getters
63 SymbolPin& getObj() noexcept { return *mPin; }
64 const std::shared_ptr<SymbolPin>& getPtr() noexcept { return mPin; }
65
66 // General Methods
67 void updateText() noexcept;
68
69 // Inherited from QGraphicsItem
70 QPainterPath shape() const noexcept override;
71
72 // Operator Overloadings
73 SymbolPinGraphicsItem& operator=(const SymbolPinGraphicsItem& rhs) = delete;
74
75private: // Methods
76 void pinEdited(const SymbolPin& pin, SymbolPin::Event event) noexcept;
77 virtual QVariant itemChange(GraphicsItemChange change,
78 const QVariant& value) noexcept override;
79 void setLength(const UnsignedLength& length) noexcept;
80 void updateNamePosition() noexcept;
81 void updateNumbersTransform() noexcept;
82
83private: // Data
84 std::shared_ptr<SymbolPin> mPin;
86 QPointer<const Component> mComponent; // Can be nullptr.
87 std::shared_ptr<const ComponentSymbolVariantItem> mItem; // Can be nullptr.
88 const bool mHideIfUnused;
93
94 // Slots
95 SymbolPin::OnEditedSlot mOnEditedSlot;
96};
97
98/*******************************************************************************
99 * End of File
100 ******************************************************************************/
101
102} // namespace editor
103} // namespace librepcb
104
105#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 GraphicsLayerList class.
Definition graphicslayerlist.h:48
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:50
QScopedPointer< PrimitiveTextGraphicsItem > mNumbersGraphicsItem
Definition symbolpingraphicsitem.h:92
void updateText() noexcept
Definition symbolpingraphicsitem.cpp:117
QPointer< const Component > mComponent
Definition symbolpingraphicsitem.h:86
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) noexcept override
Definition symbolpingraphicsitem.cpp:175
const std::shared_ptr< SymbolPin > & getPtr() noexcept
Definition symbolpingraphicsitem.h:64
std::shared_ptr< const ComponentSymbolVariantItem > mItem
Definition symbolpingraphicsitem.h:87
QScopedPointer< PrimitiveCircleGraphicsItem > mCircleGraphicsItem
Definition symbolpingraphicsitem.h:89
SymbolPinGraphicsItem(const SymbolPinGraphicsItem &other)=delete
std::shared_ptr< SymbolPin > mPin
Definition symbolpingraphicsitem.h:84
const GraphicsLayerList & mLayers
Definition symbolpingraphicsitem.h:85
QPainterPath shape() const noexcept override
Definition symbolpingraphicsitem.cpp:170
void setLength(const UnsignedLength &length) noexcept
Definition symbolpingraphicsitem.cpp:233
void pinEdited(const SymbolPin &pin, SymbolPin::Event event) noexcept
Definition symbolpingraphicsitem.cpp:191
QScopedPointer< LineGraphicsItem > mLineGraphicsItem
Definition symbolpingraphicsitem.h:90
const bool mHideIfUnused
Definition symbolpingraphicsitem.h:88
void updateNamePosition() noexcept
Definition symbolpingraphicsitem.cpp:237
SymbolPin::OnEditedSlot mOnEditedSlot
Definition symbolpingraphicsitem.h:95
SymbolPin & getObj() noexcept
Definition symbolpingraphicsitem.h:63
void updateNumbersTransform() noexcept
Definition symbolpingraphicsitem.cpp:242
QScopedPointer< PrimitiveTextGraphicsItem > mNameGraphicsItem
Definition symbolpingraphicsitem.h:91
Definition occmodel.cpp:77
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition length.h:694
Definition uuid.h:186