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  ******************************************************************************/
27 #include <librepcb/common/uuid.h>
28 
29 #include <QtCore>
30 #include <QtWidgets>
31 
32 /*******************************************************************************
33  * Namespace / Forward Declarations
34  ******************************************************************************/
35 namespace librepcb {
36 
37 class Circle;
38 class Polygon;
39 class StrokeText;
40 class Hole;
41 class IF_GraphicsLayerProvider;
42 class PolygonGraphicsItem;
43 class CircleGraphicsItem;
44 class StrokeTextGraphicsItem;
45 class HoleGraphicsItem;
46 
47 namespace library {
48 
49 class Footprint;
50 class FootprintPad;
51 class FootprintPadGraphicsItem;
52 
53 /*******************************************************************************
54  * Class FootprintGraphicsItem
55  ******************************************************************************/
56 
60 class FootprintGraphicsItem final : public QGraphicsItem {
61 public:
62  // Constructors / Destructor
63  FootprintGraphicsItem() = delete;
64  FootprintGraphicsItem(const FootprintGraphicsItem& other) = delete;
66  const IF_GraphicsLayerProvider& lp) noexcept;
67  ~FootprintGraphicsItem() noexcept;
68 
69  // Getters
70  Footprint& getFootprint() noexcept { return mFootprint; }
72  const FootprintPad& pin) noexcept;
73  CircleGraphicsItem* getCircleGraphicsItem(const Circle& circle) noexcept;
74  PolygonGraphicsItem* getPolygonGraphicsItem(const Polygon& polygon) noexcept;
76  HoleGraphicsItem* getHoleGraphicsItem(const Hole& hole) noexcept;
78  const Point& pos, QList<QSharedPointer<FootprintPadGraphicsItem>>* pads,
79  QList<QSharedPointer<CircleGraphicsItem>>* circles,
80  QList<QSharedPointer<PolygonGraphicsItem>>* polygons,
81  QList<QSharedPointer<StrokeTextGraphicsItem>>* texts,
82  QList<QSharedPointer<HoleGraphicsItem>>* holes) noexcept;
83  QList<QSharedPointer<FootprintPadGraphicsItem>> getSelectedPads() noexcept;
84  QList<QSharedPointer<CircleGraphicsItem>> getSelectedCircles() noexcept;
85  QList<QSharedPointer<PolygonGraphicsItem>> getSelectedPolygons() noexcept;
86  QList<QSharedPointer<StrokeTextGraphicsItem>>
87  getSelectedStrokeTexts() noexcept;
88  QList<QSharedPointer<HoleGraphicsItem>> getSelectedHoles() noexcept;
89 
90  // Setters
91  void setPosition(const Point& pos) noexcept;
92  void setRotation(const Angle& rot) noexcept;
93 
94  // General Methods
95  void addPad(FootprintPad& pad) noexcept;
96  void removePad(FootprintPad& pad) noexcept;
97  void addCircle(Circle& circle) noexcept;
98  void removeCircle(Circle& circle) noexcept;
99  void addPolygon(Polygon& polygon) noexcept;
100  void removePolygon(Polygon& polygon) noexcept;
101  void addStrokeText(StrokeText& text) noexcept;
102  void removeStrokeText(StrokeText& text) noexcept;
103  void addHole(Hole& hole) noexcept;
104  void removeHole(Hole& hole) noexcept;
105  void setSelectionRect(const QRectF rect) noexcept;
106 
107  // Inherited from QGraphicsItem
108  QRectF boundingRect() const noexcept override { return QRectF(); }
109  QPainterPath shape() const noexcept override { return QPainterPath(); }
110  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
111  QWidget* widget = 0) noexcept override;
112 
113  // Operator Overloadings
114  FootprintGraphicsItem& operator=(const FootprintGraphicsItem& rhs) = delete;
115 
116 private: // Data
119  QHash<const FootprintPad*, QSharedPointer<FootprintPadGraphicsItem>>
121  QHash<const Circle*, QSharedPointer<CircleGraphicsItem>> mCircleGraphicsItems;
122  QHash<const Polygon*, QSharedPointer<PolygonGraphicsItem>>
124  QHash<const StrokeText*, QSharedPointer<StrokeTextGraphicsItem>>
126  QHash<const Hole*, QSharedPointer<HoleGraphicsItem>> mHoleGraphicsItems;
127 };
128 
129 /*******************************************************************************
130  * End of File
131  ******************************************************************************/
132 
133 } // namespace library
134 } // namespace librepcb
135 
136 #endif // LIBREPCB_LIBRARY_FOOTPRINTGRAPHICSITEM_H
QList< QSharedPointer< HoleGraphicsItem > > getSelectedHoles() noexcept
Definition: footprintgraphicsitem.cpp:210
QList< QSharedPointer< CircleGraphicsItem > > getSelectedCircles() noexcept
Definition: footprintgraphicsitem.cpp:174
QPainterPath shape() const noexceptoverride
Definition: footprintgraphicsitem.h:109
void addStrokeText(StrokeText &text) noexcept
Definition: footprintgraphicsitem.cpp:268
The PolygonGraphicsItem class.
Definition: polygongraphicsitem.h:46
QHash< const Circle *, QSharedPointer< CircleGraphicsItem > > mCircleGraphicsItems
Definition: footprintgraphicsitem.h:121
The Hole class.
Definition: hole.h:46
The StrokeText class.
Definition: stroketext.h:119
Footprint & getFootprint() noexcept
Definition: footprintgraphicsitem.h:70
QHash< const Hole *, QSharedPointer< HoleGraphicsItem > > mHoleGraphicsItems
Definition: footprintgraphicsitem.h:126
The HoleGraphicsItem class is the graphical representation of a librepcb::Hole.
Definition: holegraphicsitem.h:48
void removePad(FootprintPad &pad) noexcept
Definition: footprintgraphicsitem.cpp:239
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:123
void removeCircle(Circle &circle) noexcept
Definition: footprintgraphicsitem.cpp:251
QHash< const FootprintPad *, QSharedPointer< FootprintPadGraphicsItem > > mPadGraphicsItems
Definition: footprintgraphicsitem.h:120
~FootprintGraphicsItem() noexcept
Definition: footprintgraphicsitem.cpp:69
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:102
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:286
QList< QSharedPointer< PolygonGraphicsItem > > getSelectedPolygons() noexcept
Definition: footprintgraphicsitem.cpp:186
StrokeTextGraphicsItem * getTextGraphicsItem(const StrokeText &text) noexcept
Definition: footprintgraphicsitem.cpp:92
void removePolygon(Polygon &polygon) noexcept
Definition: footprintgraphicsitem.cpp:263
Footprint & mFootprint
Definition: footprintgraphicsitem.h:117
FootprintPadGraphicsItem * getPadGraphicsItem(const FootprintPad &pin) noexcept
Definition: footprintgraphicsitem.cpp:77
QList< QSharedPointer< StrokeTextGraphicsItem > > getSelectedStrokeTexts() noexcept
Definition: footprintgraphicsitem.cpp:198
const IF_GraphicsLayerProvider & mLayerProvider
Definition: footprintgraphicsitem.h:118
The FootprintGraphicsItem class.
Definition: footprintgraphicsitem.h:60
The Circle class.
Definition: circle.h:47
void setSelectionRect(const QRectF rect) noexcept
Definition: footprintgraphicsitem.cpp:291
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:51
PolygonGraphicsItem * getPolygonGraphicsItem(const Polygon &polygon) noexcept
Definition: footprintgraphicsitem.cpp:87
QList< QSharedPointer< FootprintPadGraphicsItem > > getSelectedPads() noexcept
Definition: footprintgraphicsitem.cpp:162
void addPad(FootprintPad &pad) noexcept
Definition: footprintgraphicsitem.cpp:232
void addCircle(Circle &circle) noexcept
Definition: footprintgraphicsitem.cpp:244
QRectF boundingRect() const noexceptoverride
Definition: footprintgraphicsitem.h:108
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0) noexceptoverride
Definition: footprintgraphicsitem.cpp:324
void setRotation(const Angle &rot) noexcept
Definition: footprintgraphicsitem.cpp:228
The Polygon class.
Definition: polygon.h:49
HoleGraphicsItem * getHoleGraphicsItem(const Hole &hole) noexcept
Definition: footprintgraphicsitem.cpp:97
void addHole(Hole &hole) noexcept
Definition: footprintgraphicsitem.cpp:280
CircleGraphicsItem * getCircleGraphicsItem(const Circle &circle) noexcept
Definition: footprintgraphicsitem.cpp:82
void setPosition(const Point &pos) noexcept
Definition: footprintgraphicsitem.cpp:224
The Footprint class represents one footprint variant of a package.
Definition: footprint.h:61
void addPolygon(Polygon &polygon) noexcept
Definition: footprintgraphicsitem.cpp:256
QHash< const StrokeText *, QSharedPointer< StrokeTextGraphicsItem > > mStrokeTextGraphicsItems
Definition: footprintgraphicsitem.h:125
void removeStrokeText(StrokeText &text) noexcept
Definition: footprintgraphicsitem.cpp:275