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 
55 class FootprintPreviewGraphicsItem final : public QGraphicsItem,
56  public AttributeProvider {
57 public:
58  // Constructors / Destructor
60  const IF_GraphicsLayerProvider& layerProvider,
61  const QStringList& localeOrder, const Footprint& footprint,
62  const Package* package = nullptr, /*const Device* device = nullptr,*/
63  const Component* component = nullptr,
64  const AttributeProvider* attrProvider = nullptr) noexcept;
66 
67  // Setters
68  void setDrawBoundingRect(bool enable) noexcept;
69 
70  // General Methods
71  void updateCacheAndRepaint() noexcept;
72 
73  // Inherited from QGraphicsItem
74  QRectF boundingRect() const noexcept override { return mBoundingRect; }
75  QPainterPath shape() const noexcept override { return mShape; }
76  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
77  QWidget* widget = 0) noexcept override;
78 
79 signals:
80 
82  void attributesChanged() override {}
83 
84 private:
85  // make some methods inaccessible...
88  delete;
90  const FootprintPreviewGraphicsItem& rhs) = delete;
91 
92  // Inherited from AttributeProvider
94  QString getBuiltInAttributeValue(const QString& key) const noexcept override;
95 
96  // General Attributes
99  const Package* mPackage;
100  // const Device* mDevice;
104  QStringList mLocaleOrder;
106 
107  // Cached Attributes
109  QPainterPath mShape;
110 };
111 
112 /*******************************************************************************
113  * End of File
114  ******************************************************************************/
115 
116 } // namespace library
117 } // namespace librepcb
118 
119 #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:99
QPainterPath mShape
Definition: footprintpreviewgraphicsitem.h:109
QStringList mLocaleOrder
Definition: footprintpreviewgraphicsitem.h:104
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:227
~FootprintPreviewGraphicsItem() noexcept
Definition: footprintpreviewgraphicsitem.cpp:87
const IF_GraphicsLayerProvider & mLayerProvider
Definition: footprintpreviewgraphicsitem.h:97
void attributesChanged() override
This signal is emited when the value of attributes has changed.
Definition: footprintpreviewgraphicsitem.h:82
The FootprintPreviewGraphicsItem class.
Definition: footprintpreviewgraphicsitem.h:55
const Footprint & mFootprint
Definition: footprintpreviewgraphicsitem.h:98
QPainterPath shape() const noexceptoverride
Definition: footprintpreviewgraphicsitem.h:75
StrokeTextList mStrokeTexts
Definition: footprintpreviewgraphicsitem.h:105
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0) noexceptoverride
Definition: footprintpreviewgraphicsitem.cpp:137
const AttributeProvider * mAttributeProvider
Definition: footprintpreviewgraphicsitem.h:102
FootprintPreviewGraphicsItem & operator=(const FootprintPreviewGraphicsItem &rhs)=delete
bool mDrawBoundingRect
Definition: footprintpreviewgraphicsitem.h:103
void setDrawBoundingRect(bool enable) noexcept
Definition: footprintpreviewgraphicsitem.cpp:96
void updateCacheAndRepaint() noexcept
Definition: footprintpreviewgraphicsitem.cpp:109
const Component * mComponent
Definition: footprintpreviewgraphicsitem.h:101
QRectF boundingRect() const noexceptoverride
Definition: footprintpreviewgraphicsitem.h:74
The Component class represents a "generic" device in the library.
Definition: component.h:73
QRectF mBoundingRect
Definition: footprintpreviewgraphicsitem.h:108
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:59