LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bi_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_PROJECT_BI_POLYGON_H
21 #define LIBREPCB_PROJECT_BI_POLYGON_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "bi_base.h"
27 
30 #include <librepcb/common/uuid.h>
31 
32 #include <QtCore>
33 
34 /*******************************************************************************
35  * Namespace / Forward Declarations
36  ******************************************************************************/
37 namespace librepcb {
38 
39 class Path;
40 class Polygon;
41 class PolygonGraphicsItem;
42 
43 namespace project {
44 
45 class Project;
46 class Board;
47 class BGI_Polygon;
48 
49 /*******************************************************************************
50  * Class BI_Polygon
51  ******************************************************************************/
52 
59 class BI_Polygon final : public BI_Base, public SerializableObject {
60  Q_OBJECT
61 
62 public:
63  // Constructors / Destructor
64  BI_Polygon() = delete;
65  BI_Polygon(const BI_Polygon& other) = delete;
66  BI_Polygon(Board& board, const BI_Polygon& other);
67  BI_Polygon(Board& board, const SExpression& node);
68  BI_Polygon(Board& board, const Polygon& polygon);
69  BI_Polygon(Board& board, const Uuid& uuid, const GraphicsLayerName& layerName,
70  const UnsignedLength& lineWidth, bool fill, bool isGrabArea,
71  const Path& path);
72  ~BI_Polygon() noexcept;
73 
74  // Getters
75  Polygon& getPolygon() noexcept { return *mPolygon; }
76  const Polygon& getPolygon() const noexcept { return *mPolygon; }
77  const Uuid& getUuid() const
78  noexcept; // convenience function, e.g. for template usage
79  bool isSelectable() const noexcept override;
80 
81  // General Methods
82  void addToBoard() override;
83  void removeFromBoard() override;
84 
86  void serialize(SExpression& root) const override;
87 
88  // Inherited from BI_Base
89  Type_t getType() const noexcept override { return BI_Base::Type_t::Polygon; }
90  const Point& getPosition() const noexcept override {
91  static Point p(0, 0);
92  return p;
93  }
94  bool getIsMirrored() const noexcept override { return false; }
95  QPainterPath getGrabAreaScenePx() const noexcept override;
96  void setSelected(bool selected) noexcept override;
97 
98  // Operator Overloadings
99  BI_Polygon& operator=(const BI_Polygon& rhs) = delete;
100 
101 private slots:
102 
103  void boardAttributesChanged();
104 
105 private:
106  void init();
107 
108  // General
109  QScopedPointer<Polygon> mPolygon;
111 };
112 
113 /*******************************************************************************
114  * End of File
115  ******************************************************************************/
116 
117 } // namespace project
118 } // namespace librepcb
119 
120 #endif // LIBREPCB_PROJECT_BI_POLYGON_H
void addToBoard() override
Definition: bi_polygon.cpp:89
bool getIsMirrored() const noexceptoverride
Definition: bi_polygon.h:94
const Polygon & getPolygon() const noexcept
Definition: bi_polygon.h:76
The PolygonGraphicsItem class.
Definition: polygongraphicsitem.h:49
librepcb::project::BI_Polygon
type_safe::constrained_type< QString, GraphicsLayerNameConstraint, GraphicsLayerNameVerifier > GraphicsLayerName
Definition: graphicslayername.h:78
void removeFromBoard() override
Definition: bi_polygon.cpp:96
Type_t
Definition: bi_base.h:57
Type_t getType() const noexceptoverride
Definition: bi_polygon.h:89
void boardAttributesChanged()
Definition: bi_polygon.cpp:134
void setSelected(bool selected) noexceptoverride
Definition: bi_polygon.cpp:125
void init()
Definition: bi_polygon.cpp:70
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:46
bool isSelectable() const noexceptoverride
Definition: bi_polygon.cpp:119
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:81
The BI_Polygon class.
Definition: bi_polygon.h:59
The Board Item Base (BI_Base) class.
Definition: bi_base.h:52
const Uuid & getUuid() const noexcept
Definition: bi_polygon.cpp:115
QScopedPointer< PolygonGraphicsItem > mGraphicsItem
Definition: bi_polygon.h:110
QScopedPointer< Polygon > mPolygon
Definition: bi_polygon.h:109
The Path class represents a list of vertices connected by straight lines or circular arc segments...
Definition: path.h:53
const Point & getPosition() const noexceptoverride
Definition: bi_polygon.h:90
~BI_Polygon() noexcept
Definition: bi_polygon.cpp:80
Polygon & getPolygon() noexcept
Definition: bi_polygon.h:75
The Board class represents a PCB of a project and is always part of a circuit.
Definition: board.h:82
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
The Polygon class.
Definition: polygon.h:76
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: bi_polygon.cpp:103
The SExpression class.
Definition: sexpression.h:60
QPainterPath getGrabAreaScenePx() const noexceptoverride
Definition: bi_polygon.cpp:111
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:662