LibrePCB Developers Documentation
Loading...
Searching...
No Matches
polygon.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_POLYGON_H
21#define LIBREPCB_CORE_POLYGON_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../serialization/serializableobjectlist.h"
27#include "../types/layer.h"
28#include "../types/length.h"
29#include "path.h"
30
31#include <QtCore>
32
33/*******************************************************************************
34 * Namespace / Forward Declarations
35 ******************************************************************************/
36namespace librepcb {
37
38/*******************************************************************************
39 * Class Polygon
40 ******************************************************************************/
41
45class Polygon final {
46 Q_DECLARE_TR_FUNCTIONS(Polygon)
47
48public:
49 // Signals
60
61 // Constructors / Destructor
62 Polygon() = delete;
63 Polygon(const Polygon& other) noexcept;
64 Polygon(const Uuid& uuid, const Polygon& other) noexcept;
65 Polygon(const Uuid& uuid, const Layer& layer, const UnsignedLength& lineWidth,
66 bool fill, bool isGrabArea, const Path& path) noexcept;
67 explicit Polygon(const SExpression& node);
68 ~Polygon() noexcept;
69
70 // Getters
71 const Uuid& getUuid() const noexcept { return mUuid; }
72 const Layer& getLayer() const noexcept { return *mLayer; }
73 const UnsignedLength& getLineWidth() const noexcept { return mLineWidth; }
74 bool isFilled() const noexcept { return mIsFilled; }
75 bool isGrabArea() const noexcept { return mIsGrabArea; }
76 const Path& getPath() const noexcept { return mPath; }
77 Path getPathForRendering() const noexcept;
78
79 // Setters
80 bool setLayer(const Layer& layer) noexcept;
81 bool setLineWidth(const UnsignedLength& width) noexcept;
82 bool setIsFilled(bool isFilled) noexcept;
83 bool setIsGrabArea(bool isGrabArea) noexcept;
84 bool setPath(const Path& path) noexcept;
85
86 // General Methods
87
93 void serialize(SExpression& root) const;
94
95 // Operator Overloadings
96 bool operator==(const Polygon& rhs) const noexcept;
97 bool operator!=(const Polygon& rhs) const noexcept { return !(*this == rhs); }
98 Polygon& operator=(const Polygon& rhs) noexcept;
99
100private: // Data
102 const Layer* mLayer;
107};
108
109/*******************************************************************************
110 * Class PolygonList
111 ******************************************************************************/
112
114 static constexpr const char* tagname = "polygon";
115};
118
119/*******************************************************************************
120 * End of File
121 ******************************************************************************/
122
123} // namespace librepcb
124
125#endif
The Layer class provides all supported geometry layers.
Definition layer.h:42
The Path class represents a list of vertices connected by straight lines or circular arc segments.
Definition path.h:57
The Polygon class.
Definition polygon.h:45
bool setLineWidth(const UnsignedLength &width) noexcept
Definition polygon.cpp:104
bool isFilled() const noexcept
Definition polygon.h:74
Signal< Polygon, Event > onEdited
Definition polygon.h:58
~Polygon() noexcept
Definition polygon.cpp:75
const Path & getPath() const noexcept
Definition polygon.h:76
UnsignedLength mLineWidth
Definition polygon.h:103
Uuid mUuid
Definition polygon.h:101
Event
Definition polygon.h:50
bool mIsGrabArea
Definition polygon.h:105
const Layer & getLayer() const noexcept
Definition polygon.h:72
bool mIsFilled
Definition polygon.h:104
bool setPath(const Path &path) noexcept
Definition polygon.cpp:134
bool setIsGrabArea(bool isGrabArea) noexcept
Definition polygon.cpp:124
Slot< Polygon, Event > OnEditedSlot
Definition polygon.h:59
bool setLayer(const Layer &layer) noexcept
Definition polygon.cpp:94
const UnsignedLength & getLineWidth() const noexcept
Definition polygon.h:73
Polygon & operator=(const Polygon &rhs) noexcept
Definition polygon.cpp:174
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition polygon.cpp:148
const Uuid & getUuid() const noexcept
Definition polygon.h:71
const Layer * mLayer
Definition polygon.h:102
Path getPathForRendering() const noexcept
Definition polygon.cpp:82
Path mPath
Definition polygon.h:106
bool setIsFilled(bool isFilled) noexcept
Definition polygon.cpp:114
bool isGrabArea() const noexcept
Definition polygon.h:75
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 Slot class is used to receive signals from non-QObject derived classes.
Definition signalslot.h:170
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition uuid.h:56
Definition occmodel.cpp:76
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition length.h:694
Definition polygon.h:113
static constexpr const char * tagname
Definition polygon.h:114