LibrePCB Developers Documentation
schematicgraphicsscene.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_EDITOR_SCHEMATICGRAPHICSSCENE_H
21#define LIBREPCB_EDITOR_SCHEMATICGRAPHICSSCENE_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../graphics/graphicsscene.h"
27
28#include <QtCore>
29#include <QtWidgets>
30
31#include <memory>
32
33/*******************************************************************************
34 * Namespace / Forward Declarations
35 ******************************************************************************/
36namespace librepcb {
37
38class NetSignal;
39class SI_NetLabel;
40class SI_NetLine;
41class SI_NetPoint;
42class SI_NetSegment;
43class SI_Polygon;
44class SI_Symbol;
45class SI_SymbolPin;
46class SI_Text;
47class Schematic;
48
49namespace editor {
50
51class IF_GraphicsLayerProvider;
52class PolygonGraphicsItem;
53class SGI_NetLabel;
54class SGI_NetLine;
55class SGI_NetPoint;
56class SGI_Symbol;
57class SGI_SymbolPin;
58class SGI_Text;
59
60/*******************************************************************************
61 * Class SchematicGraphicsScene
62 ******************************************************************************/
63
68 Q_OBJECT
69
70public:
80 enum ZValue : int {
91 };
92
93 // Constructors / Destructor
97 Schematic& schematic, const IF_GraphicsLayerProvider& lp,
98 std::shared_ptr<const QSet<const NetSignal*>> highlightedNetSignals,
99 QObject* parent = nullptr) noexcept;
100 virtual ~SchematicGraphicsScene() noexcept;
101
102 // Getters
103 Schematic& getSchematic() noexcept { return mSchematic; }
104 const QHash<SI_Symbol*, std::shared_ptr<SGI_Symbol>>& getSymbols() noexcept {
105 return mSymbols;
106 }
107 const QHash<SI_SymbolPin*, std::shared_ptr<SGI_SymbolPin>>&
108 getSymbolPins() noexcept {
109 return mSymbolPins;
110 }
111 const QHash<SI_NetPoint*, std::shared_ptr<SGI_NetPoint>>&
112 getNetPoints() noexcept {
113 return mNetPoints;
114 }
115 const QHash<SI_NetLine*, std::shared_ptr<SGI_NetLine>>&
116 getNetLines() noexcept {
117 return mNetLines;
118 }
119 const QHash<SI_NetLabel*, std::shared_ptr<SGI_NetLabel>>&
120 getNetLabels() noexcept {
121 return mNetLabels;
122 }
123 const QHash<SI_Polygon*, std::shared_ptr<PolygonGraphicsItem>>&
124 getPolygons() noexcept {
125 return mPolygons;
126 }
127 const QHash<SI_Text*, std::shared_ptr<SGI_Text>>& getTexts() noexcept {
128 return mTexts;
129 }
130
131 // General Methods
132 void selectAll() noexcept;
133 void selectItemsInRect(const Point& p1, const Point& p2) noexcept;
134 void clearSelection() noexcept;
135 void updateHighlightedNetSignals() noexcept;
136
137 // Operator Overloadings
138 SchematicGraphicsScene& operator=(const SchematicGraphicsScene& rhs) = delete;
139
140private: // Methods
141 void addSymbol(SI_Symbol& symbol) noexcept;
142 void removeSymbol(SI_Symbol& symbol) noexcept;
143 void addSymbolPin(SI_SymbolPin& pin,
144 std::weak_ptr<SGI_Symbol> symbol) noexcept;
145 void removeSymbolPin(SI_SymbolPin& pin) noexcept;
146 void addNetSegment(SI_NetSegment& netSegment) noexcept;
147 void removeNetSegment(SI_NetSegment& netSegment) noexcept;
148 void addNetPointsAndNetLines(const QList<SI_NetPoint*>& netPoints,
149 const QList<SI_NetLine*>& netLines) noexcept;
150 void removeNetPointsAndNetLines(const QList<SI_NetPoint*>& netPoints,
151 const QList<SI_NetLine*>& netLines) noexcept;
152 void addNetPoint(SI_NetPoint& netPoint) noexcept;
153 void removeNetPoint(SI_NetPoint& netPoint) noexcept;
154 void addNetLine(SI_NetLine& netLine) noexcept;
155 void removeNetLine(SI_NetLine& netLine) noexcept;
156 void addNetLabel(SI_NetLabel& netLabel) noexcept;
157 void removeNetLabel(SI_NetLabel& netLabel) noexcept;
158 void addPolygon(SI_Polygon& polygon) noexcept;
159 void removePolygon(SI_Polygon& polygon) noexcept;
160 void addText(SI_Text& text) noexcept;
161 void removeText(SI_Text& text) noexcept;
162
163private: // Data
166 std::shared_ptr<const QSet<const NetSignal*>> mHighlightedNetSignals;
167 QHash<SI_Symbol*, std::shared_ptr<SGI_Symbol>> mSymbols;
168 QHash<SI_SymbolPin*, std::shared_ptr<SGI_SymbolPin>> mSymbolPins;
169 QHash<SI_NetPoint*, std::shared_ptr<SGI_NetPoint>> mNetPoints;
170 QHash<SI_NetLine*, std::shared_ptr<SGI_NetLine>> mNetLines;
171 QHash<SI_NetLabel*, std::shared_ptr<SGI_NetLabel>> mNetLabels;
172 QHash<SI_Polygon*, std::shared_ptr<PolygonGraphicsItem>> mPolygons;
173 QHash<SI_Text*, std::shared_ptr<SGI_Text>> mTexts;
174};
175
176/*******************************************************************************
177 * End of File
178 ******************************************************************************/
179
180} // namespace editor
181} // namespace librepcb
182
183#endif
The NetSignal class.
Definition: netsignal.h:50
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition: point.h:79
The SI_NetLabel class.
Definition: si_netlabel.h:49
The SI_NetLine class.
Definition: si_netline.h:65
The SI_NetPoint class.
Definition: si_netpoint.h:44
The SI_NetSegment class.
Definition: si_netsegment.h:53
The SI_Polygon class represents a polygon in a schematic.
Definition: si_polygon.h:47
The SI_Symbol class.
Definition: si_symbol.h:54
The SI_SymbolPin class.
Definition: si_symbolpin.h:52
The SI_Text class represents a text label in a schematic.
Definition: si_text.h:48
The Schematic class represents one schematic page of a project and is always part of a circuit.
Definition: schematic.h:74
The GraphicsScene class.
Definition: graphicsscene.h:45
The IF_GraphicsLayerProvider class defines an interface for classes which provide layers.
Definition: graphicslayer.h:111
The PolygonGraphicsItem class.
Definition: polygongraphicsitem.h:48
The SGI_NetLabel class.
Definition: sgi_netlabel.h:50
The SGI_NetLine class.
Definition: sgi_netline.h:49
The SGI_NetPoint class.
Definition: sgi_netpoint.h:49
The SGI_Symbol class.
Definition: sgi_symbol.h:52
The SGI_SymbolPin class.
Definition: sgi_symbolpin.h:53
The SGI_Text class.
Definition: sgi_text.h:50
The SchematicGraphicsScene class.
Definition: schematicgraphicsscene.h:67
void removeNetPoint(SI_NetPoint &netPoint) noexcept
Definition: schematicgraphicsscene.cpp:359
void removeNetPointsAndNetLines(const QList< SI_NetPoint * > &netPoints, const QList< SI_NetLine * > &netLines) noexcept
Definition: schematicgraphicsscene.cpp:340
std::shared_ptr< const QSet< const NetSignal * > > mHighlightedNetSignals
Definition: schematicgraphicsscene.h:166
void addPolygon(SI_Polygon &polygon) noexcept
Definition: schematicgraphicsscene.cpp:399
void removePolygon(SI_Polygon &polygon) noexcept
Definition: schematicgraphicsscene.cpp:408
const QHash< SI_Text *, std::shared_ptr< SGI_Text > > & getTexts() noexcept
Definition: schematicgraphicsscene.h:127
QHash< SI_NetPoint *, std::shared_ptr< SGI_NetPoint > > mNetPoints
Definition: schematicgraphicsscene.h:169
const QHash< SI_NetLabel *, std::shared_ptr< SGI_NetLabel > > & getNetLabels() noexcept
Definition: schematicgraphicsscene.h:120
Schematic & mSchematic
Definition: schematicgraphicsscene.h:164
void removeNetSegment(SI_NetSegment &netSegment) noexcept
Definition: schematicgraphicsscene.cpp:308
void clearSelection() noexcept
Definition: schematicgraphicsscene.cpp:188
void removeNetLabel(SI_NetLabel &netLabel) noexcept
Definition: schematicgraphicsscene.cpp:391
void removeText(SI_Text &text) noexcept
Definition: schematicgraphicsscene.cpp:424
const QHash< SI_NetLine *, std::shared_ptr< SGI_NetLine > > & getNetLines() noexcept
Definition: schematicgraphicsscene.h:116
QHash< SI_Polygon *, std::shared_ptr< PolygonGraphicsItem > > mPolygons
Definition: schematicgraphicsscene.h:172
ZValue
Z-values of all items in a schematic (to define the stacking order)
Definition: schematicgraphicsscene.h:80
@ ZValue_VisibleNetPoints
For visible librepcb::SI_NetPoint items.
Definition: schematicgraphicsscene.h:90
@ ZValue_HiddenNetPoints
Foror hidden librepcb::SI_NetPoint items.
Definition: schematicgraphicsscene.h:89
@ ZValue_NetLabels
For librepcb::SI_NetLabel items.
Definition: schematicgraphicsscene.h:87
@ ZValue_Texts
For librepcb::SI_Text items.
Definition: schematicgraphicsscene.h:86
@ ZValue_Default
this is the default value (behind all other items)
Definition: schematicgraphicsscene.h:81
@ ZValue_SymbolPins
For librepcb::SI_SymbolPin items.
Definition: schematicgraphicsscene.h:84
@ ZValue_Symbols
For librepcb::SI_Symbol items.
Definition: schematicgraphicsscene.h:83
@ ZValue_NetLines
For librepcb::SI_NetLine items.
Definition: schematicgraphicsscene.h:88
@ ZValue_TextAnchors
For librepcb::SI_Text anchor lines.
Definition: schematicgraphicsscene.h:82
@ ZValue_Polygons
For librepcb::SI_Polygon items.
Definition: schematicgraphicsscene.h:85
void removeNetLine(SI_NetLine &netLine) noexcept
Definition: schematicgraphicsscene.cpp:375
void addNetLine(SI_NetLine &netLine) noexcept
Definition: schematicgraphicsscene.cpp:367
const IF_GraphicsLayerProvider & mLayerProvider
Definition: schematicgraphicsscene.h:165
void addNetPointsAndNetLines(const QList< SI_NetPoint * > &netPoints, const QList< SI_NetLine * > &netLines) noexcept
Definition: schematicgraphicsscene.cpp:329
void addNetSegment(SI_NetSegment &netSegment) noexcept
Definition: schematicgraphicsscene.cpp:288
QHash< SI_Text *, std::shared_ptr< SGI_Text > > mTexts
Definition: schematicgraphicsscene.h:173
void addSymbolPin(SI_SymbolPin &pin, std::weak_ptr< SGI_Symbol > symbol) noexcept
Definition: schematicgraphicsscene.cpp:271
QHash< SI_Symbol *, std::shared_ptr< SGI_Symbol > > mSymbols
Definition: schematicgraphicsscene.h:167
const QHash< SI_Symbol *, std::shared_ptr< SGI_Symbol > > & getSymbols() noexcept
Definition: schematicgraphicsscene.h:104
const QHash< SI_NetPoint *, std::shared_ptr< SGI_NetPoint > > & getNetPoints() noexcept
Definition: schematicgraphicsscene.h:112
void addText(SI_Text &text) noexcept
Definition: schematicgraphicsscene.cpp:416
const QHash< SI_Polygon *, std::shared_ptr< PolygonGraphicsItem > > & getPolygons() noexcept
Definition: schematicgraphicsscene.h:124
void removeSymbolPin(SI_SymbolPin &pin) noexcept
Definition: schematicgraphicsscene.cpp:280
void addNetPoint(SI_NetPoint &netPoint) noexcept
Definition: schematicgraphicsscene.cpp:351
Schematic & getSchematic() noexcept
Definition: schematicgraphicsscene.h:103
QHash< SI_NetLabel *, std::shared_ptr< SGI_NetLabel > > mNetLabels
Definition: schematicgraphicsscene.h:171
void addNetLabel(SI_NetLabel &netLabel) noexcept
Definition: schematicgraphicsscene.cpp:383
QHash< SI_NetLine *, std::shared_ptr< SGI_NetLine > > mNetLines
Definition: schematicgraphicsscene.h:170
QHash< SI_SymbolPin *, std::shared_ptr< SGI_SymbolPin > > mSymbolPins
Definition: schematicgraphicsscene.h:168
void selectAll() noexcept
Definition: schematicgraphicsscene.cpp:126
void removeSymbol(SI_Symbol &symbol) noexcept
Definition: schematicgraphicsscene.cpp:251
void selectItemsInRect(const Point &p1, const Point &p2) noexcept
Definition: schematicgraphicsscene.cpp:150
void addSymbol(SI_Symbol &symbol) noexcept
Definition: schematicgraphicsscene.cpp:231
void updateHighlightedNetSignals() noexcept
Definition: schematicgraphicsscene.cpp:212
const QHash< SI_SymbolPin *, std::shared_ptr< SGI_SymbolPin > > & getSymbolPins() noexcept
Definition: schematicgraphicsscene.h:108
SchematicGraphicsScene(const SchematicGraphicsScene &other)=delete
Definition: occmodel.cpp:77