LibrePCB Developers Documentation
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_CORE_CIRCLE_H
21 #define LIBREPCB_CORE_CIRCLE_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../serialization/serializableobjectlist.h"
27 #include "../types/length.h"
28 #include "../types/point.h"
29 
30 #include <QtCore>
31 
32 /*******************************************************************************
33  * Namespace / Forward Declarations
34  ******************************************************************************/
35 namespace librepcb {
36 
37 class Layer;
38 
39 /*******************************************************************************
40  * Class Circle
41  ******************************************************************************/
42 
46 class Circle final {
47  Q_DECLARE_TR_FUNCTIONS(Circle)
48 
49 public:
50  // Signals
51  enum class Event {
59  };
62 
63  // Constructors / Destructor
64  Circle() = delete;
65  Circle(const Circle& other) noexcept;
66  Circle(const Uuid& uuid, const Circle& other) noexcept;
67  Circle(const Uuid& uuid, const Layer& layer, const UnsignedLength& lineWidth,
68  bool fill, bool isGrabArea, const Point& center,
69  const PositiveLength& diameter) noexcept;
70  explicit Circle(const SExpression& node);
71  ~Circle() noexcept;
72 
73  // Getters
74  const Uuid& getUuid() const noexcept { return mUuid; }
75  const Layer& getLayer() const noexcept { return *mLayer; }
76  const UnsignedLength& getLineWidth() const noexcept { return mLineWidth; }
77  bool isFilled() const noexcept { return mIsFilled; }
78  bool isGrabArea() const noexcept { return mIsGrabArea; }
79  const Point& getCenter() const noexcept { return mCenter; }
80  const PositiveLength& getDiameter() const noexcept { return mDiameter; }
81 
82  // Setters
83  bool setLayer(const Layer& layer) noexcept;
84  bool setLineWidth(const UnsignedLength& width) noexcept;
85  bool setIsFilled(bool isFilled) noexcept;
86  bool setIsGrabArea(bool isGrabArea) noexcept;
87  bool setCenter(const Point& center) noexcept;
88  bool setDiameter(const PositiveLength& dia) noexcept;
89 
90  // General Methods
91 
97  void serialize(SExpression& root) const;
98 
99  // Operator Overloadings
100  bool operator==(const Circle& rhs) const noexcept;
101  bool operator!=(const Circle& rhs) const noexcept { return !(*this == rhs); }
102  Circle& operator=(const Circle& rhs) noexcept;
103 
104 private: // Data
106  const Layer* mLayer;
108  bool mIsFilled;
112 };
113 
114 /*******************************************************************************
115  * Class CircleList
116  ******************************************************************************/
117 
119  static constexpr const char* tagname = "circle";
120 };
121 using CircleList =
123 
124 /*******************************************************************************
125  * End of File
126  ******************************************************************************/
127 
128 } // namespace librepcb
129 
130 #endif
Uuid mUuid
Definition: circle.h:105
PositiveLength mDiameter
Definition: circle.h:111
bool setCenter(const Point &center) noexcept
Definition: circle.cpp:122
Circle & operator=(const Circle &rhs) noexcept
Definition: circle.cpp:173
UnsignedLength mLineWidth
Definition: circle.h:107
Definition: occmodel.cpp:76
bool isGrabArea() const noexcept
Definition: circle.h:78
The Layer class provides all supported geometry layers.
Definition: layer.h:40
Signal< Circle, Event > onEdited
Definition: circle.h:60
bool operator!=(const Circle &rhs) const noexcept
Definition: circle.h:101
const Uuid & getUuid() const noexcept
Definition: circle.h:74
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition: circle.cpp:146
bool setDiameter(const PositiveLength &dia) noexcept
Definition: circle.cpp:132
bool operator==(const Circle &rhs) const noexcept
Definition: circle.cpp:162
bool setIsGrabArea(bool isGrabArea) noexcept
Definition: circle.cpp:112
bool isFilled() const noexcept
Definition: circle.h:77
Event
Definition: circle.h:51
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
const Layer & getLayer() const noexcept
Definition: circle.h:75
const PositiveLength & getDiameter() const noexcept
Definition: circle.h:80
const UnsignedLength & getLineWidth() const noexcept
Definition: circle.h:76
bool setIsFilled(bool isFilled) noexcept
Definition: circle.cpp:102
The Circle class.
Definition: circle.h:46
~Circle() noexcept
Definition: circle.cpp:75
Point mCenter
Definition: circle.h:110
bool mIsGrabArea
Definition: circle.h:109
Definition: circle.h:118
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:785
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:56
bool setLayer(const Layer &layer) noexcept
Definition: circle.cpp:82
Slot< Circle, Event > OnEditedSlot
Definition: circle.h:61
The SExpression class.
Definition: sexpression.h:66
const Layer * mLayer
Definition: circle.h:106
const Point & getCenter() const noexcept
Definition: circle.h:79
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:670
bool mIsFilled
Definition: circle.h:108