LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sgi_netlabel.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_PROJECT_SGI_NETLABEL_H
21 #define LIBREPCB_PROJECT_SGI_NETLABEL_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "sgi_base.h"
27 
28 #include <QtCore>
29 #include <QtWidgets>
30 
31 /*******************************************************************************
32  * Namespace / Forward Declarations
33  ******************************************************************************/
34 namespace librepcb {
35 
36 class GraphicsLayer;
37 class LineGraphicsItem;
38 
39 namespace project {
40 
41 class SI_NetLabel;
42 
43 /*******************************************************************************
44  * Class SGI_NetLabel
45  ******************************************************************************/
46 
50 class SGI_NetLabel final : public SGI_Base {
51 public:
52  // Constructors / Destructor
53  explicit SGI_NetLabel(SI_NetLabel& netlabel) noexcept;
54  ~SGI_NetLabel() noexcept;
55 
56  // General Methods
57  void updateCacheAndRepaint() noexcept;
58  void setAnchor(const Point& pos) noexcept;
59 
60  // Inherited from QGraphicsItem
61  QRectF boundingRect() const { return mBoundingRect; }
62  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
63  QWidget* widget);
64 
65 private:
66  // make some methods inaccessible...
67  SGI_NetLabel() = delete;
68  SGI_NetLabel(const SGI_NetLabel& other) = delete;
69  SGI_NetLabel& operator=(const SGI_NetLabel& rhs) = delete;
70 
71  // Private Methods
72  GraphicsLayer* getLayer(const QString& name) const noexcept;
73 
74  // Attributes
76  QScopedPointer<LineGraphicsItem> mAnchorGraphicsItem;
77 
78  // Cached Attributes
79  QStaticText mStaticText;
80  QFont mFont;
81  bool mRotate180;
82  QPointF mTextOrigin;
83  QRectF mBoundingRect;
84 
85  // Static Stuff
86  static QVector<QLineF> sOriginCrossLines;
87 };
88 
89 /*******************************************************************************
90  * End of File
91  ******************************************************************************/
92 
93 } // namespace project
94 } // namespace librepcb
95 
96 #endif // LIBREPCB_PROJECT_SGI_NETLABEL_H
void updateCacheAndRepaint() noexcept
Definition: sgi_netlabel.cpp:82
The GraphicsLayer class represents a graphical layer used in schematics and boards.
Definition: graphicslayer.h:50
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
Definition: sgi_netlabel.cpp:116
The SGI_NetLabel class.
Definition: sgi_netlabel.h:50
static QVector< QLineF > sOriginCrossLines
Definition: sgi_netlabel.h:86
void setAnchor(const Point &pos) noexcept
Definition: sgi_netlabel.cpp:107
SGI_NetLabel & operator=(const SGI_NetLabel &rhs)=delete
SI_NetLabel & mNetLabel
Definition: sgi_netlabel.h:75
QPointF mTextOrigin
Definition: sgi_netlabel.h:82
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
QRectF boundingRect() const
Definition: sgi_netlabel.h:61
QStaticText mStaticText
Definition: sgi_netlabel.h:79
QScopedPointer< LineGraphicsItem > mAnchorGraphicsItem
Definition: sgi_netlabel.h:76
The Schematic Graphics Item Base (SGI_Base) class.
Definition: sgi_base.h:44
GraphicsLayer * getLayer(const QString &name) const noexcept
Definition: sgi_netlabel.cpp:179
The SI_NetLabel class.
Definition: si_netlabel.h:51
QRectF mBoundingRect
Definition: sgi_netlabel.h:83
bool mRotate180
Definition: sgi_netlabel.h:81
QFont mFont
Definition: sgi_netlabel.h:80
~SGI_NetLabel() noexcept
Definition: sgi_netlabel.cpp:75