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 
56 class BI_Polygon final : public BI_Base, public SerializableObject {
57  Q_OBJECT
58 
59 public:
60  // Constructors / Destructor
61  BI_Polygon() = delete;
62  BI_Polygon(const BI_Polygon& other) = delete;
63  BI_Polygon(Board& board, const BI_Polygon& other);
64  BI_Polygon(Board& board, const SExpression& node);
65  BI_Polygon(Board& board, const Polygon& polygon);
66  BI_Polygon(Board& board, const Uuid& uuid, const GraphicsLayerName& layerName,
67  const UnsignedLength& lineWidth, bool fill, bool isGrabArea,
68  const Path& path);
69  ~BI_Polygon() noexcept;
70 
71  // Getters
72  Polygon& getPolygon() noexcept { return *mPolygon; }
73  const Polygon& getPolygon() const noexcept { return *mPolygon; }
74  const Uuid& getUuid() const
75  noexcept; // convenience function, e.g. for template usage
76  bool isSelectable() const noexcept override;
77 
78  // General Methods
79  void addToBoard() override;
80  void removeFromBoard() override;
81 
83  void serialize(SExpression& root) const override;
84 
85  // Inherited from BI_Base
86  Type_t getType() const noexcept override { return BI_Base::Type_t::Polygon; }
87  const Point& getPosition() const noexcept override {
88  static Point p(0, 0);
89  return p;
90  }
91  bool getIsMirrored() const noexcept override { return false; }
92  QPainterPath getGrabAreaScenePx() const noexcept override;
93  void setSelected(bool selected) noexcept override;
94 
95  // Operator Overloadings
96  BI_Polygon& operator=(const BI_Polygon& rhs) = delete;
97 
98 private slots:
99 
100  void boardAttributesChanged();
101 
102 private:
103  void init();
104 
105  // General
106  QScopedPointer<Polygon> mPolygon;
108 };
109 
110 /*******************************************************************************
111  * End of File
112  ******************************************************************************/
113 
114 } // namespace project
115 } // namespace librepcb
116 
117 #endif // LIBREPCB_PROJECT_BI_POLYGON_H
void addToBoard() override
Definition: bi_polygon.cpp:89
bool getIsMirrored() const noexceptoverride
Definition: bi_polygon.h:91
const Polygon & getPolygon() const noexcept
Definition: bi_polygon.h:73
The PolygonGraphicsItem class.
Definition: polygongraphicsitem.h:46
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:86
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:43
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:78
The BI_Polygon class.
Definition: bi_polygon.h:56
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:107
QScopedPointer< Polygon > mPolygon
Definition: bi_polygon.h:106
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:87
~BI_Polygon() noexcept
Definition: bi_polygon.cpp:80
Polygon & getPolygon() noexcept
Definition: bi_polygon.h:72
The Board class represents a PCB of a project and is always part of a circuit.
Definition: board.h:83
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
The Polygon class.
Definition: polygon.h:49
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:57
QPainterPath getGrabAreaScenePx() const noexceptoverride
Definition: bi_polygon.cpp:111
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:659