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
28/*******************************************************************************
29 * Namespace / Forward Declarations
30 ******************************************************************************/
31namespace librepcb {
32
33class Angle;
34class Board;
35class ComponentInstance;
36class Point;
37class Project;
38class Uuid;
39class Workspace;
40
41namespace editor {
42
43class BoardEditorFsmAdapter;
44class BoardEditorState;
45class GraphicsLayerList;
46class UndoStack;
47struct GraphicsSceneKeyEvent;
48struct GraphicsSceneMouseEvent;
49
50/*******************************************************************************
51 * Class BoardEditorFsm
52 ******************************************************************************/
53
57class BoardEditorFsm final : public QObject {
58 Q_OBJECT
59
60public:
86
96
97 // Constructors / Destructor
98 BoardEditorFsm() = delete;
99 BoardEditorFsm(const BoardEditorFsm& other) = delete;
100 explicit BoardEditorFsm(const Context& context,
101 QObject* parent = nullptr) noexcept;
102 virtual ~BoardEditorFsm() noexcept;
103
104 // Getters
105 State getCurrentState() const noexcept { return mCurrentState; }
106
107 // Event Handlers
108 bool processSelect() noexcept;
109 bool processAddHole() noexcept;
110 bool processAddStrokeText() noexcept;
111 bool processAddVia() noexcept;
112 bool processAddDevice(ComponentInstance& component, const Uuid& device,
113 const Uuid& footprint) noexcept;
114 bool processDrawPolygon() noexcept;
115 bool processDrawPlane() noexcept;
116 bool processDrawZone() noexcept;
117 bool processDrawTrace() noexcept;
118 bool processImportDxf() noexcept;
119 bool processMeasure() noexcept;
120 bool processAbortCommand() noexcept;
121 bool processSelectAll() noexcept;
122 bool processCut() noexcept;
123 bool processCopy() noexcept;
124 bool processPaste() noexcept;
125 bool processMove(const Point& delta) noexcept;
126 bool processRotate(const Angle& rotation) noexcept;
127 bool processFlip(Qt::Orientation orientation) noexcept;
128 bool processSnapToGrid() noexcept;
129 bool processSetLocked(bool locked) noexcept;
130 bool processChangeLineWidth(int step) noexcept;
131 bool processResetAllTexts() noexcept;
132 bool processRemove() noexcept;
133 bool processEditProperties() noexcept;
134 bool processKeyPressed(const GraphicsSceneKeyEvent& e) noexcept;
135 bool processKeyReleased(const GraphicsSceneKeyEvent& e) noexcept;
137 const GraphicsSceneMouseEvent& e) noexcept;
139 const GraphicsSceneMouseEvent& e) noexcept;
141 const GraphicsSceneMouseEvent& e) noexcept;
143 const GraphicsSceneMouseEvent& e) noexcept;
145 const GraphicsSceneMouseEvent& e) noexcept;
146
147 // Operator Overloadings
148 BoardEditorFsm& operator=(const BoardEditorFsm& rhs) = delete;
149
150private:
151 BoardEditorState* getCurrentStateObj() const noexcept;
152 bool setNextState(State state) noexcept;
153 bool leaveCurrentState() noexcept;
154 bool enterNextState(State state) noexcept;
155 bool switchToPreviousState() noexcept;
156
157private: // Data
161};
162
163/*******************************************************************************
164 * End of File
165 ******************************************************************************/
166
167} // namespace editor
168} // namespace librepcb
169
170#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition angle.h:76
The Board class represents a PCB of a project and is always part of a circuit.
Definition board.h:73
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
Interface for the integration of the board editor FSM.
Definition boardeditorfsmadapter.h:63
The board editor finite state machine.
Definition boardeditorfsm.h:57
bool processResetAllTexts() noexcept
Definition boardeditorfsm.cpp:250
State getCurrentState() const noexcept
Definition boardeditorfsm.h:105
bool processDrawPlane() noexcept
Definition boardeditorfsm.cpp:123
bool setNextState(State state) noexcept
Definition boardeditorfsm.cpp:361
bool processAddStrokeText() noexcept
Definition boardeditorfsm.cpp:95
BoardEditorState * getCurrentStateObj() const noexcept
Definition boardeditorfsm.cpp:357
bool processSelectAll() noexcept
Definition boardeditorfsm.cpp:160
bool processAddDevice(ComponentInstance &component, const Uuid &device, const Uuid &footprint) noexcept
Definition boardeditorfsm.cpp:103
bool processDrawPolygon() noexcept
Definition boardeditorfsm.cpp:119
bool processRemove() noexcept
Definition boardeditorfsm.cpp:259
bool processSelect() noexcept
Definition boardeditorfsm.cpp:87
bool processKeyPressed(const GraphicsSceneKeyEvent &e) noexcept
Definition boardeditorfsm.cpp:277
bool processCopy() noexcept
Definition boardeditorfsm.cpp:178
bool processDrawTrace() noexcept
Definition boardeditorfsm.cpp:131
bool processEditProperties() noexcept
Definition boardeditorfsm.cpp:268
State mPreviousState
Definition boardeditorfsm.h:160
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:169
bool processImportDxf() noexcept
Definition boardeditorfsm.cpp:135
bool leaveCurrentState() noexcept
Definition boardeditorfsm.cpp:371
bool switchToPreviousState() noexcept
Definition boardeditorfsm.cpp:404
bool processMeasure() noexcept
Definition boardeditorfsm.cpp:145
bool processGraphicsSceneRightMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept
Definition boardeditorfsm.cpp:337
bool processAbortCommand() noexcept
Definition boardeditorfsm.cpp:149
bool processAddVia() noexcept
Definition boardeditorfsm.cpp:99
bool processKeyReleased(const GraphicsSceneKeyEvent &e) noexcept
Definition boardeditorfsm.cpp:287
BoardEditorFsm(const BoardEditorFsm &other)=delete
bool processFlip(Qt::Orientation orientation) noexcept
Definition boardeditorfsm.cpp:214
bool processGraphicsSceneLeftMouseButtonPressed(const GraphicsSceneMouseEvent &e) noexcept
Definition boardeditorfsm.cpp:307
bool processGraphicsSceneLeftMouseButtonDoubleClicked(const GraphicsSceneMouseEvent &e) noexcept
Definition boardeditorfsm.cpp:327
bool processMove(const Point &delta) noexcept
Definition boardeditorfsm.cpp:196
bool enterNextState(State state) noexcept
Definition boardeditorfsm.cpp:394
State mCurrentState
Definition boardeditorfsm.h:159
bool processSetLocked(bool locked) noexcept
Definition boardeditorfsm.cpp:232
bool processGraphicsSceneMouseMoved(const GraphicsSceneMouseEvent &e) noexcept
Definition boardeditorfsm.cpp:297
bool processRotate(const Angle &rotation) noexcept
Definition boardeditorfsm.cpp:205
bool processAddHole() noexcept
Definition boardeditorfsm.cpp:91
bool processChangeLineWidth(int step) noexcept
Definition boardeditorfsm.cpp:241
bool processDrawZone() noexcept
Definition boardeditorfsm.cpp:127
QMap< State, BoardEditorState * > mStates
Definition boardeditorfsm.h:158
bool processGraphicsSceneLeftMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept
Definition boardeditorfsm.cpp:317
bool processPaste() noexcept
Definition boardeditorfsm.cpp:187
bool processSnapToGrid() noexcept
Definition boardeditorfsm.cpp:223
The board editor state base class.
Definition boardeditorstate.h:60
The GraphicsLayerList class.
Definition graphicslayerlist.h:48
The UndoStack class holds UndoCommand objects and provides undo/redo commands.
Definition undostack.h:106
Definition occmodel.cpp:77
FSM Context.
Definition boardeditorfsm.h:88
GraphicsLayerList & layers
Definition boardeditorfsm.h:93
BoardEditorFsmAdapter & adapter
Definition boardeditorfsm.h:94
Workspace & workspace
Definition boardeditorfsm.h:89
Board & board
Definition boardeditorfsm.h:91
UndoStack & undoStack
Definition boardeditorfsm.h:92
Project & project
Definition boardeditorfsm.h:90
Definition graphicsscene.h:52
Definition graphicsscene.h:45