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 
47 class OriginCrossGraphicsItem final : public QGraphicsItem,
49 public:
50  // Constructors / Destructor
51  // OriginCrossGraphicsItem() = delete;
52  OriginCrossGraphicsItem(const OriginCrossGraphicsItem& other) = delete;
53  explicit OriginCrossGraphicsItem(QGraphicsItem* parent = nullptr) noexcept;
54  ~OriginCrossGraphicsItem() noexcept;
55 
56  // Setters
57  void setPosition(const Point& pos) noexcept;
58  void setRotation(const Angle& rot) noexcept;
59  void setSize(const UnsignedLength& size) noexcept;
60  void setLayer(const GraphicsLayer* layer) noexcept;
61 
62  // Inherited from IF_LayerObserver
63  void layerColorChanged(const GraphicsLayer& layer,
64  const QColor& newColor) noexcept override;
65  void layerHighlightColorChanged(const GraphicsLayer& layer,
66  const QColor& newColor) noexcept override;
67  void layerVisibleChanged(const GraphicsLayer& layer,
68  bool newVisible) noexcept override;
69  void layerEnabledChanged(const GraphicsLayer& layer,
70  bool newEnabled) noexcept override;
71  void layerDestroyed(const GraphicsLayer& layer) noexcept override;
72 
73  // Inherited from QGraphicsItem
74  QRectF boundingRect() const noexcept override { return mBoundingRect; }
75  QPainterPath shape() const noexcept override { return mShape; }
76  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
77  QWidget* widget = 0) noexcept override;
78 
79  // Operator Overloadings
80  OriginCrossGraphicsItem& operator=(const OriginCrossGraphicsItem& rhs) =
81  delete;
82 
83 private: // Methods
84  void updateBoundingRectAndShape() noexcept;
85 
86 private: // Data
88  QPen mPen;
91  QLineF mLineH;
92  QLineF mLineV;
93  QRectF mBoundingRect;
94  QPainterPath mShape;
95 };
96 
97 /*******************************************************************************
98  * End of File
99  ******************************************************************************/
100 
101 } // namespace librepcb
102 
103 #endif // LIBREPCB_ORIGINCROSSGRAPHICSITEM_H
QPainterPath mShape
Definition: origincrossgraphicsitem.h:94
void setRotation(const Angle &rot) noexcept
Definition: origincrossgraphicsitem.cpp:59
void layerEnabledChanged(const GraphicsLayer &layer, bool newEnabled) noexceptoverride
Definition: origincrossgraphicsitem.cpp:113
The GraphicsLayer class represents a graphical layer used in schematics and boards.
Definition: graphicslayer.h:54
void setSize(const UnsignedLength &size) noexcept
Definition: origincrossgraphicsitem.cpp:63
The IF_GraphicsLayerOblayerHighlightColorChangedserver class defines an interface for classes which c...
Definition: graphicslayer.h:227
QLineF mLineH
Definition: origincrossgraphicsitem.h:91
QPen mPenHighlighted
Definition: origincrossgraphicsitem.h:89
OriginCrossGraphicsItem(const OriginCrossGraphicsItem &other)=delete
QRectF mBoundingRect
Definition: origincrossgraphicsitem.h:93
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:81
QPen mPen
Definition: origincrossgraphicsitem.h:88
QLineF mLineV
Definition: origincrossgraphicsitem.h:92
QPainterPath shape() const noexceptoverride
Definition: origincrossgraphicsitem.h:75
void layerHighlightColorChanged(const GraphicsLayer &layer, const QColor &newColor) noexceptoverride
Definition: origincrossgraphicsitem.cpp:98
void layerDestroyed(const GraphicsLayer &layer) noexceptoverride
Definition: origincrossgraphicsitem.cpp:119
void setPosition(const Point &pos) noexcept
Definition: origincrossgraphicsitem.cpp:55
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:81
void layerColorChanged(const GraphicsLayer &layer, const QColor &newColor) noexceptoverride
Definition: origincrossgraphicsitem.cpp:90
void updateBoundingRectAndShape() noexcept
Definition: origincrossgraphicsitem.cpp:146
UnsignedLength mSize
Definition: origincrossgraphicsitem.h:90
const GraphicsLayer * mLayer
Definition: origincrossgraphicsitem.h:87
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0) noexceptoverride
Definition: origincrossgraphicsitem.cpp:129
~OriginCrossGraphicsItem() noexcept
Definition: origincrossgraphicsitem.cpp:46
void layerVisibleChanged(const GraphicsLayer &layer, bool newVisible) noexceptoverride
Definition: origincrossgraphicsitem.cpp:106
void setLayer(const GraphicsLayer *layer) noexcept
Definition: origincrossgraphicsitem.cpp:71
QRectF boundingRect() const noexceptoverride
Definition: origincrossgraphicsitem.h:74
The OriginCrossGraphicsItem class.
Definition: origincrossgraphicsitem.h:47
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:662