LibrePCB Developers Documentation
Loading...
Searching...
No Matches
boardeditorstate_drawpolygon.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_EDITOR_BOARDEDITORSTATE_DRAWPOLYGON_H
21#define LIBREPCB_EDITOR_BOARDEDITORSTATE_DRAWPOLYGON_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "boardeditorstate.h"
27
29
30#include <QtCore>
31
32#include <memory>
33
34/*******************************************************************************
35 * Namespace / Forward Declarations
36 ******************************************************************************/
37namespace librepcb {
38
39class BI_Polygon;
40
41namespace editor {
42
43class CmdBoardPolygonEdit;
44
45/*******************************************************************************
46 * Class BoardEditorState_DrawPolygon
47 ******************************************************************************/
48
53 Q_OBJECT
54
55public:
56 // Constructors / Destructor
59 delete;
60 explicit BoardEditorState_DrawPolygon(const Context& context) noexcept;
61 virtual ~BoardEditorState_DrawPolygon() noexcept;
62
63 // General Methods
64 virtual bool entry() noexcept override;
65 virtual bool exit() noexcept override;
66
67 // Event Handlers
68 virtual bool processAbortCommand() noexcept override;
70 const GraphicsSceneMouseEvent& e) noexcept override;
72 const GraphicsSceneMouseEvent& e) noexcept override;
74 const GraphicsSceneMouseEvent& e) noexcept override;
75
76 // Connection to UI
77 QSet<const Layer*> getAvailableLayers() noexcept;
78 const Layer& getLayer() const noexcept {
80 }
81 void setLayer(const Layer& layer) noexcept;
82 const UnsignedLength& getLineWidth() const noexcept {
84 }
85 void setLineWidth(const UnsignedLength& width) noexcept;
86 bool getFilled() const noexcept { return mCurrentProperties.isFilled(); }
87 void setFilled(bool filled) noexcept;
88
89 // Operator Overloadings
91 const BoardEditorState_DrawPolygon& rhs) = delete;
92
93signals:
94 void layerChanged(const Layer& layer);
95 void lineWidthChanged(const UnsignedLength& width);
96 void filledChanged(bool filled);
97
98private: // Methods
99 bool startAddPolygon(const Point& pos) noexcept;
100 bool addSegment(const Point& pos) noexcept;
101 bool updateLastVertexPosition(const Point& pos) noexcept;
102 bool abortCommand(bool showErrMsgBox) noexcept;
103
104private:
105 // State
108
109 // Current tool settings
111
112 // Information about the current polygon to place. Only valid if
113 // mIsUndoCmdActive == true.
115 std::unique_ptr<CmdBoardPolygonEdit> mCurrentPolygonEditCmd;
116};
117
118/*******************************************************************************
119 * End of File
120 ******************************************************************************/
121
122} // namespace editor
123} // namespace librepcb
124
125#endif
The BI_Polygon class.
Definition bi_polygon.h:46
The BoardPolygonData class.
Definition boardpolygondata.h:45
bool isFilled() const noexcept
Definition boardpolygondata.h:62
const Layer & getLayer() const noexcept
Definition boardpolygondata.h:59
const UnsignedLength & getLineWidth() const noexcept
Definition boardpolygondata.h:60
The Layer class provides all supported geometry layers.
Definition layer.h:42
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition point.h:78
The "draw polygon" state/tool of the board editor.
Definition boardeditorstate_drawpolygon.h:52
virtual bool processGraphicsSceneMouseMoved(const GraphicsSceneMouseEvent &e) noexcept override
Definition boardeditorstate_drawpolygon.cpp:101
bool startAddPolygon(const Point &pos) noexcept
Definition boardeditorstate_drawpolygon.cpp:170
BI_Polygon * mCurrentPolygon
Definition boardeditorstate_drawpolygon.h:114
BoardEditorState_DrawPolygon(const BoardEditorState_DrawPolygon &other)=delete
void setLayer(const Layer &layer) noexcept
Definition boardeditorstate_drawpolygon.cpp:132
QSet< const Layer * > getAvailableLayers() noexcept
Definition boardeditorstate_drawpolygon.cpp:128
BoardPolygonData mCurrentProperties
Definition boardeditorstate_drawpolygon.h:110
virtual bool processGraphicsSceneLeftMouseButtonPressed(const GraphicsSceneMouseEvent &e) noexcept override
Definition boardeditorstate_drawpolygon.cpp:107
virtual bool processAbortCommand() noexcept override
Definition boardeditorstate_drawpolygon.cpp:91
const Layer & getLayer() const noexcept
Definition boardeditorstate_drawpolygon.h:78
BoardEditorState_DrawPolygon & operator=(const BoardEditorState_DrawPolygon &rhs)=delete
virtual bool processGraphicsSceneLeftMouseButtonDoubleClicked(const GraphicsSceneMouseEvent &e) noexcept override
Definition boardeditorstate_drawpolygon.cpp:119
bool abortCommand(bool showErrMsgBox) noexcept
Definition boardeditorstate_drawpolygon.cpp:254
const UnsignedLength & getLineWidth() const noexcept
Definition boardeditorstate_drawpolygon.h:82
bool mIsUndoCmdActive
Definition boardeditorstate_drawpolygon.h:106
void setFilled(bool filled) noexcept
Definition boardeditorstate_drawpolygon.cpp:155
virtual bool exit() noexcept override
Definition boardeditorstate_drawpolygon.cpp:78
bool addSegment(const Point &pos) noexcept
Definition boardeditorstate_drawpolygon.cpp:201
std::unique_ptr< CmdBoardPolygonEdit > mCurrentPolygonEditCmd
Definition boardeditorstate_drawpolygon.h:115
void setLineWidth(const UnsignedLength &width) noexcept
Definition boardeditorstate_drawpolygon.cpp:143
bool getFilled() const noexcept
Definition boardeditorstate_drawpolygon.h:86
virtual ~BoardEditorState_DrawPolygon() noexcept
Definition boardeditorstate_drawpolygon.cpp:63
bool updateLastVertexPosition(const Point &pos) noexcept
Definition boardeditorstate_drawpolygon.cpp:242
void lineWidthChanged(const UnsignedLength &width)
Point mLastSegmentPos
Definition boardeditorstate_drawpolygon.h:107
virtual bool entry() noexcept override
Definition boardeditorstate_drawpolygon.cpp:70
The board editor state base class.
Definition boardeditorstate.h:60
Definition occmodel.cpp:77
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition length.h:694
FSM Context.
Definition boardeditorfsm.h:88
Definition graphicsscene.h:45