LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
circle.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_CIRCLE_H
21 #define LIBREPCB_CIRCLE_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 
33 #include <QtCore>
34 
35 /*******************************************************************************
36  * Namespace / Forward Declarations
37  ******************************************************************************/
38 namespace librepcb {
39 
40 /*******************************************************************************
41  * Class Circle
42  ******************************************************************************/
43 
47 class Circle : public SerializableObject {
48  Q_DECLARE_TR_FUNCTIONS(Circle)
49 
50 public:
51  // Signals
52  enum class Event {
60  };
63 
64  // Constructors / Destructor
65  Circle() = delete;
66  Circle(const Circle& other) noexcept;
67  Circle(const Uuid& uuid, const Circle& other) noexcept;
68  Circle(const Uuid& uuid, const GraphicsLayerName& layerName,
69  const UnsignedLength& lineWidth, bool fill, bool isGrabArea,
70  const Point& center, const PositiveLength& diameter) noexcept;
71  explicit Circle(const SExpression& node);
72  virtual ~Circle() noexcept;
73 
74  // Getters
75  const Uuid& getUuid() const noexcept { return mUuid; }
76  const GraphicsLayerName& getLayerName() const noexcept { return mLayerName; }
77  const UnsignedLength& getLineWidth() const noexcept { return mLineWidth; }
78  bool isFilled() const noexcept { return mIsFilled; }
79  bool isGrabArea() const noexcept { return mIsGrabArea; }
80  const Point& getCenter() const noexcept { return mCenter; }
81  const PositiveLength& getDiameter() const noexcept { return mDiameter; }
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 setCenter(const Point& center) noexcept;
89  bool setDiameter(const PositiveLength& dia) noexcept;
90 
92  void serialize(SExpression& root) const override;
93 
94  // Operator Overloadings
95  bool operator==(const Circle& rhs) const noexcept;
96  bool operator!=(const Circle& rhs) const noexcept { return !(*this == rhs); }
97  Circle& operator=(const Circle& rhs) noexcept;
98 
99 private: // Data
103  bool mIsFilled;
107 };
108 
109 /*******************************************************************************
110  * Class CircleList
111  ******************************************************************************/
112 
114  static constexpr const char* tagname = "circle";
115 };
116 using CircleList =
118 using CmdCircleInsert =
120 using CmdCircleRemove =
122 using CmdCirclesSwap =
124 
125 /*******************************************************************************
126  * End of File
127  ******************************************************************************/
128 
129 } // namespace librepcb
130 
131 #endif // LIBREPCB_CIRCLE_H
Uuid mUuid
Definition: circle.h:100
PositiveLength mDiameter
Definition: circle.h:106
GraphicsLayerName mLayerName
Definition: circle.h:101
static constexpr const char * tagname
Definition: circle.h:114
The CmdListElementRemove class.
Definition: cmdlistelementremove.h:44
bool setCenter(const Point &center) noexcept
Definition: circle.cpp:122
Circle & operator=(const Circle &rhs) noexcept
Definition: circle.cpp:171
UnsignedLength mLineWidth
Definition: circle.h:102
type_safe::constrained_type< QString, GraphicsLayerNameConstraint, GraphicsLayerNameVerifier > GraphicsLayerName
Definition: graphicslayername.h:78
bool isGrabArea() const noexcept
Definition: circle.h:79
Signal< Circle, Event > onEdited
Definition: circle.h:61
bool operator!=(const Circle &rhs) const noexcept
Definition: circle.h:96
const GraphicsLayerName & getLayerName() const noexcept
Definition: circle.h:76
const Uuid & getUuid() const noexcept
Definition: circle.h:75
bool setDiameter(const PositiveLength &dia) noexcept
Definition: circle.cpp:132
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: circle.cpp:146
bool operator==(const Circle &rhs) const noexcept
Definition: circle.cpp:160
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:43
bool setIsGrabArea(bool isGrabArea) noexcept
Definition: circle.cpp:112
The CmdListElementsSwap class.
Definition: cmdlistelementsswap.h:44
bool isFilled() const noexcept
Definition: circle.h:78
Event
Definition: circle.h:52
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
const PositiveLength & getDiameter() const noexcept
Definition: circle.h:81
const UnsignedLength & getLineWidth() const noexcept
Definition: circle.h:77
bool setIsFilled(bool isFilled) noexcept
Definition: circle.cpp:102
The Circle class.
Definition: circle.h:47
virtual ~Circle() noexcept
Definition: circle.cpp:75
Point mCenter
Definition: circle.h:105
bool mIsGrabArea
Definition: circle.h:104
Definition: circle.h:113
bool setLayerName(const GraphicsLayerName &name) noexcept
Definition: circle.cpp:82
bool setLineWidth(const UnsignedLength &width) noexcept
Definition: circle.cpp:92
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:780
The CmdListElementInsert class.
Definition: cmdlistelementinsert.h:44
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
Slot< Circle, Event > OnEditedSlot
Definition: circle.h:62
The SExpression class.
Definition: sexpression.h:57
const Point & getCenter() const noexcept
Definition: circle.h:80
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:659
bool mIsFilled
Definition: circle.h:103