LibrePCB Developers Documentation
zone.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_CORE_ZONE_H
21#define LIBREPCB_CORE_ZONE_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../serialization/serializableobjectlist.h"
27#include "path.h"
28
29#include <QtCore>
30
31/*******************************************************************************
32 * Namespace / Forward Declarations
33 ******************************************************************************/
34namespace librepcb {
35
36/*******************************************************************************
37 * Class Zone
38 ******************************************************************************/
39
43class Zone final {
44 Q_DECLARE_TR_FUNCTIONS(Zone)
45
46public:
47 enum class Layer : quint32 {
48 Top = 1 << 0,
49 Inner = 1 << 1,
50 Bottom = 1 << 2,
51 };
52 Q_DECLARE_FLAGS(Layers, Layer)
53
54 enum class Rule : quint32 {
55 NoCopper = (1 << 0),
56 NoPlanes = (1 << 1),
57 NoExposure = (1 << 2),
58 NoDevices = (1 << 3),
59 All = NoCopper | NoPlanes | NoExposure | NoDevices,
60 };
61 Q_DECLARE_FLAGS(Rules, Rule)
62
63 // Signals
64 enum class Event {
65 UuidChanged,
66 LayersChanged,
67 RulesChanged,
68 OutlineChanged,
69 };
72
73 // Constructors / Destructor
74 Zone() = delete;
75 Zone(const Zone& other) noexcept;
76 Zone(const Uuid& uuid, const Zone& other) noexcept;
77 Zone(const Uuid& uuid, Layers layers, Rules rules,
78 const Path& outline) noexcept;
79 explicit Zone(const SExpression& node);
80 ~Zone() noexcept;
81
82 // Getters
83 const Uuid& getUuid() const noexcept { return mUuid; }
84 Layers getLayers() const noexcept { return mLayers; }
85 Rules getRules() const noexcept { return mRules; }
86 const Path& getOutline() const noexcept { return mOutline; }
87
88 // Setters
89 bool setLayers(Layers layers) noexcept;
90 bool setRules(Rules rules) noexcept;
91 bool setOutline(const Path& outline) noexcept;
92
93 // General Methods
94
100 void serialize(SExpression& root) const;
101
102 // Operator Overloadings
103 bool operator==(const Zone& rhs) const noexcept;
104 bool operator!=(const Zone& rhs) const noexcept { return !(*this == rhs); }
105 Zone& operator=(const Zone& rhs) noexcept;
106
107private: // Data
109 Layers mLayers;
110 Rules mRules;
112};
113
114/*******************************************************************************
115 * Class ZoneList
116 ******************************************************************************/
117
119 static constexpr const char* tagname = "zone";
120};
121using ZoneList =
123
124/*******************************************************************************
125 * End of File
126 ******************************************************************************/
127
128} // namespace librepcb
129
130Q_DECLARE_METATYPE(librepcb::Zone::Layer)
131Q_DECLARE_METATYPE(librepcb::Zone::Rule)
132Q_DECLARE_OPERATORS_FOR_FLAGS(librepcb::Zone::Layers)
133Q_DECLARE_OPERATORS_FOR_FLAGS(librepcb::Zone::Rules)
134
135#endif
The Layer class provides all supported geometry layers.
Definition: layer.h:40
The Path class represents a list of vertices connected by straight lines or circular arc segments.
Definition: path.h:58
The SExpression class.
Definition: sexpression.h:69
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
The Zone class.
Definition: zone.h:43
bool setOutline(const Path &outline) noexcept
Definition: zone.cpp:103
Layers getLayers() const noexcept
Definition: zone.h:84
Layer
Definition: zone.h:47
Rule
Definition: zone.h:54
Uuid mUuid
Definition: zone.h:108
~Zone() noexcept
Definition: zone.cpp:76
Event
Definition: zone.h:64
bool operator!=(const Zone &rhs) const noexcept
Definition: zone.h:104
bool setRules(Rules rules) noexcept
Definition: zone.cpp:93
Signal< Zone, Event > onEdited
Definition: zone.h:70
Rules mRules
Definition: zone.h:110
Zone & operator=(const Zone &rhs) noexcept
Definition: zone.cpp:145
bool operator==(const Zone &rhs) const noexcept
Definition: zone.cpp:137
Path mOutline
Definition: zone.h:111
bool setLayers(Layers layers) noexcept
Definition: zone.cpp:83
Rules getRules() const noexcept
Definition: zone.h:85
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition: zone.cpp:117
const Uuid & getUuid() const noexcept
Definition: zone.h:83
const Path & getOutline() const noexcept
Definition: zone.h:86
Slot< Zone, Event > OnEditedSlot
Definition: zone.h:71
Layers mLayers
Definition: zone.h:109
Definition: occmodel.cpp:77
Definition: zone.h:118
static constexpr const char * tagname
Definition: zone.h:119