LibrePCB Developers Documentation
Loading...
Searching...
No Matches
schematiceditorfsm.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_SCHEMATICEDITORFSM_H
21#define LIBREPCB_EDITOR_SCHEMATICEDITORFSM_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
27
28#include <QtCore>
29
30/*******************************************************************************
31 * Namespace / Forward Declarations
32 ******************************************************************************/
33namespace librepcb {
34
35class Angle;
36class Project;
37class Schematic;
38class Uuid;
39class Workspace;
40
41namespace editor {
42
43class SchematicEditorFsmAdapter;
44class SchematicEditorState;
45class SchematicGraphicsScene;
46class UndoStack;
47struct GraphicsSceneKeyEvent;
48struct GraphicsSceneMouseEvent;
49
50/*******************************************************************************
51 * Class SchematicEditorFsm
52 ******************************************************************************/
53
57class SchematicEditorFsm final : public QObject {
58 Q_OBJECT
59
60public:
69
89
90 // Constructors / Destructor
92 SchematicEditorFsm(const SchematicEditorFsm& other) = delete;
93 explicit SchematicEditorFsm(const Context& context,
94 QObject* parent = nullptr) noexcept;
95 virtual ~SchematicEditorFsm() noexcept;
96
97 // Event Handlers
98 bool processSelect() noexcept;
99 bool processAddComponent(const QString& searchTerm = QString()) noexcept;
100 bool processAddComponent(const Uuid& cmp, const Uuid& symbVar) noexcept;
101 bool processAddNetLabel() noexcept;
102 bool processDrawPolygon() noexcept;
103 bool processAddText() noexcept;
104 bool processDrawWire() noexcept;
105 bool processMeasure() noexcept;
106 bool processAbortCommand() noexcept;
107 bool processSelectAll() noexcept;
108 bool processCut() noexcept;
109 bool processCopy() noexcept;
110 bool processPaste() noexcept;
111 bool processMove(const Point& delta) noexcept;
112 bool processRotate(const Angle& rotation) noexcept;
113 bool processMirror(Qt::Orientation orientation) noexcept;
114 bool processSnapToGrid() noexcept;
115 bool processResetAllTexts() noexcept;
116 bool processRemove() noexcept;
117 bool processEditProperties() noexcept;
118 bool processKeyPressed(const GraphicsSceneKeyEvent& e) noexcept;
119 bool processKeyReleased(const GraphicsSceneKeyEvent& e) noexcept;
121 const GraphicsSceneMouseEvent& e) noexcept;
123 const GraphicsSceneMouseEvent& e) noexcept;
125 const GraphicsSceneMouseEvent& e) noexcept;
127 const GraphicsSceneMouseEvent& e) noexcept;
129 const GraphicsSceneMouseEvent& e) noexcept;
130
131 // Operator Overloadings
132 SchematicEditorFsm& operator=(const SchematicEditorFsm& rhs) = delete;
133
134private:
136 bool setNextState(State state) noexcept;
137 bool leaveCurrentState() noexcept;
138 bool enterNextState(State state) noexcept;
139 bool switchToPreviousState() noexcept;
140
141private: // Data
145};
146
147/*******************************************************************************
148 * End of File
149 ******************************************************************************/
150
151} // namespace editor
152} // namespace librepcb
153
154#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition angle.h:76
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 Schematic class represents one schematic page of a project and is always part of a circuit.
Definition schematic.h:74
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 schematic editor FSM.
Definition schematiceditorfsmadapter.h:60
The schematic editor finite state machine (FSM)
Definition schematiceditorfsm.h:57
bool processResetAllTexts() noexcept
Definition schematiceditorfsm.cpp:228
bool setNextState(State state) noexcept
Definition schematiceditorfsm.cpp:339
bool processSelectAll() noexcept
Definition schematiceditorfsm.cpp:156
bool processDrawPolygon() noexcept
Definition schematiceditorfsm.cpp:129
bool processRemove() noexcept
Definition schematiceditorfsm.cpp:237
SchematicEditorFsm(const SchematicEditorFsm &other)=delete
bool processSelect() noexcept
Definition schematiceditorfsm.cpp:91
bool processKeyPressed(const GraphicsSceneKeyEvent &e) noexcept
Definition schematiceditorfsm.cpp:255
bool processCopy() noexcept
Definition schematiceditorfsm.cpp:174
bool processEditProperties() noexcept
Definition schematiceditorfsm.cpp:246
State mPreviousState
Definition schematiceditorfsm.h:144
State
FSM States.
Definition schematiceditorfsm.h:71
@ ADD_COMPONENT
librepcb::editor::SchematicEditorState_AddComponent
Definition schematiceditorfsm.h:81
@ MEASURE
librepcb::editor::SchematicEditorState_Measure
Definition schematiceditorfsm.h:87
@ SELECT
librepcb::editor::SchematicEditorState_Select
Definition schematiceditorfsm.h:75
@ DRAW_WIRE
librepcb::editor::SchematicEditorState_DrawWire
Definition schematiceditorfsm.h:77
@ DRAW_POLYGON
librepcb::editor::SchematicEditorState_DrawPolygon
Definition schematiceditorfsm.h:83
@ ADD_NETLABEL
librepcb::editor::SchematicEditorState_AddNetLabel
Definition schematiceditorfsm.h:79
@ ADD_TEXT
librepcb::editor::SchematicEditorState_AddText
Definition schematiceditorfsm.h:85
@ IDLE
no state active
Definition schematiceditorfsm.h:73
bool processCut() noexcept
Definition schematiceditorfsm.cpp:165
bool leaveCurrentState() noexcept
Definition schematiceditorfsm.cpp:349
bool switchToPreviousState() noexcept
Definition schematiceditorfsm.cpp:381
bool processMeasure() noexcept
Definition schematiceditorfsm.cpp:141
bool processGraphicsSceneRightMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept
Definition schematiceditorfsm.cpp:315
bool processAbortCommand() noexcept
Definition schematiceditorfsm.cpp:145
bool processKeyReleased(const GraphicsSceneKeyEvent &e) noexcept
Definition schematiceditorfsm.cpp:265
bool processGraphicsSceneLeftMouseButtonPressed(const GraphicsSceneMouseEvent &e) noexcept
Definition schematiceditorfsm.cpp:285
bool processGraphicsSceneLeftMouseButtonDoubleClicked(const GraphicsSceneMouseEvent &e) noexcept
Definition schematiceditorfsm.cpp:305
bool processMove(const Point &delta) noexcept
Definition schematiceditorfsm.cpp:192
bool enterNextState(State state) noexcept
Definition schematiceditorfsm.cpp:371
State mCurrentState
Definition schematiceditorfsm.h:143
bool processGraphicsSceneMouseMoved(const GraphicsSceneMouseEvent &e) noexcept
Definition schematiceditorfsm.cpp:275
bool processRotate(const Angle &rotation) noexcept
Definition schematiceditorfsm.cpp:201
bool processAddText() noexcept
Definition schematiceditorfsm.cpp:133
bool processDrawWire() noexcept
Definition schematiceditorfsm.cpp:137
bool processAddComponent(const QString &searchTerm=QString()) noexcept
Definition schematiceditorfsm.cpp:95
SchematicEditorState * getCurrentStateObj() const noexcept
Definition schematiceditorfsm.cpp:335
bool processMirror(Qt::Orientation orientation) noexcept
Definition schematiceditorfsm.cpp:210
bool processAddNetLabel() noexcept
Definition schematiceditorfsm.cpp:125
bool processGraphicsSceneLeftMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept
Definition schematiceditorfsm.cpp:295
QMap< State, SchematicEditorState * > mStates
Definition schematiceditorfsm.h:142
bool processPaste() noexcept
Definition schematiceditorfsm.cpp:183
bool processSnapToGrid() noexcept
Definition schematiceditorfsm.cpp:219
The schematic editor state base class.
Definition schematiceditorstate.h:58
The UndoStack class holds UndoCommand objects and provides undo/redo commands.
Definition undostack.h:106
Definition occmodel.cpp:77
Definition graphicsscene.h:52
Definition graphicsscene.h:45
FSM Context.
Definition schematiceditorfsm.h:62
Schematic & schematic
Definition schematiceditorfsm.h:65
Workspace & workspace
Definition schematiceditorfsm.h:63
UndoStack & undoStack
Definition schematiceditorfsm.h:66
SchematicEditorFsmAdapter & adapter
Definition schematiceditorfsm.h:67
Project & project
Definition schematiceditorfsm.h:64