LibrePCB Developers Documentation
Loading...
Searching...
No Matches
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 setToolTipText(const QString& text) noexcept;
73 void setLayer(const QString& layerName) noexcept;
74 void setGeometries(const QHash<const Layer*, QList<PadGeometry>>& geometries,
75 const Length& clearance) noexcept;
76
77 // Inherited from QGraphicsItem
78 QPainterPath shape() const noexcept override;
79
80 // Operator Overloadings
82 const PrimitiveFootprintPadGraphicsItem& rhs) = delete;
83
84private: // Methods
85 void layerEdited(const GraphicsLayer& layer,
86 GraphicsLayer::Event event) noexcept;
87 virtual QVariant itemChange(GraphicsItemChange change,
88 const QVariant& value) noexcept override;
89 void updatePathLayers() noexcept;
90 void updateTextHeight() noexcept;
91 void updateRegisteredLayers() noexcept;
92
93private: // Data
95 bool mMirror;
99 struct PathItem {
100 std::shared_ptr<GraphicsLayer> layer;
103 std::shared_ptr<PrimitivePathGraphicsItem> item;
104 };
105 QVector<PathItem> mPathGraphicsItems;
106 QMap<std::shared_ptr<GraphicsLayer>, QPainterPath> mShapes;
108
109 // Slots
111};
112
113/*******************************************************************************
114 * End of File
115 ******************************************************************************/
116
117} // namespace editor
118} // namespace librepcb
119
120#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition angle.h:76
The Layer class provides all supported geometry layers.
Definition layer.h:42
The Length class is used to represent a length (for example 12.75 millimeters)
Definition length.h:82
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:78
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:97
std::shared_ptr< GraphicsLayer > mCopperLayer
Definition primitivefootprintpadgraphicsitem.h:96
PrimitiveFootprintPadGraphicsItem(const PrimitiveFootprintPadGraphicsItem &other)=delete
void updateTextHeight() noexcept
Definition primitivefootprintpadgraphicsitem.cpp:268
QMap< std::shared_ptr< GraphicsLayer >, QPainterPath > mShapes
Definition primitivefootprintpadgraphicsitem.h:106
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) noexcept override
Definition primitivefootprintpadgraphicsitem.cpp:223
QScopedPointer< PrimitivePathGraphicsItem > mTextGraphicsItem
Definition primitivefootprintpadgraphicsitem.h:98
void setText(const QString &text) noexcept
Definition primitivefootprintpadgraphicsitem.cpp:112
void updatePathLayers() noexcept
Definition primitivefootprintpadgraphicsitem.cpp:253
QPainterPath shape() const noexcept override
Definition primitivefootprintpadgraphicsitem.cpp:207
QVector< PathItem > mPathGraphicsItems
Definition primitivefootprintpadgraphicsitem.h:105
GraphicsLayer::OnEditedSlot mOnLayerEditedSlot
Definition primitivefootprintpadgraphicsitem.h:110
void setGeometries(const QHash< const Layer *, QList< PadGeometry > > &geometries, const Length &clearance) noexcept
Definition primitivefootprintpadgraphicsitem.cpp:141
bool mMirror
Definition primitivefootprintpadgraphicsitem.h:95
void setLayer(const QString &layerName) noexcept
Definition primitivefootprintpadgraphicsitem.cpp:130
const IF_GraphicsLayerProvider & mLayerProvider
Definition primitivefootprintpadgraphicsitem.h:94
void setMirrored(bool mirrored) noexcept
Definition primitivefootprintpadgraphicsitem.cpp:105
void layerEdited(const GraphicsLayer &layer, GraphicsLayer::Event event) noexcept
Definition primitivefootprintpadgraphicsitem.cpp:240
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:278
QRectF mShapesBoundingRect
Definition primitivefootprintpadgraphicsitem.h:107
void setToolTipText(const QString &text) noexcept
Definition primitivefootprintpadgraphicsitem.cpp:121
The PrimitivePathGraphicsItem class.
Definition primitivepathgraphicsitem.h:50
Definition occmodel.cpp:76
Definition uuid.h:186
Definition primitivefootprintpadgraphicsitem.h:99
bool isClearance
Definition primitivefootprintpadgraphicsitem.h:102
std::shared_ptr< GraphicsLayer > layer
Definition primitivefootprintpadgraphicsitem.h:100
bool isCopper
Definition primitivefootprintpadgraphicsitem.h:101
std::shared_ptr< PrimitivePathGraphicsItem > item
Definition primitivefootprintpadgraphicsitem.h:103