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
HoleGraphicsItem;
54
class
IF_GraphicsLayerProvider;
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
IF_GraphicsLayerProvider
& lp,
88
const
StrokeFont
& font,
89
const
PackagePadList
* packagePadList =
nullptr
,
90
const
Component
* component =
nullptr
,
91
const QStringList& localeOrder = {})
noexcept
;
92
~FootprintGraphicsItem
() noexcept;
93
94
// Getters
95
std
::shared_ptr<
FootprintPadGraphicsItem
>
getGraphicsItem
(
96
std
::shared_ptr<
FootprintPad
> pad) noexcept {
97
return
mPadGraphicsItems
.value(pad);
98
}
99
std::shared_ptr<CircleGraphicsItem>
getGraphicsItem
(
100
std::shared_ptr<Circle> circle)
noexcept
{
101
return
mCircleGraphicsItems
.value(circle);
102
}
103
std::shared_ptr<PolygonGraphicsItem>
getGraphicsItem
(
104
std::shared_ptr<Polygon> polygon)
noexcept
{
105
return
mPolygonGraphicsItems
.value(polygon);
106
}
107
std::shared_ptr<StrokeTextGraphicsItem>
getGraphicsItem
(
108
std::shared_ptr<StrokeText> text)
noexcept
{
109
return
mStrokeTextGraphicsItems
.value(text);
110
}
111
std::shared_ptr<ZoneGraphicsItem>
getGraphicsItem
(
112
std::shared_ptr<Zone> zone)
noexcept
{
113
return
mZoneGraphicsItems
.value(zone);
114
}
115
std::shared_ptr<HoleGraphicsItem>
getGraphicsItem
(
116
std::shared_ptr<Hole> hole)
noexcept
{
117
return
mHoleGraphicsItems
.value(hole);
118
}
119
QList<std::shared_ptr<FootprintPadGraphicsItem>>
getSelectedPads
() noexcept;
120
QList<
std
::shared_ptr<
CircleGraphicsItem
>>
getSelectedCircles
() noexcept;
121
QList<
std
::shared_ptr<
PolygonGraphicsItem
>>
getSelectedPolygons
() noexcept;
122
QList<
std
::shared_ptr<
StrokeTextGraphicsItem
>>
123
getSelectedStrokeTexts
() noexcept;
124
QList<
std
::shared_ptr<
ZoneGraphicsItem
>>
getSelectedZones
() noexcept;
125
QList<
std
::shared_ptr<
HoleGraphicsItem
>>
getSelectedHoles
() noexcept;
126
QList<
std
::shared_ptr<QGraphicsItem>>
findItemsAtPos
(
127
const QPainterPath& posAreaSmall, const QPainterPath& posAreaLarge,
128
FindFlags flags) noexcept;
129
130
// Setters
131
void
setPosition
(const
Point
& pos) noexcept;
132
void
setRotation
(const
Angle
& rot) noexcept;
133
134
// General Methods
135
void
updateAllTexts
() noexcept;
136
void
setSelectionRect
(const QRectF rect) noexcept;
137
138
// Operator Overloadings
139
FootprintGraphicsItem
& operator=(const
FootprintGraphicsItem
& rhs) = delete;
140
141
private:
// Methods
142
void
syncPads
() noexcept;
143
void
syncCircles
() noexcept;
144
void
syncPolygons
() noexcept;
145
void
syncStrokeTexts
() noexcept;
146
void
syncZones
() noexcept;
147
void
syncHoles
() noexcept;
148
void
footprintEdited
(const
Footprint
& footprint,
149
Footprint
::Event event) noexcept;
150
void
substituteText
(
StrokeTextGraphicsItem
& text) noexcept;
151
152
private:
// Data
153
std
::shared_ptr<
Footprint
>
mFootprint
;
154
const
IF_GraphicsLayerProvider
&
mLayerProvider
;
155
const
StrokeFont
&
mFont
;
156
const
PackagePadList
*
mPackagePadList
;
// Can be nullptr.
157
QPointer<const
Component
>
mComponent
;
// Can be nullptr.
158
QStringList
mLocaleOrder
;
159
QMap<
std
::shared_ptr<
FootprintPad
>,
std
::shared_ptr<
FootprintPadGraphicsItem
>>
160
mPadGraphicsItems
;
161
QMap<
std
::shared_ptr<
Circle
>,
std
::shared_ptr<
CircleGraphicsItem
>>
162
mCircleGraphicsItems
;
163
QMap<
std
::shared_ptr<
Polygon
>,
std
::shared_ptr<
PolygonGraphicsItem
>>
164
mPolygonGraphicsItems
;
165
QMap<
std
::shared_ptr<
StrokeText
>,
std
::shared_ptr<
StrokeTextGraphicsItem
>>
166
mStrokeTextGraphicsItems
;
167
QMap<
std
::shared_ptr<
Zone
>,
std
::shared_ptr<
ZoneGraphicsItem
>>
168
mZoneGraphicsItems
;
169
QMap<
std
::shared_ptr<
Hole
>,
std
::shared_ptr<
HoleGraphicsItem
>>
170
mHoleGraphicsItems
;
171
172
// Slots
173
Footprint
::OnEditedSlot
mOnEditedSlot
;
174
};
175
176
}
// namespace editor
177
}
// namespace librepcb
178
179
Q_DECLARE_OPERATORS_FOR_FLAGS(
180
librepcb
::editor::
FootprintGraphicsItem
::FindFlags)
181
182
/*******************************************************************************
183
* End of File
184
******************************************************************************/
185
186
#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:99
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:170
librepcb::editor::FootprintGraphicsItem::mPolygonGraphicsItems
QMap< std::shared_ptr< Polygon >, std::shared_ptr< PolygonGraphicsItem > > mPolygonGraphicsItems
Definition
footprintgraphicsitem.h:164
librepcb::editor::FootprintGraphicsItem::getGraphicsItem
std::shared_ptr< FootprintPadGraphicsItem > getGraphicsItem(std::shared_ptr< FootprintPad > pad) noexcept
Definition
footprintgraphicsitem.h:95
librepcb::editor::FootprintGraphicsItem::mPadGraphicsItems
QMap< std::shared_ptr< FootprintPad >, std::shared_ptr< FootprintPadGraphicsItem > > mPadGraphicsItems
Definition
footprintgraphicsitem.h:160
librepcb::editor::FootprintGraphicsItem::mComponent
QPointer< const Component > mComponent
Definition
footprintgraphicsitem.h:157
librepcb::editor::FootprintGraphicsItem::mPackagePadList
const PackagePadList * mPackagePadList
Definition
footprintgraphicsitem.h:156
librepcb::editor::FootprintGraphicsItem::mZoneGraphicsItems
QMap< std::shared_ptr< Zone >, std::shared_ptr< ZoneGraphicsItem > > mZoneGraphicsItems
Definition
footprintgraphicsitem.h:168
librepcb::editor::FootprintGraphicsItem::syncZones
void syncZones() noexcept
Definition
footprintgraphicsitem.cpp:425
librepcb::editor::FootprintGraphicsItem::footprintEdited
void footprintEdited(const Footprint &footprint, Footprint::Event event) noexcept
Definition
footprintgraphicsitem.cpp:471
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:448
librepcb::editor::FootprintGraphicsItem::getGraphicsItem
std::shared_ptr< ZoneGraphicsItem > getGraphicsItem(std::shared_ptr< Zone > zone) noexcept
Definition
footprintgraphicsitem.h:111
librepcb::editor::FootprintGraphicsItem::substituteText
void substituteText(StrokeTextGraphicsItem &text) noexcept
Definition
footprintgraphicsitem.cpp:498
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::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::mLayerProvider
const IF_GraphicsLayerProvider & mLayerProvider
Definition
footprintgraphicsitem.h:154
librepcb::editor::FootprintGraphicsItem::getGraphicsItem
std::shared_ptr< StrokeTextGraphicsItem > getGraphicsItem(std::shared_ptr< StrokeText > text) noexcept
Definition
footprintgraphicsitem.h:107
librepcb::editor::FootprintGraphicsItem::mCircleGraphicsItems
QMap< std::shared_ptr< Circle >, std::shared_ptr< CircleGraphicsItem > > mCircleGraphicsItems
Definition
footprintgraphicsitem.h:162
librepcb::editor::FootprintGraphicsItem::mOnEditedSlot
Footprint::OnEditedSlot mOnEditedSlot
Definition
footprintgraphicsitem.h:173
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:166
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:103
librepcb::editor::FootprintGraphicsItem::mFont
const StrokeFont & mFont
Definition
footprintgraphicsitem.h:155
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:115
librepcb::editor::FootprintGraphicsItem::mFootprint
std::shared_ptr< Footprint > mFootprint
Definition
footprintgraphicsitem.h:153
librepcb::editor::FootprintGraphicsItem::syncStrokeTexts
void syncStrokeTexts() noexcept
Definition
footprintgraphicsitem.cpp:400
librepcb::editor::FootprintGraphicsItem::mLocaleOrder
QStringList mLocaleOrder
Definition
footprintgraphicsitem.h:158
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::HoleGraphicsItem
The HoleGraphicsItem class is the graphical representation of a librepcb::Hole.
Definition
holegraphicsitem.h:48
librepcb::editor::IF_GraphicsLayerProvider
The IF_GraphicsLayerProvider class defines an interface for classes which provide layers.
Definition
graphicslayer.h:111
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
Definition
occmodel.cpp:76
std
Definition
uuid.h:186
packagepad.h
libs
librepcb
editor
library
pkg
footprintgraphicsitem.h
Generated on Wed Dec 18 2024 20:12:48 for LibrePCB Developers Documentation by
1.9.8