LibrePCB Developers Documentation
Loading...
Searching...
No Matches
packageeditorfsm.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_PACKAGEEDITORFSM_H
21#define LIBREPCB_EDITOR_PACKAGEEDITORFSM_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../editorwidgetbase.h"
27
29
30#include <QtCore>
31
32#include <memory>
33
34/*******************************************************************************
35 * Namespace / Forward Declarations
36 ******************************************************************************/
37namespace librepcb {
38
39class Footprint;
40class Package;
41
42namespace editor {
43
44class FootprintGraphicsItem;
45class GraphicsScene;
46class GraphicsView;
47class PackageEditorState;
48class PackageEditorWidget;
49class PrimitiveTextGraphicsItem;
50class UndoStack;
51
52/*******************************************************************************
53 * Class PackageEditorFsm
54 ******************************************************************************/
55
60class PackageEditorFsm final : public QObject {
61 Q_OBJECT
62
63private: // Types
88
89public: // Types
102
103public:
104 // Constructors / Destructor
106 PackageEditorFsm(const PackageEditorFsm& other) = delete;
107 explicit PackageEditorFsm(const Context& context) noexcept;
108 virtual ~PackageEditorFsm() noexcept;
109
110 // Getters
111 EditorWidgetBase::Tool getCurrentTool() const noexcept;
112 std::shared_ptr<Footprint> getCurrentFootprint() const noexcept;
113 const QSet<EditorWidgetBase::Feature>& getAvailableFeatures() const noexcept {
114 return mAvailableFeatures;
115 }
116
117 // General Methods
118 void updateAvailableFeatures() noexcept;
119
120 // Event Handlers
122 const std::shared_ptr<Footprint>& fpt) noexcept;
123 bool processKeyPressed(const QKeyEvent& e) noexcept;
124 bool processKeyReleased(const QKeyEvent& e) noexcept;
125 bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent& e) noexcept;
127 QGraphicsSceneMouseEvent& e) noexcept;
129 QGraphicsSceneMouseEvent& e) noexcept;
131 QGraphicsSceneMouseEvent& e) noexcept;
133 QGraphicsSceneMouseEvent& e) noexcept;
134 bool processSelectAll() noexcept;
135 bool processCut() noexcept;
136 bool processCopy() noexcept;
137 bool processPaste() noexcept;
138 bool processMove(const Point& delta) noexcept;
139 bool processRotate(const Angle& rotation) noexcept;
140 bool processMirror(Qt::Orientation orientation) noexcept;
141 bool processFlip(Qt::Orientation orientation) noexcept;
142 bool processMoveAlign() noexcept;
143 bool processSnapToGrid() noexcept;
144 bool processRemove() noexcept;
145 bool processEditProperties() noexcept;
146 bool processGenerateOutline() noexcept;
147 bool processGenerateCourtyard() noexcept;
148 bool processAbortCommand() noexcept;
149 bool processStartSelecting() noexcept;
152 FootprintPad::Function function) noexcept;
153 bool processStartAddingNames() noexcept;
154 bool processStartAddingValues() noexcept;
155 bool processStartDrawLines() noexcept;
156 bool processStartDrawArcs() noexcept;
157 bool processStartDrawRects() noexcept;
158 bool processStartDrawPolygons() noexcept;
159 bool processStartDrawCircles() noexcept;
160 bool processStartDrawTexts() noexcept;
161 bool processStartDrawZones() noexcept;
162 bool processStartAddingHoles() noexcept;
163 bool processStartDxfImport() noexcept;
164 bool processStartMeasure() noexcept;
165 bool processStartReNumberPads() noexcept;
166
167 // Operator Overloadings
168 PackageEditorFsm& operator=(const PackageEditorFsm& rhs) = delete;
169
170signals:
171 void toolChanged(EditorWidgetBase::Tool newTool);
173 void statusBarMessageChanged(const QString& message, int timeoutMs = -1);
174
175private: // Methods
176 PackageEditorState* getCurrentState() const noexcept;
177 bool setNextState(State state) noexcept;
178 bool leaveCurrentState() noexcept;
179 bool enterNextState(State state) noexcept;
180 bool switchToPreviousState() noexcept;
181
182private: // Data
189};
190
191/*******************************************************************************
192 * End of File
193 ******************************************************************************/
194
195} // namespace editor
196} // namespace librepcb
197
198#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition angle.h:76
The Footprint class represents one footprint variant of a package.
Definition footprint.h:55
The FootprintPad class represents a pad of a footprint.
Definition footprintpad.h:54
The LengthUnit class represents a length unit (millimeters, inches,...) and provides some useful meth...
Definition lengthunit.h:60
The Package class represents a package of a component (including footprint and 3D model)
Definition package.h:59
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition point.h:78
The EditorWidgetBase class.
Definition editorwidgetbase.h:61
The GraphicsScene class.
Definition graphicsscene.h:45
The GraphicsView class.
Definition graphicsview.h:52
The PackageEditorFsm class is the finit state machine (FSM) of the package editor.
Definition packageeditorfsm.h:60
Context mContext
Definition packageeditorfsm.h:183
bool processGraphicsSceneRightMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexcept
Definition packageeditorfsm.cpp:301
bool processKeyReleased(const QKeyEvent &e) noexcept
Definition packageeditorfsm.cpp:251
bool processStartAddingNames() noexcept
Definition packageeditorfsm.cpp:472
bool processStartAddingHoles() noexcept
Definition packageeditorfsm.cpp:508
bool setNextState(State state) noexcept
Definition packageeditorfsm.cpp:538
bool processStartAddingValues() noexcept
Definition packageeditorfsm.cpp:476
bool processKeyPressed(const QKeyEvent &e) noexcept
Definition packageeditorfsm.cpp:242
bool processGraphicsSceneLeftMouseButtonDoubleClicked(QGraphicsSceneMouseEvent &e) noexcept
Definition packageeditorfsm.cpp:290
void statusBarMessageChanged(const QString &message, int timeoutMs=-1)
PackageEditorState * getCurrentState() const noexcept
Definition packageeditorfsm.cpp:534
bool processChangeCurrentFootprint(const std::shared_ptr< Footprint > &fpt) noexcept
Definition packageeditorfsm.cpp:202
EditorWidgetBase::Tool getCurrentTool() const noexcept
Definition packageeditorfsm.cpp:132
bool processStartSelecting() noexcept
Definition packageeditorfsm.cpp:444
bool processStartDrawLines() noexcept
Definition packageeditorfsm.cpp:480
bool processSelectAll() noexcept
Definition packageeditorfsm.cpp:319
bool processStartDrawRects() noexcept
Definition packageeditorfsm.cpp:488
bool processRemove() noexcept
Definition packageeditorfsm.cpp:403
QSet< EditorWidgetBase::Feature > mAvailableFeatures
Definition packageeditorfsm.h:188
bool processCopy() noexcept
Definition packageeditorfsm.cpp:335
bool processStartAddingFootprintSmtPads(FootprintPad::Function function) noexcept
Definition packageeditorfsm.cpp:452
bool processEditProperties() noexcept
Definition packageeditorfsm.cpp:412
State mPreviousState
Definition packageeditorfsm.h:186
State
Definition packageeditorfsm.h:64
bool processCut() noexcept
Definition packageeditorfsm.cpp:327
QMap< State, PackageEditorState * > mStates
Definition packageeditorfsm.h:184
bool leaveCurrentState() noexcept
Definition packageeditorfsm.cpp:554
bool switchToPreviousState() noexcept
Definition packageeditorfsm.cpp:589
bool processStartDrawTexts() noexcept
Definition packageeditorfsm.cpp:500
bool processStartDxfImport() noexcept
Definition packageeditorfsm.cpp:512
bool processGenerateOutline() noexcept
Definition packageeditorfsm.cpp:420
bool processAbortCommand() noexcept
Definition packageeditorfsm.cpp:436
bool processFlip(Qt::Orientation orientation) noexcept
Definition packageeditorfsm.cpp:378
void toolChanged(EditorWidgetBase::Tool newTool)
QScopedPointer< PrimitiveTextGraphicsItem > mSelectFootprintGraphicsItem
Definition packageeditorfsm.h:187
bool processGraphicsSceneLeftMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexcept
Definition packageeditorfsm.cpp:280
bool processGraphicsSceneLeftMouseButtonPressed(QGraphicsSceneMouseEvent &e) noexcept
Definition packageeditorfsm.cpp:270
bool processStartDrawCircles() noexcept
Definition packageeditorfsm.cpp:496
bool processMove(const Point &delta) noexcept
Definition packageeditorfsm.cpp:351
void updateAvailableFeatures() noexcept
Definition packageeditorfsm.cpp:187
bool enterNextState(State state) noexcept
Definition packageeditorfsm.cpp:573
State mCurrentState
Definition packageeditorfsm.h:185
bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent &e) noexcept
Definition packageeditorfsm.cpp:260
bool processRotate(const Angle &rotation) noexcept
Definition packageeditorfsm.cpp:360
const QSet< EditorWidgetBase::Feature > & getAvailableFeatures() const noexcept
Definition packageeditorfsm.h:113
bool processStartMeasure() noexcept
Definition packageeditorfsm.cpp:522
PackageEditorFsm(const PackageEditorFsm &other)=delete
std::shared_ptr< Footprint > getCurrentFootprint() const noexcept
Definition packageeditorfsm.cpp:178
virtual ~PackageEditorFsm() noexcept
Definition packageeditorfsm.cpp:122
bool processStartDrawZones() noexcept
Definition packageeditorfsm.cpp:504
bool processStartReNumberPads() noexcept
Definition packageeditorfsm.cpp:526
bool processMoveAlign() noexcept
Definition packageeditorfsm.cpp:387
bool processGenerateCourtyard() noexcept
Definition packageeditorfsm.cpp:428
bool processMirror(Qt::Orientation orientation) noexcept
Definition packageeditorfsm.cpp:369
bool processStartDrawArcs() noexcept
Definition packageeditorfsm.cpp:484
bool processStartAddingFootprintThtPads() noexcept
Definition packageeditorfsm.cpp:448
bool processStartDrawPolygons() noexcept
Definition packageeditorfsm.cpp:492
bool processPaste() noexcept
Definition packageeditorfsm.cpp:343
bool processSnapToGrid() noexcept
Definition packageeditorfsm.cpp:395
The PackageEditorState class is the base class of all package editor FSM states.
Definition packageeditorstate.h:52
The PackageEditorWidget class.
Definition packageeditorwidget.h:81
The PrimitiveTextGraphicsItem class is the graphical representation of a text.
Definition primitivetextgraphicsitem.h:52
The ToolBarProxy class allows to map a list of QAction's to one QToolBar.
Definition toolbarproxy.h:45
The UndoStack class holds UndoCommand objects and provides undo/redo commands.
Definition undostack.h:106
Definition occmodel.cpp:76
Definition uuid.h:186
Definition editorwidgetbase.h:67
Definition packageeditorfsm.h:90
LengthUnit & lengthUnit
Definition packageeditorfsm.h:96
PackageEditorWidget & editorWidget
Definition packageeditorfsm.h:92
Package & package
Definition packageeditorfsm.h:97
GraphicsView & graphicsView
Definition packageeditorfsm.h:95
std::shared_ptr< FootprintGraphicsItem > currentGraphicsItem
Definition packageeditorfsm.h:99
ToolBarProxy & commandToolBar
Definition packageeditorfsm.h:100
GraphicsScene & graphicsScene
Definition packageeditorfsm.h:94
EditorWidgetBase::Context & editorContext
Definition packageeditorfsm.h:91
std::shared_ptr< Footprint > currentFootprint
Definition packageeditorfsm.h:98
UndoStack & undoStack
Definition packageeditorfsm.h:93