LibrePCB Developers Documentation
Loading...
Searching...
No Matches
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_Hole;
41class BI_NetLine;
42class BI_NetPoint;
43class BI_NetSegment;
44class BI_Pad;
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_Hole;
59class BGI_NetLine;
60class BGI_NetPoint;
61class BGI_Pad;
62class BGI_Plane;
63class BGI_Plane;
64class BGI_Polygon;
65class BGI_StrokeText;
66class BGI_Via;
67class BGI_Zone;
68class GraphicsLayerList;
69
70/*******************************************************************************
71 * Class BoardGraphicsScene
72 ******************************************************************************/
73
77class BoardGraphicsScene final : public GraphicsScene {
78 Q_OBJECT
79
80public:
114
115 // Constructors / Destructor
118 explicit BoardGraphicsScene(
119 Board& board, const GraphicsLayerList& layers,
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_Pad*, std::shared_ptr<BGI_Pad>>& getPads() noexcept {
130 return mPads;
131 }
132 const QHash<BI_Via*, std::shared_ptr<BGI_Via>>& getVias() noexcept {
133 return mVias;
134 }
135 const QHash<BI_NetPoint*, std::shared_ptr<BGI_NetPoint>>&
136 getNetPoints() noexcept {
137 return mNetPoints;
138 }
139 const QHash<BI_NetLine*, std::shared_ptr<BGI_NetLine>>&
140 getNetLines() noexcept {
141 return mNetLines;
142 }
143 const QHash<BI_Plane*, std::shared_ptr<BGI_Plane>>& getPlanes() noexcept {
144 return mPlanes;
145 }
146 const QHash<BI_Zone*, std::shared_ptr<BGI_Zone>>& getZones() noexcept {
147 return mZones;
148 }
149 const QHash<BI_Polygon*, std::shared_ptr<BGI_Polygon>>&
150 getPolygons() noexcept {
151 return mPolygons;
152 }
153 const QHash<BI_StrokeText*, std::shared_ptr<BGI_StrokeText>>&
154 getStrokeTexts() noexcept {
155 return mStrokeTexts;
156 }
157 const QHash<BI_Hole*, std::shared_ptr<BGI_Hole>>& getHoles() noexcept {
158 return mHoles;
159 }
160 const QHash<BI_AirWire*, std::shared_ptr<BGI_AirWire>>&
161 getAirWires() noexcept {
162 return mAirWires;
163 }
164
165 // General Methods
166 void selectAll() noexcept;
167 void selectItemsInRect(const Point& p1, const Point& p2) noexcept;
168 void selectNetSegment(BI_NetSegment& netSegment) noexcept;
169 void clearSelection() noexcept;
170 void updateHighlightedNetSignals() noexcept;
171 static qreal getZValueOfCopperLayer(const Layer& layer) noexcept;
172
173 // Operator Overloadings
174 BoardGraphicsScene& operator=(const BoardGraphicsScene& rhs) = delete;
175
176private: // Methods
177 void addDevice(BI_Device& device) noexcept;
178 void removeDevice(BI_Device& device) noexcept;
179 void addPad(BI_Pad& pad, std::weak_ptr<BGI_Device> device) noexcept;
180 void removePad(BI_Pad& pad) noexcept;
181 void addNetSegment(BI_NetSegment& netSegment) noexcept;
182 void removeNetSegment(BI_NetSegment& netSegment) noexcept;
183 void addNetSegmentElements(const QList<BI_Pad*>& pads,
184 const QList<BI_Via*>& vias,
185 const QList<BI_NetPoint*>& netPoints,
186 const QList<BI_NetLine*>& netLines) noexcept;
187 void removeNetSegmentElements(const QList<BI_Pad*>& pads,
188 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;
215 QHash<BI_Pad*, std::shared_ptr<BGI_Pad>> mPads;
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;
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_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:53
A pad in a board (either standalone or from a footprint)
Definition bi_pad.h:49
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:74
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:78
The BGI_AirWire class.
Definition bgi_airwire.h:53
The BGI_Device class.
Definition bgi_device.h:58
The BGI_Hole class.
Definition bgi_hole.h:47
The BGI_NetLine class.
Definition bgi_netline.h:53
The BGI_NetPoint class.
Definition bgi_netpoint.h:48
The BGI_Pad class.
Definition bgi_pad.h:54
The BGI_Plane class.
Definition bgi_plane.h:56
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:54
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_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_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_PadsBottom
For librepcb::BI_Pad items.
Definition boardgraphicsscene.h:97
@ ZValue_PadsTop
For librepcb::BI_Pad items.
Definition boardgraphicsscene.h:104
@ 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:161
const QHash< BI_Polygon *, std::shared_ptr< BGI_Polygon > > & getPolygons() noexcept
Definition boardgraphicsscene.h:150
const QHash< BI_Pad *, std::shared_ptr< BGI_Pad > > & getPads() noexcept
Definition boardgraphicsscene.h:129
QHash< BI_StrokeText *, std::shared_ptr< BGI_StrokeText > > mStrokeTexts
Definition boardgraphicsscene.h:222
void addZone(BI_Zone &zone) noexcept
Definition boardgraphicsscene.cpp:547
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:132
void clearSelection() noexcept
Definition boardgraphicsscene.cpp:279
BoardGraphicsScene(const BoardGraphicsScene &other)=delete
static qreal getZValueOfCopperLayer(const Layer &layer) noexcept
Definition boardgraphicsscene.cpp:333
void addAirWire(BI_AirWire &airWire) noexcept
Definition boardgraphicsscene.cpp:609
Board & getBoard() noexcept
Definition boardgraphicsscene.h:125
void addPlane(BI_Plane &plane) noexcept
Definition boardgraphicsscene.cpp:531
void selectNetSegment(BI_NetSegment &netSegment) noexcept
Definition boardgraphicsscene.cpp:253
void removePolygon(BI_Polygon &polygon) noexcept
Definition boardgraphicsscene.cpp:570
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:140
const GraphicsLayerList & mLayers
Definition boardgraphicsscene.h:212
void removeDevice(BI_Device &device) noexcept
Definition boardgraphicsscene.cpp:372
void removeNetLine(BI_NetLine &netLine) noexcept
Definition boardgraphicsscene.cpp:523
void addHole(BI_Hole &hole) noexcept
Definition boardgraphicsscene.cpp:594
const QHash< BI_Device *, std::shared_ptr< BGI_Device > > & getDevices() noexcept
Definition boardgraphicsscene.h:126
void addNetPoint(BI_NetPoint &netPoint) noexcept
Definition boardgraphicsscene.cpp:499
Board & mBoard
Definition boardgraphicsscene.h:211
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:157
const QHash< BI_Plane *, std::shared_ptr< BGI_Plane > > & getPlanes() noexcept
Definition boardgraphicsscene.h:143
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:562
void removeStrokeText(BI_StrokeText &text) noexcept
Definition boardgraphicsscene.cpp:586
QHash< BI_Zone *, std::shared_ptr< BGI_Zone > > mZones
Definition boardgraphicsscene.h:220
void addNetSegment(BI_NetSegment &netSegment) noexcept
Definition boardgraphicsscene.cpp:409
void removeNetSegment(BI_NetSegment &netSegment) noexcept
Definition boardgraphicsscene.cpp:428
void addNetLine(BI_NetLine &netLine) noexcept
Definition boardgraphicsscene.cpp:515
void removePad(BI_Pad &pad) noexcept
Definition boardgraphicsscene.cpp:401
void addStrokeText(BI_StrokeText &text) noexcept
Definition boardgraphicsscene.cpp:578
QHash< BI_Pad *, std::shared_ptr< BGI_Pad > > mPads
Definition boardgraphicsscene.h:215
void addVia(BI_Via &via) noexcept
Definition boardgraphicsscene.cpp:483
void addNetSegmentElements(const QList< BI_Pad * > &pads, const QList< BI_Via * > &vias, const QList< BI_NetPoint * > &netPoints, const QList< BI_NetLine * > &netLines) noexcept
Definition boardgraphicsscene.cpp:447
void removeAirWire(BI_AirWire &airWire) noexcept
Definition boardgraphicsscene.cpp:617
QHash< BI_AirWire *, std::shared_ptr< BGI_AirWire > > mAirWires
Definition boardgraphicsscene.h:224
void removeZone(BI_Zone &zone) noexcept
Definition boardgraphicsscene.cpp:554
void removeVia(BI_Via &via) noexcept
Definition boardgraphicsscene.cpp:491
void addPad(BI_Pad &pad, std::weak_ptr< BGI_Device > device) noexcept
Definition boardgraphicsscene.cpp:392
const QHash< BI_Zone *, std::shared_ptr< BGI_Zone > > & getZones() noexcept
Definition boardgraphicsscene.h:146
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:601
void selectAll() noexcept
Definition boardgraphicsscene.cpp:167
void removeNetSegmentElements(const QList< BI_Pad * > &pads, const QList< BI_Via * > &vias, const QList< BI_NetPoint * > &netPoints, const QList< BI_NetLine * > &netLines) noexcept
Definition boardgraphicsscene.cpp:465
void removeNetPoint(BI_NetPoint &netPoint) noexcept
Definition boardgraphicsscene.cpp:507
void removePlane(BI_Plane &plane) noexcept
Definition boardgraphicsscene.cpp:539
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:136
void updateHighlightedNetSignals() noexcept
Definition boardgraphicsscene.cpp:312
void addDevice(BI_Device &device) noexcept
Definition boardgraphicsscene.cpp:352
const QHash< BI_StrokeText *, std::shared_ptr< BGI_StrokeText > > & getStrokeTexts() noexcept
Definition boardgraphicsscene.h:154
The GraphicsLayerList class.
Definition graphicslayerlist.h:48
The GraphicsScene class.
Definition graphicsscene.h:64
Definition occmodel.cpp:77
Definition uuid.h:186