LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
boardlayerstack.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_BOARDLAYERSTACK_H
21 #define LIBREPCB_PROJECT_BOARDLAYERSTACK_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
29 
30 #include <QtCore>
31 
32 /*******************************************************************************
33  * Namespace / Forward Declarations
34  ******************************************************************************/
35 namespace librepcb {
36 namespace project {
37 
38 class Board;
39 
40 /*******************************************************************************
41  * Class BoardLayerStack
42  ******************************************************************************/
43 
48 class BoardLayerStack final : public QObject,
49  public SerializableObject,
51  Q_OBJECT
52 
53 public:
54  // Constructors / Destructor
55  BoardLayerStack() = delete;
56  BoardLayerStack(const BoardLayerStack& other) = delete;
57  BoardLayerStack(Board& board, const BoardLayerStack& other);
58  BoardLayerStack(Board& board, const SExpression& node);
59  explicit BoardLayerStack(Board& board);
60  ~BoardLayerStack() noexcept;
61 
62  // Getters
63  Board& getBoard() const noexcept { return mBoard; }
64  int getInnerLayerCount() const noexcept { return mInnerLayerCount; }
65  QList<GraphicsLayer*> getAllowedPolygonLayers() const noexcept;
66 
68  QList<GraphicsLayer*> getAllLayers() const noexcept override {
69  return mLayers;
70  }
71 
73  GraphicsLayer* getLayer(const QString& name) const noexcept override {
74  foreach (GraphicsLayer* layer, mLayers) {
75  if (layer->getName() == name) {
76  return layer;
77  }
78  }
79  return nullptr;
80  }
81 
82  // Setters
83  void setInnerLayerCount(int count) noexcept;
84 
85  // General Methods
86 
88  void serialize(SExpression& root) const override;
89 
90  // Operator Overloadings
91  BoardLayerStack& operator=(const BoardLayerStack& rhs) = delete;
92 
93 private slots:
94  void layerAttributesChanged() noexcept;
95  void boardAttributesChanged() noexcept;
96 
97 private:
98  void addAllLayers() noexcept;
99  void addLayer(const QString& name, bool disable = false) noexcept;
100  void addLayer(GraphicsLayer* layer) noexcept;
101 
102  // General
106 
107  // Settings
109 };
110 
111 /*******************************************************************************
112  * End of File
113  ******************************************************************************/
114 
115 } // namespace project
116 } // namespace librepcb
117 
118 #endif // LIBREPCB_PROJECT_BOARDLAYERSTACK_H
QList< GraphicsLayer * > getAllowedPolygonLayers() const noexcept
Definition: boardlayerstack.cpp:87
The GraphicsLayer class represents a graphical layer used in schematics and boards.
Definition: graphicslayer.h:54
QList< GraphicsLayer * > mLayers
Definition: boardlayerstack.h:104
The IF_GraphicsLayerProvider class defines an interface for classes which provide layers...
Definition: graphicslayer.h:250
QList< GraphicsLayer * > getAllLayers() const noexceptoverride
Definition: boardlayerstack.h:68
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:46
void addAllLayers() noexcept
Definition: boardlayerstack.cpp:159
void setInnerLayerCount(int count) noexcept
Definition: boardlayerstack.cpp:121
bool mLayersChanged
Definition: boardlayerstack.h:105
BoardLayerStack & operator=(const BoardLayerStack &rhs)=delete
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: boardlayerstack.cpp:136
Board & getBoard() const noexcept
Definition: boardlayerstack.h:63
~BoardLayerStack() noexcept
Definition: boardlayerstack.cpp:78
The BoardLayerStack class provides and manages all available layers of a board.
Definition: boardlayerstack.h:48
const QString & getName() const noexcept
Definition: graphicslayer.h:150
GraphicsLayer * getLayer(const QString &name) const noexceptoverride
Definition: boardlayerstack.h:73
int mInnerLayerCount
Definition: boardlayerstack.h:108
void boardAttributesChanged() noexcept
Definition: boardlayerstack.cpp:151
void layerAttributesChanged() noexcept
Definition: boardlayerstack.cpp:144
The Board class represents a PCB of a project and is always part of a circuit.
Definition: board.h:82
The SExpression class.
Definition: sexpression.h:60
int getInnerLayerCount() const noexcept
Definition: boardlayerstack.h:64
void addLayer(const QString &name, bool disable=false) noexcept
Definition: boardlayerstack.cpp:214
Board & mBoard
A reference to the Board object (from the ctor)
Definition: boardlayerstack.h:103