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 ******************************************************************************/
27
28#include <QtCore>
29
30/*******************************************************************************
31 * Namespace / Forward Declarations
32 ******************************************************************************/
33namespace librepcb {
34
35class Angle;
36class Board;
37class ComponentInstance;
38class Point;
39class Project;
40class Uuid;
41class Workspace;
42
43namespace editor {
44
45class BoardEditorFsmAdapter;
46class BoardEditorState;
47class GraphicsLayerList;
48class UndoStack;
49struct GraphicsSceneKeyEvent;
50struct GraphicsSceneMouseEvent;
51
52/*******************************************************************************
53 * Class BoardEditorFsm
54 ******************************************************************************/
55
59class BoardEditorFsm final : public QObject {
60 Q_OBJECT
61
62public:
97
107
108 // Constructors / Destructor
109 BoardEditorFsm() = delete;
110 BoardEditorFsm(const BoardEditorFsm& other) = delete;
111 explicit BoardEditorFsm(const Context& context,
112 QObject* parent = nullptr) noexcept;
113 virtual ~BoardEditorFsm() noexcept;
114
115 // Getters
116 State getCurrentState() const noexcept { return mCurrentState; }
117
118 // Event Handlers
119 bool processSelect() noexcept;
120 bool processAddHole() noexcept;
121 bool processAddStrokeText() noexcept;
122 bool processAddVia() noexcept;
123 bool processAddThtPad() noexcept;
124 bool processAddSmtPad(Pad::Function function) noexcept;
125 bool processAddDevice(ComponentInstance& component, const Uuid& device,
126 const Uuid& footprint) noexcept;
127 bool processDrawPolygon() noexcept;
128 bool processDrawPlane() noexcept;
129 bool processDrawZone() noexcept;
130 bool processDrawTrace() noexcept;
131 bool processImportDxf() noexcept;
132 bool processMeasure() noexcept;
133 bool processAbortCommand() 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 processFlip(Qt::Orientation orientation) noexcept;
141 bool processSnapToGrid() noexcept;
142 bool processSetLocked(bool locked) noexcept;
143 bool processChangeLineWidth(int step) noexcept;
144 bool processResetAllTexts() noexcept;
145 bool processRemove() noexcept;
146 bool processEditProperties() noexcept;
147 bool processKeyPressed(const GraphicsSceneKeyEvent& e) noexcept;
148 bool processKeyReleased(const GraphicsSceneKeyEvent& e) noexcept;
150 const GraphicsSceneMouseEvent& e) noexcept;
152 const GraphicsSceneMouseEvent& e) noexcept;
154 const GraphicsSceneMouseEvent& e) noexcept;
156 const GraphicsSceneMouseEvent& e) noexcept;
158 const GraphicsSceneMouseEvent& e) noexcept;
159
160 // Operator Overloadings
161 BoardEditorFsm& operator=(const BoardEditorFsm& rhs) = delete;
162
163private:
164 BoardEditorState* getCurrentStateObj() const noexcept;
165 bool setNextState(State state) noexcept;
166 bool leaveCurrentState() noexcept;
167 bool enterNextState(State state) noexcept;
168 bool switchToPreviousState() noexcept;
169
170private: // Data
174};
175
176/*******************************************************************************
177 * End of File
178 ******************************************************************************/
179
180} // namespace editor
181} // namespace librepcb
182
183#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:74
The ComponentInstance class.
Definition componentinstance.h:54
Base class for pads, extended in derived classes.
Definition pad.h:53
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:64
The board editor finite state machine.
Definition boardeditorfsm.h:59
bool processResetAllTexts() noexcept
Definition boardeditorfsm.cpp:306
State getCurrentState() const noexcept
Definition boardeditorfsm.h:116
bool processDrawPlane() noexcept
Definition boardeditorfsm.cpp:179
bool setNextState(State state) noexcept
Definition boardeditorfsm.cpp:417
bool processAddStrokeText() noexcept
Definition boardeditorfsm.cpp:128
BoardEditorState * getCurrentStateObj() const noexcept
Definition boardeditorfsm.cpp:413
bool processSelectAll() noexcept
Definition boardeditorfsm.cpp:216
bool processAddDevice(ComponentInstance &component, const Uuid &device, const Uuid &footprint) noexcept
Definition boardeditorfsm.cpp:159
bool processDrawPolygon() noexcept
Definition boardeditorfsm.cpp:175
bool processRemove() noexcept
Definition boardeditorfsm.cpp:315
bool processSelect() noexcept
Definition boardeditorfsm.cpp:120
bool processKeyPressed(const GraphicsSceneKeyEvent &e) noexcept
Definition boardeditorfsm.cpp:333
bool processCopy() noexcept
Definition boardeditorfsm.cpp:234
bool processDrawTrace() noexcept
Definition boardeditorfsm.cpp:187
bool processEditProperties() noexcept
Definition boardeditorfsm.cpp:324
State mPreviousState
Definition boardeditorfsm.h:173
bool processAddSmtPad(Pad::Function function) noexcept
Definition boardeditorfsm.cpp:140
State
FSM States.
Definition boardeditorfsm.h:64
@ ADD_SMT_PAD_GLOBAL_FIDUCIAL
Definition boardeditorfsm.h:83
@ MEASURE
librepcb::editor::BoardEditorState_Measure
Definition boardeditorfsm.h:95
@ SELECT
librepcb::editor::BoardEditorState_Select
Definition boardeditorfsm.h:68
@ ADD_STROKE_TEXT
librepcb::editor::BoardEditorState_AddStrokeText
Definition boardeditorfsm.h:72
@ ADD_VIA
librepcb::editor::BoardEditorState_AddVia
Definition boardeditorfsm.h:74
@ ADD_SMT_PAD_TEST
Definition boardeditorfsm.h:81
@ DRAW_PLANE
librepcb::editor::BoardEditorState_DrawPlane
Definition boardeditorfsm.h:89
@ ADD_THT_PAD
librepcb::editor::BoardEditorState_AddPad
Definition boardeditorfsm.h:76
@ ADD_SMT_PAD_EDGE_CONNECTOR
Definition boardeditorfsm.h:80
@ DRAW_POLYGON
librepcb::editor::BoardEditorState_DrawPolygon
Definition boardeditorfsm.h:87
@ ADD_SMT_PAD_LOCAL_FIDUCIAL
Definition boardeditorfsm.h:82
@ ADD_SMT_PAD_THERMAL
Definition boardeditorfsm.h:78
@ ADD_SMT_PAD_STANDARD
Definition boardeditorfsm.h:77
@ DRAW_TRACE
librepcb::editor::BoardEditorState_DrawTrace
Definition boardeditorfsm.h:93
@ ADD_DEVICE
librepcb::editor::BoardEditorState_AddDevice
Definition boardeditorfsm.h:85
@ DRAW_ZONE
librepcb::editor::BoardEditorState_DrawZone
Definition boardeditorfsm.h:91
@ ADD_SMT_PAD_BGA
Definition boardeditorfsm.h:79
@ ADD_HOLE
librepcb::editor::BoardEditorState_AddHole
Definition boardeditorfsm.h:70
@ IDLE
No state active.
Definition boardeditorfsm.h:66
bool processCut() noexcept
Definition boardeditorfsm.cpp:225
bool processImportDxf() noexcept
Definition boardeditorfsm.cpp:191
bool leaveCurrentState() noexcept
Definition boardeditorfsm.cpp:427
bool processAddThtPad() noexcept
Definition boardeditorfsm.cpp:136
bool switchToPreviousState() noexcept
Definition boardeditorfsm.cpp:460
bool processMeasure() noexcept
Definition boardeditorfsm.cpp:201
bool processGraphicsSceneRightMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept
Definition boardeditorfsm.cpp:393
bool processAbortCommand() noexcept
Definition boardeditorfsm.cpp:205
bool processAddVia() noexcept
Definition boardeditorfsm.cpp:132
bool processKeyReleased(const GraphicsSceneKeyEvent &e) noexcept
Definition boardeditorfsm.cpp:343
BoardEditorFsm(const BoardEditorFsm &other)=delete
bool processFlip(Qt::Orientation orientation) noexcept
Definition boardeditorfsm.cpp:270
bool processGraphicsSceneLeftMouseButtonPressed(const GraphicsSceneMouseEvent &e) noexcept
Definition boardeditorfsm.cpp:363
bool processGraphicsSceneLeftMouseButtonDoubleClicked(const GraphicsSceneMouseEvent &e) noexcept
Definition boardeditorfsm.cpp:383
bool processMove(const Point &delta) noexcept
Definition boardeditorfsm.cpp:252
bool enterNextState(State state) noexcept
Definition boardeditorfsm.cpp:450
State mCurrentState
Definition boardeditorfsm.h:172
bool processSetLocked(bool locked) noexcept
Definition boardeditorfsm.cpp:288
bool processGraphicsSceneMouseMoved(const GraphicsSceneMouseEvent &e) noexcept
Definition boardeditorfsm.cpp:353
bool processRotate(const Angle &rotation) noexcept
Definition boardeditorfsm.cpp:261
bool processAddHole() noexcept
Definition boardeditorfsm.cpp:124
bool processChangeLineWidth(int step) noexcept
Definition boardeditorfsm.cpp:297
bool processDrawZone() noexcept
Definition boardeditorfsm.cpp:183
QMap< State, BoardEditorState * > mStates
Definition boardeditorfsm.h:171
bool processGraphicsSceneLeftMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept
Definition boardeditorfsm.cpp:373
bool processPaste() noexcept
Definition boardeditorfsm.cpp:243
bool processSnapToGrid() noexcept
Definition boardeditorfsm.cpp:279
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:99
GraphicsLayerList & layers
Definition boardeditorfsm.h:104
BoardEditorFsmAdapter & adapter
Definition boardeditorfsm.h:105
Workspace & workspace
Definition boardeditorfsm.h:100
Board & board
Definition boardeditorfsm.h:102
UndoStack & undoStack
Definition boardeditorfsm.h:103
Project & project
Definition boardeditorfsm.h:101
Definition graphicsscene.h:52
Definition graphicsscene.h:45