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_POLYGONGRAPHICSITEM_H
21 #define LIBREPCB_POLYGONGRAPHICSITEM_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../geometry/polygon.h"
28 
29 #include <QtCore>
30 #include <QtWidgets>
31 
32 /*******************************************************************************
33  * Namespace / Forward Declarations
34  ******************************************************************************/
35 namespace librepcb {
36 
37 class IF_GraphicsLayerProvider;
38 
39 /*******************************************************************************
40  * Class PolygonGraphicsItem
41  ******************************************************************************/
42 
47 public:
48  // Constructors / Destructor
49  PolygonGraphicsItem() = delete;
50  PolygonGraphicsItem(const PolygonGraphicsItem& other) = delete;
52  QGraphicsItem* parent = nullptr) noexcept;
53  ~PolygonGraphicsItem() noexcept;
54 
55  // Getters
56  Polygon& getPolygon() noexcept { return mPolygon; }
57 
65  int getLineIndexAtPosition(const Point& pos) const noexcept;
66 
71  QVector<int> getVertexIndicesAtPosition(const Point& pos) const noexcept;
72 
73  // Inherited Methods
74  QVariant itemChange(GraphicsItemChange change,
75  const QVariant& value) noexcept override;
76 
77  // Operator Overloadings
79 
80 private: // Methods
81  void polygonEdited(const Polygon& polygon, Polygon::Event event) noexcept;
82  void updateFillLayer() noexcept;
83  void updateVertexGraphicsItems() noexcept;
84 
85 private: // Data
88 
90  QList<std::shared_ptr<PrimitivePathGraphicsItem>> mVertexGraphicsItems;
91 
92  // Slots
94 };
95 
96 /*******************************************************************************
97  * End of File
98  ******************************************************************************/
99 
100 } // namespace librepcb
101 
102 #endif // LIBREPCB_POLYGONGRAPHICSITEM_H
QList< std::shared_ptr< PrimitivePathGraphicsItem > > mVertexGraphicsItems
The square graphics items to drag each vertex.
Definition: polygongraphicsitem.h:90
PolygonGraphicsItem & operator=(const PolygonGraphicsItem &rhs)=delete
The PolygonGraphicsItem class.
Definition: polygongraphicsitem.h:46
~PolygonGraphicsItem() noexcept
Definition: polygongraphicsitem.cpp:57
Definition: airwiresbuilder.cpp:32
QVector< int > getVertexIndicesAtPosition(const Point &pos) const noexcept
Definition: polygongraphicsitem.cpp:88
Polygon & getPolygon() noexcept
Definition: polygongraphicsitem.h:56
const IF_GraphicsLayerProvider & mLayerProvider
Definition: polygongraphicsitem.h:87
Event
Definition: polygon.h:54
QVariant itemChange(GraphicsItemChange change, const QVariant &value) noexcept override
Definition: polygongraphicsitem.cpp:100
The IF_GraphicsLayerProvider class defines an interface for classes which provide layers...
Definition: graphicslayer.h:227
The PrimitivePathGraphicsItem class.
Definition: primitivepathgraphicsitem.h:44
int getLineIndexAtPosition(const Point &pos) const noexcept
Definition: polygongraphicsitem.cpp:64
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
void updateVertexGraphicsItems() noexcept
Definition: polygongraphicsitem.cpp:153
void polygonEdited(const Polygon &polygon, Polygon::Event event) noexcept
Definition: polygongraphicsitem.cpp:114
Polygon::OnEditedSlot mOnEditedSlot
Definition: polygongraphicsitem.h:93
The Polygon class.
Definition: polygon.h:49
Polygon & mPolygon
Definition: polygongraphicsitem.h:86
void updateFillLayer() noexcept
Definition: polygongraphicsitem.cpp:142