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 
54 class SymbolPinPreviewGraphicsItem final : public QGraphicsItem {
55 public:
56  // Constructors / Destructor
58  const IF_GraphicsLayerProvider& layerProvider, const SymbolPin& pin,
59  const ComponentSignal* compSignal,
60  const CmpSigPinDisplayType& displayType) noexcept;
62 
63  // Setters
64  void setDrawBoundingRect(bool enable) noexcept { mDrawBoundingRect = enable; }
65 
66  // General Methods
67  void updateCacheAndRepaint() noexcept;
68 
69  // Inherited from QGraphicsItem
70  QRectF boundingRect() const noexcept override { return mBoundingRect; }
71  QPainterPath shape() const noexcept override { return mShape; }
72  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
73  QWidget* widget = 0) noexcept override;
74 
75 private:
76  // make some methods inaccessible...
79  delete;
80  SymbolPinPreviewGraphicsItem& operator =(
81  const SymbolPinPreviewGraphicsItem& rhs) = delete;
82 
83  // General Attributes
84  const SymbolPin& mPin;
90  QFont mFont;
91  qreal mRadiusPx;
93 
94  // Cached Attributes
95  QStaticText mStaticText;
96  bool mRotate180;
97  QRectF mBoundingRect;
98  QPointF mTextOrigin;
100  QPainterPath mShape;
101 };
102 
103 /*******************************************************************************
104  * End of File
105  ******************************************************************************/
106 
107 } // namespace library
108 } // namespace librepcb
109 
110 #endif // LIBREPCB_LIBRARY_SYMBOLPINPREVIEWGRAPHICSITEM_H
bool mRotate180
Definition: symbolpinpreviewgraphicsitem.h:96
The GraphicsLayer class represents a graphical layer used in schematics and boards.
Definition: graphicslayer.h:54
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0) noexceptoverride
Definition: symbolpinpreviewgraphicsitem.cpp:149
GraphicsLayer * mTextLayer
Definition: symbolpinpreviewgraphicsitem.h:89
The CmpSigPinDisplayType clas.
Definition: cmpsigpindisplaytype.h:46
void setDrawBoundingRect(bool enable) noexcept
Definition: symbolpinpreviewgraphicsitem.h:64
QRectF mBoundingRect
Definition: symbolpinpreviewgraphicsitem.h:97
QRectF boundingRect() const noexceptoverride
Definition: symbolpinpreviewgraphicsitem.h:70
The ComponentSignal class represents one signal of a component.
Definition: componentsignal.h:49
QPainterPath mShape
Definition: symbolpinpreviewgraphicsitem.h:100
The IF_GraphicsLayerProvider class defines an interface for classes which provide layers...
Definition: graphicslayer.h:250
QStaticText mStaticText
Definition: symbolpinpreviewgraphicsitem.h:95
QFont mFont
Definition: symbolpinpreviewgraphicsitem.h:90
bool mDrawBoundingRect
Definition: symbolpinpreviewgraphicsitem.h:92
const SymbolPin & mPin
Definition: symbolpinpreviewgraphicsitem.h:84
qreal mRadiusPx
Definition: symbolpinpreviewgraphicsitem.h:91
GraphicsLayer * mCircleLayer
Definition: symbolpinpreviewgraphicsitem.h:87
~SymbolPinPreviewGraphicsItem() noexcept
Definition: symbolpinpreviewgraphicsitem.cpp:78
GraphicsLayer * mLineLayer
Definition: symbolpinpreviewgraphicsitem.h:88
CmpSigPinDisplayType mDisplayType
Definition: symbolpinpreviewgraphicsitem.h:86
const ComponentSignal * mComponentSignal
Definition: symbolpinpreviewgraphicsitem.h:85
The SymbolPinPreviewGraphicsItem class.
Definition: symbolpinpreviewgraphicsitem.h:54
QPointF mTextOrigin
Definition: symbolpinpreviewgraphicsitem.h:98
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:71
QRectF mTextBoundingRect
Definition: symbolpinpreviewgraphicsitem.h:99