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