LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
footprintpadpreviewgraphicsitem.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_FOOTPRINTPADPREVIEWGRAPHICSITEM_H
21 #define LIBREPCB_LIBRARY_FOOTPRINTPADPREVIEWGRAPHICSITEM_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include <QtCore>
27 #include <QtWidgets>
28 
29 /*******************************************************************************
30  * Namespace / Forward Declarations
31  ******************************************************************************/
32 namespace librepcb {
33 
34 class GraphicsLayer;
35 class IF_GraphicsLayerProvider;
36 
37 namespace library {
38 
39 class PackagePad;
40 class FootprintPad;
41 
42 /*******************************************************************************
43  * Class FootprintPadPreviewGraphicsItem
44  ******************************************************************************/
45 
52 class FootprintPadPreviewGraphicsItem final : public QGraphicsItem {
53 public:
54  // Constructors / Destructor
56  const IF_GraphicsLayerProvider& layerProvider, const FootprintPad& fptPad,
57  const PackagePad* pkgPad = nullptr) noexcept;
59 
60  // Setters
61  void setDrawBoundingRect(bool enable) noexcept { mDrawBoundingRect = enable; }
62 
63  // General Methods
64  void updateCacheAndRepaint() noexcept;
65 
66  // Inherited from QGraphicsItem
67  QRectF boundingRect() const noexcept override { return mBoundingRect; }
68  QPainterPath shape() const noexcept override { return mShape; }
69  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
70  QWidget* widget = 0) noexcept override;
71 
72 private:
73  // make some methods inaccessible...
76  const FootprintPadPreviewGraphicsItem& other) = delete;
78  const FootprintPadPreviewGraphicsItem& rhs) = delete;
79 
80  // General Attributes
85 
86  // Cached Attributes
87  QRectF mBoundingRect;
88  QPainterPath mShape;
89  QFont mFont;
90 };
91 
92 /*******************************************************************************
93  * End of File
94  ******************************************************************************/
95 
96 } // namespace library
97 } // namespace librepcb
98 
99 #endif // LIBREPCB_LIBRARY_FOOTPRINTPADPREVIEWGRAPHICSITEM_H
The GraphicsLayer class represents a graphical layer used in schematics and boards.
Definition: graphicslayer.h:54
GraphicsLayer * mLayer
Definition: footprintpadpreviewgraphicsitem.h:83
QFont mFont
Definition: footprintpadpreviewgraphicsitem.h:89
QPainterPath shape() const noexceptoverride
Definition: footprintpadpreviewgraphicsitem.h:68
The IF_GraphicsLayerProvider class defines an interface for classes which provide layers...
Definition: graphicslayer.h:250
bool mDrawBoundingRect
Definition: footprintpadpreviewgraphicsitem.h:84
QRectF boundingRect() const noexceptoverride
Definition: footprintpadpreviewgraphicsitem.h:67
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0) noexceptoverride
Definition: footprintpadpreviewgraphicsitem.cpp:81
The FootprintPadPreviewGraphicsItem class.
Definition: footprintpadpreviewgraphicsitem.h:52
const PackagePad * mPackagePad
Definition: footprintpadpreviewgraphicsitem.h:82
const FootprintPad & mFootprintPad
Definition: footprintpadpreviewgraphicsitem.h:81
The FootprintPad class represents a pad of a footprint.
Definition: footprintpad.h:52
void setDrawBoundingRect(bool enable) noexcept
Definition: footprintpadpreviewgraphicsitem.h:61
QPainterPath mShape
Definition: footprintpadpreviewgraphicsitem.h:88
void updateCacheAndRepaint() noexcept
Definition: footprintpadpreviewgraphicsitem.cpp:70
~FootprintPadPreviewGraphicsItem() noexcept
Definition: footprintpadpreviewgraphicsitem.cpp:63
The PackagePad class represents one logical pad of a package.
Definition: packagepad.h:51
QRectF mBoundingRect
Definition: footprintpadpreviewgraphicsitem.h:87