LibrePCB Developers Documentation
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, const Version& fileFormat);
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
77  bool isSelectable() const noexcept override;
78 
79  // General Methods
80  void addToBoard() override;
81  void removeFromBoard() override;
82 
84  void serialize(SExpression& root) const override;
85 
86  // Inherited from BI_Base
87  Type_t getType() const noexcept override { return BI_Base::Type_t::Polygon; }
88  const Point& getPosition() const noexcept override {
89  static Point p(0, 0);
90  return p;
91  }
92  bool getIsMirrored() const noexcept override { return false; }
93  QPainterPath getGrabAreaScenePx() const noexcept override;
94  void setSelected(bool selected) noexcept override;
95 
96  // Operator Overloadings
97  BI_Polygon& operator=(const BI_Polygon& rhs) = delete;
98 
99 private slots:
100 
101  void boardAttributesChanged();
102 
103 private:
104  void init();
105 
106  // General
107  QScopedPointer<Polygon> mPolygon;
108  QScopedPointer<PolygonGraphicsItem> mGraphicsItem;
109 };
110 
111 /*******************************************************************************
112  * End of File
113  ******************************************************************************/
114 
115 } // namespace project
116 } // namespace librepcb
117 
118 #endif // LIBREPCB_PROJECT_BI_POLYGON_H
void addToBoard() override
Definition: bi_polygon.cpp:91
const Point & getPosition() const noexcept override
Definition: bi_polygon.h:88
The Version class represents a version number in the format "1.42.7".
Definition: version.h:60
BI_Polygon & operator=(const BI_Polygon &rhs)=delete
const Polygon & getPolygon() const noexcept
Definition: bi_polygon.h:73
The PolygonGraphicsItem class.
Definition: polygongraphicsitem.h:46
librepcb::project::BI_Polygon
Definition: airwiresbuilder.cpp:32
type_safe::constrained_type< QString, GraphicsLayerNameConstraint, GraphicsLayerNameVerifier > GraphicsLayerName
Definition: graphicslayername.h:78
void removeFromBoard() override
Definition: bi_polygon.cpp:98
Type_t
Definition: bi_base.h:57
bool isSelectable() const noexcept override
Definition: bi_polygon.cpp:121
void boardAttributesChanged()
Definition: bi_polygon.cpp:136
void init()
Definition: bi_polygon.cpp:72
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:43
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
PolygonGraphicsItem & getGraphicsItem() noexcept
Definition: bi_polygon.h:76
The BI_Polygon class.
Definition: bi_polygon.h:56
QPainterPath getGrabAreaScenePx() const noexcept override
Definition: bi_polygon.cpp:113
bool getIsMirrored() const noexcept override
Definition: bi_polygon.h:92
The Board Item Base (BI_Base) class.
Definition: bi_base.h:52
void setSelected(bool selected) noexcept override
Definition: bi_polygon.cpp:127
const Uuid & getUuid() const noexcept
Definition: bi_polygon.cpp:117
QScopedPointer< PolygonGraphicsItem > mGraphicsItem
Definition: bi_polygon.h:108
QScopedPointer< Polygon > mPolygon
Definition: bi_polygon.h:107
The Path class represents a list of vertices connected by straight lines or circular arc segments...
Definition: path.h:53
~BI_Polygon() noexcept
Definition: bi_polygon.cpp:82
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
Type_t getType() const noexcept override
Definition: bi_polygon.h:87
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: bi_polygon.cpp:105
The SExpression class.
Definition: sexpression.h:72
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:672