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 ******************************************************************************/
28
29#include <QtCore>
30
31#include <optional>
32
33/*******************************************************************************
34 * Namespace / Forward Declarations
35 ******************************************************************************/
36namespace librepcb {
37
38class Angle;
39class Project;
40class Schematic;
41class Uuid;
42class Workspace;
43
44namespace editor {
45
46class SchematicEditorFsmAdapter;
47class SchematicEditorState;
48class SchematicGraphicsScene;
49class UndoStack;
50struct GraphicsSceneKeyEvent;
51struct GraphicsSceneMouseEvent;
52
53/*******************************************************************************
54 * Class SchematicEditorFsm
55 ******************************************************************************/
56
60class SchematicEditorFsm final : public QObject {
61 Q_OBJECT
62
63public:
72
96
97 // Constructors / Destructor
99 SchematicEditorFsm(const SchematicEditorFsm& other) = delete;
100 explicit SchematicEditorFsm(const Context& context,
101 QObject* parent = nullptr) noexcept;
102 virtual ~SchematicEditorFsm() noexcept;
103
104 // Event Handlers
105 bool processSelect() noexcept;
106 bool processAddComponent(const QString& searchTerm = QString()) noexcept;
107 bool processAddComponent(const Uuid& cmp, const Uuid& symbVar) noexcept;
108 bool processAddNetLabel() noexcept;
109 bool processDrawPolygon() noexcept;
110 bool processAddText() noexcept;
111 bool processAddImage(const QByteArray& data = QByteArray(),
112 const QString& format = QString(),
113 const QString& basename = QString()) noexcept;
114 bool processDrawWire() noexcept;
115 bool processDrawBus(std::optional<Uuid> busUuid = std::nullopt) noexcept;
116 bool processMeasure() noexcept;
117 bool processAbortCommand() noexcept;
118 bool processSelectAll() noexcept;
119 bool processCut() noexcept;
120 bool processCopy() noexcept;
121 bool processPaste() noexcept;
122 bool processMove(const Point& delta) noexcept;
123 bool processRotate(const Angle& rotation) noexcept;
124 bool processMirror(Qt::Orientation orientation) noexcept;
125 bool processSnapToGrid() noexcept;
126 bool processResetAllTexts() noexcept;
127 bool processRemove() noexcept;
128 bool processEditProperties() noexcept;
129 bool processKeyPressed(const GraphicsSceneKeyEvent& e) noexcept;
130 bool processKeyReleased(const GraphicsSceneKeyEvent& e) noexcept;
132 const GraphicsSceneMouseEvent& e) noexcept;
134 const GraphicsSceneMouseEvent& e) noexcept;
136 const GraphicsSceneMouseEvent& e) noexcept;
138 const GraphicsSceneMouseEvent& e) noexcept;
140 const GraphicsSceneMouseEvent& e) noexcept;
141 bool processGridIntervalChanged(const PositiveLength& interval) noexcept;
142
143 // Operator Overloadings
144 SchematicEditorFsm& operator=(const SchematicEditorFsm& rhs) = delete;
145
146private:
148 bool setNextState(State state) noexcept;
149 bool leaveCurrentState() noexcept;
150 bool enterNextState(State state) noexcept;
151 bool switchToPreviousState() noexcept;
152
153private: // Data
157};
158
159/*******************************************************************************
160 * End of File
161 ******************************************************************************/
162
163} // namespace editor
164} // namespace librepcb
165
166#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:81
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:62
The schematic editor finite state machine (FSM)
Definition schematiceditorfsm.h:60
bool processResetAllTexts() noexcept
Definition schematiceditorfsm.cpp:259
bool setNextState(State state) noexcept
Definition schematiceditorfsm.cpp:380
bool processDrawBus(std::optional< Uuid > busUuid=std::nullopt) noexcept
Definition schematiceditorfsm.cpp:160
bool processSelectAll() noexcept
Definition schematiceditorfsm.cpp:187
bool processDrawPolygon() noexcept
Definition schematiceditorfsm.cpp:132
bool processRemove() noexcept
Definition schematiceditorfsm.cpp:268
SchematicEditorFsm(const SchematicEditorFsm &other)=delete
bool processSelect() noexcept
Definition schematiceditorfsm.cpp:94
bool processKeyPressed(const GraphicsSceneKeyEvent &e) noexcept
Definition schematiceditorfsm.cpp:286
bool processAddImage(const QByteArray &data=QByteArray(), const QString &format=QString(), const QString &basename=QString()) noexcept
Definition schematiceditorfsm.cpp:140
bool processCopy() noexcept
Definition schematiceditorfsm.cpp:205
bool processEditProperties() noexcept
Definition schematiceditorfsm.cpp:277
State mPreviousState
Definition schematiceditorfsm.h:156
State
FSM States.
Definition schematiceditorfsm.h:74
@ DRAW_BUS
librepcb::editor::SchematicEditorState_DrawBus
Definition schematiceditorfsm.h:82
@ ADD_COMPONENT
librepcb::editor::SchematicEditorState_AddComponent
Definition schematiceditorfsm.h:86
@ MEASURE
librepcb::editor::SchematicEditorState_Measure
Definition schematiceditorfsm.h:94
@ SELECT
librepcb::editor::SchematicEditorState_Select
Definition schematiceditorfsm.h:78
@ ADD_IMAGE
librepcb::editor::SchematicEditorState_AddImage
Definition schematiceditorfsm.h:92
@ DRAW_WIRE
librepcb::editor::SchematicEditorState_DrawWire
Definition schematiceditorfsm.h:80
@ DRAW_POLYGON
librepcb::editor::SchematicEditorState_DrawPolygon
Definition schematiceditorfsm.h:88
@ ADD_LABEL
librepcb::editor::SchematicEditorState_AddLabel
Definition schematiceditorfsm.h:84
@ ADD_TEXT
librepcb::editor::SchematicEditorState_AddText
Definition schematiceditorfsm.h:90
@ IDLE
no state active
Definition schematiceditorfsm.h:76
bool processCut() noexcept
Definition schematiceditorfsm.cpp:196
bool leaveCurrentState() noexcept
Definition schematiceditorfsm.cpp:394
bool switchToPreviousState() noexcept
Definition schematiceditorfsm.cpp:426
bool processMeasure() noexcept
Definition schematiceditorfsm.cpp:172
bool processGraphicsSceneRightMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept
Definition schematiceditorfsm.cpp:346
bool processAbortCommand() noexcept
Definition schematiceditorfsm.cpp:176
bool processKeyReleased(const GraphicsSceneKeyEvent &e) noexcept
Definition schematiceditorfsm.cpp:296
bool processGridIntervalChanged(const PositiveLength &interval) noexcept
Definition schematiceditorfsm.cpp:362
bool processGraphicsSceneLeftMouseButtonPressed(const GraphicsSceneMouseEvent &e) noexcept
Definition schematiceditorfsm.cpp:316
bool processGraphicsSceneLeftMouseButtonDoubleClicked(const GraphicsSceneMouseEvent &e) noexcept
Definition schematiceditorfsm.cpp:336
bool processMove(const Point &delta) noexcept
Definition schematiceditorfsm.cpp:223
bool enterNextState(State state) noexcept
Definition schematiceditorfsm.cpp:416
State mCurrentState
Definition schematiceditorfsm.h:155
bool processGraphicsSceneMouseMoved(const GraphicsSceneMouseEvent &e) noexcept
Definition schematiceditorfsm.cpp:306
bool processRotate(const Angle &rotation) noexcept
Definition schematiceditorfsm.cpp:232
bool processAddText() noexcept
Definition schematiceditorfsm.cpp:136
bool processDrawWire() noexcept
Definition schematiceditorfsm.cpp:156
bool processAddComponent(const QString &searchTerm=QString()) noexcept
Definition schematiceditorfsm.cpp:98
SchematicEditorState * getCurrentStateObj() const noexcept
Definition schematiceditorfsm.cpp:376
bool processMirror(Qt::Orientation orientation) noexcept
Definition schematiceditorfsm.cpp:241
bool processAddNetLabel() noexcept
Definition schematiceditorfsm.cpp:128
bool processGraphicsSceneLeftMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept
Definition schematiceditorfsm.cpp:326
QMap< State, SchematicEditorState * > mStates
Definition schematiceditorfsm.h:154
bool processPaste() noexcept
Definition schematiceditorfsm.cpp:214
bool processSnapToGrid() noexcept
Definition schematiceditorfsm.cpp:250
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
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition length.h:810
Definition uuid.h:186
Definition graphicsscene.h:52
Definition graphicsscene.h:45
FSM Context.
Definition schematiceditorfsm.h:65
Schematic & schematic
Definition schematiceditorfsm.h:68
Workspace & workspace
Definition schematiceditorfsm.h:66
UndoStack & undoStack
Definition schematiceditorfsm.h:69
SchematicEditorFsmAdapter & adapter
Definition schematiceditorfsm.h:70
Project & project
Definition schematiceditorfsm.h:67