LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
primitivecirclegraphicsitem.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_PRIMITIVECIRCLEGRAPHICSITEM_H
21 #define LIBREPCB_PRIMITIVECIRCLEGRAPHICSITEM_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 PrimitiveCircleGraphicsItem
39  ******************************************************************************/
40 
44 class PrimitiveCircleGraphicsItem : public QGraphicsItem {
45 public:
46  // Constructors / Destructor
47  // PrimitiveCircleGraphicsItem() = delete;
49  delete;
51  QGraphicsItem* parent = nullptr) noexcept;
52  virtual ~PrimitiveCircleGraphicsItem() noexcept;
53 
54  // Setters
55  void setPosition(const Point& pos) noexcept;
56  void setDiameter(const UnsignedLength& dia) noexcept;
57  void setLineWidth(const UnsignedLength& width) noexcept;
58  void setLineLayer(const GraphicsLayer* layer) noexcept;
59  void setFillLayer(const GraphicsLayer* layer) noexcept;
60 
61  // Inherited from QGraphicsItem
62  virtual QRectF boundingRect() const noexcept override {
63  return mBoundingRect;
64  }
65  virtual QPainterPath shape() const noexcept override { return mShape; }
66  virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
67  QWidget* widget = 0) noexcept override;
68 
69  // Operator Overloadings
70  PrimitiveCircleGraphicsItem& operator =(
71  const PrimitiveCircleGraphicsItem& rhs) = delete;
72 
73 private: // Methods
74  void layerEdited(const GraphicsLayer& layer,
75  GraphicsLayer::Event event) noexcept;
76  void updateColors() noexcept;
77  void updateBoundingRectAndShape() noexcept;
78  void updateVisibility() noexcept;
79 
80 private: // Data
83  QPen mPen;
85  QBrush mBrush;
87  QRectF mCircleRect;
88  QRectF mBoundingRect;
89  QPainterPath mShape;
90 
91  // Slots
93 };
94 
95 /*******************************************************************************
96  * End of File
97  ******************************************************************************/
98 
99 } // namespace librepcb
100 
101 #endif // LIBREPCB_PRIMITIVECIRCLEGRAPHICSITEM_H
The GraphicsLayer class represents a graphical layer used in schematics and boards.
Definition: graphicslayer.h:50
QPainterPath mShape
Definition: primitivecirclegraphicsitem.h:89
void setLineLayer(const GraphicsLayer *layer) noexcept
Definition: primitivecirclegraphicsitem.cpp:77
void updateVisibility() noexcept
Definition: primitivecirclegraphicsitem.cpp:195
void setLineWidth(const UnsignedLength &width) noexcept
Definition: primitivecirclegraphicsitem.cpp:70
void layerEdited(const GraphicsLayer &layer, GraphicsLayer::Event event) noexcept
Definition: primitivecirclegraphicsitem.cpp:137
void updateBoundingRectAndShape() noexcept
Definition: primitivecirclegraphicsitem.cpp:186
virtual QPainterPath shape() const noexceptoverride
Definition: primitivecirclegraphicsitem.h:65
QBrush mBrush
Definition: primitivecirclegraphicsitem.h:85
QPen mPenHighlighted
Definition: primitivecirclegraphicsitem.h:84
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
QBrush mBrushHighlighted
Definition: primitivecirclegraphicsitem.h:86
GraphicsLayer::OnEditedSlot mOnLayerEditedSlot
Definition: primitivecirclegraphicsitem.h:92
const GraphicsLayer * mFillLayer
Definition: primitivecirclegraphicsitem.h:82
virtual QRectF boundingRect() const noexceptoverride
Definition: primitivecirclegraphicsitem.h:62
virtual ~PrimitiveCircleGraphicsItem() noexcept
Definition: primitivecirclegraphicsitem.cpp:53
QRectF mBoundingRect
Definition: primitivecirclegraphicsitem.h:88
QRectF mCircleRect
Definition: primitivecirclegraphicsitem.h:87
void updateColors() noexcept
Definition: primitivecirclegraphicsitem.cpp:163
void setFillLayer(const GraphicsLayer *layer) noexcept
Definition: primitivecirclegraphicsitem.cpp:91
QPen mPen
Definition: primitivecirclegraphicsitem.h:83
void setDiameter(const UnsignedLength &dia) noexcept
Definition: primitivecirclegraphicsitem.cpp:64
PrimitiveCircleGraphicsItem(const PrimitiveCircleGraphicsItem &other)=delete
The PrimitiveCircleGraphicsItem class.
Definition: primitivecirclegraphicsitem.h:44
void setPosition(const Point &pos) noexcept
Definition: primitivecirclegraphicsitem.cpp:60
const GraphicsLayer * mLineLayer
Definition: primitivecirclegraphicsitem.h:81
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0) noexceptoverride
Definition: primitivecirclegraphicsitem.cpp:109
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:659