LibrePCB Developers Documentation
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  ******************************************************************************/
36 namespace librepcb {
37 
38 /*******************************************************************************
39  * Class Polygon
40  ******************************************************************************/
41 
45 class Polygon final {
46  Q_DECLARE_TR_FUNCTIONS(Polygon)
47 
48 public:
49  // Signals
50  enum class Event {
57  };
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 
100 private: // Data
102  const Layer* mLayer;
104  bool mIsFilled;
107 };
108 
109 /*******************************************************************************
110  * Class PolygonList
111  ******************************************************************************/
112 
114  static constexpr const char* tagname = "polygon";
115 };
116 using PolygonList =
118 
119 /*******************************************************************************
120  * End of File
121  ******************************************************************************/
122 
123 } // namespace librepcb
124 
125 #endif
Definition: polygon.h:113
UnsignedLength mLineWidth
Definition: polygon.h:103
Polygon & operator=(const Polygon &rhs) noexcept
Definition: polygon.cpp:174
bool setLineWidth(const UnsignedLength &width) noexcept
Definition: polygon.cpp:104
bool isGrabArea() const noexcept
Definition: polygon.h:75
bool operator!=(const Polygon &rhs) const noexcept
Definition: polygon.h:97
Definition: occmodel.cpp:77
The Layer class provides all supported geometry layers.
Definition: layer.h:40
bool setIsFilled(bool isFilled) noexcept
Definition: polygon.cpp:114
bool mIsFilled
Definition: polygon.h:104
Event
Definition: polygon.h:50
bool setIsGrabArea(bool isGrabArea) noexcept
Definition: polygon.cpp:124
Slot< Polygon, Event > OnEditedSlot
Definition: polygon.h:59
Uuid mUuid
Definition: polygon.h:101
const Layer & getLayer() const noexcept
Definition: polygon.h:72
bool operator==(const Polygon &rhs) const noexcept
Definition: polygon.cpp:164
Path mPath
Definition: polygon.h:106
Signal< Polygon, Event > onEdited
Definition: polygon.h:58
bool setPath(const Path &path) noexcept
Definition: polygon.cpp:134
const Layer * mLayer
Definition: polygon.h:102
The Path class represents a list of vertices connected by straight lines or circular arc segments...
Definition: path.h:58
bool mIsGrabArea
Definition: polygon.h:105
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
bool isFilled() const noexcept
Definition: polygon.h:74
const Uuid & getUuid() const noexcept
Definition: polygon.h:71
~Polygon() noexcept
Definition: polygon.cpp:75
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
const Path & getPath() const noexcept
Definition: polygon.h:76
The Polygon class.
Definition: polygon.h:45
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition: polygon.cpp:148
bool setLayer(const Layer &layer) noexcept
Definition: polygon.cpp:94
The SExpression class.
Definition: sexpression.h:69
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:696
Path getPathForRendering() const noexcept
Definition: polygon.cpp:82
const UnsignedLength & getLineWidth() const noexcept
Definition: polygon.h:73