LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sgi_symbol.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_SYMBOL_H
21 #define LIBREPCB_PROJECT_SGI_SYMBOL_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 Text;
37 class GraphicsLayer;
38 
39 namespace library {
40 class Symbol;
41 }
42 
43 namespace project {
44 
45 class SI_Symbol;
46 
47 /*******************************************************************************
48  * Class SGI_Symbol
49  ******************************************************************************/
50 
54 class SGI_Symbol final : public SGI_Base {
55 public:
56  // Constructors / Destructor
57  explicit SGI_Symbol(SI_Symbol& symbol) noexcept;
58  ~SGI_Symbol() noexcept;
59 
60  // General Methods
61  void updateCacheAndRepaint() noexcept;
62 
63  // Inherited from QGraphicsItem
64  QRectF boundingRect() const noexcept { return mBoundingRect; }
65  QPainterPath shape() const noexcept { return mShape; }
66  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
67  QWidget* widget = 0);
68 
69 private:
70  // make some methods inaccessible...
71  SGI_Symbol() = delete;
72  SGI_Symbol(const SGI_Symbol& other) = delete;
73  SGI_Symbol& operator=(const SGI_Symbol& rhs) = delete;
74 
75  // Private Methods
76  GraphicsLayer* getLayer(const QString& name) const noexcept;
77 
78  // Types
79 
81  QString text;
83  qreal scaleFactor;
84  bool rotate180;
85  bool mirrored;
86  int flags;
87  QRectF textRect; // not scaled
88  };
89 
90  // General Attributes
93  QFont mFont;
94 
95  // Cached Attributes
96  QRectF mBoundingRect;
97  QPainterPath mShape;
98  QHash<const Text*, CachedTextProperties_t> mCachedTextProperties;
99 };
100 
101 /*******************************************************************************
102  * End of File
103  ******************************************************************************/
104 
105 } // namespace project
106 } // namespace librepcb
107 
108 #endif // LIBREPCB_PROJECT_SGI_SYMBOL_H
QFont mFont
Definition: sgi_symbol.h:93
The GraphicsLayer class represents a graphical layer used in schematics and boards.
Definition: graphicslayer.h:50
The SI_Symbol class.
Definition: si_symbol.h:57
QRectF textRect
Definition: sgi_symbol.h:87
qreal scaleFactor
Definition: sgi_symbol.h:83
SI_Symbol & mSymbol
Definition: sgi_symbol.h:91
GraphicsLayer * getLayer(const QString &name) const noexcept
Definition: sgi_symbol.cpp:352
The Symbol class represents the part of a component which is added to schematics. ...
Definition: symbol.h:57
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
Definition: sgi_symbol.cpp:183
QPainterPath mShape
Definition: sgi_symbol.h:97
SGI_Symbol & operator=(const SGI_Symbol &rhs)=delete
const library::Symbol & mLibSymbol
Definition: sgi_symbol.h:92
The Schematic Graphics Item Base (SGI_Base) class.
Definition: sgi_base.h:44
The SGI_Symbol class.
Definition: sgi_symbol.h:54
QRectF mBoundingRect
Definition: sgi_symbol.h:96
QRectF boundingRect() const noexcept
Definition: sgi_symbol.h:64
QHash< const Text *, CachedTextProperties_t > mCachedTextProperties
Definition: sgi_symbol.h:98
QPainterPath shape() const noexcept
Definition: sgi_symbol.h:65
void updateCacheAndRepaint() noexcept
Definition: sgi_symbol.cpp:66
~SGI_Symbol() noexcept
Definition: sgi_symbol.cpp:59