LibrePCB Developers Documentation
Loading...
Searching...
No Matches
symboleditorstate_drawpolygonbase.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_SYMBOLEDITORSTATE_DRAWPOLYGONBASE_H
21#define LIBREPCB_EDITOR_SYMBOLEDITORSTATE_DRAWPOLYGONBASE_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "symboleditorstate.h"
27
29
30#include <QtCore>
31
32#include <memory>
33
34/*******************************************************************************
35 * Namespace / Forward Declarations
36 ******************************************************************************/
37namespace librepcb {
38namespace editor {
39
40class CmdPolygonEdit;
41class PolygonGraphicsItem;
42
43/*******************************************************************************
44 * Class SymbolEditorState_DrawPolygonBase
45 ******************************************************************************/
46
51 Q_OBJECT
52
53public:
54 // Types
55 enum class Mode { LINE, ARC, RECT, POLYGON };
56
57 // Constructors / Destructor
60 const SymbolEditorState_DrawPolygonBase& other) = delete;
61 SymbolEditorState_DrawPolygonBase(const Context& context, Mode mode) noexcept;
62 virtual ~SymbolEditorState_DrawPolygonBase() noexcept;
63
64 // General Methods
65 bool processKeyPressed(const GraphicsSceneKeyEvent& e) noexcept override;
66 bool processKeyReleased(const GraphicsSceneKeyEvent& e) noexcept override;
67 bool entry() noexcept override;
68 bool exit() noexcept override;
69
70 // Event Handlers
72 const GraphicsSceneMouseEvent& e) noexcept override;
74 const GraphicsSceneMouseEvent& e) noexcept override;
76 const GraphicsSceneMouseEvent& e) noexcept override;
77 bool processAbortCommand() noexcept override;
78
79 // Connection to UI
80 QSet<const Layer*> getAvailableLayers() const noexcept;
81 const Layer& getLayer() const noexcept {
83 }
84 void setLayer(const Layer& layer) noexcept;
85 const UnsignedLength& getLineWidth() const noexcept {
87 }
88 void setLineWidth(const UnsignedLength& width) noexcept;
89 bool getFilled() const noexcept { return mCurrentProperties.isFilled(); }
90 void setFilled(bool filled) noexcept;
91 bool getGrabArea() const noexcept { return mCurrentProperties.isGrabArea(); }
92 void setGrabArea(bool grabArea) noexcept;
93 const Angle& getAngle() const noexcept { return mLastAngle; }
94 void setAngle(const Angle& angle) noexcept;
95
96 // Operator Overloadings
98 const SymbolEditorState_DrawPolygonBase& rhs) = delete;
99
100signals:
101 void layerChanged(const Layer& layer);
103 void filledChanged(bool filled);
104 void grabAreaChanged(bool grabArea);
105 void angleChanged(const Angle& angle);
106
107protected:
108 virtual void notifyToolEnter() noexcept = 0;
109
110private: // Methods
111 bool start() noexcept;
112 bool abort(bool showErrMsgBox = true) noexcept;
113 bool addNextSegment() noexcept;
114 void updateCursorPosition(Qt::KeyboardModifiers modifiers) noexcept;
115 void updatePolygonPath() noexcept;
116 void updateOverlayText() noexcept;
117 void updateStatusBarMessage() noexcept;
118
119private:
120 const Mode mMode;
125
126 // Arc tool state
129
130 // Current tool settings
132
133 // Information about the current polygon to place. Only valid if
134 // mIsUndoCmdActive == true.
138};
139
140/*******************************************************************************
141 * End of File
142 ******************************************************************************/
143
144} // namespace editor
145} // namespace librepcb
146
147#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition angle.h:76
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 Polygon class.
Definition polygon.h:45
bool isFilled() const noexcept
Definition polygon.h:74
const Layer & getLayer() const noexcept
Definition polygon.h:72
const UnsignedLength & getLineWidth() const noexcept
Definition polygon.h:73
bool isGrabArea() const noexcept
Definition polygon.h:75
The CmdPolygonEdit class.
Definition cmdpolygonedit.h:51
The PolygonGraphicsItem class.
Definition polygongraphicsitem.h:48
The SymbolEditorState_DrawPolygonBase class.
Definition symboleditorstate_drawpolygonbase.h:50
bool processGraphicsSceneMouseMoved(const GraphicsSceneMouseEvent &e) noexcept override
Definition symboleditorstate_drawpolygonbase.cpp:119
bool getGrabArea() const noexcept
Definition symboleditorstate_drawpolygonbase.h:91
bool abort(bool showErrMsgBox=true) noexcept
Definition symboleditorstate_drawpolygonbase.cpp:267
Point mArcCenter
Definition symboleditorstate_drawpolygonbase.h:127
void setLayer(const Layer &layer) noexcept
Definition symboleditorstate_drawpolygonbase.cpp:161
bool addNextSegment() noexcept
Definition symboleditorstate_drawpolygonbase.cpp:290
Mode
Definition symboleditorstate_drawpolygonbase.h:55
bool mArcInSecondState
Definition symboleditorstate_drawpolygonbase.h:128
bool processGraphicsSceneLeftMouseButtonPressed(const GraphicsSceneMouseEvent &e) noexcept override
Definition symboleditorstate_drawpolygonbase.cpp:127
void updateCursorPosition(Qt::KeyboardModifiers modifiers) noexcept
Definition symboleditorstate_drawpolygonbase.cpp:354
Angle mLastAngle
Definition symboleditorstate_drawpolygonbase.h:122
bool processAbortCommand() noexcept override
Definition symboleditorstate_drawpolygonbase.cpp:144
const Layer & getLayer() const noexcept
Definition symboleditorstate_drawpolygonbase.h:81
QSet< const Layer * > getAvailableLayers() const noexcept
Definition symboleditorstate_drawpolygonbase.cpp:156
bool processGraphicsSceneLeftMouseButtonDoubleClicked(const GraphicsSceneMouseEvent &e) noexcept override
Definition symboleditorstate_drawpolygonbase.cpp:138
void updateOverlayText() noexcept
Definition symboleditorstate_drawpolygonbase.cpp:426
bool processKeyPressed(const GraphicsSceneKeyEvent &e) noexcept override
Definition symboleditorstate_drawpolygonbase.cpp:99
const UnsignedLength & getLineWidth() const noexcept
Definition symboleditorstate_drawpolygonbase.h:85
bool mIsUndoCmdActive
Definition symboleditorstate_drawpolygonbase.h:124
SymbolEditorState_DrawPolygonBase(const SymbolEditorState_DrawPolygonBase &other)=delete
bool start() noexcept
Definition symboleditorstate_drawpolygonbase.cpp:221
Polygon mCurrentProperties
Definition symboleditorstate_drawpolygonbase.h:131
void setFilled(bool filled) noexcept
Definition symboleditorstate_drawpolygonbase.cpp:182
bool exit() noexcept override
Definition symboleditorstate_drawpolygonbase.cpp:82
std::shared_ptr< Polygon > mCurrentPolygon
Definition symboleditorstate_drawpolygonbase.h:135
void setGrabArea(bool grabArea) noexcept
Definition symboleditorstate_drawpolygonbase.cpp:192
void setAngle(const Angle &angle) noexcept
Definition symboleditorstate_drawpolygonbase.cpp:202
const Mode mMode
Definition symboleditorstate_drawpolygonbase.h:120
std::unique_ptr< CmdPolygonEdit > mCurrentEditCmd
Definition symboleditorstate_drawpolygonbase.h:136
void setLineWidth(const UnsignedLength &width) noexcept
Definition symboleditorstate_drawpolygonbase.cpp:171
bool processKeyReleased(const GraphicsSceneKeyEvent &e) noexcept override
Definition symboleditorstate_drawpolygonbase.cpp:109
void updateStatusBarMessage() noexcept
Definition symboleditorstate_drawpolygonbase.cpp:513
bool getFilled() const noexcept
Definition symboleditorstate_drawpolygonbase.h:89
SymbolEditorState_DrawPolygonBase & operator=(const SymbolEditorState_DrawPolygonBase &rhs)=delete
Point mLastScenePos
Definition symboleditorstate_drawpolygonbase.h:121
void lineWidthChanged(const UnsignedLength &width)
Point mCursorPos
Definition symboleditorstate_drawpolygonbase.h:123
bool entry() noexcept override
Definition symboleditorstate_drawpolygonbase.cpp:71
std::shared_ptr< PolygonGraphicsItem > mCurrentGraphicsItem
Definition symboleditorstate_drawpolygonbase.h:137
void updatePolygonPath() noexcept
Definition symboleditorstate_drawpolygonbase.cpp:369
virtual ~SymbolEditorState_DrawPolygonBase() noexcept
Definition symboleditorstate_drawpolygonbase.cpp:64
const Angle & getAngle() const noexcept
Definition symboleditorstate_drawpolygonbase.h:93
The SymbolEditorState class is the base class of all symbol editor FSM states.
Definition symboleditorstate.h:56
Definition occmodel.cpp:77
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition length.h:694
Definition uuid.h:186
Definition graphicsscene.h:52
Definition graphicsscene.h:45
Definition symboleditorfsm.h:75