LibrePCB Developers Documentation
Loading...
Searching...
No Matches
footprintgraphicsitem.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_FOOTPRINTGRAPHICSITEM_H
21
#define LIBREPCB_EDITOR_FOOTPRINTGRAPHICSITEM_H
22
23
/*******************************************************************************
24
* Includes
25
******************************************************************************/
26
#include <
librepcb/core/library/pkg/footprint.h
>
27
#include <
librepcb/core/library/pkg/packagepad.h
>
28
29
#include <QtCore>
30
#include <QtWidgets>
31
32
#include <memory>
33
34
/*******************************************************************************
35
* Namespace / Forward Declarations
36
******************************************************************************/
37
namespace
librepcb
{
38
39
class
Angle;
40
class
Circle
;
41
class
Component;
42
class
FootprintPad;
43
class
Hole;
44
class
Point;
45
class
Polygon
;
46
class
StrokeText;
47
class
Zone;
48
49
namespace
editor {
50
51
class
CircleGraphicsItem;
52
class
FootprintPadGraphicsItem;
53
class
GraphicsLayerList;
54
class
HoleGraphicsItem;
55
class
PolygonGraphicsItem;
56
class
StrokeTextGraphicsItem;
57
class
ZoneGraphicsItem;
58
59
/*******************************************************************************
60
* Class FootprintGraphicsItem
61
******************************************************************************/
62
66
class
FootprintGraphicsItem
final :
public
QGraphicsItemGroup {
67
public
:
68
enum class
FindFlag
{
69
// Item types
70
Pads
= (1 << 0),
71
Circles
= (1 << 1),
72
Polygons
= (1 << 2),
73
StrokeTexts
= (1 << 3),
74
Zones
= (1 << 4),
75
Holes
= (1 << 5),
76
All
=
Pads
|
Circles
|
Polygons
|
StrokeTexts
|
Zones
|
Holes
,
77
78
// Match behavior
79
AcceptNearMatch
= (1 << 10),
80
};
81
Q_DECLARE_FLAGS(FindFlags,
FindFlag
)
82
83
// Constructors / Destructor
84
FootprintGraphicsItem
() = delete;
85
FootprintGraphicsItem
(const
FootprintGraphicsItem
& other) = delete;
86
FootprintGraphicsItem
(
std
::shared_ptr<
Footprint
> footprint,
87
const
GraphicsLayerList
& layers, const
StrokeFont
& font,
88
const
PackagePadList
* packagePadList =
nullptr
,
89
const
Component
* component =
nullptr
,
90
const QStringList& localeOrder = {})
noexcept
;
91
~FootprintGraphicsItem
() noexcept;
92
93
// Getters
94
std
::shared_ptr<
FootprintPadGraphicsItem
>
getGraphicsItem
(
95
std
::shared_ptr<
FootprintPad
> pad) noexcept {
96
return
mPadGraphicsItems
.value(pad);
97
}
98
std::shared_ptr<CircleGraphicsItem>
getGraphicsItem
(
99
std::shared_ptr<Circle> circle)
noexcept
{
100
return
mCircleGraphicsItems
.value(circle);
101
}
102
std::shared_ptr<PolygonGraphicsItem>
getGraphicsItem
(
103
std::shared_ptr<Polygon> polygon)
noexcept
{
104
return
mPolygonGraphicsItems
.value(polygon);
105
}
106
std::shared_ptr<StrokeTextGraphicsItem>
getGraphicsItem
(
107
std::shared_ptr<StrokeText> text)
noexcept
{
108
return
mStrokeTextGraphicsItems
.value(text);
109
}
110
std::shared_ptr<ZoneGraphicsItem>
getGraphicsItem
(
111
std::shared_ptr<Zone> zone)
noexcept
{
112
return
mZoneGraphicsItems
.value(zone);
113
}
114
std::shared_ptr<HoleGraphicsItem>
getGraphicsItem
(
115
std::shared_ptr<Hole> hole)
noexcept
{
116
return
mHoleGraphicsItems
.value(hole);
117
}
118
QList<std::shared_ptr<FootprintPadGraphicsItem>>
getSelectedPads
() noexcept;
119
QList<
std
::shared_ptr<
CircleGraphicsItem
>>
getSelectedCircles
() noexcept;
120
QList<
std
::shared_ptr<
PolygonGraphicsItem
>>
getSelectedPolygons
() noexcept;
121
QList<
std
::shared_ptr<
StrokeTextGraphicsItem
>>
122
getSelectedStrokeTexts
() noexcept;
123
QList<
std
::shared_ptr<
ZoneGraphicsItem
>>
getSelectedZones
() noexcept;
124
QList<
std
::shared_ptr<
HoleGraphicsItem
>>
getSelectedHoles
() noexcept;
125
QList<
std
::shared_ptr<QGraphicsItem>>
findItemsAtPos
(
126
const QPainterPath& posAreaSmall, const QPainterPath& posAreaLarge,
127
FindFlags flags) noexcept;
128
129
// Setters
130
void
setPosition
(const
Point
& pos) noexcept;
131
void
setRotation
(const
Angle
& rot) noexcept;
132
133
// General Methods
134
void
updateAllTexts
() noexcept;
135
void
setSelectionRect
(const QRectF rect) noexcept;
136
137
// Operator Overloadings
138
FootprintGraphicsItem
& operator=(const
FootprintGraphicsItem
& rhs) = delete;
139
140
private:
// Methods
141
void
syncPads
() noexcept;
142
void
syncCircles
() noexcept;
143
void
syncPolygons
() noexcept;
144
void
syncStrokeTexts
() noexcept;
145
void
syncZones
() noexcept;
146
void
syncHoles
() noexcept;
147
void
footprintEdited
(const
Footprint
& footprint,
148
Footprint
::Event event) noexcept;
149
void
substituteText
(
StrokeTextGraphicsItem
& text) noexcept;
150
151
private:
// Data
152
std
::shared_ptr<
Footprint
>
mFootprint
;
153
const
GraphicsLayerList
&
mLayers
;
154
const
StrokeFont
&
mFont
;
155
const
PackagePadList
*
mPackagePadList
;
// Can be nullptr.
156
QPointer<const
Component
>
mComponent
;
// Can be nullptr.
157
QStringList
mLocaleOrder
;
158
QMap<
std
::shared_ptr<
FootprintPad
>,
std
::shared_ptr<
FootprintPadGraphicsItem
>>
159
mPadGraphicsItems
;
160
QMap<
std
::shared_ptr<
Circle
>,
std
::shared_ptr<
CircleGraphicsItem
>>
161
mCircleGraphicsItems
;
162
QMap<
std
::shared_ptr<
Polygon
>,
std
::shared_ptr<
PolygonGraphicsItem
>>
163
mPolygonGraphicsItems
;
164
QMap<
std
::shared_ptr<
StrokeText
>,
std
::shared_ptr<
StrokeTextGraphicsItem
>>
165
mStrokeTextGraphicsItems
;
166
QMap<
std
::shared_ptr<
Zone
>,
std
::shared_ptr<
ZoneGraphicsItem
>>
167
mZoneGraphicsItems
;
168
QMap<
std
::shared_ptr<
Hole
>,
std
::shared_ptr<
HoleGraphicsItem
>>
169
mHoleGraphicsItems
;
170
171
// Slots
172
Footprint
::OnEditedSlot
mOnEditedSlot
;
173
};
174
175
}
// namespace editor
176
}
// namespace librepcb
177
178
Q_DECLARE_OPERATORS_FOR_FLAGS(
179
librepcb
::editor::
FootprintGraphicsItem
::FindFlags)
180
181
/*******************************************************************************
182
* End of File
183
******************************************************************************/
184
185
#endif
librepcb::Angle
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition
angle.h:76
librepcb::Circle
The Circle class.
Definition
circle.h:46
librepcb::Component
The Component class represents a "generic" device in the library.
Definition
component.h:73
librepcb::Footprint
The Footprint class represents one footprint variant of a package.
Definition
footprint.h:55
librepcb::FootprintPad
The FootprintPad class represents a pad of a footprint.
Definition
footprintpad.h:54
librepcb::Hole
The Hole class.
Definition
hole.h:45
librepcb::Point
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition
point.h:78
librepcb::Polygon
The Polygon class.
Definition
polygon.h:45
librepcb::SerializableObjectList< PackagePad, PackagePadListNameProvider, PackagePad::Event >
librepcb::StrokeFont
The StrokeFont class.
Definition
strokefont.h:56
librepcb::StrokeText
The StrokeText class.
Definition
stroketext.h:51
librepcb::Zone
The Zone class.
Definition
zone.h:43
librepcb::editor::CircleGraphicsItem
The CircleGraphicsItem class.
Definition
circlegraphicsitem.h:48
librepcb::editor::FootprintGraphicsItem
The FootprintGraphicsItem class.
Definition
footprintgraphicsitem.h:66
librepcb::editor::FootprintGraphicsItem::getGraphicsItem
std::shared_ptr< CircleGraphicsItem > getGraphicsItem(std::shared_ptr< Circle > circle) noexcept
Definition
footprintgraphicsitem.h:98
librepcb::editor::FootprintGraphicsItem::getSelectedZones
QList< std::shared_ptr< ZoneGraphicsItem > > getSelectedZones() noexcept
Definition
footprintgraphicsitem.cpp:127
librepcb::editor::FootprintGraphicsItem::mHoleGraphicsItems
QMap< std::shared_ptr< Hole >, std::shared_ptr< HoleGraphicsItem > > mHoleGraphicsItems
Definition
footprintgraphicsitem.h:169
librepcb::editor::FootprintGraphicsItem::mPolygonGraphicsItems
QMap< std::shared_ptr< Polygon >, std::shared_ptr< PolygonGraphicsItem > > mPolygonGraphicsItems
Definition
footprintgraphicsitem.h:163
librepcb::editor::FootprintGraphicsItem::getGraphicsItem
std::shared_ptr< FootprintPadGraphicsItem > getGraphicsItem(std::shared_ptr< FootprintPad > pad) noexcept
Definition
footprintgraphicsitem.h:94
librepcb::editor::FootprintGraphicsItem::mPadGraphicsItems
QMap< std::shared_ptr< FootprintPad >, std::shared_ptr< FootprintPadGraphicsItem > > mPadGraphicsItems
Definition
footprintgraphicsitem.h:159
librepcb::editor::FootprintGraphicsItem::mComponent
QPointer< const Component > mComponent
Definition
footprintgraphicsitem.h:156
librepcb::editor::FootprintGraphicsItem::mPackagePadList
const PackagePadList * mPackagePadList
Definition
footprintgraphicsitem.h:155
librepcb::editor::FootprintGraphicsItem::mZoneGraphicsItems
QMap< std::shared_ptr< Zone >, std::shared_ptr< ZoneGraphicsItem > > mZoneGraphicsItems
Definition
footprintgraphicsitem.h:167
librepcb::editor::FootprintGraphicsItem::syncZones
void syncZones() noexcept
Definition
footprintgraphicsitem.cpp:424
librepcb::editor::FootprintGraphicsItem::footprintEdited
void footprintEdited(const Footprint &footprint, Footprint::Event event) noexcept
Definition
footprintgraphicsitem.cpp:469
librepcb::editor::FootprintGraphicsItem::syncCircles
void syncCircles() noexcept
Definition
footprintgraphicsitem.cpp:352
librepcb::editor::FootprintGraphicsItem::findItemsAtPos
QList< std::shared_ptr< QGraphicsItem > > findItemsAtPos(const QPainterPath &posAreaSmall, const QPainterPath &posAreaLarge, FindFlags flags) noexcept
Definition
footprintgraphicsitem.cpp:148
librepcb::editor::FootprintGraphicsItem::getSelectedPads
QList< std::shared_ptr< FootprintPadGraphicsItem > > getSelectedPads() noexcept
Definition
footprintgraphicsitem.cpp:83
librepcb::editor::FootprintGraphicsItem::syncHoles
void syncHoles() noexcept
Definition
footprintgraphicsitem.cpp:447
librepcb::editor::FootprintGraphicsItem::getGraphicsItem
std::shared_ptr< ZoneGraphicsItem > getGraphicsItem(std::shared_ptr< Zone > zone) noexcept
Definition
footprintgraphicsitem.h:110
librepcb::editor::FootprintGraphicsItem::substituteText
void substituteText(StrokeTextGraphicsItem &text) noexcept
Definition
footprintgraphicsitem.cpp:496
librepcb::editor::FootprintGraphicsItem::getSelectedCircles
QList< std::shared_ptr< CircleGraphicsItem > > getSelectedCircles() noexcept
Definition
footprintgraphicsitem.cpp:94
librepcb::editor::FootprintGraphicsItem::syncPads
void syncPads() noexcept
Definition
footprintgraphicsitem.cpp:329
librepcb::editor::FootprintGraphicsItem::getSelectedHoles
QList< std::shared_ptr< HoleGraphicsItem > > getSelectedHoles() noexcept
Definition
footprintgraphicsitem.cpp:138
librepcb::editor::FootprintGraphicsItem::mLayers
const GraphicsLayerList & mLayers
Definition
footprintgraphicsitem.h:153
librepcb::editor::FootprintGraphicsItem::getSelectedPolygons
QList< std::shared_ptr< PolygonGraphicsItem > > getSelectedPolygons() noexcept
Definition
footprintgraphicsitem.cpp:105
librepcb::editor::FootprintGraphicsItem::~FootprintGraphicsItem
~FootprintGraphicsItem() noexcept
Definition
footprintgraphicsitem.cpp:75
librepcb::editor::FootprintGraphicsItem::updateAllTexts
void updateAllTexts() noexcept
Definition
footprintgraphicsitem.cpp:287
librepcb::editor::FootprintGraphicsItem::getGraphicsItem
std::shared_ptr< StrokeTextGraphicsItem > getGraphicsItem(std::shared_ptr< StrokeText > text) noexcept
Definition
footprintgraphicsitem.h:106
librepcb::editor::FootprintGraphicsItem::mCircleGraphicsItems
QMap< std::shared_ptr< Circle >, std::shared_ptr< CircleGraphicsItem > > mCircleGraphicsItems
Definition
footprintgraphicsitem.h:161
librepcb::editor::FootprintGraphicsItem::mOnEditedSlot
Footprint::OnEditedSlot mOnEditedSlot
Definition
footprintgraphicsitem.h:172
librepcb::editor::FootprintGraphicsItem::FindFlag
FindFlag
Definition
footprintgraphicsitem.h:68
librepcb::editor::FootprintGraphicsItem::FindFlag::Circles
@ Circles
librepcb::editor::FootprintGraphicsItem::FindFlag::AcceptNearMatch
@ AcceptNearMatch
librepcb::editor::FootprintGraphicsItem::FindFlag::Holes
@ Holes
librepcb::editor::FootprintGraphicsItem::FindFlag::StrokeTexts
@ StrokeTexts
librepcb::editor::FootprintGraphicsItem::FindFlag::Polygons
@ Polygons
librepcb::editor::FootprintGraphicsItem::FindFlag::All
@ All
librepcb::editor::FootprintGraphicsItem::FindFlag::Pads
@ Pads
librepcb::editor::FootprintGraphicsItem::FindFlag::Zones
@ Zones
librepcb::editor::FootprintGraphicsItem::mStrokeTextGraphicsItems
QMap< std::shared_ptr< StrokeText >, std::shared_ptr< StrokeTextGraphicsItem > > mStrokeTextGraphicsItems
Definition
footprintgraphicsitem.h:165
librepcb::editor::FootprintGraphicsItem::getSelectedStrokeTexts
QList< std::shared_ptr< StrokeTextGraphicsItem > > getSelectedStrokeTexts() noexcept
Definition
footprintgraphicsitem.cpp:116
librepcb::editor::FootprintGraphicsItem::setSelectionRect
void setSelectionRect(const QRectF rect) noexcept
Definition
footprintgraphicsitem.cpp:296
librepcb::editor::FootprintGraphicsItem::getGraphicsItem
std::shared_ptr< PolygonGraphicsItem > getGraphicsItem(std::shared_ptr< Polygon > polygon) noexcept
Definition
footprintgraphicsitem.h:102
librepcb::editor::FootprintGraphicsItem::mFont
const StrokeFont & mFont
Definition
footprintgraphicsitem.h:154
librepcb::editor::FootprintGraphicsItem::setRotation
void setRotation(const Angle &rot) noexcept
Definition
footprintgraphicsitem.cpp:283
librepcb::editor::FootprintGraphicsItem::syncPolygons
void syncPolygons() noexcept
Definition
footprintgraphicsitem.cpp:375
librepcb::editor::FootprintGraphicsItem::getGraphicsItem
std::shared_ptr< HoleGraphicsItem > getGraphicsItem(std::shared_ptr< Hole > hole) noexcept
Definition
footprintgraphicsitem.h:114
librepcb::editor::FootprintGraphicsItem::mFootprint
std::shared_ptr< Footprint > mFootprint
Definition
footprintgraphicsitem.h:152
librepcb::editor::FootprintGraphicsItem::syncStrokeTexts
void syncStrokeTexts() noexcept
Definition
footprintgraphicsitem.cpp:399
librepcb::editor::FootprintGraphicsItem::mLocaleOrder
QStringList mLocaleOrder
Definition
footprintgraphicsitem.h:157
librepcb::editor::FootprintGraphicsItem::setPosition
void setPosition(const Point &pos) noexcept
Definition
footprintgraphicsitem.cpp:279
librepcb::editor::FootprintPadGraphicsItem
The FootprintPadGraphicsItem class.
Definition
footprintpadgraphicsitem.h:50
librepcb::editor::GraphicsLayerList
The GraphicsLayerList class.
Definition
graphicslayerlist.h:48
librepcb::editor::HoleGraphicsItem
The HoleGraphicsItem class is the graphical representation of a librepcb::Hole.
Definition
holegraphicsitem.h:48
librepcb::editor::PolygonGraphicsItem
The PolygonGraphicsItem class.
Definition
polygongraphicsitem.h:48
librepcb::editor::StrokeTextGraphicsItem
The StrokeTextGraphicsItem class is the graphical representation of a librepcb::StrokeText.
Definition
stroketextgraphicsitem.h:49
librepcb::editor::ZoneGraphicsItem
The ZoneGraphicsItem class.
Definition
zonegraphicsitem.h:48
footprint.h
librepcb::kicadimport::KiCadPadShape::Circle
@ Circle
librepcb::rs::InteractiveHtmlBomDrawingKind::Polygon
@ Polygon
librepcb
Definition
occmodel.cpp:77
std
Definition
uuid.h:186
packagepad.h
libs
librepcb
editor
library
pkg
footprintgraphicsitem.h
Generated on Wed Jul 16 2025 14:19:25 for LibrePCB Developers Documentation by
1.9.8