LibrePCB Developers Documentation
Loading...
Searching...
No Matches
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_EDITOR_PRIMITIVECIRCLEGRAPHICSITEM_H
21#define LIBREPCB_EDITOR_PRIMITIVECIRCLEGRAPHICSITEM_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "graphicslayer.h"
27
29
30#include <QtCore>
31#include <QtWidgets>
32
33/*******************************************************************************
34 * Namespace / Forward Declarations
35 ******************************************************************************/
36namespace librepcb {
37
38class Point;
39
40namespace editor {
41
42/*******************************************************************************
43 * Class PrimitiveCircleGraphicsItem
44 ******************************************************************************/
45
49class PrimitiveCircleGraphicsItem : public QGraphicsItem {
50public:
51 // Types
52 enum class ShapeMode {
56
59 };
60
61 // Constructors / Destructor
62 // PrimitiveCircleGraphicsItem() = delete;
64 delete;
66 QGraphicsItem* parent = nullptr) noexcept;
67 virtual ~PrimitiveCircleGraphicsItem() noexcept;
68
69 // Setters
70 void setPosition(const Point& pos) noexcept;
71 void setDiameter(const UnsignedLength& dia) noexcept;
72 void setLineWidth(const UnsignedLength& width) noexcept;
73 void setLineLayer(const std::shared_ptr<GraphicsLayer>& layer) noexcept;
74 void setFillLayer(const std::shared_ptr<GraphicsLayer>& layer) noexcept;
75 void setShapeMode(ShapeMode mode) noexcept;
76
77 // Inherited from QGraphicsItem
78 virtual QRectF boundingRect() const noexcept override {
79 return mBoundingRect;
80 }
81 virtual QPainterPath shape() const noexcept override;
82 virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
83 QWidget* widget = 0) noexcept override;
84
85 // Operator Overloadings
87 const PrimitiveCircleGraphicsItem& rhs) = delete;
88
89private: // Methods
90 void layerEdited(const GraphicsLayer& layer,
91 GraphicsLayer::Event event) noexcept;
92 void updateColors() noexcept;
93 void updateBoundingRectAndShape() noexcept;
94 void updateVisibility() noexcept;
95
96private: // Data
100 QPen mPen;
102 QBrush mBrush;
106 QPainterPath mShape;
107
108 // Slots
110};
111
112/*******************************************************************************
113 * End of File
114 ******************************************************************************/
115
116} // namespace editor
117} // namespace librepcb
118
119#endif
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 PrimitiveCircleGraphicsItem class.
Definition primitivecirclegraphicsitem.h:49
QPen mPenHighlighted
Definition primitivecirclegraphicsitem.h:101
ShapeMode
Definition primitivecirclegraphicsitem.h:52
@ FilledOutline
Only the area within the painter path is used as shape.
QRectF mCircleRect
Definition primitivecirclegraphicsitem.h:104
QBrush mBrush
Definition primitivecirclegraphicsitem.h:102
void setFillLayer(const std::shared_ptr< GraphicsLayer > &layer) noexcept
Definition primitivecirclegraphicsitem.cpp:94
QPainterPath mShape
Definition primitivecirclegraphicsitem.h:106
PrimitiveCircleGraphicsItem(const PrimitiveCircleGraphicsItem &other)=delete
QBrush mBrushHighlighted
Definition primitivecirclegraphicsitem.h:103
virtual QPainterPath shape() const noexcept override
Definition primitivecirclegraphicsitem.cpp:117
void setDiameter(const UnsignedLength &dia) noexcept
Definition primitivecirclegraphicsitem.cpp:67
GraphicsLayer::OnEditedSlot mOnLayerEditedSlot
Definition primitivecirclegraphicsitem.h:109
std::shared_ptr< GraphicsLayer > mLineLayer
Definition primitivecirclegraphicsitem.h:97
void setLineLayer(const std::shared_ptr< GraphicsLayer > &layer) noexcept
Definition primitivecirclegraphicsitem.cpp:80
ShapeMode mShapeMode
Definition primitivecirclegraphicsitem.h:99
void setShapeMode(ShapeMode mode) noexcept
Definition primitivecirclegraphicsitem.cpp:108
QRectF mBoundingRect
Definition primitivecirclegraphicsitem.h:105
void layerEdited(const GraphicsLayer &layer, GraphicsLayer::Event event) noexcept
Definition primitivecirclegraphicsitem.cpp:140
std::shared_ptr< GraphicsLayer > mFillLayer
Definition primitivecirclegraphicsitem.h:98
virtual QRectF boundingRect() const noexcept override
Definition primitivecirclegraphicsitem.h:78
QPen mPen
Definition primitivecirclegraphicsitem.h:100
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0) noexcept override
Definition primitivecirclegraphicsitem.cpp:124
void setLineWidth(const UnsignedLength &width) noexcept
Definition primitivecirclegraphicsitem.cpp:73
void updateVisibility() noexcept
Definition primitivecirclegraphicsitem.cpp:195
void setPosition(const Point &pos) noexcept
Definition primitivecirclegraphicsitem.cpp:63
void updateBoundingRectAndShape() noexcept
Definition primitivecirclegraphicsitem.cpp:182
void updateColors() noexcept
Definition primitivecirclegraphicsitem.cpp:159
Definition occmodel.cpp:76
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition length.h:694
Definition uuid.h:186