LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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_LIBRARY_FOOTPRINTGRAPHICSITEM_H
21 #define LIBREPCB_LIBRARY_FOOTPRINTGRAPHICSITEM_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../pkg/packagepad.h"
27 
29 #include <librepcb/common/uuid.h>
30 
31 #include <QtCore>
32 #include <QtWidgets>
33 
34 /*******************************************************************************
35  * Namespace / Forward Declarations
36  ******************************************************************************/
37 namespace librepcb {
38 
39 class Circle;
40 class Polygon;
41 class StrokeText;
42 class Hole;
43 class IF_GraphicsLayerProvider;
44 class PolygonGraphicsItem;
45 class CircleGraphicsItem;
46 class StrokeTextGraphicsItem;
47 class HoleGraphicsItem;
48 
49 namespace library {
50 
51 class Footprint;
52 class FootprintPad;
53 class FootprintPadGraphicsItem;
54 
55 /*******************************************************************************
56  * Class FootprintGraphicsItem
57  ******************************************************************************/
58 
62 class FootprintGraphicsItem final : public QGraphicsItem {
63 public:
64  // Constructors / Destructor
65  FootprintGraphicsItem() = delete;
66  FootprintGraphicsItem(const FootprintGraphicsItem& other) = delete;
68  const PackagePadList* packagePadList) noexcept;
69  ~FootprintGraphicsItem() noexcept;
70 
71  // Getters
72  Footprint& getFootprint() noexcept { return mFootprint; }
74  const FootprintPad& pin) noexcept;
75  CircleGraphicsItem* getCircleGraphicsItem(const Circle& circle) noexcept;
76  PolygonGraphicsItem* getPolygonGraphicsItem(const Polygon& polygon) noexcept;
78  HoleGraphicsItem* getHoleGraphicsItem(const Hole& hole) noexcept;
80  const Point& pos, QList<QSharedPointer<FootprintPadGraphicsItem>>* pads,
81  QList<QSharedPointer<CircleGraphicsItem>>* circles,
82  QList<QSharedPointer<PolygonGraphicsItem>>* polygons,
83  QList<QSharedPointer<StrokeTextGraphicsItem>>* texts,
84  QList<QSharedPointer<HoleGraphicsItem>>* holes) noexcept;
85  QList<QSharedPointer<FootprintPadGraphicsItem>> getSelectedPads() noexcept;
86  QList<QSharedPointer<CircleGraphicsItem>> getSelectedCircles() noexcept;
87  QList<QSharedPointer<PolygonGraphicsItem>> getSelectedPolygons() noexcept;
88  QList<QSharedPointer<StrokeTextGraphicsItem>>
89  getSelectedStrokeTexts() noexcept;
90  QList<QSharedPointer<HoleGraphicsItem>> getSelectedHoles() noexcept;
91 
92  // Setters
93  void setPosition(const Point& pos) noexcept;
94  void setRotation(const Angle& rot) noexcept;
95 
96  // General Methods
97  void addPad(FootprintPad& pad) noexcept;
98  void removePad(FootprintPad& pad) noexcept;
99  void addCircle(Circle& circle) noexcept;
100  void removeCircle(Circle& circle) noexcept;
101  void addPolygon(Polygon& polygon) noexcept;
102  void removePolygon(Polygon& polygon) noexcept;
103  void addStrokeText(StrokeText& text) noexcept;
104  void removeStrokeText(StrokeText& text) noexcept;
105  void addHole(Hole& hole) noexcept;
106  void removeHole(Hole& hole) noexcept;
107  void setSelectionRect(const QRectF rect) noexcept;
108 
109  // Inherited from QGraphicsItem
110  QRectF boundingRect() const noexcept override { return QRectF(); }
111  QPainterPath shape() const noexcept override { return QPainterPath(); }
112  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
113  QWidget* widget = 0) noexcept override;
114 
115  // Operator Overloadings
116  FootprintGraphicsItem& operator=(const FootprintGraphicsItem& rhs) = delete;
117 
118 private: // Data
122  QHash<const FootprintPad*, QSharedPointer<FootprintPadGraphicsItem>>
124  QHash<const Circle*, QSharedPointer<CircleGraphicsItem>> mCircleGraphicsItems;
125  QHash<const Polygon*, QSharedPointer<PolygonGraphicsItem>>
127  QHash<const StrokeText*, QSharedPointer<StrokeTextGraphicsItem>>
129  QHash<const Hole*, QSharedPointer<HoleGraphicsItem>> mHoleGraphicsItems;
130 };
131 
132 /*******************************************************************************
133  * End of File
134  ******************************************************************************/
135 
136 } // namespace library
137 } // namespace librepcb
138 
139 #endif // LIBREPCB_LIBRARY_FOOTPRINTGRAPHICSITEM_H
QList< QSharedPointer< HoleGraphicsItem > > getSelectedHoles() noexcept
Definition: footprintgraphicsitem.cpp:214
QList< QSharedPointer< CircleGraphicsItem > > getSelectedCircles() noexcept
Definition: footprintgraphicsitem.cpp:178
QPainterPath shape() const noexceptoverride
Definition: footprintgraphicsitem.h:111
void addStrokeText(StrokeText &text) noexcept
Definition: footprintgraphicsitem.cpp:272
The PolygonGraphicsItem class.
Definition: polygongraphicsitem.h:46
QHash< const Circle *, QSharedPointer< CircleGraphicsItem > > mCircleGraphicsItems
Definition: footprintgraphicsitem.h:124
The Hole class.
Definition: hole.h:46
The StrokeText class.
Definition: stroketext.h:119
const PackagePadList * mPackagePadList
Definition: footprintgraphicsitem.h:121
Footprint & getFootprint() noexcept
Definition: footprintgraphicsitem.h:72
QHash< const Hole *, QSharedPointer< HoleGraphicsItem > > mHoleGraphicsItems
Definition: footprintgraphicsitem.h:129
The HoleGraphicsItem class is the graphical representation of a librepcb::Hole.
Definition: holegraphicsitem.h:48
void removePad(FootprintPad &pad) noexcept
Definition: footprintgraphicsitem.cpp:243
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
The IF_GraphicsLayerProvider class defines an interface for classes which provide layers...
Definition: graphicslayer.h:227
QHash< const Polygon *, QSharedPointer< PolygonGraphicsItem > > mPolygonGraphicsItems
Definition: footprintgraphicsitem.h:126
void removeCircle(Circle &circle) noexcept
Definition: footprintgraphicsitem.cpp:255
QHash< const FootprintPad *, QSharedPointer< FootprintPadGraphicsItem > > mPadGraphicsItems
Definition: footprintgraphicsitem.h:123
~FootprintGraphicsItem() noexcept
Definition: footprintgraphicsitem.cpp:73
int getItemsAtPosition(const Point &pos, QList< QSharedPointer< FootprintPadGraphicsItem >> *pads, QList< QSharedPointer< CircleGraphicsItem >> *circles, QList< QSharedPointer< PolygonGraphicsItem >> *polygons, QList< QSharedPointer< StrokeTextGraphicsItem >> *texts, QList< QSharedPointer< HoleGraphicsItem >> *holes) noexcept
Definition: footprintgraphicsitem.cpp:106
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
void removeHole(Hole &hole) noexcept
Definition: footprintgraphicsitem.cpp:290
QList< QSharedPointer< PolygonGraphicsItem > > getSelectedPolygons() noexcept
Definition: footprintgraphicsitem.cpp:190
StrokeTextGraphicsItem * getTextGraphicsItem(const StrokeText &text) noexcept
Definition: footprintgraphicsitem.cpp:96
void removePolygon(Polygon &polygon) noexcept
Definition: footprintgraphicsitem.cpp:267
Footprint & mFootprint
Definition: footprintgraphicsitem.h:119
FootprintPadGraphicsItem * getPadGraphicsItem(const FootprintPad &pin) noexcept
Definition: footprintgraphicsitem.cpp:81
QList< QSharedPointer< StrokeTextGraphicsItem > > getSelectedStrokeTexts() noexcept
Definition: footprintgraphicsitem.cpp:202
const IF_GraphicsLayerProvider & mLayerProvider
Definition: footprintgraphicsitem.h:120
The FootprintGraphicsItem class.
Definition: footprintgraphicsitem.h:62
The Circle class.
Definition: circle.h:47
void setSelectionRect(const QRectF rect) noexcept
Definition: footprintgraphicsitem.cpp:295
The FootprintPad class represents a pad of a footprint.
Definition: footprintpad.h:52
The CircleGraphicsItem class.
Definition: circlegraphicsitem.h:46
The StrokeTextGraphicsItem class is the graphical representation of a librepcb::StrokeText.
Definition: stroketextgraphicsitem.h:48
The FootprintPadGraphicsItem class.
Definition: footprintpadgraphicsitem.h:53
PolygonGraphicsItem * getPolygonGraphicsItem(const Polygon &polygon) noexcept
Definition: footprintgraphicsitem.cpp:91
QList< QSharedPointer< FootprintPadGraphicsItem > > getSelectedPads() noexcept
Definition: footprintgraphicsitem.cpp:166
void addPad(FootprintPad &pad) noexcept
Definition: footprintgraphicsitem.cpp:236
void addCircle(Circle &circle) noexcept
Definition: footprintgraphicsitem.cpp:248
QRectF boundingRect() const noexceptoverride
Definition: footprintgraphicsitem.h:110
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0) noexceptoverride
Definition: footprintgraphicsitem.cpp:328
void setRotation(const Angle &rot) noexcept
Definition: footprintgraphicsitem.cpp:232
The Polygon class.
Definition: polygon.h:49
HoleGraphicsItem * getHoleGraphicsItem(const Hole &hole) noexcept
Definition: footprintgraphicsitem.cpp:101
void addHole(Hole &hole) noexcept
Definition: footprintgraphicsitem.cpp:284
CircleGraphicsItem * getCircleGraphicsItem(const Circle &circle) noexcept
Definition: footprintgraphicsitem.cpp:86
void setPosition(const Point &pos) noexcept
Definition: footprintgraphicsitem.cpp:228
The Footprint class represents one footprint variant of a package.
Definition: footprint.h:61
void addPolygon(Polygon &polygon) noexcept
Definition: footprintgraphicsitem.cpp:260
QHash< const StrokeText *, QSharedPointer< StrokeTextGraphicsItem > > mStrokeTextGraphicsItems
Definition: footprintgraphicsitem.h:128
void removeStrokeText(StrokeText &text) noexcept
Definition: footprintgraphicsitem.cpp:279