LibrePCB Developers Documentation
packageeditorstate_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_PACKAGEEDITORSTATE_DRAWPOLYGONBASE_H
21#define LIBREPCB_EDITOR_PACKAGEEDITORSTATE_DRAWPOLYGONBASE_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "packageeditorstate.h"
27
31
32#include <QtCore>
33#include <QtWidgets>
34
35#include <memory>
36
37/*******************************************************************************
38 * Namespace / Forward Declarations
39 ******************************************************************************/
40namespace librepcb {
41
42class Layer;
43class Polygon;
44
45namespace editor {
46
47class CmdPolygonEdit;
48class PolygonGraphicsItem;
49
50/*******************************************************************************
51 * Class PackageEditorState_DrawPolygonBase
52 ******************************************************************************/
53
58 Q_OBJECT
59
60public:
61 // Types
62 enum class Mode { LINE, ARC, RECT, POLYGON };
63
64 // Constructors / Destructor
67 const PackageEditorState_DrawPolygonBase& other) = delete;
68 PackageEditorState_DrawPolygonBase(Context& context, Mode mode) noexcept;
69 virtual ~PackageEditorState_DrawPolygonBase() noexcept;
70
71 // General Methods
72 bool entry() noexcept override;
73 bool exit() noexcept override;
75 const noexcept override;
76
77 // Event Handlers
78 bool processKeyPressed(const QKeyEvent& e) noexcept override;
79 bool processKeyReleased(const QKeyEvent& e) noexcept override;
81 QGraphicsSceneMouseEvent& e) noexcept override;
83 QGraphicsSceneMouseEvent& e) noexcept override;
85 QGraphicsSceneMouseEvent& e) noexcept override;
86 bool processAbortCommand() noexcept override;
87
88 // Operator Overloadings
90 const PackageEditorState_DrawPolygonBase& rhs) = delete;
91
92signals:
93 void requestLineWidth(const UnsignedLength& value);
94
95private: // Methods
96 bool start() noexcept;
97 bool abort(bool showErrMsgBox = true) noexcept;
98 bool addNextSegment() noexcept;
99 void updateCursorPosition(Qt::KeyboardModifiers modifiers) noexcept;
100 void updatePolygonPath() noexcept;
101 void updateOverlayText() noexcept;
102 void updateStatusBarMessage() noexcept;
103
104 void layerComboBoxValueChanged(const Layer& layer) noexcept;
105 void lineWidthEditValueChanged(const UnsignedLength& value) noexcept;
106 void angleEditValueChanged(const Angle& value) noexcept;
107 void fillCheckBoxCheckedChanged(bool checked) noexcept;
108 void grabAreaCheckBoxCheckedChanged(bool checked) noexcept;
109
110private: // Types / Data
113 QScopedPointer<CmdPolygonEdit> mEditCmd;
114 std::shared_ptr<Polygon> mCurrentPolygon;
118
119 // Arc tool state
122
123 // parameter memory
130};
131
132/*******************************************************************************
133 * End of File
134 ******************************************************************************/
135
136} // namespace editor
137} // namespace librepcb
138
139#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
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:79
The Polygon class.
Definition: polygon.h:45
The CmdPolygonEdit class.
Definition: cmdpolygonedit.h:51
The EditorWidgetBase class.
Definition: editorwidgetbase.h:62
The PackageEditorState_DrawPolygonBase class.
Definition: packageeditorstate_drawpolygonbase.h:57
bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent &e) noexcept override
Definition: packageeditorstate_drawpolygonbase.cpp:208
PackageEditorState_DrawPolygonBase(const PackageEditorState_DrawPolygonBase &other)=delete
const Layer * mLastLayer
Definition: packageeditorstate_drawpolygonbase.h:124
void requestLineWidth(const UnsignedLength &value)
bool abort(bool showErrMsgBox=true) noexcept
Definition: packageeditorstate_drawpolygonbase.cpp:289
Point mArcCenter
Definition: packageeditorstate_drawpolygonbase.h:120
bool mLastFill
Definition: packageeditorstate_drawpolygonbase.h:127
bool addNextSegment() noexcept
Definition: packageeditorstate_drawpolygonbase.cpp:312
Mode
Definition: packageeditorstate_drawpolygonbase.h:62
bool mArcInSecondState
Definition: packageeditorstate_drawpolygonbase.h:121
Mode mMode
Definition: packageeditorstate_drawpolygonbase.h:111
void updateCursorPosition(Qt::KeyboardModifiers modifiers) noexcept
Definition: packageeditorstate_drawpolygonbase.cpp:376
Angle mLastAngle
Definition: packageeditorstate_drawpolygonbase.h:126
QHash< const Layer *, UnsignedLength > mUsedLineWidths
Definition: packageeditorstate_drawpolygonbase.h:129
bool processAbortCommand() noexcept override
Definition: packageeditorstate_drawpolygonbase.cpp:233
bool processKeyPressed(const QKeyEvent &e) noexcept override
Definition: packageeditorstate_drawpolygonbase.cpp:188
void fillCheckBoxCheckedChanged(bool checked) noexcept
Definition: packageeditorstate_drawpolygonbase.cpp:609
void updateOverlayText() noexcept
Definition: packageeditorstate_drawpolygonbase.cpp:449
void grabAreaCheckBoxCheckedChanged(bool checked) noexcept
Definition: packageeditorstate_drawpolygonbase.cpp:617
bool mIsUndoCmdActive
Definition: packageeditorstate_drawpolygonbase.h:112
bool start() noexcept
Definition: packageeditorstate_drawpolygonbase.cpp:245
bool mLastGrabArea
Definition: packageeditorstate_drawpolygonbase.h:128
void angleEditValueChanged(const Angle &value) noexcept
Definition: packageeditorstate_drawpolygonbase.cpp:597
QScopedPointer< CmdPolygonEdit > mEditCmd
Definition: packageeditorstate_drawpolygonbase.h:113
void layerComboBoxValueChanged(const Layer &layer) noexcept
Definition: packageeditorstate_drawpolygonbase.cpp:571
bool exit() noexcept override
Definition: packageeditorstate_drawpolygonbase.cpp:162
std::shared_ptr< Polygon > mCurrentPolygon
Definition: packageeditorstate_drawpolygonbase.h:114
UnsignedLength mLastLineWidth
Definition: packageeditorstate_drawpolygonbase.h:125
virtual ~PackageEditorState_DrawPolygonBase() noexcept
Definition: packageeditorstate_drawpolygonbase.cpp:69
void updateStatusBarMessage() noexcept
Definition: packageeditorstate_drawpolygonbase.cpp:536
QSet< EditorWidgetBase::Feature > getAvailableFeatures() const noexcept override
Definition: packageeditorstate_drawpolygonbase.cpp:178
void lineWidthEditValueChanged(const UnsignedLength &value) noexcept
Definition: packageeditorstate_drawpolygonbase.cpp:588
bool processKeyReleased(const QKeyEvent &e) noexcept override
Definition: packageeditorstate_drawpolygonbase.cpp:198
bool processGraphicsSceneLeftMouseButtonPressed(QGraphicsSceneMouseEvent &e) noexcept override
Definition: packageeditorstate_drawpolygonbase.cpp:216
Point mLastScenePos
Definition: packageeditorstate_drawpolygonbase.h:116
Point mCursorPos
Definition: packageeditorstate_drawpolygonbase.h:117
bool entry() noexcept override
Definition: packageeditorstate_drawpolygonbase.cpp:76
std::shared_ptr< PolygonGraphicsItem > mCurrentGraphicsItem
Definition: packageeditorstate_drawpolygonbase.h:115
bool processGraphicsSceneLeftMouseButtonDoubleClicked(QGraphicsSceneMouseEvent &e) noexcept override
Definition: packageeditorstate_drawpolygonbase.cpp:227
void updatePolygonPath() noexcept
Definition: packageeditorstate_drawpolygonbase.cpp:392
The PackageEditorState class is the base class of all package editor FSM states.
Definition: packageeditorstate.h:52
The PolygonGraphicsItem class.
Definition: polygongraphicsitem.h:48
Definition: occmodel.cpp:77
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:696
Definition: packageeditorfsm.h:90