LibrePCB Developers Documentation
boardgraphicsscene.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_BOARDGRAPHICSSCENE_H
21#define LIBREPCB_EDITOR_BOARDGRAPHICSSCENE_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 BI_AirWire;
39class BI_Device;
40class BI_FootprintPad;
41class BI_Hole;
42class BI_NetLine;
43class BI_NetPoint;
44class BI_NetSegment;
45class BI_Plane;
46class BI_Polygon;
47class BI_StrokeText;
48class BI_Via;
49class BI_Zone;
50class Board;
51class Layer;
52class NetSignal;
53
54namespace editor {
55
56class BGI_AirWire;
57class BGI_Device;
58class BGI_FootprintPad;
59class BGI_Hole;
60class BGI_NetLine;
61class BGI_NetPoint;
62class BGI_Plane;
63class BGI_Plane;
64class BGI_Polygon;
65class BGI_StrokeText;
66class BGI_Via;
67class BGI_Zone;
68class IF_GraphicsLayerProvider;
69
70/*******************************************************************************
71 * Class BoardGraphicsScene
72 ******************************************************************************/
73
77class BoardGraphicsScene final : public GraphicsScene {
78 Q_OBJECT
79
80public:
113 };
114
115 // Constructors / Destructor
118 explicit BoardGraphicsScene(
119 Board& board, const IF_GraphicsLayerProvider& lp,
120 std::shared_ptr<const QSet<const NetSignal*>> highlightedNetSignals,
121 QObject* parent = nullptr) noexcept;
122 virtual ~BoardGraphicsScene() noexcept;
123
124 // Getters
125 Board& getBoard() noexcept { return mBoard; }
126 const QHash<BI_Device*, std::shared_ptr<BGI_Device>>& getDevices() noexcept {
127 return mDevices;
128 }
129 const QHash<BI_FootprintPad*, std::shared_ptr<BGI_FootprintPad>>&
130 getFootprintPads() noexcept {
131 return mFootprintPads;
132 }
133 const QHash<BI_Via*, std::shared_ptr<BGI_Via>>& getVias() noexcept {
134 return mVias;
135 }
136 const QHash<BI_NetPoint*, std::shared_ptr<BGI_NetPoint>>&
137 getNetPoints() noexcept {
138 return mNetPoints;
139 }
140 const QHash<BI_NetLine*, std::shared_ptr<BGI_NetLine>>&
141 getNetLines() noexcept {
142 return mNetLines;
143 }
144 const QHash<BI_Plane*, std::shared_ptr<BGI_Plane>>& getPlanes() noexcept {
145 return mPlanes;
146 }
147 const QHash<BI_Zone*, std::shared_ptr<BGI_Zone>>& getZones() noexcept {
148 return mZones;
149 }
150 const QHash<BI_Polygon*, std::shared_ptr<BGI_Polygon>>&
151 getPolygons() noexcept {
152 return mPolygons;
153 }
154 const QHash<BI_StrokeText*, std::shared_ptr<BGI_StrokeText>>&
155 getStrokeTexts() noexcept {
156 return mStrokeTexts;
157 }
158 const QHash<BI_Hole*, std::shared_ptr<BGI_Hole>>& getHoles() noexcept {
159 return mHoles;
160 }
161 const QHash<BI_AirWire*, std::shared_ptr<BGI_AirWire>>&
162 getAirWires() noexcept {
163 return mAirWires;
164 }
165
166 // General Methods
167 void selectAll() noexcept;
168 void selectItemsInRect(const Point& p1, const Point& p2) noexcept;
169 void selectNetSegment(BI_NetSegment& netSegment) noexcept;
170 void clearSelection() noexcept;
171 void updateHighlightedNetSignals() noexcept;
172 static qreal getZValueOfCopperLayer(const Layer& layer) noexcept;
173
174 // Operator Overloadings
175 BoardGraphicsScene& operator=(const BoardGraphicsScene& rhs) = delete;
176
177private: // Methods
178 void addDevice(BI_Device& device) noexcept;
179 void removeDevice(BI_Device& device) noexcept;
181 std::weak_ptr<BGI_Device> device) noexcept;
182 void removeFootprintPad(BI_FootprintPad& pad) noexcept;
183 void addNetSegment(BI_NetSegment& netSegment) noexcept;
184 void removeNetSegment(BI_NetSegment& netSegment) noexcept;
185 void addNetSegmentElements(const QList<BI_Via*>& vias,
186 const QList<BI_NetPoint*>& netPoints,
187 const QList<BI_NetLine*>& netLines) noexcept;
188 void removeNetSegmentElements(const QList<BI_Via*>& vias,
189 const QList<BI_NetPoint*>& netPoints,
190 const QList<BI_NetLine*>& netLines) noexcept;
191 void addVia(BI_Via& via) noexcept;
192 void removeVia(BI_Via& via) noexcept;
193 void addNetPoint(BI_NetPoint& netPoint) noexcept;
194 void removeNetPoint(BI_NetPoint& netPoint) noexcept;
195 void addNetLine(BI_NetLine& netLine) noexcept;
196 void removeNetLine(BI_NetLine& netLine) noexcept;
197 void addPlane(BI_Plane& plane) noexcept;
198 void removePlane(BI_Plane& plane) noexcept;
199 void addZone(BI_Zone& zone) noexcept;
200 void removeZone(BI_Zone& zone) noexcept;
201 void addPolygon(BI_Polygon& polygon) noexcept;
202 void removePolygon(BI_Polygon& polygon) noexcept;
203 void addStrokeText(BI_StrokeText& text) noexcept;
204 void removeStrokeText(BI_StrokeText& text) noexcept;
205 void addHole(BI_Hole& hole) noexcept;
206 void removeHole(BI_Hole& hole) noexcept;
207 void addAirWire(BI_AirWire& airWire) noexcept;
208 void removeAirWire(BI_AirWire& airWire) noexcept;
209
210private: // Data
213 std::shared_ptr<const QSet<const NetSignal*>> mHighlightedNetSignals;
214 QHash<BI_Device*, std::shared_ptr<BGI_Device>> mDevices;
216 QHash<BI_Via*, std::shared_ptr<BGI_Via>> mVias;
217 QHash<BI_NetPoint*, std::shared_ptr<BGI_NetPoint>> mNetPoints;
218 QHash<BI_NetLine*, std::shared_ptr<BGI_NetLine>> mNetLines;
219 QHash<BI_Plane*, std::shared_ptr<BGI_Plane>> mPlanes;
220 QHash<BI_Zone*, std::shared_ptr<BGI_Zone>> mZones;
221 QHash<BI_Polygon*, std::shared_ptr<BGI_Polygon>> mPolygons;
222 QHash<BI_StrokeText*, std::shared_ptr<BGI_StrokeText>> mStrokeTexts;
223 QHash<BI_Hole*, std::shared_ptr<BGI_Hole>> mHoles;
224 QHash<BI_AirWire*, std::shared_ptr<BGI_AirWire>> mAirWires;
225};
226
227/*******************************************************************************
228 * End of File
229 ******************************************************************************/
230
231} // namespace editor
232} // namespace librepcb
233
234#endif
The BI_AirWire class.
Definition: bi_airwire.h:45
The BI_Device class.
Definition: bi_device.h:57
The BI_FootprintPad class.
Definition: bi_footprintpad.h:48
The BI_Hole class.
Definition: bi_hole.h:46
The BI_NetLine class.
Definition: bi_netline.h:71
The BI_NetPoint class.
Definition: bi_netpoint.h:46
The BI_NetSegment class.
Definition: bi_netsegment.h:52
The BI_Plane class.
Definition: bi_plane.h:52
The BI_Polygon class.
Definition: bi_polygon.h:46
The BI_StrokeText class.
Definition: bi_stroketext.h:49
The BI_Via class.
Definition: bi_via.h:44
The BI_Zone class.
Definition: bi_zone.h:46
The Board class represents a PCB of a project and is always part of a circuit.
Definition: board.h:73
The Layer class provides all supported geometry layers.
Definition: layer.h:42
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 BGI_AirWire class.
Definition: bgi_airwire.h:53
The BGI_Device class.
Definition: bgi_device.h:57
The BGI_FootprintPad class.
Definition: bgi_footprintpad.h:54
The BGI_Hole class.
Definition: bgi_hole.h:47
The BGI_NetLine class.
Definition: bgi_netline.h:51
The BGI_NetPoint class.
Definition: bgi_netpoint.h:46
The BGI_Plane class.
Definition: bgi_plane.h:54
The BGI_Polygon class.
Definition: bgi_polygon.h:48
The BGI_StrokeText class.
Definition: bgi_stroketext.h:51
The BGI_Via class.
Definition: bgi_via.h:53
The BGI_Zone class.
Definition: bgi_zone.h:48
The BoardGraphicsScene class.
Definition: boardgraphicsscene.h:77
ItemZValue
Z Values of all items in a board scene (to define the stacking order)
Definition: boardgraphicsscene.h:91
@ ZValue_CopperBottom
Definition: boardgraphicsscene.h:96
@ ZValue_AirWires
For librepcb::BI_AirWire items.
Definition: boardgraphicsscene.h:112
@ ZValue_InnerTop
Definition: boardgraphicsscene.h:101
@ ZValue_Texts
For librepcb::BI_StrokeText items.
Definition: boardgraphicsscene.h:111
@ ZValue_Default
this is the default value (behind all other items)
Definition: boardgraphicsscene.h:92
@ ZValue_TextsBottom
For librepcb::BI_StrokeText items.
Definition: boardgraphicsscene.h:93
@ ZValue_FootprintPadsBottom
For librepcb::BI_FootprintPad items.
Definition: boardgraphicsscene.h:97
@ ZValue_PlanesBottom
For librepcb::BI_Plane items.
Definition: boardgraphicsscene.h:99
@ ZValue_InnerBottom
Definition: boardgraphicsscene.h:100
@ ZValue_PolygonsBottom
For librepcb::BI_Polygon items.
Definition: boardgraphicsscene.h:94
@ ZValue_PolygonsTop
For librepcb::BI_Polygon items.
Definition: boardgraphicsscene.h:107
@ ZValue_TextsTop
For librepcb::BI_StrokeText items.
Definition: boardgraphicsscene.h:108
@ ZValue_CopperTop
Definition: boardgraphicsscene.h:105
@ ZValue_DevicesTop
For librepcb::BI_Device items.
Definition: boardgraphicsscene.h:106
@ ZValue_FootprintPadsTop
For librepcb::BI_FootprintPad items.
Definition: boardgraphicsscene.h:104
@ ZValue_Holes
For librepcb::BI_Hole items.
Definition: boardgraphicsscene.h:109
@ ZValue_Vias
For librepcb::BI_Via items.
Definition: boardgraphicsscene.h:110
@ ZValue_PlanesTop
For librepcb::BI_Plane items.
Definition: boardgraphicsscene.h:102
@ ZValue_ZonesBottom
For librepcb::BI_Zone items.
Definition: boardgraphicsscene.h:98
@ ZValue_DevicesBottom
For librepcb::BI_Device items.
Definition: boardgraphicsscene.h:95
@ ZValue_ZonesTop
For librepcb::BI_Zone items.
Definition: boardgraphicsscene.h:103
std::shared_ptr< const QSet< const NetSignal * > > mHighlightedNetSignals
Definition: boardgraphicsscene.h:213
const QHash< BI_AirWire *, std::shared_ptr< BGI_AirWire > > & getAirWires() noexcept
Definition: boardgraphicsscene.h:162
const QHash< BI_Polygon *, std::shared_ptr< BGI_Polygon > > & getPolygons() noexcept
Definition: boardgraphicsscene.h:151
void addFootprintPad(BI_FootprintPad &pad, std::weak_ptr< BGI_Device > device) noexcept
Definition: boardgraphicsscene.cpp:375
QHash< BI_StrokeText *, std::shared_ptr< BGI_StrokeText > > mStrokeTexts
Definition: boardgraphicsscene.h:222
void addZone(BI_Zone &zone) noexcept
Definition: boardgraphicsscene.cpp:516
QHash< BI_Plane *, std::shared_ptr< BGI_Plane > > mPlanes
Definition: boardgraphicsscene.h:219
const QHash< BI_Via *, std::shared_ptr< BGI_Via > > & getVias() noexcept
Definition: boardgraphicsscene.h:133
const QHash< BI_FootprintPad *, std::shared_ptr< BGI_FootprintPad > > & getFootprintPads() noexcept
Definition: boardgraphicsscene.h:130
void clearSelection() noexcept
Definition: boardgraphicsscene.cpp:265
BoardGraphicsScene(const BoardGraphicsScene &other)=delete
static qreal getZValueOfCopperLayer(const Layer &layer) noexcept
Definition: boardgraphicsscene.cpp:316
void addAirWire(BI_AirWire &airWire) noexcept
Definition: boardgraphicsscene.cpp:580
Board & getBoard() noexcept
Definition: boardgraphicsscene.h:125
void addPlane(BI_Plane &plane) noexcept
Definition: boardgraphicsscene.cpp:500
void selectNetSegment(BI_NetSegment &netSegment) noexcept
Definition: boardgraphicsscene.cpp:247
void removePolygon(BI_Polygon &polygon) noexcept
Definition: boardgraphicsscene.cpp:540
QHash< BI_Device *, std::shared_ptr< BGI_Device > > mDevices
Definition: boardgraphicsscene.h:214
const QHash< BI_NetLine *, std::shared_ptr< BGI_NetLine > > & getNetLines() noexcept
Definition: boardgraphicsscene.h:141
void removeDevice(BI_Device &device) noexcept
Definition: boardgraphicsscene.cpp:355
void removeNetLine(BI_NetLine &netLine) noexcept
Definition: boardgraphicsscene.cpp:492
void removeFootprintPad(BI_FootprintPad &pad) noexcept
Definition: boardgraphicsscene.cpp:384
void addHole(BI_Hole &hole) noexcept
Definition: boardgraphicsscene.cpp:564
const QHash< BI_Device *, std::shared_ptr< BGI_Device > > & getDevices() noexcept
Definition: boardgraphicsscene.h:126
void addNetPoint(BI_NetPoint &netPoint) noexcept
Definition: boardgraphicsscene.cpp:468
Board & mBoard
Definition: boardgraphicsscene.h:211
const IF_GraphicsLayerProvider & mLayerProvider
Definition: boardgraphicsscene.h:212
QHash< BI_NetPoint *, std::shared_ptr< BGI_NetPoint > > mNetPoints
Definition: boardgraphicsscene.h:217
const QHash< BI_Hole *, std::shared_ptr< BGI_Hole > > & getHoles() noexcept
Definition: boardgraphicsscene.h:158
const QHash< BI_Plane *, std::shared_ptr< BGI_Plane > > & getPlanes() noexcept
Definition: boardgraphicsscene.h:144
void addNetSegmentElements(const QList< BI_Via * > &vias, const QList< BI_NetPoint * > &netPoints, const QList< BI_NetLine * > &netLines) noexcept
Definition: boardgraphicsscene.cpp:424
QHash< BI_Via *, std::shared_ptr< BGI_Via > > mVias
Definition: boardgraphicsscene.h:216
QHash< BI_NetLine *, std::shared_ptr< BGI_NetLine > > mNetLines
Definition: boardgraphicsscene.h:218
void addPolygon(BI_Polygon &polygon) noexcept
Definition: boardgraphicsscene.cpp:532
void removeStrokeText(BI_StrokeText &text) noexcept
Definition: boardgraphicsscene.cpp:556
QHash< BI_Zone *, std::shared_ptr< BGI_Zone > > mZones
Definition: boardgraphicsscene.h:220
void addNetSegment(BI_NetSegment &netSegment) noexcept
Definition: boardgraphicsscene.cpp:392
void removeNetSegment(BI_NetSegment &netSegment) noexcept
Definition: boardgraphicsscene.cpp:408
void addNetLine(BI_NetLine &netLine) noexcept
Definition: boardgraphicsscene.cpp:484
void addStrokeText(BI_StrokeText &text) noexcept
Definition: boardgraphicsscene.cpp:548
void addVia(BI_Via &via) noexcept
Definition: boardgraphicsscene.cpp:452
void removeNetSegmentElements(const QList< BI_Via * > &vias, const QList< BI_NetPoint * > &netPoints, const QList< BI_NetLine * > &netLines) noexcept
Definition: boardgraphicsscene.cpp:438
void removeAirWire(BI_AirWire &airWire) noexcept
Definition: boardgraphicsscene.cpp:588
QHash< BI_AirWire *, std::shared_ptr< BGI_AirWire > > mAirWires
Definition: boardgraphicsscene.h:224
void removeZone(BI_Zone &zone) noexcept
Definition: boardgraphicsscene.cpp:524
void removeVia(BI_Via &via) noexcept
Definition: boardgraphicsscene.cpp:460
QHash< BI_FootprintPad *, std::shared_ptr< BGI_FootprintPad > > mFootprintPads
Definition: boardgraphicsscene.h:215
const QHash< BI_Zone *, std::shared_ptr< BGI_Zone > > & getZones() noexcept
Definition: boardgraphicsscene.h:147
QHash< BI_Hole *, std::shared_ptr< BGI_Hole > > mHoles
Definition: boardgraphicsscene.h:223
QHash< BI_Polygon *, std::shared_ptr< BGI_Polygon > > mPolygons
Definition: boardgraphicsscene.h:221
void removeHole(BI_Hole &hole) noexcept
Definition: boardgraphicsscene.cpp:572
void selectAll() noexcept
Definition: boardgraphicsscene.cpp:167
void removeNetPoint(BI_NetPoint &netPoint) noexcept
Definition: boardgraphicsscene.cpp:476
void removePlane(BI_Plane &plane) noexcept
Definition: boardgraphicsscene.cpp:508
void selectItemsInRect(const Point &p1, const Point &p2) noexcept
Definition: boardgraphicsscene.cpp:200
const QHash< BI_NetPoint *, std::shared_ptr< BGI_NetPoint > > & getNetPoints() noexcept
Definition: boardgraphicsscene.h:137
void updateHighlightedNetSignals() noexcept
Definition: boardgraphicsscene.cpp:298
void addDevice(BI_Device &device) noexcept
Definition: boardgraphicsscene.cpp:335
const QHash< BI_StrokeText *, std::shared_ptr< BGI_StrokeText > > & getStrokeTexts() noexcept
Definition: boardgraphicsscene.h:155
The GraphicsScene class.
Definition: graphicsscene.h:45
The IF_GraphicsLayerProvider class defines an interface for classes which provide layers.
Definition: graphicslayer.h:111
Definition: occmodel.cpp:77