LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
footprintpreviewgraphicsitem.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_FOOTPRINTPREVIEWGRAPHICSITEM_H
21 #define LIBREPCB_LIBRARY_FOOTPRINTPREVIEWGRAPHICSITEM_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
28 #include <librepcb/common/uuid.h>
29 
30 #include <QtCore>
31 #include <QtWidgets>
32 
33 /*******************************************************************************
34  * Namespace / Forward Declarations
35  ******************************************************************************/
36 namespace librepcb {
37 
38 class GraphicsLayer;
39 class IF_GraphicsLayerProvider;
40 
41 namespace library {
42 
43 class Component;
44 // class Device;
45 class Package;
46 class Footprint;
47 
48 /*******************************************************************************
49  * Class FootprintPreviewGraphicsItem
50  ******************************************************************************/
51 
58 class FootprintPreviewGraphicsItem final : public QGraphicsItem,
59  public AttributeProvider {
60 public:
61  // Constructors / Destructor
63  const IF_GraphicsLayerProvider& layerProvider,
64  const QStringList& localeOrder, const Footprint& footprint,
65  const Package* package = nullptr, /*const Device* device = nullptr,*/
66  const Component* component = nullptr,
67  const AttributeProvider* attrProvider = nullptr) noexcept;
69 
70  // Setters
71  void setDrawBoundingRect(bool enable) noexcept;
72 
73  // General Methods
74  void updateCacheAndRepaint() noexcept;
75 
76  // Inherited from QGraphicsItem
77  QRectF boundingRect() const noexcept override { return mBoundingRect; }
78  QPainterPath shape() const noexcept override { return mShape; }
79  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
80  QWidget* widget = 0) noexcept override;
81 
82 signals:
83 
85  void attributesChanged() override {}
86 
87 private:
88  // make some methods inaccessible...
91  delete;
93  const FootprintPreviewGraphicsItem& rhs) = delete;
94 
95  // Inherited from AttributeProvider
97  QString getBuiltInAttributeValue(const QString& key) const noexcept override;
98 
99  // General Attributes
103  // const Device* mDevice;
107  QStringList mLocaleOrder;
109 
110  // Cached Attributes
112  QPainterPath mShape;
113 };
114 
115 /*******************************************************************************
116  * End of File
117  ******************************************************************************/
118 
119 } // namespace library
120 } // namespace librepcb
121 
122 #endif // LIBREPCB_LIBRARY_FOOTPRINTPREVIEWGRAPHICSITEM_H
QString getBuiltInAttributeValue(const QString &key) const noexceptoverride
Get the value of a built-in attribute (if available)
Definition: footprintpreviewgraphicsitem.cpp:223
const Package * mPackage
Definition: footprintpreviewgraphicsitem.h:102
QPainterPath mShape
Definition: footprintpreviewgraphicsitem.h:112
QStringList mLocaleOrder
Definition: footprintpreviewgraphicsitem.h:107
The Package class represents a package of a component (including footprint and 3D model) ...
Definition: package.h:56
The IF_GraphicsLayerProvider class defines an interface for classes which provide layers...
Definition: graphicslayer.h:250
~FootprintPreviewGraphicsItem() noexcept
Definition: footprintpreviewgraphicsitem.cpp:87
const IF_GraphicsLayerProvider & mLayerProvider
Definition: footprintpreviewgraphicsitem.h:100
void attributesChanged() override
This signal is emited when the value of attributes has changed.
Definition: footprintpreviewgraphicsitem.h:85
The FootprintPreviewGraphicsItem class.
Definition: footprintpreviewgraphicsitem.h:58
const Footprint & mFootprint
Definition: footprintpreviewgraphicsitem.h:101
QPainterPath shape() const noexceptoverride
Definition: footprintpreviewgraphicsitem.h:78
StrokeTextList mStrokeTexts
Definition: footprintpreviewgraphicsitem.h:108
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0) noexceptoverride
Definition: footprintpreviewgraphicsitem.cpp:137
const AttributeProvider * mAttributeProvider
Definition: footprintpreviewgraphicsitem.h:105
FootprintPreviewGraphicsItem & operator=(const FootprintPreviewGraphicsItem &rhs)=delete
bool mDrawBoundingRect
Definition: footprintpreviewgraphicsitem.h:106
void setDrawBoundingRect(bool enable) noexcept
Definition: footprintpreviewgraphicsitem.cpp:96
void updateCacheAndRepaint() noexcept
Definition: footprintpreviewgraphicsitem.cpp:109
const Component * mComponent
Definition: footprintpreviewgraphicsitem.h:104
QRectF boundingRect() const noexceptoverride
Definition: footprintpreviewgraphicsitem.h:77
The Component class represents a "generic" device in the library.
Definition: component.h:73
QRectF mBoundingRect
Definition: footprintpreviewgraphicsitem.h:111
The Footprint class represents one footprint variant of a package.
Definition: footprint.h:61
The AttributeProvider class defines an interface for classes which provides some attributes which can...
Definition: attributeprovider.h:62