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  ******************************************************************************/
36 namespace librepcb {
37 
38 class Angle;
39 class Point;
40 
41 namespace editor {
42 
43 /*******************************************************************************
44  * Class OriginCrossGraphicsItem
45  ******************************************************************************/
46 
50 class OriginCrossGraphicsItem final : public QGraphicsItem {
51 public:
52  // Constructors / Destructor
53  // OriginCrossGraphicsItem() = delete;
54  OriginCrossGraphicsItem(const OriginCrossGraphicsItem& other) = 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 
74 private: // Methods
75  void layerEdited(const GraphicsLayer& layer,
76  GraphicsLayer::Event event) noexcept;
77  void updateBoundingRectAndShape() noexcept;
78 
79 private: // Data
80  std::shared_ptr<GraphicsLayer> mLayer;
81  QPen mPen;
84  QLineF mLineH;
85  QLineF mLineV;
86  QRectF mBoundingRect;
87  QPainterPath mShape;
88 
89  // Slots
91 };
92 
93 /*******************************************************************************
94  * End of File
95  ******************************************************************************/
96 
97 } // namespace editor
98 } // namespace librepcb
99 
100 #endif
QRectF boundingRect() const noexcept override
Definition: origincrossgraphicsitem.h:65
void layerEdited(const GraphicsLayer &layer, GraphicsLayer::Event event) noexcept
Definition: origincrossgraphicsitem.cpp:116
QLineF mLineH
Definition: origincrossgraphicsitem.h:84
QPainterPath mShape
Definition: origincrossgraphicsitem.h:87
Definition: occmodel.cpp:77
The OriginCrossGraphicsItem class.
Definition: origincrossgraphicsitem.h:50
void updateBoundingRectAndShape() noexcept
Definition: origincrossgraphicsitem.cpp:139
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
OriginCrossGraphicsItem & operator=(const OriginCrossGraphicsItem &rhs)=delete
GraphicsLayer::OnEditedSlot mOnLayerEditedSlot
Definition: origincrossgraphicsitem.h:90
QPen mPenHighlighted
Definition: origincrossgraphicsitem.h:82
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0) noexcept override
Definition: origincrossgraphicsitem.cpp:100
The GraphicsLayer class represents a graphical layer used in schematics and boards.
Definition: graphicslayer.h:53
OriginCrossGraphicsItem(const OriginCrossGraphicsItem &other)=delete
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:79
std::shared_ptr< GraphicsLayer > mLayer
Definition: origincrossgraphicsitem.h:80
void setSize(const UnsignedLength &size) noexcept
Definition: origincrossgraphicsitem.cpp:68
void setRotation(const Angle &rot) noexcept
Definition: origincrossgraphicsitem.cpp:64
QLineF mLineV
Definition: origincrossgraphicsitem.h:85
void setLayer(const std::shared_ptr< GraphicsLayer > &layer) noexcept
Definition: origincrossgraphicsitem.cpp:76
QPen mPen
Definition: origincrossgraphicsitem.h:81
UnsignedLength mSize
Definition: origincrossgraphicsitem.h:83
QPainterPath shape() const noexcept override
Definition: origincrossgraphicsitem.cpp:96
QRectF mBoundingRect
Definition: origincrossgraphicsitem.h:86
Event
Definition: graphicslayer.h:58
virtual ~OriginCrossGraphicsItem() noexcept
Definition: origincrossgraphicsitem.cpp:53
void setPosition(const Point &pos) noexcept
Definition: origincrossgraphicsitem.cpp:60
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:696