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 
49 class FootprintPadPreviewGraphicsItem final : public QGraphicsItem {
50 public:
51  // Constructors / Destructor
53  const IF_GraphicsLayerProvider& layerProvider, const FootprintPad& fptPad,
54  const PackagePad* pkgPad = nullptr) noexcept;
56 
57  // Setters
58  void setDrawBoundingRect(bool enable) noexcept { mDrawBoundingRect = enable; }
59 
60  // General Methods
61  void updateCacheAndRepaint() noexcept;
62 
63  // Inherited from QGraphicsItem
64  QRectF boundingRect() const noexcept override { return mBoundingRect; }
65  QPainterPath shape() const noexcept override { return mShape; }
66  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
67  QWidget* widget = 0) noexcept override;
68 
69 private:
70  // make some methods inaccessible...
73  const FootprintPadPreviewGraphicsItem& other) = delete;
75  const FootprintPadPreviewGraphicsItem& rhs) = delete;
76 
77  // General Attributes
82 
83  // Cached Attributes
84  QRectF mBoundingRect;
85  QPainterPath mShape;
86  QFont mFont;
87 };
88 
89 /*******************************************************************************
90  * End of File
91  ******************************************************************************/
92 
93 } // namespace library
94 } // namespace librepcb
95 
96 #endif // LIBREPCB_LIBRARY_FOOTPRINTPADPREVIEWGRAPHICSITEM_H
The GraphicsLayer class represents a graphical layer used in schematics and boards.
Definition: graphicslayer.h:50
GraphicsLayer * mLayer
Definition: footprintpadpreviewgraphicsitem.h:80
QFont mFont
Definition: footprintpadpreviewgraphicsitem.h:86
QPainterPath shape() const noexceptoverride
Definition: footprintpadpreviewgraphicsitem.h:65
The IF_GraphicsLayerProvider class defines an interface for classes which provide layers...
Definition: graphicslayer.h:227
bool mDrawBoundingRect
Definition: footprintpadpreviewgraphicsitem.h:81
QRectF boundingRect() const noexceptoverride
Definition: footprintpadpreviewgraphicsitem.h:64
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0) noexceptoverride
Definition: footprintpadpreviewgraphicsitem.cpp:81
The FootprintPadPreviewGraphicsItem class.
Definition: footprintpadpreviewgraphicsitem.h:49
const PackagePad * mPackagePad
Definition: footprintpadpreviewgraphicsitem.h:79
const FootprintPad & mFootprintPad
Definition: footprintpadpreviewgraphicsitem.h:78
The FootprintPad class represents a pad of a footprint.
Definition: footprintpad.h:52
void setDrawBoundingRect(bool enable) noexcept
Definition: footprintpadpreviewgraphicsitem.h:58
QPainterPath mShape
Definition: footprintpadpreviewgraphicsitem.h:85
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:84