LibrePCB Developers Documentation
polygongraphicsitem.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_POLYGONGRAPHICSITEM_H
21#define LIBREPCB_EDITOR_POLYGONGRAPHICSITEM_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
27
29
30#include <QtCore>
31#include <QtWidgets>
32
33/*******************************************************************************
34 * Namespace / Forward Declarations
35 ******************************************************************************/
36namespace librepcb {
37namespace editor {
38
39class IF_GraphicsLayerProvider;
40
41/*******************************************************************************
42 * Class PolygonGraphicsItem
43 ******************************************************************************/
44
49public:
50 // Constructors / Destructor
54 QGraphicsItem* parent = nullptr) noexcept;
55 virtual ~PolygonGraphicsItem() noexcept;
56
57 // Getters
58 Polygon& getObj() noexcept { return mPolygon; }
59
67 int getLineIndexAtPosition(const Point& pos) const noexcept;
68
73 QVector<int> getVertexIndicesAtPosition(const Point& pos) const noexcept;
74
75 // Setters
76
86 void setEditable(bool editable) noexcept;
87
88 // Inherited Methods
89 QVariant itemChange(GraphicsItemChange change,
90 const QVariant& value) noexcept override;
91 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
92 QWidget* widget = 0) noexcept override;
93
94 // Operator Overloadings
95 PolygonGraphicsItem& operator=(const PolygonGraphicsItem& rhs) = delete;
96
97private: // Methods
98 void polygonEdited(const Polygon& polygon, Polygon::Event event) noexcept;
99 void updateFillLayer() noexcept;
100 void updatePath() noexcept;
101 void updateZValue() noexcept;
102 void updateBoundingRectMargin() noexcept;
103
104private: // Data
108
109 // Cached attributes
114 };
115 QVector<VertexHandle> mVertexHandles;
116
117 // Slots
119};
120
121/*******************************************************************************
122 * End of File
123 ******************************************************************************/
124
125} // namespace editor
126} // namespace librepcb
127
128#endif
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition: point.h:79
The Polygon class.
Definition: polygon.h:45
The IF_GraphicsLayerProvider class defines an interface for classes which provide layers.
Definition: graphicslayer.h:111
The PolygonGraphicsItem class.
Definition: polygongraphicsitem.h:48
PolygonGraphicsItem(const PolygonGraphicsItem &other)=delete
void updateBoundingRectMargin() noexcept
Definition: polygongraphicsitem.cpp:234
int getLineIndexAtPosition(const Point &pos) const noexcept
Definition: polygongraphicsitem.cpp:70
QVariant itemChange(GraphicsItemChange change, const QVariant &value) noexcept override
Definition: polygongraphicsitem.cpp:114
void updateFillLayer() noexcept
Definition: polygongraphicsitem.cpp:193
void polygonEdited(const Polygon &polygon, Polygon::Event event) noexcept
Definition: polygongraphicsitem.cpp:165
qreal mVertexHandleRadiusPx
Definition: polygongraphicsitem.h:110
const IF_GraphicsLayerProvider & mLayerProvider
Definition: polygongraphicsitem.h:106
QVector< VertexHandle > mVertexHandles
Definition: polygongraphicsitem.h:115
Polygon & mPolygon
Definition: polygongraphicsitem.h:105
Polygon & getObj() noexcept
Definition: polygongraphicsitem.h:58
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0) noexcept override
Definition: polygongraphicsitem.cpp:122
void updatePath() noexcept
Definition: polygongraphicsitem.cpp:204
QVector< int > getVertexIndicesAtPosition(const Point &pos) const noexcept
Definition: polygongraphicsitem.cpp:96
Polygon::OnEditedSlot mOnEditedSlot
Definition: polygongraphicsitem.h:118
bool mEditable
Definition: polygongraphicsitem.h:107
void setEditable(bool editable) noexcept
Definition: polygongraphicsitem.cpp:109
void updateZValue() noexcept
Definition: polygongraphicsitem.cpp:223
The PrimitivePathGraphicsItem class.
Definition: primitivepathgraphicsitem.h:50
Definition: occmodel.cpp:77
Definition: polygongraphicsitem.h:111
qreal maxGlowRadiusPx
Definition: polygongraphicsitem.h:113
Point pos
Definition: polygongraphicsitem.h:112