LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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_POLYGON_H
21 #define LIBREPCB_POLYGON_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../fileio/cmd/cmdlistelementinsert.h"
27 #include "../fileio/cmd/cmdlistelementremove.h"
28 #include "../fileio/cmd/cmdlistelementsswap.h"
29 #include "../fileio/serializableobjectlist.h"
30 #include "../graphics/graphicslayername.h"
31 #include "../units/all_length_units.h"
32 #include "path.h"
33 
34 #include <QtCore>
35 #include <QtWidgets>
36 
37 /*******************************************************************************
38  * Namespace / Forward Declarations
39  ******************************************************************************/
40 namespace librepcb {
41 
42 /*******************************************************************************
43  * Class Polygon
44  ******************************************************************************/
45 
49 class Polygon final : public SerializableObject {
50  Q_DECLARE_TR_FUNCTIONS(Polygon)
51 
52 public:
53  // Signals
54  enum class Event {
61  };
64 
65  // Constructors / Destructor
66  Polygon() = delete;
67  Polygon(const Polygon& other) noexcept;
68  Polygon(const Uuid& uuid, const Polygon& other) noexcept;
69  Polygon(const Uuid& uuid, const GraphicsLayerName& layerName,
70  const UnsignedLength& lineWidth, bool fill, bool isGrabArea,
71  const Path& path) noexcept;
72  explicit Polygon(const SExpression& node);
73  ~Polygon() noexcept;
74 
75  // Getters
76  const Uuid& getUuid() const noexcept { return mUuid; }
77  const GraphicsLayerName& getLayerName() const noexcept { return mLayerName; }
78  const UnsignedLength& getLineWidth() const noexcept { return mLineWidth; }
79  bool isFilled() const noexcept { return mIsFilled; }
80  bool isGrabArea() const noexcept { return mIsGrabArea; }
81  const Path& getPath() const noexcept { return mPath; }
82 
83  // Setters
84  bool setLayerName(const GraphicsLayerName& name) noexcept;
85  bool setLineWidth(const UnsignedLength& width) noexcept;
86  bool setIsFilled(bool isFilled) noexcept;
87  bool setIsGrabArea(bool isGrabArea) noexcept;
88  bool setPath(const Path& path) noexcept;
89 
91  void serialize(SExpression& root) const override;
92 
93  // Operator Overloadings
94  bool operator==(const Polygon& rhs) const noexcept;
95  bool operator!=(const Polygon& rhs) const noexcept { return !(*this == rhs); }
96  Polygon& operator=(const Polygon& rhs) noexcept;
97 
98 private: // Data
102  bool mIsFilled;
105 };
106 
107 /*******************************************************************************
108  * Class PolygonList
109  ******************************************************************************/
110 
112  static constexpr const char* tagname = "polygon";
113 };
114 using PolygonList =
116 using CmdPolygonInsert =
118 using CmdPolygonRemove =
120 using CmdPolygonsSwap =
122 
123 /*******************************************************************************
124  * End of File
125  ******************************************************************************/
126 
127 } // namespace librepcb
128 
129 #endif // LIBREPCB_POLYGON_H
Definition: polygon.h:111
UnsignedLength mLineWidth
Definition: polygon.h:101
Polygon & operator=(const Polygon &rhs) noexcept
Definition: polygon.cpp:159
const GraphicsLayerName & getLayerName() const noexcept
Definition: polygon.h:77
The CmdListElementRemove class.
Definition: cmdlistelementremove.h:44
bool setLineWidth(const UnsignedLength &width) noexcept
Definition: polygon.cpp:92
bool isGrabArea() const noexcept
Definition: polygon.h:80
bool operator!=(const Polygon &rhs) const noexcept
Definition: polygon.h:95
type_safe::constrained_type< QString, GraphicsLayerNameConstraint, GraphicsLayerNameVerifier > GraphicsLayerName
Definition: graphicslayername.h:78
bool setIsFilled(bool isFilled) noexcept
Definition: polygon.cpp:102
bool mIsFilled
Definition: polygon.h:102
Event
Definition: polygon.h:54
bool setIsGrabArea(bool isGrabArea) noexcept
Definition: polygon.cpp:112
Slot< Polygon, Event > OnEditedSlot
Definition: polygon.h:63
GraphicsLayerName mLayerName
Definition: polygon.h:100
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:43
bool setLayerName(const GraphicsLayerName &name) noexcept
Definition: polygon.cpp:82
The CmdListElementsSwap class.
Definition: cmdlistelementsswap.h:44
Uuid mUuid
Definition: polygon.h:99
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: polygon.cpp:136
bool operator==(const Polygon &rhs) const noexcept
Definition: polygon.cpp:149
Path mPath
Definition: polygon.h:104
static constexpr const char * tagname
Definition: polygon.h:112
Signal< Polygon, Event > onEdited
Definition: polygon.h:62
bool setPath(const Path &path) noexcept
Definition: polygon.cpp:122
The Path class represents a list of vertices connected by straight lines or circular arc segments...
Definition: path.h:53
bool mIsGrabArea
Definition: polygon.h:103
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
bool isFilled() const noexcept
Definition: polygon.h:79
The CmdListElementInsert class.
Definition: cmdlistelementinsert.h:44
const Uuid & getUuid() const noexcept
Definition: polygon.h:76
~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:81
The Polygon class.
Definition: polygon.h:49
The SExpression class.
Definition: sexpression.h:57
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:659
const UnsignedLength & getLineWidth() const noexcept
Definition: polygon.h:78