LibrePCB Developers Documentation
origincrossgraphicsitem.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_ORIGINCROSSGRAPHICSITEM_H
21#define LIBREPCB_EDITOR_ORIGINCROSSGRAPHICSITEM_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 OriginCrossGraphicsItem
45 ******************************************************************************/
46
50class OriginCrossGraphicsItem final : public QGraphicsItem {
51public:
52 // Constructors / Destructor
53 // OriginCrossGraphicsItem() = delete;
55 explicit OriginCrossGraphicsItem(QGraphicsItem* parent = nullptr) noexcept;
56 virtual ~OriginCrossGraphicsItem() noexcept;
57
58 // Setters
59 void setPosition(const Point& pos) noexcept;
60 void setRotation(const Angle& rot) noexcept;
61 void setSize(const UnsignedLength& size) noexcept;
62 void setLayer(const std::shared_ptr<GraphicsLayer>& layer) noexcept;
63
64 // Inherited from QGraphicsItem
65 QRectF boundingRect() const noexcept override { return mBoundingRect; }
66 QPainterPath shape() const noexcept override;
67 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
68 QWidget* widget = 0) noexcept override;
69
70 // Operator Overloadings
72 delete;
73
74private: // Methods
75 void layerEdited(const GraphicsLayer& layer,
76 GraphicsLayer::Event event) noexcept;
77 void updateBoundingRectAndShape() noexcept;
78
79private: // Data
80 std::shared_ptr<GraphicsLayer> mLayer;
81 QPen mPen;
84 QLineF mLineH;
85 QLineF mLineV;
87 QPainterPath mShape;
88
89 // Slots
91};
92
93/*******************************************************************************
94 * End of File
95 ******************************************************************************/
96
97} // namespace editor
98} // namespace librepcb
99
100#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition: point.h:79
The GraphicsLayer class represents a graphical layer used in schematics and boards.
Definition: graphicslayer.h:53
The OriginCrossGraphicsItem class.
Definition: origincrossgraphicsitem.h:50
QPen mPenHighlighted
Definition: origincrossgraphicsitem.h:82
UnsignedLength mSize
Definition: origincrossgraphicsitem.h:83
QRectF boundingRect() const noexcept override
Definition: origincrossgraphicsitem.h:65
OriginCrossGraphicsItem(const OriginCrossGraphicsItem &other)=delete
void setLayer(const std::shared_ptr< GraphicsLayer > &layer) noexcept
Definition: origincrossgraphicsitem.cpp:76
QPainterPath mShape
Definition: origincrossgraphicsitem.h:87
std::shared_ptr< GraphicsLayer > mLayer
Definition: origincrossgraphicsitem.h:80
QPainterPath shape() const noexcept override
Definition: origincrossgraphicsitem.cpp:96
QLineF mLineV
Definition: origincrossgraphicsitem.h:85
GraphicsLayer::OnEditedSlot mOnLayerEditedSlot
Definition: origincrossgraphicsitem.h:90
QRectF mBoundingRect
Definition: origincrossgraphicsitem.h:86
void layerEdited(const GraphicsLayer &layer, GraphicsLayer::Event event) noexcept
Definition: origincrossgraphicsitem.cpp:116
void setSize(const UnsignedLength &size) noexcept
Definition: origincrossgraphicsitem.cpp:68
QPen mPen
Definition: origincrossgraphicsitem.h:81
void setRotation(const Angle &rot) noexcept
Definition: origincrossgraphicsitem.cpp:64
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0) noexcept override
Definition: origincrossgraphicsitem.cpp:100
void setPosition(const Point &pos) noexcept
Definition: origincrossgraphicsitem.cpp:60
void updateBoundingRectAndShape() noexcept
Definition: origincrossgraphicsitem.cpp:139
QLineF mLineH
Definition: origincrossgraphicsitem.h:84
Definition: occmodel.cpp:77
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:696