LibrePCB Developers Documentation
Loading...
Searching...
No Matches
symboleditorfsm.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_SYMBOLEDITORFSM_H
21#define LIBREPCB_EDITOR_SYMBOLEDITORFSM_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../editorwidgetbase.h"
27
28#include <QtCore>
29
30#include <memory>
31
32/*******************************************************************************
33 * Namespace / Forward Declarations
34 ******************************************************************************/
35namespace librepcb {
36
37class Symbol;
38
39namespace editor {
40
41class SymbolEditorFsmAdapter;
42class SymbolEditorState;
43class UndoStack;
44struct GraphicsSceneKeyEvent;
45struct GraphicsSceneMouseEvent;
46
47/*******************************************************************************
48 * Class SymbolEditorFsm
49 ******************************************************************************/
50
55class SymbolEditorFsm final : public QObject {
56 Q_OBJECT
57
58private: // Types
59 enum class State {
60 IDLE,
61 SELECT,
71 MEASURE,
72 };
73
74public: // Types
82
83public:
84 // Constructors / Destructor
85 SymbolEditorFsm() = delete;
86 SymbolEditorFsm(const SymbolEditorFsm& other) = delete;
87 explicit SymbolEditorFsm(const Context& context) noexcept;
88 virtual ~SymbolEditorFsm() noexcept;
89
90 // Getters
91 EditorWidgetBase::Tool getCurrentTool() const noexcept;
92
93 // Event Handlers
94 bool processKeyPressed(const GraphicsSceneKeyEvent& e) noexcept;
95 bool processKeyReleased(const GraphicsSceneKeyEvent& e) noexcept;
97 const GraphicsSceneMouseEvent& e) noexcept;
99 const GraphicsSceneMouseEvent& e) noexcept;
101 const GraphicsSceneMouseEvent& e) noexcept;
103 const GraphicsSceneMouseEvent& e) noexcept;
105 const GraphicsSceneMouseEvent& e) noexcept;
106 bool processSelectAll() noexcept;
107 bool processCut() noexcept;
108 bool processCopy() noexcept;
109 bool processPaste() noexcept;
110 bool processMove(const Point& delta) noexcept;
111 bool processRotate(const Angle& rotation) noexcept;
112 bool processMirror(Qt::Orientation orientation) noexcept;
113 bool processSnapToGrid() noexcept;
114 bool processRemove() noexcept;
115 bool processEditProperties() noexcept;
116 bool processAbortCommand() noexcept;
117 bool processStartSelecting() noexcept;
118 bool processStartAddingSymbolPins(bool import) noexcept;
119 bool processStartAddingNames() noexcept;
120 bool processStartAddingValues() noexcept;
121 bool processStartDrawLines() noexcept;
122 bool processStartDrawArcs() noexcept;
123 bool processStartDrawRects() noexcept;
124 bool processStartDrawPolygons() noexcept;
125 bool processStartDrawCircles() noexcept;
126 bool processStartDrawTexts() noexcept;
127 bool processStartDxfImport() noexcept;
128 bool processStartMeasure() noexcept;
129 bool processGridIntervalChanged(const PositiveLength& inverval) noexcept;
130
131 // Operator Overloadings
132 SymbolEditorState& operator=(const SymbolEditorState& rhs) = delete;
133
134private: // Methods
135 SymbolEditorState* getCurrentState() const noexcept;
136 bool setNextState(State state) noexcept;
137 bool leaveCurrentState() noexcept;
138 bool enterNextState(State state) noexcept;
139 bool switchToPreviousState() noexcept;
140 void handlePasteRequest() noexcept;
141
142private: // Data
146};
147
148/*******************************************************************************
149 * End of File
150 ******************************************************************************/
151
152} // namespace editor
153} // namespace librepcb
154
155#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition angle.h:76
The LengthUnit class represents a length unit (millimeters, inches,...) and provides some useful meth...
Definition lengthunit.h:62
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition point.h:78
The Symbol class represents the part of a component which is added to schematics.
Definition symbol.h:55
The EditorWidgetBase class.
Definition editorwidgetbase.h:61
Interface for the integration of the Symbol editor FSM.
Definition symboleditorfsmadapter.h:61
The SymbolEditorFsm class is the finit state machine (FSM) of the symbol editor.
Definition symboleditorfsm.h:55
SymbolEditorFsm(const SymbolEditorFsm &other)=delete
bool processStartAddingNames() noexcept
Definition symboleditorfsm.cpp:289
bool setNextState(State state) noexcept
Definition symboleditorfsm.cpp:353
bool processStartAddingValues() noexcept
Definition symboleditorfsm.cpp:293
EditorWidgetBase::Tool getCurrentTool() const noexcept
Definition symboleditorfsm.cpp:78
bool processStartSelecting() noexcept
Definition symboleditorfsm.cpp:274
bool processStartDrawLines() noexcept
Definition symboleditorfsm.cpp:297
bool processSelectAll() noexcept
Definition symboleditorfsm.cpp:186
bool processStartDrawRects() noexcept
Definition symboleditorfsm.cpp:305
void handlePasteRequest() noexcept
Definition symboleditorfsm.cpp:400
QMap< State, SymbolEditorState * > mStates
Definition symboleditorfsm.h:143
bool processRemove() noexcept
Definition symboleditorfsm.cpp:250
bool processKeyPressed(const GraphicsSceneKeyEvent &e) noexcept
Definition symboleditorfsm.cpp:114
bool processCopy() noexcept
Definition symboleditorfsm.cpp:202
SymbolEditorState * getCurrentState() const noexcept
Definition symboleditorfsm.cpp:349
bool processEditProperties() noexcept
Definition symboleditorfsm.cpp:258
State mPreviousState
Definition symboleditorfsm.h:145
State
Definition symboleditorfsm.h:59
bool processCut() noexcept
Definition symboleditorfsm.cpp:194
bool leaveCurrentState() noexcept
Definition symboleditorfsm.cpp:363
bool switchToPreviousState() noexcept
Definition symboleditorfsm.cpp:392
bool processStartDrawTexts() noexcept
Definition symboleditorfsm.cpp:317
virtual ~SymbolEditorFsm() noexcept
Definition symboleditorfsm.cpp:68
bool processStartDxfImport() noexcept
Definition symboleditorfsm.cpp:321
bool processGraphicsSceneRightMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept
Definition symboleditorfsm.cpp:169
bool processAbortCommand() noexcept
Definition symboleditorfsm.cpp:266
bool processKeyReleased(const GraphicsSceneKeyEvent &e) noexcept
Definition symboleditorfsm.cpp:123
bool processGraphicsSceneLeftMouseButtonPressed(const GraphicsSceneMouseEvent &e) noexcept
Definition symboleditorfsm.cpp:141
bool processGraphicsSceneLeftMouseButtonDoubleClicked(const GraphicsSceneMouseEvent &e) noexcept
Definition symboleditorfsm.cpp:159
bool processStartDrawCircles() noexcept
Definition symboleditorfsm.cpp:313
bool processMove(const Point &delta) noexcept
Definition symboleditorfsm.cpp:218
bool enterNextState(State state) noexcept
Definition symboleditorfsm.cpp:379
State mCurrentState
Definition symboleditorfsm.h:144
bool processStartAddingSymbolPins(bool import) noexcept
Definition symboleditorfsm.cpp:278
bool processGraphicsSceneMouseMoved(const GraphicsSceneMouseEvent &e) noexcept
Definition symboleditorfsm.cpp:132
bool processRotate(const Angle &rotation) noexcept
Definition symboleditorfsm.cpp:226
bool processStartMeasure() noexcept
Definition symboleditorfsm.cpp:331
bool processMirror(Qt::Orientation orientation) noexcept
Definition symboleditorfsm.cpp:234
bool processStartDrawArcs() noexcept
Definition symboleditorfsm.cpp:301
bool processGraphicsSceneLeftMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept
Definition symboleditorfsm.cpp:150
bool processGridIntervalChanged(const PositiveLength &inverval) noexcept
Definition symboleditorfsm.cpp:335
bool processStartDrawPolygons() noexcept
Definition symboleditorfsm.cpp:309
bool processPaste() noexcept
Definition symboleditorfsm.cpp:210
bool processSnapToGrid() noexcept
Definition symboleditorfsm.cpp:242
The SymbolEditorState class is the base class of all symbol editor FSM states.
Definition symboleditorstate.h:56
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 graphicsscene.h:52
Definition graphicsscene.h:45
Definition symboleditorfsm.h:75
const bool readOnly
Definition symboleditorfsm.h:78
Symbol & symbol
Definition symboleditorfsm.h:76
SymbolEditorFsmAdapter & adapter
Definition symboleditorfsm.h:80
const LengthUnit & lengthUnit
Definition symboleditorfsm.h:79
UndoStack & undoStack
Definition symboleditorfsm.h:77