LibrePCB Developers Documentation
Loading...
Searching...
No Matches
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_BusJunction;
40class SI_BusLabel;
41class SI_BusLine;
42class SI_BusSegment;
43class SI_Image;
44class SI_NetLabel;
45class SI_NetLine;
46class SI_NetPoint;
47class SI_NetSegment;
48class SI_Polygon;
49class SI_Symbol;
50class SI_SymbolPin;
51class SI_Text;
52class Schematic;
53
54namespace editor {
55
56class GraphicsLayerList;
57class ImageGraphicsItem;
58class PolygonGraphicsItem;
59class SGI_BusJunction;
60class SGI_BusLabel;
61class SGI_BusLine;
62class SGI_NetLabel;
63class SGI_NetLine;
64class SGI_NetPoint;
65class SGI_Symbol;
66class SGI_SymbolPin;
67class SGI_Text;
68
69/*******************************************************************************
70 * Class SchematicGraphicsScene
71 ******************************************************************************/
72
77 Q_OBJECT
78
79public:
108
109 // Constructors / Destructor
112 explicit SchematicGraphicsScene(
113 Schematic& schematic, const GraphicsLayerList& layers,
114 std::shared_ptr<const QSet<const NetSignal*>> highlightedNetSignals,
115 bool& ignorePlacementLocks, QObject* parent = nullptr) noexcept;
116 virtual ~SchematicGraphicsScene() noexcept;
117
118 // Getters
119 Schematic& getSchematic() noexcept { return mSchematic; }
120 const QHash<SI_Symbol*, std::shared_ptr<SGI_Symbol>>& getSymbols() noexcept {
121 return mSymbols;
122 }
123 const QHash<SI_SymbolPin*, std::shared_ptr<SGI_SymbolPin>>&
124 getSymbolPins() noexcept {
125 return mSymbolPins;
126 }
127 const QHash<SI_BusJunction*, std::shared_ptr<SGI_BusJunction>>&
128 getBusJunctions() noexcept {
129 return mBusJunctions;
130 }
131 const QHash<SI_BusLine*, std::shared_ptr<SGI_BusLine>>&
132 getBusLines() noexcept {
133 return mBusLines;
134 }
135 const QHash<SI_BusLabel*, std::shared_ptr<SGI_BusLabel>>&
136 getBusLabels() noexcept {
137 return mBusLabels;
138 }
139 const QHash<SI_NetPoint*, std::shared_ptr<SGI_NetPoint>>&
140 getNetPoints() noexcept {
141 return mNetPoints;
142 }
143 const QHash<SI_NetLine*, std::shared_ptr<SGI_NetLine>>&
144 getNetLines() noexcept {
145 return mNetLines;
146 }
147 const QHash<SI_NetLabel*, std::shared_ptr<SGI_NetLabel>>&
148 getNetLabels() noexcept {
149 return mNetLabels;
150 }
151 const QHash<SI_Polygon*, std::shared_ptr<PolygonGraphicsItem>>&
152 getPolygons() noexcept {
153 return mPolygons;
154 }
155 const QHash<SI_Text*, std::shared_ptr<SGI_Text>>& getTexts() noexcept {
156 return mTexts;
157 }
158 const QHash<SI_Image*, std::shared_ptr<ImageGraphicsItem>>&
159 getImages() noexcept {
160 return mImages;
161 }
162
163 // General Methods
164 void selectAll() noexcept;
165 void selectItemsInRect(const Point& p1, const Point& p2) noexcept;
166 void clearSelection() noexcept;
167 void updateHighlightedNetSignals() noexcept;
168
169 // Operator Overloadings
170 SchematicGraphicsScene& operator=(const SchematicGraphicsScene& rhs) = delete;
171
172private: // Methods
173 void addSymbol(SI_Symbol& symbol) noexcept;
174 void removeSymbol(SI_Symbol& symbol) noexcept;
175 void addSymbolPin(SI_SymbolPin& pin,
176 std::weak_ptr<SGI_Symbol> symbol) noexcept;
177 void removeSymbolPin(SI_SymbolPin& pin) noexcept;
178 void addBusSegment(SI_BusSegment& segment) noexcept;
179 void removeBusSegment(SI_BusSegment& segment) noexcept;
180 void addBusJunctionsAndLines(const QList<SI_BusJunction*>& junctions,
181 const QList<SI_BusLine*>& lines) noexcept;
182 void removeBusJunctionsAndLines(const QList<SI_BusJunction*>& junctions,
183 const QList<SI_BusLine*>& lines) noexcept;
184 void addBusJunction(SI_BusJunction& junction) noexcept;
185 void removeBusJunction(SI_BusJunction& junction) noexcept;
186 void addBusLine(SI_BusLine& line) noexcept;
187 void removeBusLine(SI_BusLine& line) noexcept;
188 void addBusLabel(SI_BusLabel& label) noexcept;
189 void removeBusLabel(SI_BusLabel& label) noexcept;
190 void addNetSegment(SI_NetSegment& netSegment) noexcept;
191 void removeNetSegment(SI_NetSegment& netSegment) noexcept;
192 void addNetPointsAndNetLines(const QList<SI_NetPoint*>& netPoints,
193 const QList<SI_NetLine*>& netLines) noexcept;
194 void removeNetPointsAndNetLines(const QList<SI_NetPoint*>& netPoints,
195 const QList<SI_NetLine*>& netLines) noexcept;
196 void addNetPoint(SI_NetPoint& netPoint) noexcept;
197 void removeNetPoint(SI_NetPoint& netPoint) noexcept;
198 void addNetLine(SI_NetLine& netLine) noexcept;
199 void removeNetLine(SI_NetLine& netLine) noexcept;
200 void addNetLabel(SI_NetLabel& netLabel) noexcept;
201 void removeNetLabel(SI_NetLabel& netLabel) noexcept;
202 void addPolygon(SI_Polygon& polygon) noexcept;
203 void removePolygon(SI_Polygon& polygon) noexcept;
204 void addText(SI_Text& text) noexcept;
205 void removeText(SI_Text& text) noexcept;
206 void addImage(SI_Image& image) noexcept;
207 void removeImage(SI_Image& image) noexcept;
208
209private: // Data
212 std::shared_ptr<const QSet<const NetSignal*>> mHighlightedNetSignals;
214 QHash<SI_Symbol*, std::shared_ptr<SGI_Symbol>> mSymbols;
217 QHash<SI_BusLine*, std::shared_ptr<SGI_BusLine>> mBusLines;
218 QHash<SI_BusLabel*, std::shared_ptr<SGI_BusLabel>> mBusLabels;
219 QHash<SI_NetPoint*, std::shared_ptr<SGI_NetPoint>> mNetPoints;
220 QHash<SI_NetLine*, std::shared_ptr<SGI_NetLine>> mNetLines;
221 QHash<SI_NetLabel*, std::shared_ptr<SGI_NetLabel>> mNetLabels;
223 QHash<SI_Text*, std::shared_ptr<SGI_Text>> mTexts;
224 QHash<SI_Image*, std::shared_ptr<ImageGraphicsItem>> mImages;
225};
226
227/*******************************************************************************
228 * End of File
229 ******************************************************************************/
230
231} // namespace editor
232} // namespace librepcb
233
234#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:78
The SI_BusJunction class.
Definition si_busjunction.h:45
The SI_BusLabel class.
Definition si_buslabel.h:48
The SI_BusLine class.
Definition si_busline.h:47
The SI_BusSegment class.
Definition si_bussegment.h:52
The SI_Image class represents an image in a schematic.
Definition si_image.h:45
The SI_NetLabel class.
Definition si_netlabel.h:48
The SI_NetLine class.
Definition si_netline.h:64
The SI_NetPoint class.
Definition si_netpoint.h:44
The SI_NetSegment class.
Definition si_netsegment.h:55
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:53
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:81
The GraphicsLayerList class.
Definition graphicslayerlist.h:48
The GraphicsScene class.
Definition graphicsscene.h:64
The ImageGraphicsItem class is the graphical representation of a librepcb::Image.
Definition imagegraphicsitem.h:52
The PolygonGraphicsItem class.
Definition polygongraphicsitem.h:48
The SGI_BusJunction class.
Definition sgi_busjunction.h:49
The SGI_BusLabel class.
Definition sgi_buslabel.h:50
The SGI_BusLine class.
Definition sgi_busline.h:52
The SGI_NetLabel class.
Definition sgi_netlabel.h:53
The SGI_NetLine class.
Definition sgi_netline.h:52
The SGI_NetPoint class.
Definition sgi_netpoint.h:52
The SGI_Symbol class.
Definition sgi_symbol.h:53
The SGI_SymbolPin class.
Definition sgi_symbolpin.h:53
The SGI_Text class.
Definition sgi_text.h:50
The SchematicGraphicsScene class.
Definition schematicgraphicsscene.h:76
QHash< SI_BusJunction *, std::shared_ptr< SGI_BusJunction > > mBusJunctions
Definition schematicgraphicsscene.h:216
void removeNetPoint(SI_NetPoint &netPoint) noexcept
Definition schematicgraphicsscene.cpp:556
void removeNetPointsAndNetLines(const QList< SI_NetPoint * > &netPoints, const QList< SI_NetLine * > &netLines) noexcept
Definition schematicgraphicsscene.cpp:537
std::shared_ptr< const QSet< const NetSignal * > > mHighlightedNetSignals
Definition schematicgraphicsscene.h:212
void addPolygon(SI_Polygon &polygon) noexcept
Definition schematicgraphicsscene.cpp:596
void removePolygon(SI_Polygon &polygon) noexcept
Definition schematicgraphicsscene.cpp:605
const QHash< SI_Text *, std::shared_ptr< SGI_Text > > & getTexts() noexcept
Definition schematicgraphicsscene.h:155
QHash< SI_NetPoint *, std::shared_ptr< SGI_NetPoint > > mNetPoints
Definition schematicgraphicsscene.h:219
void addBusLabel(SI_BusLabel &label) noexcept
Definition schematicgraphicsscene.cpp:469
const QHash< SI_NetLabel *, std::shared_ptr< SGI_NetLabel > > & getNetLabels() noexcept
Definition schematicgraphicsscene.h:148
Schematic & mSchematic
Definition schematicgraphicsscene.h:210
void removeNetSegment(SI_NetSegment &netSegment) noexcept
Definition schematicgraphicsscene.cpp:505
void clearSelection() noexcept
Definition schematicgraphicsscene.cpp:262
void removeNetLabel(SI_NetLabel &netLabel) noexcept
Definition schematicgraphicsscene.cpp:588
void removeText(SI_Text &text) noexcept
Definition schematicgraphicsscene.cpp:621
void addBusSegment(SI_BusSegment &segment) noexcept
Definition schematicgraphicsscene.cpp:374
const QHash< SI_NetLine *, std::shared_ptr< SGI_NetLine > > & getNetLines() noexcept
Definition schematicgraphicsscene.h:144
QHash< SI_Polygon *, std::shared_ptr< PolygonGraphicsItem > > mPolygons
Definition schematicgraphicsscene.h:222
ZValue
Z-values of all items in a schematic (to define the stacking order)
Definition schematicgraphicsscene.h:89
@ ZValue_ErcLocation
ERC location highlighting.
Definition schematicgraphicsscene.h:106
@ ZValue_VisibleNetPoints
For visible librepcb::SI_NetPoint items.
Definition schematicgraphicsscene.h:100
@ ZValue_HiddenNetPoints
Foror hidden librepcb::SI_NetPoint items.
Definition schematicgraphicsscene.h:99
@ ZValue_NetLabels
For librepcb::SI_NetLabel items.
Definition schematicgraphicsscene.h:97
@ ZValue_Texts
For librepcb::SI_Text items.
Definition schematicgraphicsscene.h:96
@ ZValue_Default
this is the default value (behind all other items)
Definition schematicgraphicsscene.h:90
@ ZValue_HiddenBusJunctions
For librepcb::SI_BusJunction items.
Definition schematicgraphicsscene.h:104
@ ZValue_SymbolPins
For librepcb::SI_SymbolPin items.
Definition schematicgraphicsscene.h:93
@ ZValue_Images
For librepcb::SI_Image items.
Definition schematicgraphicsscene.h:94
@ ZValue_Symbols
For librepcb::SI_Symbol items.
Definition schematicgraphicsscene.h:92
@ ZValue_NetLines
For librepcb::SI_NetLine items.
Definition schematicgraphicsscene.h:98
@ ZValue_VisibleBusJunctions
For librepcb::SI_BusJunction items.
Definition schematicgraphicsscene.h:105
@ ZValue_Buses
For librepcb::SI_BusLine items.
Definition schematicgraphicsscene.h:103
@ ZValue_TextAnchors
For librepcb::SI_Text anchor lines.
Definition schematicgraphicsscene.h:91
@ ZValue_Polygons
For librepcb::SI_Polygon items.
Definition schematicgraphicsscene.h:95
void removeBusSegment(SI_BusSegment &segment) noexcept
Definition schematicgraphicsscene.cpp:394
void removeNetLine(SI_NetLine &netLine) noexcept
Definition schematicgraphicsscene.cpp:572
QHash< SI_BusLine *, std::shared_ptr< SGI_BusLine > > mBusLines
Definition schematicgraphicsscene.h:217
const GraphicsLayerList & mLayers
Definition schematicgraphicsscene.h:211
QHash< SI_Image *, std::shared_ptr< ImageGraphicsItem > > mImages
Definition schematicgraphicsscene.h:224
const QHash< SI_BusLabel *, std::shared_ptr< SGI_BusLabel > > & getBusLabels() noexcept
Definition schematicgraphicsscene.h:136
void addNetLine(SI_NetLine &netLine) noexcept
Definition schematicgraphicsscene.cpp:564
void addNetPointsAndNetLines(const QList< SI_NetPoint * > &netPoints, const QList< SI_NetLine * > &netLines) noexcept
Definition schematicgraphicsscene.cpp:526
void removeBusLine(SI_BusLine &line) noexcept
Definition schematicgraphicsscene.cpp:461
void addNetSegment(SI_NetSegment &netSegment) noexcept
Definition schematicgraphicsscene.cpp:485
QHash< SI_Text *, std::shared_ptr< SGI_Text > > mTexts
Definition schematicgraphicsscene.h:223
void addBusJunction(SI_BusJunction &junction) noexcept
Definition schematicgraphicsscene.cpp:436
void addSymbolPin(SI_SymbolPin &pin, std::weak_ptr< SGI_Symbol > symbol) noexcept
Definition schematicgraphicsscene.cpp:357
QHash< SI_Symbol *, std::shared_ptr< SGI_Symbol > > mSymbols
Definition schematicgraphicsscene.h:214
const QHash< SI_Symbol *, std::shared_ptr< SGI_Symbol > > & getSymbols() noexcept
Definition schematicgraphicsscene.h:120
void removeBusJunctionsAndLines(const QList< SI_BusJunction * > &junctions, const QList< SI_BusLine * > &lines) noexcept
Definition schematicgraphicsscene.cpp:425
const QHash< SI_NetPoint *, std::shared_ptr< SGI_NetPoint > > & getNetPoints() noexcept
Definition schematicgraphicsscene.h:140
void addText(SI_Text &text) noexcept
Definition schematicgraphicsscene.cpp:613
const QHash< SI_Polygon *, std::shared_ptr< PolygonGraphicsItem > > & getPolygons() noexcept
Definition schematicgraphicsscene.h:152
void addBusJunctionsAndLines(const QList< SI_BusJunction * > &junctions, const QList< SI_BusLine * > &lines) noexcept
Definition schematicgraphicsscene.cpp:414
void removeSymbolPin(SI_SymbolPin &pin) noexcept
Definition schematicgraphicsscene.cpp:366
void addNetPoint(SI_NetPoint &netPoint) noexcept
Definition schematicgraphicsscene.cpp:548
const QHash< SI_BusLine *, std::shared_ptr< SGI_BusLine > > & getBusLines() noexcept
Definition schematicgraphicsscene.h:132
void addImage(SI_Image &image) noexcept
Definition schematicgraphicsscene.cpp:629
const QHash< SI_BusJunction *, std::shared_ptr< SGI_BusJunction > > & getBusJunctions() noexcept
Definition schematicgraphicsscene.h:128
Schematic & getSchematic() noexcept
Definition schematicgraphicsscene.h:119
void removeImage(SI_Image &image) noexcept
Definition schematicgraphicsscene.cpp:639
void addBusLine(SI_BusLine &line) noexcept
Definition schematicgraphicsscene.cpp:453
QHash< SI_NetLabel *, std::shared_ptr< SGI_NetLabel > > mNetLabels
Definition schematicgraphicsscene.h:221
void addNetLabel(SI_NetLabel &netLabel) noexcept
Definition schematicgraphicsscene.cpp:580
const bool & mIgnorePlacementLocks
Definition schematicgraphicsscene.h:213
QHash< SI_NetLine *, std::shared_ptr< SGI_NetLine > > mNetLines
Definition schematicgraphicsscene.h:220
QHash< SI_SymbolPin *, std::shared_ptr< SGI_SymbolPin > > mSymbolPins
Definition schematicgraphicsscene.h:215
void selectAll() noexcept
Definition schematicgraphicsscene.cpp:162
void removeSymbol(SI_Symbol &symbol) noexcept
Definition schematicgraphicsscene.cpp:337
void removeBusLabel(SI_BusLabel &label) noexcept
Definition schematicgraphicsscene.cpp:477
void selectItemsInRect(const Point &p1, const Point &p2) noexcept
Definition schematicgraphicsscene.cpp:198
void addSymbol(SI_Symbol &symbol) noexcept
Definition schematicgraphicsscene.cpp:317
void updateHighlightedNetSignals() noexcept
Definition schematicgraphicsscene.cpp:298
QHash< SI_BusLabel *, std::shared_ptr< SGI_BusLabel > > mBusLabels
Definition schematicgraphicsscene.h:218
void removeBusJunction(SI_BusJunction &junction) noexcept
Definition schematicgraphicsscene.cpp:444
const QHash< SI_SymbolPin *, std::shared_ptr< SGI_SymbolPin > > & getSymbolPins() noexcept
Definition schematicgraphicsscene.h:124
SchematicGraphicsScene(const SchematicGraphicsScene &other)=delete
const QHash< SI_Image *, std::shared_ptr< ImageGraphicsItem > > & getImages() noexcept
Definition schematicgraphicsscene.h:159
Definition occmodel.cpp:77
Definition uuid.h:186