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 GraphicsLayerList;
47class OriginCrossGraphicsItem;
48class PrimitivePathGraphicsItem;
49
50/*******************************************************************************
51 * Class PrimitiveFootprintPadGraphicsItem
52 ******************************************************************************/
53
57class PrimitiveFootprintPadGraphicsItem final : public QGraphicsItemGroup {
58public:
59 // Constructors / Destructor
62 const PrimitiveFootprintPadGraphicsItem& other) = delete;
64 bool originCrossVisible,
65 QGraphicsItem* parent = nullptr) noexcept;
67
68 // Setters
69 void setPosition(const Point& position) noexcept;
70 void setRotation(const Angle& rotation) noexcept;
71 void setMirrored(bool mirrored) noexcept;
72 void setText(const QString& text) noexcept;
73 void setToolTipText(const QString& text) noexcept;
74 void setLayer(const QString& layerName) noexcept;
75 void setGeometries(const QHash<const Layer*, QList<PadGeometry>>& geometries,
76 const Length& clearance) noexcept;
77
78 // Inherited from QGraphicsItem
79 QPainterPath shape() const noexcept override;
80
81 // Operator Overloadings
83 const PrimitiveFootprintPadGraphicsItem& rhs) = delete;
84
85private: // Methods
86 void layerEdited(const GraphicsLayer& layer,
87 GraphicsLayer::Event event) noexcept;
88 virtual QVariant itemChange(GraphicsItemChange change,
89 const QVariant& value) noexcept override;
90 void updatePathLayers() noexcept;
91 void updateTextHeight() noexcept;
92 void updateRegisteredLayers() noexcept;
93
94private: // Data
96 bool mMirror;
97 std::shared_ptr<const GraphicsLayer> mCopperLayer;
100 struct PathItem {
101 std::shared_ptr<const GraphicsLayer> layer;
104 std::shared_ptr<PrimitivePathGraphicsItem> item;
105 };
106 QVector<PathItem> mPathGraphicsItems;
107 QMap<std::shared_ptr<const GraphicsLayer>, QPainterPath> mShapes;
109
110 // Slots
112};
113
114/*******************************************************************************
115 * End of File
116 ******************************************************************************/
117
118} // namespace editor
119} // namespace librepcb
120
121#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 GraphicsLayerList class.
Definition graphicslayerlist.h:48
The OriginCrossGraphicsItem class.
Definition origincrossgraphicsitem.h:50
The PrimitiveFootprintPadGraphicsItem class.
Definition primitivefootprintpadgraphicsitem.h:57
QScopedPointer< OriginCrossGraphicsItem > mOriginCrossGraphicsItem
Definition primitivefootprintpadgraphicsitem.h:98
PrimitiveFootprintPadGraphicsItem(const PrimitiveFootprintPadGraphicsItem &other)=delete
void updateTextHeight() noexcept
Definition primitivefootprintpadgraphicsitem.cpp:269
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) noexcept override
Definition primitivefootprintpadgraphicsitem.cpp:224
std::shared_ptr< const GraphicsLayer > mCopperLayer
Definition primitivefootprintpadgraphicsitem.h:97
QScopedPointer< PrimitivePathGraphicsItem > mTextGraphicsItem
Definition primitivefootprintpadgraphicsitem.h:99
void setText(const QString &text) noexcept
Definition primitivefootprintpadgraphicsitem.cpp:113
void updatePathLayers() noexcept
Definition primitivefootprintpadgraphicsitem.cpp:254
const GraphicsLayerList & mLayers
Definition primitivefootprintpadgraphicsitem.h:95
QPainterPath shape() const noexcept override
Definition primitivefootprintpadgraphicsitem.cpp:208
QVector< PathItem > mPathGraphicsItems
Definition primitivefootprintpadgraphicsitem.h:106
GraphicsLayer::OnEditedSlot mOnLayerEditedSlot
Definition primitivefootprintpadgraphicsitem.h:111
void setGeometries(const QHash< const Layer *, QList< PadGeometry > > &geometries, const Length &clearance) noexcept
Definition primitivefootprintpadgraphicsitem.cpp:142
bool mMirror
Definition primitivefootprintpadgraphicsitem.h:96
void setLayer(const QString &layerName) noexcept
Definition primitivefootprintpadgraphicsitem.cpp:131
void setMirrored(bool mirrored) noexcept
Definition primitivefootprintpadgraphicsitem.cpp:106
void layerEdited(const GraphicsLayer &layer, GraphicsLayer::Event event) noexcept
Definition primitivefootprintpadgraphicsitem.cpp:241
QMap< std::shared_ptr< const GraphicsLayer >, QPainterPath > mShapes
Definition primitivefootprintpadgraphicsitem.h:107
void setRotation(const Angle &rotation) noexcept
Definition primitivefootprintpadgraphicsitem.cpp:97
void setPosition(const Point &position) noexcept
Definition primitivefootprintpadgraphicsitem.cpp:92
void updateRegisteredLayers() noexcept
Definition primitivefootprintpadgraphicsitem.cpp:279
QRectF mShapesBoundingRect
Definition primitivefootprintpadgraphicsitem.h:108
void setToolTipText(const QString &text) noexcept
Definition primitivefootprintpadgraphicsitem.cpp:122
The PrimitivePathGraphicsItem class.
Definition primitivepathgraphicsitem.h:50
Definition occmodel.cpp:77
Definition uuid.h:186
Definition primitivefootprintpadgraphicsitem.h:100
bool isClearance
Definition primitivefootprintpadgraphicsitem.h:103
std::shared_ptr< const GraphicsLayer > layer
Definition primitivefootprintpadgraphicsitem.h:101
bool isCopper
Definition primitivefootprintpadgraphicsitem.h:102
std::shared_ptr< PrimitivePathGraphicsItem > item
Definition primitivefootprintpadgraphicsitem.h:104