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