LibrePCB Developers Documentation
Loading...
Searching...
No Matches
boardeditorfsm.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_BOARDEDITORFSM_H
21#define LIBREPCB_EDITOR_BOARDEDITORFSM_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include <QtCore>
27#include <QtWidgets>
28
29/*******************************************************************************
30 * Namespace / Forward Declarations
31 ******************************************************************************/
32namespace librepcb {
33
34class Angle;
35class ComponentInstance;
36class Point;
37class Project;
38class Uuid;
39class Workspace;
40
41namespace editor {
42
43class BoardEditor;
44class BoardEditorState;
45class GraphicsView;
46class ProjectEditor;
47class ToolBarProxy;
48class UndoStack;
49
50/*******************************************************************************
51 * Class BoardEditorFsm
52 ******************************************************************************/
53
57class BoardEditorFsm final : public QObject {
58 Q_OBJECT
59
60public:
86
97
98 // Constructors / Destructor
99 BoardEditorFsm() = delete;
100 BoardEditorFsm(const BoardEditorFsm& other) = delete;
101 explicit BoardEditorFsm(const Context& context,
102 QObject* parent = nullptr) noexcept;
103 virtual ~BoardEditorFsm() noexcept;
104
105 // Getters
106 State getCurrentState() const noexcept { return mCurrentState; }
107
108 // Event Handlers
109 bool processSelect() noexcept;
110 bool processAddHole() noexcept;
111 bool processAddStrokeText() noexcept;
112 bool processAddVia() noexcept;
113 bool processAddDevice(ComponentInstance& component, const Uuid& device,
114 const Uuid& footprint) noexcept;
115 bool processDrawPolygon() noexcept;
116 bool processDrawPlane() noexcept;
117 bool processDrawZone() noexcept;
118 bool processDrawTrace() noexcept;
119 bool processImportDxf() noexcept;
120 bool processMeasure() noexcept;
121 bool processAbortCommand() noexcept;
122 bool processSelectAll() noexcept;
123 bool processCut() noexcept;
124 bool processCopy() noexcept;
125 bool processPaste() noexcept;
126 bool processMove(const Point& delta) noexcept;
127 bool processRotate(const Angle& rotation) noexcept;
128 bool processFlip(Qt::Orientation orientation) noexcept;
129 bool processSnapToGrid() noexcept;
130 bool processSetLocked(bool locked) noexcept;
131 bool processChangeLineWidth(int step) noexcept;
132 bool processResetAllTexts() noexcept;
133 bool processRemove() noexcept;
134 bool processEditProperties() noexcept;
135 bool processKeyPressed(const QKeyEvent& e) noexcept;
136 bool processKeyReleased(const QKeyEvent& e) noexcept;
137 bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent& e) noexcept;
139 QGraphicsSceneMouseEvent& e) noexcept;
141 QGraphicsSceneMouseEvent& e) noexcept;
143 QGraphicsSceneMouseEvent& e) noexcept;
145 QGraphicsSceneMouseEvent& e) noexcept;
146
162 bool processSwitchToBoard(int index) noexcept;
163
164 // Operator Overloadings
165 BoardEditorFsm& operator=(const BoardEditorFsm& rhs) = delete;
166
167signals:
168 void stateChanged(State newState);
169 void statusBarMessageChanged(const QString& message, int timeoutMs = -1);
170
171private:
172 BoardEditorState* getCurrentStateObj() const noexcept;
173 bool setNextState(State state) noexcept;
174 bool leaveCurrentState() noexcept;
175 bool enterNextState(State state) noexcept;
176 bool switchToPreviousState() noexcept;
177
178private: // Data
182};
183
184/*******************************************************************************
185 * End of File
186 ******************************************************************************/
187
188} // namespace editor
189} // namespace librepcb
190
191#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition angle.h:76
The ComponentInstance class.
Definition componentinstance.h:54
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition point.h:78
The Project class represents a whole (opened) project with all its content.
Definition project.h:71
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition uuid.h:56
The Workspace class represents a workspace with all its data (library, projects, settings,...
Definition workspace.h:54
The board editor finite state machine.
Definition boardeditorfsm.h:57
bool processResetAllTexts() noexcept
Definition boardeditorfsm.cpp:256
State getCurrentState() const noexcept
Definition boardeditorfsm.h:106
bool processDrawPlane() noexcept
Definition boardeditorfsm.cpp:129
bool processGraphicsSceneRightMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexcept
Definition boardeditorfsm.cpp:341
bool processKeyReleased(const QKeyEvent &e) noexcept
Definition boardeditorfsm.cpp:292
bool setNextState(State state) noexcept
Definition boardeditorfsm.cpp:374
bool processSwitchToBoard(int index) noexcept
Definition boardeditorfsm.cpp:357
bool processAddStrokeText() noexcept
Definition boardeditorfsm.cpp:101
BoardEditorState * getCurrentStateObj() const noexcept
Definition boardeditorfsm.cpp:370
bool processKeyPressed(const QKeyEvent &e) noexcept
Definition boardeditorfsm.cpp:283
bool processGraphicsSceneLeftMouseButtonDoubleClicked(QGraphicsSceneMouseEvent &e) noexcept
Definition boardeditorfsm.cpp:331
void statusBarMessageChanged(const QString &message, int timeoutMs=-1)
bool processSelectAll() noexcept
Definition boardeditorfsm.cpp:166
bool processAddDevice(ComponentInstance &component, const Uuid &device, const Uuid &footprint) noexcept
Definition boardeditorfsm.cpp:109
bool processDrawPolygon() noexcept
Definition boardeditorfsm.cpp:125
bool processRemove() noexcept
Definition boardeditorfsm.cpp:265
bool processSelect() noexcept
Definition boardeditorfsm.cpp:93
bool processCopy() noexcept
Definition boardeditorfsm.cpp:184
bool processDrawTrace() noexcept
Definition boardeditorfsm.cpp:137
bool processEditProperties() noexcept
Definition boardeditorfsm.cpp:274
State mPreviousState
Definition boardeditorfsm.h:181
State
FSM States.
Definition boardeditorfsm.h:62
@ MEASURE
librepcb::editor::BoardEditorState_Measure
Definition boardeditorfsm.h:84
@ SELECT
librepcb::editor::BoardEditorState_Select
Definition boardeditorfsm.h:66
@ ADD_STROKE_TEXT
librepcb::editor::BoardEditorState_AddStrokeText
Definition boardeditorfsm.h:70
@ ADD_VIA
librepcb::editor::BoardEditorState_AddVia
Definition boardeditorfsm.h:72
@ DRAW_PLANE
librepcb::editor::BoardEditorState_DrawPlane
Definition boardeditorfsm.h:78
@ DRAW_POLYGON
librepcb::editor::BoardEditorState_DrawPolygon
Definition boardeditorfsm.h:76
@ DRAW_TRACE
librepcb::editor::BoardEditorState_DrawTrace
Definition boardeditorfsm.h:82
@ ADD_DEVICE
librepcb::editor::BoardEditorState_AddDevice
Definition boardeditorfsm.h:74
@ DRAW_ZONE
librepcb::editor::BoardEditorState_DrawZone
Definition boardeditorfsm.h:80
@ ADD_HOLE
librepcb::editor::BoardEditorState_AddHole
Definition boardeditorfsm.h:68
@ IDLE
No state active.
Definition boardeditorfsm.h:64
bool processCut() noexcept
Definition boardeditorfsm.cpp:175
bool processImportDxf() noexcept
Definition boardeditorfsm.cpp:141
bool leaveCurrentState() noexcept
Definition boardeditorfsm.cpp:384
bool switchToPreviousState() noexcept
Definition boardeditorfsm.cpp:419
bool processMeasure() noexcept
Definition boardeditorfsm.cpp:151
bool processAbortCommand() noexcept
Definition boardeditorfsm.cpp:155
bool processAddVia() noexcept
Definition boardeditorfsm.cpp:105
BoardEditorFsm(const BoardEditorFsm &other)=delete
bool processFlip(Qt::Orientation orientation) noexcept
Definition boardeditorfsm.cpp:220
bool processGraphicsSceneLeftMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexcept
Definition boardeditorfsm.cpp:321
bool processGraphicsSceneLeftMouseButtonPressed(QGraphicsSceneMouseEvent &e) noexcept
Definition boardeditorfsm.cpp:311
bool processMove(const Point &delta) noexcept
Definition boardeditorfsm.cpp:202
void stateChanged(State newState)
bool enterNextState(State state) noexcept
Definition boardeditorfsm.cpp:408
State mCurrentState
Definition boardeditorfsm.h:180
bool processSetLocked(bool locked) noexcept
Definition boardeditorfsm.cpp:238
bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent &e) noexcept
Definition boardeditorfsm.cpp:301
bool processRotate(const Angle &rotation) noexcept
Definition boardeditorfsm.cpp:211
bool processAddHole() noexcept
Definition boardeditorfsm.cpp:97
bool processChangeLineWidth(int step) noexcept
Definition boardeditorfsm.cpp:247
bool processDrawZone() noexcept
Definition boardeditorfsm.cpp:133
QMap< State, BoardEditorState * > mStates
Definition boardeditorfsm.h:179
bool processPaste() noexcept
Definition boardeditorfsm.cpp:193
bool processSnapToGrid() noexcept
Definition boardeditorfsm.cpp:229
The BoardEditor class.
Definition boardeditor.h:79
The board editor state base class.
Definition boardeditorstate.h:59
The GraphicsView class.
Definition graphicsview.h:52
The ProjectEditor class.
Definition projecteditor.h:66
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
FSM Context.
Definition boardeditorfsm.h:88
GraphicsView & editorGraphicsView
Definition boardeditorfsm.h:93
BoardEditor & editor
Definition boardeditorfsm.h:92
ToolBarProxy & commandToolBar
Definition boardeditorfsm.h:94
Workspace & workspace
Definition boardeditorfsm.h:89
UndoStack & undoStack
Definition boardeditorfsm.h:95
Project & project
Definition boardeditorfsm.h:90
ProjectEditor & projectEditor
Definition boardeditorfsm.h:91