LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
primitivepathgraphicsitem.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_PRIMITIVEPATHGRAPHICSITEM_H
21 #define LIBREPCB_PRIMITIVEPATHGRAPHICSITEM_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../graphics/graphicslayer.h"
27 #include "../units/all_length_units.h"
28 
29 #include <QtCore>
30 #include <QtWidgets>
31 
32 /*******************************************************************************
33  * Namespace / Forward Declarations
34  ******************************************************************************/
35 namespace librepcb {
36 
37 /*******************************************************************************
38  * Class PrimitivePathGraphicsItem
39  ******************************************************************************/
40 
44 class PrimitivePathGraphicsItem : public QGraphicsItem {
45 public:
46  // Constructors / Destructor
47  // PrimitivePathGraphicsItem() = delete;
49  explicit PrimitivePathGraphicsItem(QGraphicsItem* parent = nullptr) noexcept;
50  virtual ~PrimitivePathGraphicsItem() noexcept;
51 
52  // Setters
53  void setPosition(const Point& pos) noexcept;
54  void setRotation(const Angle& rot) noexcept;
55  void setPath(const QPainterPath& path) noexcept;
56  void setLineWidth(const UnsignedLength& width) noexcept;
57  void setLineLayer(const GraphicsLayer* layer) noexcept;
58  void setFillLayer(const GraphicsLayer* layer) noexcept;
59 
60  // Inherited from QGraphicsItem
61  QRectF boundingRect() const noexcept override { return mBoundingRect; }
62  QPainterPath shape() const noexcept override { return mShape; }
63  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
64  QWidget* widget = 0) noexcept override;
65 
66  // Operator Overloadings
68  delete;
69 
70 private: // Methods
71  void layerEdited(const GraphicsLayer& layer,
72  GraphicsLayer::Event event) noexcept;
73  void updateColors() noexcept;
74  void updateBoundingRectAndShape() noexcept;
75  void updateVisibility() noexcept;
76 
77 private: // Data
80  QPen mPen;
82  QBrush mBrush;
84  QPainterPath mPainterPath;
85  QRectF mBoundingRect;
86  QPainterPath mShape;
87 
88  // Slots
90 };
91 
92 /*******************************************************************************
93  * End of File
94  ******************************************************************************/
95 
96 } // namespace librepcb
97 
98 #endif // LIBREPCB_PRIMITIVEPATHGRAPHICSITEM_H
virtual ~PrimitivePathGraphicsItem() noexcept
Definition: primitivepathgraphicsitem.cpp:57
void updateBoundingRectAndShape() noexcept
Definition: primitivepathgraphicsitem.cpp:193
const GraphicsLayer * mFillLayer
Definition: primitivepathgraphicsitem.h:79
The GraphicsLayer class represents a graphical layer used in schematics and boards.
Definition: graphicslayer.h:50
QPen mPen
Definition: primitivepathgraphicsitem.h:80
void setFillLayer(const GraphicsLayer *layer) noexcept
Definition: primitivepathgraphicsitem.cpp:98
QBrush mBrush
Definition: primitivepathgraphicsitem.h:82
PrimitivePathGraphicsItem(const PrimitivePathGraphicsItem &other)=delete
void setPath(const QPainterPath &path) noexcept
Definition: primitivepathgraphicsitem.cpp:72
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
The PrimitivePathGraphicsItem class.
Definition: primitivepathgraphicsitem.h:44
const GraphicsLayer * mLineLayer
Definition: primitivepathgraphicsitem.h:78
QRectF boundingRect() const noexceptoverride
Definition: primitivepathgraphicsitem.h:61
QPainterPath shape() const noexceptoverride
Definition: primitivepathgraphicsitem.h:62
void setLineLayer(const GraphicsLayer *layer) noexcept
Definition: primitivepathgraphicsitem.cpp:84
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
QPainterPath mPainterPath
Definition: primitivepathgraphicsitem.h:84
void updateColors() noexcept
Definition: primitivepathgraphicsitem.cpp:170
void updateVisibility() noexcept
Definition: primitivepathgraphicsitem.cpp:201
void layerEdited(const GraphicsLayer &layer, GraphicsLayer::Event event) noexcept
Definition: primitivepathgraphicsitem.cpp:144
QPainterPath mShape
Definition: primitivepathgraphicsitem.h:86
QRectF mBoundingRect
Definition: primitivepathgraphicsitem.h:85
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0) noexceptoverride
Definition: primitivepathgraphicsitem.cpp:116
void setRotation(const Angle &rot) noexcept
Definition: primitivepathgraphicsitem.cpp:68
QBrush mBrushHighlighted
Definition: primitivepathgraphicsitem.h:83
QPen mPenHighlighted
Definition: primitivepathgraphicsitem.h:81
void setLineWidth(const UnsignedLength &width) noexcept
Definition: primitivepathgraphicsitem.cpp:77
GraphicsLayer::OnEditedSlot mOnLayerEditedSlot
Definition: primitivepathgraphicsitem.h:89
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:659
void setPosition(const Point &pos) noexcept
Definition: primitivepathgraphicsitem.cpp:64