LibrePCB Developers Documentation
Loading...
Searching...
No Matches
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_EDITOR_PRIMITIVEPATHGRAPHICSITEM_H
21#define LIBREPCB_EDITOR_PRIMITIVEPATHGRAPHICSITEM_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 Angle;
39class Point;
40
41namespace editor {
42
43/*******************************************************************************
44 * Class PrimitivePathGraphicsItem
45 ******************************************************************************/
46
50class PrimitivePathGraphicsItem : public QGraphicsItem {
51public:
52 using QGraphicsItem::setRotation;
53
54 // Types
55 enum class ShapeMode {
57 None,
58
61
65 };
66
67 // Constructors / Destructor
68 // PrimitivePathGraphicsItem() = delete;
70 explicit PrimitivePathGraphicsItem(QGraphicsItem* parent = nullptr) noexcept;
71 virtual ~PrimitivePathGraphicsItem() noexcept;
72
73 // Setters
74 void setPosition(const Point& pos) noexcept;
75 void setRotation(const Angle& rot) noexcept;
76 void setMirrored(bool mirrored) noexcept;
77 void setPath(const QPainterPath& path) noexcept;
78 void setLineWidth(const UnsignedLength& width) noexcept;
79 void setLineLayer(const std::shared_ptr<GraphicsLayer>& layer) noexcept;
80 void setFillLayer(const std::shared_ptr<GraphicsLayer>& layer) noexcept;
81 void setLighterColors(bool lighter) noexcept;
82 void setShapeMode(ShapeMode mode) noexcept;
83
84 // Inherited from QGraphicsItem
85 QRectF boundingRect() const noexcept override {
86 return mBoundingRect +
89 }
90 QPainterPath shape() const noexcept override;
91 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
92 QWidget* widget = 0) noexcept override;
93
94 // Operator Overloadings
96 delete;
97
98private: // Methods
99 void layerEdited(const GraphicsLayer& layer,
100 GraphicsLayer::Event event) noexcept;
101 void updateColors() noexcept;
102 void updateBoundingRectAndShape() noexcept;
103 void updateVisibility() noexcept;
104 QColor convertColor(const QColor& color) const noexcept;
105
106protected: // Data
112 QPen mPen;
114 QBrush mBrush;
116 QPainterPath mPainterPath;
119 QPainterPath mShape;
120
121 // Slots
123};
124
125/*******************************************************************************
126 * End of File
127 ******************************************************************************/
128
129} // namespace editor
130} // namespace librepcb
131
132#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition angle.h:76
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 PrimitivePathGraphicsItem class.
Definition primitivepathgraphicsitem.h:50
QPen mPenHighlighted
Definition primitivepathgraphicsitem.h:113
ShapeMode
Definition primitivepathgraphicsitem.h:55
@ FilledOutline
Only the area within the painter path is used as shape.
QRectF boundingRect() const noexcept override
Definition primitivepathgraphicsitem.h:85
qreal mBoundingRectMarginPx
Definition primitivepathgraphicsitem.h:118
void setLighterColors(bool lighter) noexcept
Definition primitivepathgraphicsitem.cpp:123
QBrush mBrush
Definition primitivepathgraphicsitem.h:114
void setFillLayer(const std::shared_ptr< GraphicsLayer > &layer) noexcept
Definition primitivepathgraphicsitem.cpp:109
QPainterPath mShape
Definition primitivepathgraphicsitem.h:119
QBrush mBrushHighlighted
Definition primitivepathgraphicsitem.h:115
QPainterPath shape() const noexcept override
Definition primitivepathgraphicsitem.cpp:137
QColor convertColor(const QColor &color) const noexcept
Definition primitivepathgraphicsitem.cpp:224
GraphicsLayer::OnEditedSlot mOnLayerEditedSlot
Definition primitivepathgraphicsitem.h:122
void setPath(const QPainterPath &path) noexcept
Definition primitivepathgraphicsitem.cpp:83
std::shared_ptr< GraphicsLayer > mLineLayer
Definition primitivepathgraphicsitem.h:108
void setLineLayer(const std::shared_ptr< GraphicsLayer > &layer) noexcept
Definition primitivepathgraphicsitem.cpp:95
bool mMirror
Definition primitivepathgraphicsitem.h:107
ShapeMode mShapeMode
Definition primitivepathgraphicsitem.h:111
void setShapeMode(ShapeMode mode) noexcept
Definition primitivepathgraphicsitem.cpp:128
QRectF mBoundingRect
Definition primitivepathgraphicsitem.h:117
void setMirrored(bool mirrored) noexcept
Definition primitivepathgraphicsitem.cpp:78
bool mLighterColors
Definition primitivepathgraphicsitem.h:110
void layerEdited(const GraphicsLayer &layer, GraphicsLayer::Event event) noexcept
Definition primitivepathgraphicsitem.cpp:164
QPainterPath mPainterPath
Definition primitivepathgraphicsitem.h:116
std::shared_ptr< GraphicsLayer > mFillLayer
Definition primitivepathgraphicsitem.h:109
QPen mPen
Definition primitivepathgraphicsitem.h:112
void setRotation(const Angle &rot) noexcept
Definition primitivepathgraphicsitem.cpp:74
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0) noexcept override
Definition primitivepathgraphicsitem.cpp:144
void setLineWidth(const UnsignedLength &width) noexcept
Definition primitivepathgraphicsitem.cpp:88
void updateVisibility() noexcept
Definition primitivepathgraphicsitem.cpp:220
void setPosition(const Point &pos) noexcept
Definition primitivepathgraphicsitem.cpp:70
PrimitivePathGraphicsItem(const PrimitivePathGraphicsItem &other)=delete
void updateBoundingRectAndShape() noexcept
Definition primitivepathgraphicsitem.cpp:206
void updateColors() noexcept
Definition primitivepathgraphicsitem.cpp:183
Definition occmodel.cpp:76
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition length.h:694
Definition uuid.h:186