LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
primitivepathgraphicsitem.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_PRIMITIVEPATHGRAPHICSITEM_H
21 #define LIBREPCB_PRIMITIVEPATHGRAPHICSITEM_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 PrimitivePathGraphicsItem
39  ******************************************************************************/
40 
47 class PrimitivePathGraphicsItem : public QGraphicsItem,
49 public:
50  // Constructors / Destructor
51  // PrimitivePathGraphicsItem() = delete;
53  explicit PrimitivePathGraphicsItem(QGraphicsItem* parent = nullptr) noexcept;
54  virtual ~PrimitivePathGraphicsItem() noexcept;
55 
56  // Setters
57  void setPosition(const Point& pos) noexcept;
58  void setRotation(const Angle& rot) noexcept;
59  void setPath(const QPainterPath& path) noexcept;
60  void setLineWidth(const UnsignedLength& width) noexcept;
61  void setLineLayer(const GraphicsLayer* layer) noexcept;
62  void setFillLayer(const GraphicsLayer* layer) noexcept;
63 
64  // Inherited from IF_LayerObserver
65  void layerColorChanged(const GraphicsLayer& layer,
66  const QColor& newColor) noexcept override;
67  void layerHighlightColorChanged(const GraphicsLayer& layer,
68  const QColor& newColor) noexcept override;
69  void layerVisibleChanged(const GraphicsLayer& layer,
70  bool newVisible) noexcept override;
71  void layerEnabledChanged(const GraphicsLayer& layer,
72  bool newEnabled) noexcept override;
73  void layerDestroyed(const GraphicsLayer& layer) noexcept override;
74 
75  // Inherited from QGraphicsItem
76  QRectF boundingRect() const noexcept override { return mBoundingRect; }
77  QPainterPath shape() const noexcept override { return mShape; }
78  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
79  QWidget* widget = 0) noexcept override;
80 
81  // Operator Overloadings
83  delete;
84 
85 private: // Methods
86  void updateColors() noexcept;
87  void updateBoundingRectAndShape() noexcept;
88  void updateVisibility() noexcept;
89 
90 private: // Data
93  QPen mPen;
95  QBrush mBrush;
97  QPainterPath mPainterPath;
98  QRectF mBoundingRect;
99  QPainterPath mShape;
100 };
101 
102 /*******************************************************************************
103  * End of File
104  ******************************************************************************/
105 
106 } // namespace librepcb
107 
108 #endif // LIBREPCB_PRIMITIVEPATHGRAPHICSITEM_H
virtual ~PrimitivePathGraphicsItem() noexcept
Definition: primitivepathgraphicsitem.cpp:53
void layerVisibleChanged(const GraphicsLayer &layer, bool newVisible) noexceptoverride
Definition: primitivepathgraphicsitem.cpp:131
void updateBoundingRectAndShape() noexcept
Definition: primitivepathgraphicsitem.cpp:203
const GraphicsLayer * mFillLayer
Definition: primitivepathgraphicsitem.h:92
void layerEnabledChanged(const GraphicsLayer &layer, bool newEnabled) noexceptoverride
Definition: primitivepathgraphicsitem.cpp:139
The GraphicsLayer class represents a graphical layer used in schematics and boards.
Definition: graphicslayer.h:54
QPen mPen
Definition: primitivepathgraphicsitem.h:93
void layerHighlightColorChanged(const GraphicsLayer &layer, const QColor &newColor) noexceptoverride
Definition: primitivepathgraphicsitem.cpp:123
void setFillLayer(const GraphicsLayer *layer) noexcept
Definition: primitivepathgraphicsitem.cpp:97
The IF_GraphicsLayerOblayerHighlightColorChangedserver class defines an interface for classes which c...
Definition: graphicslayer.h:227
QBrush mBrush
Definition: primitivepathgraphicsitem.h:95
PrimitivePathGraphicsItem(const PrimitivePathGraphicsItem &other)=delete
void setPath(const QPainterPath &path) noexcept
Definition: primitivepathgraphicsitem.cpp:71
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:81
The PrimitivePathGraphicsItem class.
Definition: primitivepathgraphicsitem.h:47
const GraphicsLayer * mLineLayer
Definition: primitivepathgraphicsitem.h:91
QRectF boundingRect() const noexceptoverride
Definition: primitivepathgraphicsitem.h:76
QPainterPath shape() const noexceptoverride
Definition: primitivepathgraphicsitem.h:77
void setLineLayer(const GraphicsLayer *layer) noexcept
Definition: primitivepathgraphicsitem.cpp:83
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:81
QPainterPath mPainterPath
Definition: primitivepathgraphicsitem.h:97
void updateColors() noexcept
Definition: primitivepathgraphicsitem.cpp:180
void updateVisibility() noexcept
Definition: primitivepathgraphicsitem.cpp:211
QPainterPath mShape
Definition: primitivepathgraphicsitem.h:99
void layerDestroyed(const GraphicsLayer &layer) noexceptoverride
Definition: primitivepathgraphicsitem.cpp:147
void layerColorChanged(const GraphicsLayer &layer, const QColor &newColor) noexceptoverride
Definition: primitivepathgraphicsitem.cpp:115
QRectF mBoundingRect
Definition: primitivepathgraphicsitem.h:98
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0) noexceptoverride
Definition: primitivepathgraphicsitem.cpp:162
void setRotation(const Angle &rot) noexcept
Definition: primitivepathgraphicsitem.cpp:67
QBrush mBrushHighlighted
Definition: primitivepathgraphicsitem.h:96
QPen mPenHighlighted
Definition: primitivepathgraphicsitem.h:94
void setLineWidth(const UnsignedLength &width) noexcept
Definition: primitivepathgraphicsitem.cpp:76
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:662
void setPosition(const Point &pos) noexcept
Definition: primitivepathgraphicsitem.cpp:63