LibrePCB Developers Documentation
schematicselectionquery.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_PROJECT_SCHEMATICSELECTIONQUERY_H
21 #define LIBREPCB_PROJECT_SCHEMATICSELECTIONQUERY_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
27 
28 #include <QtCore>
29 
30 /*******************************************************************************
31  * Namespace / Forward Declarations
32  ******************************************************************************/
33 namespace librepcb {
34 namespace project {
35 
36 class SI_Symbol;
37 class SI_SymbolPin;
38 class SI_NetSegment;
39 class SI_NetLine;
40 class SI_NetPoint;
41 class SI_NetLabel;
42 class SI_Polygon;
43 class SI_Text;
44 
45 /*******************************************************************************
46  * Class SchematicSelectionQuery
47  ******************************************************************************/
48 
52 class SchematicSelectionQuery final : public QObject {
53  Q_OBJECT
54 
55 public:
56  // Types
57  struct NetSegmentItems {
58  QSet<SI_NetPoint*> netpoints;
59  QSet<SI_NetLine*> netlines;
60  QSet<SI_NetLabel*> netlabels;
61  };
62 
63  // Constructors / Destructor
64  SchematicSelectionQuery() = delete;
65  SchematicSelectionQuery(const SchematicSelectionQuery& other) = delete;
66  SchematicSelectionQuery(const QList<SI_Symbol*>& symbols,
67  const QList<SI_NetSegment*>& netsegments,
68  const QList<SI_Polygon*>& polygons,
69  const QList<SI_Text*>& texts,
70  QObject* parent = nullptr);
71  ~SchematicSelectionQuery() noexcept;
72 
73  // Getters
74  const QSet<SI_Symbol*>& getSymbols() const noexcept { return mResultSymbols; }
75  const QSet<SI_NetPoint*>& getNetPoints() const noexcept {
76  return mResultNetPoints;
77  }
78  const QSet<SI_NetLine*>& getNetLines() const noexcept {
79  return mResultNetLines;
80  }
81  const QSet<SI_NetLabel*>& getNetLabels() const noexcept {
82  return mResultNetLabels;
83  }
84  const QSet<SI_Polygon*>& getPolygons() const noexcept {
85  return mResultPolygons;
86  }
87  const QSet<SI_Text*>& getTexts() const noexcept { return mResultTexts; }
88 
98  QHash<SI_NetSegment*, NetSegmentItems> getNetSegmentItems() const noexcept;
99  int getResultCount() const noexcept;
100  bool isResultEmpty() const noexcept { return (getResultCount() == 0); }
101 
102  // General Methods
103  void addSelectedSymbols() noexcept;
104  void addSelectedNetPoints() noexcept;
105  void addSelectedNetLines() noexcept;
106  void addSelectedNetLabels() noexcept;
107  void addSelectedPolygons() noexcept;
108  void addSelectedTexts() noexcept;
118  void addNetPointsOfNetLines(bool onlyIfAllNetLinesSelected = false) noexcept;
119  void addNetLinesOfSymbolPins() noexcept;
120 
121  // Operator Overloadings
123  delete;
124 
125 private:
126  // references to the Schematic object
127  const QList<SI_Symbol*>& mSymbols;
128  const QList<SI_NetSegment*>& mNetSegments;
129  const QList<SI_Polygon*>& mPolygons;
130  const QList<SI_Text*>& mTexts;
131 
132  // query result
133  QSet<SI_Symbol*> mResultSymbols;
134  QSet<SI_NetPoint*> mResultNetPoints;
135  QSet<SI_NetLine*> mResultNetLines;
136  QSet<SI_NetLabel*> mResultNetLabels;
137  QSet<SI_Polygon*> mResultPolygons;
138  QSet<SI_Text*> mResultTexts;
139 };
140 
141 /*******************************************************************************
142  * End of File
143  ******************************************************************************/
144 
145 } // namespace project
146 } // namespace librepcb
147 
148 #endif // LIBREPCB_PROJECT_SCHEMATICSELECTIONQUERY_H
const QList< SI_Symbol * > & mSymbols
Definition: schematicselectionquery.h:127
void addSelectedNetLines() noexcept
Definition: schematicselectionquery.cpp:108
void addSelectedNetPoints() noexcept
Definition: schematicselectionquery.cpp:98
~SchematicSelectionQuery() noexcept
Definition: schematicselectionquery.cpp:58
const QList< SI_Text * > & mTexts
Definition: schematicselectionquery.h:130
The SI_Symbol class.
Definition: si_symbol.h:57
The SchematicSelectionQuery class.
Definition: schematicselectionquery.h:52
QHash< SI_NetSegment *, NetSegmentItems > getNetSegmentItems() const noexcept
Get net points, net lines and net labels grouped by net segment.
Definition: schematicselectionquery.cpp:66
SchematicSelectionQuery & operator=(const SchematicSelectionQuery &rhs)=delete
QSet< SI_Symbol * > mResultSymbols
Definition: schematicselectionquery.h:133
Definition: airwiresbuilder.cpp:32
const QSet< SI_NetLine * > & getNetLines() const noexcept
Definition: schematicselectionquery.h:78
QSet< SI_NetLine * > mResultNetLines
Definition: schematicselectionquery.h:135
const QSet< SI_NetLabel * > & getNetLabels() const noexcept
Definition: schematicselectionquery.h:81
QSet< SI_NetLabel * > netlabels
Definition: schematicselectionquery.h:60
const QSet< SI_Text * > & getTexts() const noexcept
Definition: schematicselectionquery.h:87
QSet< SI_NetPoint * > mResultNetPoints
Definition: schematicselectionquery.h:134
QSet< SI_Polygon * > mResultPolygons
Definition: schematicselectionquery.h:137
QSet< SI_NetPoint * > netpoints
Definition: schematicselectionquery.h:58
const QSet< SI_Symbol * > & getSymbols() const noexcept
Definition: schematicselectionquery.h:74
void addNetPointsOfNetLines(bool onlyIfAllNetLinesSelected=false) noexcept
Add net points of the selected net lines.
Definition: schematicselectionquery.cpp:144
void addSelectedNetLabels() noexcept
Definition: schematicselectionquery.cpp:118
const QSet< SI_NetPoint * > & getNetPoints() const noexcept
Definition: schematicselectionquery.h:75
void addSelectedSymbols() noexcept
Definition: schematicselectionquery.cpp:90
void addSelectedTexts() noexcept
Definition: schematicselectionquery.cpp:136
bool isResultEmpty() const noexcept
Definition: schematicselectionquery.h:100
int getResultCount() const noexcept
Definition: schematicselectionquery.cpp:80
QSet< SI_NetLine * > netlines
Definition: schematicselectionquery.h:59
Definition: schematicselectionquery.h:57
QSet< SI_NetLabel * > mResultNetLabels
Definition: schematicselectionquery.h:136
void addSelectedPolygons() noexcept
Definition: schematicselectionquery.cpp:128
QSet< SI_Text * > mResultTexts
Definition: schematicselectionquery.h:138
const QSet< SI_Polygon * > & getPolygons() const noexcept
Definition: schematicselectionquery.h:84
void addNetLinesOfSymbolPins() noexcept
Definition: schematicselectionquery.cpp:162
const QList< SI_Polygon * > & mPolygons
Definition: schematicselectionquery.h:129
const QList< SI_NetSegment * > & mNetSegments
Definition: schematicselectionquery.h:128