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 
63 class FootprintGraphicsItem final : public QGraphicsItem {
64 public:
65  // Constructors / Destructor
66  FootprintGraphicsItem() = delete;
67  FootprintGraphicsItem(const FootprintGraphicsItem& other) = delete;
69  const IF_GraphicsLayerProvider& lp) noexcept;
70  ~FootprintGraphicsItem() noexcept;
71 
72  // Getters
73  Footprint& getFootprint() noexcept { return mFootprint; }
75  const FootprintPad& pin) noexcept;
76  CircleGraphicsItem* getCircleGraphicsItem(const Circle& circle) noexcept;
77  PolygonGraphicsItem* getPolygonGraphicsItem(const Polygon& polygon) noexcept;
79  HoleGraphicsItem* getHoleGraphicsItem(const Hole& hole) noexcept;
81  const Point& pos, QList<QSharedPointer<FootprintPadGraphicsItem>>* pads,
82  QList<QSharedPointer<CircleGraphicsItem>>* circles,
83  QList<QSharedPointer<PolygonGraphicsItem>>* polygons,
84  QList<QSharedPointer<StrokeTextGraphicsItem>>* texts,
85  QList<QSharedPointer<HoleGraphicsItem>>* holes) noexcept;
86  QList<QSharedPointer<FootprintPadGraphicsItem>> getSelectedPads() noexcept;
87  QList<QSharedPointer<CircleGraphicsItem>> getSelectedCircles() noexcept;
88  QList<QSharedPointer<PolygonGraphicsItem>> getSelectedPolygons() noexcept;
89  QList<QSharedPointer<StrokeTextGraphicsItem>>
90  getSelectedStrokeTexts() noexcept;
91  QList<QSharedPointer<HoleGraphicsItem>> getSelectedHoles() noexcept;
92 
93  // Setters
94  void setPosition(const Point& pos) noexcept;
95  void setRotation(const Angle& rot) noexcept;
96 
97  // General Methods
98  void addPad(FootprintPad& pad) noexcept;
99  void removePad(FootprintPad& pad) noexcept;
100  void addCircle(Circle& circle) noexcept;
101  void removeCircle(Circle& circle) noexcept;
102  void addPolygon(Polygon& polygon) noexcept;
103  void removePolygon(Polygon& polygon) noexcept;
104  void addStrokeText(StrokeText& text) noexcept;
105  void removeStrokeText(StrokeText& text) noexcept;
106  void addHole(Hole& hole) noexcept;
107  void removeHole(Hole& hole) noexcept;
108  void setSelectionRect(const QRectF rect) noexcept;
109 
110  // Inherited from QGraphicsItem
111  QRectF boundingRect() const noexcept override { return QRectF(); }
112  QPainterPath shape() const noexcept override { return QPainterPath(); }
113  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
114  QWidget* widget = 0) noexcept override;
115 
116  // Operator Overloadings
117  FootprintGraphicsItem& operator=(const FootprintGraphicsItem& rhs) = delete;
118 
119 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:210
QList< QSharedPointer< CircleGraphicsItem > > getSelectedCircles() noexcept
Definition: footprintgraphicsitem.cpp:174
QPainterPath shape() const noexceptoverride
Definition: footprintgraphicsitem.h:112
void addStrokeText(StrokeText &text) noexcept
Definition: footprintgraphicsitem.cpp:268
The PolygonGraphicsItem class.
Definition: polygongraphicsitem.h:49
QHash< const Circle *, QSharedPointer< CircleGraphicsItem > > mCircleGraphicsItems
Definition: footprintgraphicsitem.h:124
The Hole class.
Definition: hole.h:69
The StrokeText class.
Definition: stroketext.h:153
Footprint & getFootprint() noexcept
Definition: footprintgraphicsitem.h:73
QHash< const Hole *, QSharedPointer< HoleGraphicsItem > > mHoleGraphicsItems
Definition: footprintgraphicsitem.h:129
The HoleGraphicsItem class is the graphical representation of a librepcb::Text.
Definition: holegraphicsitem.h:51
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:81
The IF_GraphicsLayerProvider class defines an interface for classes which provide layers...
Definition: graphicslayer.h:250
QHash< const Polygon *, QSharedPointer< PolygonGraphicsItem > > mPolygonGraphicsItems
Definition: footprintgraphicsitem.h:126
void removeCircle(Circle &circle) noexcept
Definition: footprintgraphicsitem.cpp:251
QHash< const FootprintPad *, QSharedPointer< FootprintPadGraphicsItem > > mPadGraphicsItems
Definition: footprintgraphicsitem.h:123
~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:81
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:120
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:121
The FootprintGraphicsItem class.
Definition: footprintgraphicsitem.h:63
The Circle class.
Definition: circle.h:76
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:49
The StrokeTextGraphicsItem class is the graphical representation of a librepcb::StrokeText.
Definition: stroketextgraphicsitem.h:48
The FootprintPadGraphicsItem class.
Definition: footprintpadgraphicsitem.h:54
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:111
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:76
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:128
void removeStrokeText(StrokeText &text) noexcept
Definition: footprintgraphicsitem.cpp:275