LibrePCB Developers Documentation
cmdremoveboarditems.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_CMDREMOVEBOARDITEMS_H
21#define LIBREPCB_EDITOR_CMDREMOVEBOARDITEMS_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../undocommandgroup.h"
27
28#include <QtCore>
29
30/*******************************************************************************
31 * Namespace / Forward Declarations
32 ******************************************************************************/
33namespace librepcb {
34
35class BI_Device;
36class BI_FootprintPad;
37class BI_Hole;
38class BI_NetLine;
39class BI_NetPoint;
40class BI_NetSegment;
41class BI_Plane;
42class BI_Polygon;
43class BI_StrokeText;
44class BI_Via;
45class BI_Zone;
46class Board;
47
48namespace editor {
49
50/*******************************************************************************
51 * Class CmdRemoveBoardItems
52 ******************************************************************************/
53
58private:
59 // Private Types
61 QSet<BI_Via*> vias;
62 QSet<BI_NetPoint*> netpoints;
63 QSet<BI_NetLine*> netlines;
64 QSet<BI_FootprintPad*> pads;
65 };
66 typedef QHash<BI_NetSegment*, NetSegmentItems> NetSegmentItemList;
67
68public:
69 // Constructors / Destructor
72 explicit CmdRemoveBoardItems(Board& board) noexcept;
73 ~CmdRemoveBoardItems() noexcept;
74
75 // Set items to remove
76 void removeDeviceInstances(const QSet<BI_Device*>& set) {
77 Q_ASSERT(!wasEverExecuted());
78 mDeviceInstances += set;
79 }
80 void removeNetSegments(const QSet<BI_NetSegment*>& set) {
81 Q_ASSERT(!wasEverExecuted());
82 mNetSegments += set;
83 }
84 void removeVias(const QSet<BI_Via*>& set) {
85 Q_ASSERT(!wasEverExecuted());
86 mVias += set;
87 }
88 void removeNetPoints(const QSet<BI_NetPoint*>& set) {
89 Q_ASSERT(!wasEverExecuted());
90 mNetPoints += set;
91 }
92 void removeNetLines(const QSet<BI_NetLine*>& set) {
93 Q_ASSERT(!wasEverExecuted());
94 mNetLines += set;
95 }
96 void removePlanes(const QSet<BI_Plane*>& set) {
97 Q_ASSERT(!wasEverExecuted());
98 mPlanes += set;
99 }
100 void removeZones(const QSet<BI_Zone*>& set) {
101 Q_ASSERT(!wasEverExecuted());
102 mZones += set;
103 }
104 void removePolygons(const QSet<BI_Polygon*>& set) {
105 Q_ASSERT(!wasEverExecuted());
106 mPolygons += set;
107 }
108 void removeStrokeTexts(const QSet<BI_StrokeText*>& set) {
109 Q_ASSERT(!wasEverExecuted());
110 mStrokeTexts += set;
111 }
112 void removeHoles(const QSet<BI_Hole*>& set) {
113 Q_ASSERT(!wasEverExecuted());
114 mHoles += set;
115 }
116
117 // Operator Overloadings
119
120private: // Methods
122 bool performExecute() override;
123
124 void removeNetSegmentItems(BI_NetSegment& netsegment,
125 const QSet<BI_FootprintPad*>& padsToDisconnect,
126 const QSet<BI_Via*>& viasToRemove,
127 const QSet<BI_NetPoint*>& netpointsToRemove,
128 const QSet<BI_NetLine*>& netlinesToRemove);
129
130private: // Data
132
133 // Items to remove
134 QSet<BI_Device*> mDeviceInstances;
135 QSet<BI_NetSegment*> mNetSegments;
136 QSet<BI_Via*> mVias;
137 QSet<BI_NetPoint*> mNetPoints;
138 QSet<BI_NetLine*> mNetLines;
139 QSet<BI_Plane*> mPlanes;
140 QSet<BI_Zone*> mZones;
141 QSet<BI_Polygon*> mPolygons;
142 QSet<BI_StrokeText*> mStrokeTexts;
143 QSet<BI_Hole*> mHoles;
144};
145
146/*******************************************************************************
147 * End of File
148 ******************************************************************************/
149
150} // namespace editor
151} // namespace librepcb
152
153#endif
The BI_Device class.
Definition: bi_device.h:57
The BI_NetSegment class.
Definition: bi_netsegment.h:52
The Board class represents a PCB of a project and is always part of a circuit.
Definition: board.h:73
The CmdRemoveBoardItems class.
Definition: cmdremoveboarditems.h:57
QSet< BI_Plane * > mPlanes
Definition: cmdremoveboarditems.h:139
QSet< BI_NetPoint * > mNetPoints
Definition: cmdremoveboarditems.h:137
void removeNetSegmentItems(BI_NetSegment &netsegment, const QSet< BI_FootprintPad * > &padsToDisconnect, const QSet< BI_Via * > &viasToRemove, const QSet< BI_NetPoint * > &netpointsToRemove, const QSet< BI_NetLine * > &netlinesToRemove)
Definition: cmdremoveboarditems.cpp:169
void removeZones(const QSet< BI_Zone * > &set)
Definition: cmdremoveboarditems.h:100
QSet< BI_Zone * > mZones
Definition: cmdremoveboarditems.h:140
QSet< BI_Polygon * > mPolygons
Definition: cmdremoveboarditems.h:141
QSet< BI_StrokeText * > mStrokeTexts
Definition: cmdremoveboarditems.h:142
void removeDeviceInstances(const QSet< BI_Device * > &set)
Definition: cmdremoveboarditems.h:76
void removeVias(const QSet< BI_Via * > &set)
Definition: cmdremoveboarditems.h:84
Board & mBoard
Definition: cmdremoveboarditems.h:131
void removeStrokeTexts(const QSet< BI_StrokeText * > &set)
Definition: cmdremoveboarditems.h:108
CmdRemoveBoardItems(const CmdRemoveBoardItems &other)=delete
QSet< BI_Via * > mVias
Definition: cmdremoveboarditems.h:136
void removeNetPoints(const QSet< BI_NetPoint * > &set)
Definition: cmdremoveboarditems.h:88
void removePolygons(const QSet< BI_Polygon * > &set)
Definition: cmdremoveboarditems.h:104
QSet< BI_Device * > mDeviceInstances
Definition: cmdremoveboarditems.h:134
CmdRemoveBoardItems & operator=(const CmdRemoveBoardItems &other)=delete
QSet< BI_NetSegment * > mNetSegments
Definition: cmdremoveboarditems.h:135
void removeHoles(const QSet< BI_Hole * > &set)
Definition: cmdremoveboarditems.h:112
bool performExecute() override
Execute the command the first time.
Definition: cmdremoveboarditems.cpp:74
QHash< BI_NetSegment *, NetSegmentItems > NetSegmentItemList
Definition: cmdremoveboarditems.h:66
QSet< BI_Hole * > mHoles
Definition: cmdremoveboarditems.h:143
QSet< BI_NetLine * > mNetLines
Definition: cmdremoveboarditems.h:138
void removePlanes(const QSet< BI_Plane * > &set)
Definition: cmdremoveboarditems.h:96
~CmdRemoveBoardItems() noexcept
Definition: cmdremoveboarditems.cpp:67
void removeNetLines(const QSet< BI_NetLine * > &set)
Definition: cmdremoveboarditems.h:92
void removeNetSegments(const QSet< BI_NetSegment * > &set)
Definition: cmdremoveboarditems.h:80
The UndoCommandGroup class makes it possible to pack multiple undo commands together (it acts as a pa...
Definition: undocommandgroup.h:44
bool wasEverExecuted() const noexcept
This method shows whether that command was ever executed (execute() called successfully)
Definition: undocommand.h:63
Definition: occmodel.cpp:77
Definition: cmdremoveboarditems.h:60
QSet< BI_FootprintPad * > pads
Definition: cmdremoveboarditems.h:64
QSet< BI_NetPoint * > netpoints
Definition: cmdremoveboarditems.h:62
QSet< BI_NetLine * > netlines
Definition: cmdremoveboarditems.h:63
QSet< BI_Via * > vias
Definition: cmdremoveboarditems.h:61