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 
57 class SGI_Symbol final : public SGI_Base {
58 public:
59  // Constructors / Destructor
60  explicit SGI_Symbol(SI_Symbol& symbol) noexcept;
61  ~SGI_Symbol() noexcept;
62 
63  // General Methods
64  void updateCacheAndRepaint() noexcept;
65 
66  // Inherited from QGraphicsItem
67  QRectF boundingRect() const noexcept { return mBoundingRect; }
68  QPainterPath shape() const noexcept { return mShape; }
69  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
70  QWidget* widget = 0);
71 
72 private:
73  // make some methods inaccessible...
74  SGI_Symbol() = delete;
75  SGI_Symbol(const SGI_Symbol& other) = delete;
76  SGI_Symbol& operator=(const SGI_Symbol& rhs) = delete;
77 
78  // Private Methods
79  GraphicsLayer* getLayer(const QString& name) const noexcept;
80 
81  // Types
82 
84  QString text;
86  qreal scaleFactor;
87  bool rotate180;
88  bool mirrored;
89  int flags;
90  QRectF textRect; // not scaled
91  };
92 
93  // General Attributes
96  QFont mFont;
97 
98  // Cached Attributes
99  QRectF mBoundingRect;
100  QPainterPath mShape;
101  QHash<const Text*, CachedTextProperties_t> mCachedTextProperties;
102 };
103 
104 /*******************************************************************************
105  * End of File
106  ******************************************************************************/
107 
108 } // namespace project
109 } // namespace librepcb
110 
111 #endif // LIBREPCB_PROJECT_SGI_SYMBOL_H
QFont mFont
Definition: sgi_symbol.h:96
The GraphicsLayer class represents a graphical layer used in schematics and boards.
Definition: graphicslayer.h:54
The SI_Symbol class.
Definition: si_symbol.h:60
QRectF textRect
Definition: sgi_symbol.h:90
qreal scaleFactor
Definition: sgi_symbol.h:86
SI_Symbol & mSymbol
Definition: sgi_symbol.h:94
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:100
SGI_Symbol & operator=(const SGI_Symbol &rhs)=delete
const library::Symbol & mLibSymbol
Definition: sgi_symbol.h:95
The Schematic Graphics Item Base (SGI_Base) class.
Definition: sgi_base.h:44
The SGI_Symbol class.
Definition: sgi_symbol.h:57
QRectF mBoundingRect
Definition: sgi_symbol.h:99
QRectF boundingRect() const noexcept
Definition: sgi_symbol.h:67
QHash< const Text *, CachedTextProperties_t > mCachedTextProperties
Definition: sgi_symbol.h:101
QPainterPath shape() const noexcept
Definition: sgi_symbol.h:68
void updateCacheAndRepaint() noexcept
Definition: sgi_symbol.cpp:66
~SGI_Symbol() noexcept
Definition: sgi_symbol.cpp:59