LibrePCB Developers Documentation
primitivefootprintpadgraphicsitem.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_EDITOR_PRIMITIVEFOOTPRINTPADGRAPHICSITEM_H
21#define LIBREPCB_EDITOR_PRIMITIVEFOOTPRINTPADGRAPHICSITEM_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "graphicslayer.h"
27
28#include <QtCore>
29#include <QtWidgets>
30
31#include <memory>
32
33/*******************************************************************************
34 * Namespace / Forward Declarations
35 ******************************************************************************/
36namespace librepcb {
37
38class Angle;
39class Layer;
40class Length;
41class PadGeometry;
42class Point;
43
44namespace editor {
45
46class OriginCrossGraphicsItem;
47class PrimitivePathGraphicsItem;
48
49/*******************************************************************************
50 * Class PrimitiveFootprintPadGraphicsItem
51 ******************************************************************************/
52
56class PrimitiveFootprintPadGraphicsItem final : public QGraphicsItemGroup {
57public:
58 // Constructors / Destructor
61 const PrimitiveFootprintPadGraphicsItem& other) = delete;
63 bool originCrossVisible,
64 QGraphicsItem* parent = nullptr) noexcept;
66
67 // Setters
68 void setPosition(const Point& position) noexcept;
69 void setRotation(const Angle& rotation) noexcept;
70 void setMirrored(bool mirrored) noexcept;
71 void setText(const QString& text) noexcept;
72 void setLayer(const QString& layerName) noexcept;
73 void setGeometries(const QHash<const Layer*, QList<PadGeometry>>& geometries,
74 const Length& clearance) noexcept;
75
76 // Inherited from QGraphicsItem
77 QPainterPath shape() const noexcept override;
78
79 // Operator Overloadings
81 const PrimitiveFootprintPadGraphicsItem& rhs) = delete;
82
83private: // Methods
84 void layerEdited(const GraphicsLayer& layer,
85 GraphicsLayer::Event event) noexcept;
86 virtual QVariant itemChange(GraphicsItemChange change,
87 const QVariant& value) noexcept override;
88 void updatePathLayers() noexcept;
89 void updateTextHeight() noexcept;
90 void updateRegisteredLayers() noexcept;
91
92private: // Data
94 bool mMirror;
95 std::shared_ptr<GraphicsLayer> mCopperLayer;
98 struct PathItem {
99 std::shared_ptr<GraphicsLayer> layer;
102 std::shared_ptr<PrimitivePathGraphicsItem> item;
103 };
104 QVector<PathItem> mPathGraphicsItems;
105 QMap<std::shared_ptr<GraphicsLayer>, QPainterPath> mShapes;
107
108 // Slots
110};
111
112/*******************************************************************************
113 * End of File
114 ******************************************************************************/
115
116} // namespace editor
117} // namespace librepcb
118
119#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
The Layer class provides all supported geometry layers.
Definition: layer.h:40
The Length class is used to represent a length (for example 12.75 millimeters)
Definition: length.h:83
The PadGeometry class describes the shape of a pad.
Definition: padgeometry.h:46
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition: point.h:79
The GraphicsLayer class represents a graphical layer used in schematics and boards.
Definition: graphicslayer.h:53
The IF_GraphicsLayerProvider class defines an interface for classes which provide layers.
Definition: graphicslayer.h:111
The OriginCrossGraphicsItem class.
Definition: origincrossgraphicsitem.h:50
The PrimitiveFootprintPadGraphicsItem class.
Definition: primitivefootprintpadgraphicsitem.h:56
QScopedPointer< OriginCrossGraphicsItem > mOriginCrossGraphicsItem
Definition: primitivefootprintpadgraphicsitem.h:96
std::shared_ptr< GraphicsLayer > mCopperLayer
Definition: primitivefootprintpadgraphicsitem.h:95
PrimitiveFootprintPadGraphicsItem(const PrimitiveFootprintPadGraphicsItem &other)=delete
void updateTextHeight() noexcept
Definition: primitivefootprintpadgraphicsitem.cpp:265
QMap< std::shared_ptr< GraphicsLayer >, QPainterPath > mShapes
Definition: primitivefootprintpadgraphicsitem.h:105
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) noexcept override
Definition: primitivefootprintpadgraphicsitem.cpp:220
QScopedPointer< PrimitivePathGraphicsItem > mTextGraphicsItem
Definition: primitivefootprintpadgraphicsitem.h:97
void setText(const QString &text) noexcept
Definition: primitivefootprintpadgraphicsitem.cpp:112
void updatePathLayers() noexcept
Definition: primitivefootprintpadgraphicsitem.cpp:250
QPainterPath shape() const noexcept override
Definition: primitivefootprintpadgraphicsitem.cpp:204
QVector< PathItem > mPathGraphicsItems
Definition: primitivefootprintpadgraphicsitem.h:104
GraphicsLayer::OnEditedSlot mOnLayerEditedSlot
Definition: primitivefootprintpadgraphicsitem.h:109
void setGeometries(const QHash< const Layer *, QList< PadGeometry > > &geometries, const Length &clearance) noexcept
Definition: primitivefootprintpadgraphicsitem.cpp:138
bool mMirror
Definition: primitivefootprintpadgraphicsitem.h:94
void setLayer(const QString &layerName) noexcept
Definition: primitivefootprintpadgraphicsitem.cpp:127
const IF_GraphicsLayerProvider & mLayerProvider
Definition: primitivefootprintpadgraphicsitem.h:93
void setMirrored(bool mirrored) noexcept
Definition: primitivefootprintpadgraphicsitem.cpp:105
void layerEdited(const GraphicsLayer &layer, GraphicsLayer::Event event) noexcept
Definition: primitivefootprintpadgraphicsitem.cpp:237
void setRotation(const Angle &rotation) noexcept
Definition: primitivefootprintpadgraphicsitem.cpp:96
void setPosition(const Point &position) noexcept
Definition: primitivefootprintpadgraphicsitem.cpp:91
void updateRegisteredLayers() noexcept
Definition: primitivefootprintpadgraphicsitem.cpp:275
QRectF mShapesBoundingRect
Definition: primitivefootprintpadgraphicsitem.h:106
The PrimitivePathGraphicsItem class.
Definition: primitivepathgraphicsitem.h:50
Definition: occmodel.cpp:77
Definition: primitivefootprintpadgraphicsitem.h:98
bool isClearance
Definition: primitivefootprintpadgraphicsitem.h:101
std::shared_ptr< GraphicsLayer > layer
Definition: primitivefootprintpadgraphicsitem.h:99
bool isCopper
Definition: primitivefootprintpadgraphicsitem.h:100
std::shared_ptr< PrimitivePathGraphicsItem > item
Definition: primitivefootprintpadgraphicsitem.h:102