LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
symbolpinpreviewgraphicsitem.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_LIBRARY_SYMBOLPINPREVIEWGRAPHICSITEM_H
21 #define LIBREPCB_LIBRARY_SYMBOLPINPREVIEWGRAPHICSITEM_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../cmp/cmpsigpindisplaytype.h"
27 
28 #include <QtCore>
29 #include <QtWidgets>
30 
31 /*******************************************************************************
32  * Namespace / Forward Declarations
33  ******************************************************************************/
34 namespace librepcb {
35 
36 class GraphicsLayer;
37 class IF_GraphicsLayerProvider;
38 
39 namespace library {
40 
41 class SymbolPin;
42 class ComponentSignal;
43 
44 /*******************************************************************************
45  * Class SymbolPinPreviewGraphicsItem
46  ******************************************************************************/
47 
51 class SymbolPinPreviewGraphicsItem final : public QGraphicsItem {
52 public:
53  // Constructors / Destructor
55  const IF_GraphicsLayerProvider& layerProvider, const SymbolPin& pin,
56  const ComponentSignal* compSignal,
57  const CmpSigPinDisplayType& displayType) noexcept;
59 
60  // Setters
61  void setDrawBoundingRect(bool enable) noexcept { mDrawBoundingRect = enable; }
62 
63  // General Methods
64  void updateCacheAndRepaint() noexcept;
65 
66  // Inherited from QGraphicsItem
67  QRectF boundingRect() const noexcept override { return mBoundingRect; }
68  QPainterPath shape() const noexcept override { return mShape; }
69  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
70  QWidget* widget = 0) noexcept override;
71 
72 private:
73  // make some methods inaccessible...
76  delete;
77  SymbolPinPreviewGraphicsItem& operator =(
78  const SymbolPinPreviewGraphicsItem& rhs) = delete;
79 
80  // General Attributes
81  const SymbolPin& mPin;
87  QFont mFont;
88  qreal mRadiusPx;
90 
91  // Cached Attributes
92  QStaticText mStaticText;
93  bool mRotate180;
94  QRectF mBoundingRect;
95  QPointF mTextOrigin;
97  QPainterPath mShape;
98 };
99 
100 /*******************************************************************************
101  * End of File
102  ******************************************************************************/
103 
104 } // namespace library
105 } // namespace librepcb
106 
107 #endif // LIBREPCB_LIBRARY_SYMBOLPINPREVIEWGRAPHICSITEM_H
bool mRotate180
Definition: symbolpinpreviewgraphicsitem.h:93
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=0) noexceptoverride
Definition: symbolpinpreviewgraphicsitem.cpp:149
GraphicsLayer * mTextLayer
Definition: symbolpinpreviewgraphicsitem.h:86
The CmpSigPinDisplayType clas.
Definition: cmpsigpindisplaytype.h:43
void setDrawBoundingRect(bool enable) noexcept
Definition: symbolpinpreviewgraphicsitem.h:61
QRectF mBoundingRect
Definition: symbolpinpreviewgraphicsitem.h:94
QRectF boundingRect() const noexceptoverride
Definition: symbolpinpreviewgraphicsitem.h:67
The ComponentSignal class represents one signal of a component.
Definition: componentsignal.h:49
QPainterPath mShape
Definition: symbolpinpreviewgraphicsitem.h:97
The IF_GraphicsLayerProvider class defines an interface for classes which provide layers...
Definition: graphicslayer.h:227
QStaticText mStaticText
Definition: symbolpinpreviewgraphicsitem.h:92
QFont mFont
Definition: symbolpinpreviewgraphicsitem.h:87
bool mDrawBoundingRect
Definition: symbolpinpreviewgraphicsitem.h:89
const SymbolPin & mPin
Definition: symbolpinpreviewgraphicsitem.h:81
qreal mRadiusPx
Definition: symbolpinpreviewgraphicsitem.h:88
GraphicsLayer * mCircleLayer
Definition: symbolpinpreviewgraphicsitem.h:84
~SymbolPinPreviewGraphicsItem() noexcept
Definition: symbolpinpreviewgraphicsitem.cpp:78
GraphicsLayer * mLineLayer
Definition: symbolpinpreviewgraphicsitem.h:85
CmpSigPinDisplayType mDisplayType
Definition: symbolpinpreviewgraphicsitem.h:83
const ComponentSignal * mComponentSignal
Definition: symbolpinpreviewgraphicsitem.h:82
The SymbolPinPreviewGraphicsItem class.
Definition: symbolpinpreviewgraphicsitem.h:51
QPointF mTextOrigin
Definition: symbolpinpreviewgraphicsitem.h:95
void updateCacheAndRepaint() noexcept
Definition: symbolpinpreviewgraphicsitem.cpp:85
The SymbolPin class represents one pin of a symbol.
Definition: symbolpin.h:54
QPainterPath shape() const noexceptoverride
Definition: symbolpinpreviewgraphicsitem.h:68
QRectF mTextBoundingRect
Definition: symbolpinpreviewgraphicsitem.h:96