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  void setVisibleInPrintOutput(bool visible) noexcept;
58 
59  // Inherited from QGraphicsItem
60  QRectF boundingRect() const noexcept override { return mBoundingRect; }
61  QPainterPath shape() const noexcept override { return mShape; }
62  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
63  QWidget* widget = 0) noexcept override;
64 
65  // Operator Overloadings
66  OriginCrossGraphicsItem& operator=(const OriginCrossGraphicsItem& rhs) =
67  delete;
68 
69 private: // Methods
70  void layerEdited(const GraphicsLayer& layer,
71  GraphicsLayer::Event event) noexcept;
72  void updateBoundingRectAndShape() noexcept;
73 
74 private: // Data
76  QPen mPen;
79  QLineF mLineH;
80  QLineF mLineV;
81  QRectF mBoundingRect;
82  QPainterPath mShape;
84 
85  // Slots
87 };
88 
89 /*******************************************************************************
90  * End of File
91  ******************************************************************************/
92 
93 } // namespace librepcb
94 
95 #endif // LIBREPCB_ORIGINCROSSGRAPHICSITEM_H
QPainterPath mShape
Definition: origincrossgraphicsitem.h:82
void setRotation(const Angle &rot) noexcept
Definition: origincrossgraphicsitem.cpp:62
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:66
QLineF mLineH
Definition: origincrossgraphicsitem.h:79
QPen mPenHighlighted
Definition: origincrossgraphicsitem.h:77
OriginCrossGraphicsItem(const OriginCrossGraphicsItem &other)=delete
QRectF mBoundingRect
Definition: origincrossgraphicsitem.h:81
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
QPen mPen
Definition: origincrossgraphicsitem.h:76
QLineF mLineV
Definition: origincrossgraphicsitem.h:80
QPainterPath shape() const noexceptoverride
Definition: origincrossgraphicsitem.h:61
void setPosition(const Point &pos) noexcept
Definition: origincrossgraphicsitem.cpp:58
bool mVisibleInPrintOutput
Definition: origincrossgraphicsitem.h:83
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
void setVisibleInPrintOutput(bool visible) noexcept
Definition: origincrossgraphicsitem.cpp:89
void updateBoundingRectAndShape() noexcept
Definition: origincrossgraphicsitem.cpp:154
UnsignedLength mSize
Definition: origincrossgraphicsitem.h:78
void layerEdited(const GraphicsLayer &layer, GraphicsLayer::Event event) noexcept
Definition: origincrossgraphicsitem.cpp:129
const GraphicsLayer * mLayer
Definition: origincrossgraphicsitem.h:75
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0) noexceptoverride
Definition: origincrossgraphicsitem.cpp:98
~OriginCrossGraphicsItem() noexcept
Definition: origincrossgraphicsitem.cpp:51
void setLayer(const GraphicsLayer *layer) noexcept
Definition: origincrossgraphicsitem.cpp:74
QRectF boundingRect() const noexceptoverride
Definition: origincrossgraphicsitem.h:60
The OriginCrossGraphicsItem class.
Definition: origincrossgraphicsitem.h:44
GraphicsLayer::OnEditedSlot mOnLayerEditedSlot
Definition: origincrossgraphicsitem.h:86
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:659