LibrePCB Developers Documentation
schematiclayerprovider.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_SCHEMATICLAYERPROVIDER_H
21 #define LIBREPCB_PROJECT_SCHEMATICLAYERPROVIDER_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
28 
29 #include <QtCore>
30 
31 /*******************************************************************************
32  * Namespace / Forward Declarations
33  ******************************************************************************/
34 namespace librepcb {
35 namespace project {
36 
37 class Project;
38 
39 /*******************************************************************************
40  * Class SchematicLayerProvider
41  ******************************************************************************/
42 
49 public:
50  // Constructors / Destructor
51  SchematicLayerProvider() = delete;
52  SchematicLayerProvider(const SchematicLayerProvider& other) = delete;
53  explicit SchematicLayerProvider(Project& project);
54  ~SchematicLayerProvider() noexcept;
55 
56  // Getters
57  Project& getProject() const noexcept { return mProject; }
58 
60  GraphicsLayer* getLayer(const QString& name) const noexcept override {
61  foreach (GraphicsLayer* layer, mLayers) {
62  if (layer->getName() == name) {
63  return layer;
64  }
65  }
66  return nullptr;
67  }
68 
69  QList<GraphicsLayer*> getAllLayers() const noexcept override {
70  return mLayers;
71  }
72 
73  // Operator Overloadings
75 
76 private: // Methods
77  void addLayer(const QString& name) noexcept;
78 
79 private: // Data
81  QList<GraphicsLayer*> mLayers;
82 };
83 
84 /*******************************************************************************
85  * End of File
86  ******************************************************************************/
87 
88 } // namespace project
89 } // namespace librepcb
90 
91 #endif // LIBREPCB_PROJECT_SCHEMATICLAYERPROVIDER_H
The GraphicsLayer class represents a graphical layer used in schematics and boards.
Definition: graphicslayer.h:50
void addLayer(const QString &name) noexcept
Definition: schematiclayerprovider.cpp:76
Project & mProject
A reference to the Project object (from the ctor)
Definition: schematiclayerprovider.h:80
Definition: airwiresbuilder.cpp:32
The Project class represents a whole (opened) project with all its content.
Definition: project.h:80
The IF_GraphicsLayerProvider class defines an interface for classes which provide layers...
Definition: graphicslayer.h:227
QList< GraphicsLayer * > mLayers
Definition: schematiclayerprovider.h:81
SchematicLayerProvider & operator=(const SchematicLayerProvider &rhs)=delete
QList< GraphicsLayer * > getAllLayers() const noexcept override
Definition: schematiclayerprovider.h:69
The SchematicLayerProvider class provides and manages all available schematic layers which are used i...
Definition: schematiclayerprovider.h:48
GraphicsLayer * getLayer(const QString &name) const noexcept override
Definition: schematiclayerprovider.h:60
const QString & getName() const noexcept
Definition: graphicslayer.h:157
~SchematicLayerProvider() noexcept
Definition: schematiclayerprovider.cpp:67
Project & getProject() const noexcept
Definition: schematiclayerprovider.h:57