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 GraphicsScene;
42class GraphicsView;
43class SymbolEditorState;
44class SymbolEditorWidget;
45class SymbolGraphicsItem;
46class UndoStack;
47
48/*******************************************************************************
49 * Class SymbolEditorFsm
50 ******************************************************************************/
51
56class SymbolEditorFsm final : public QObject {
57 Q_OBJECT
58
59private: // Types
60 enum class State {
61 IDLE,
62 SELECT,
72 MEASURE,
73 };
74
75public: // Types
87
88public:
89 // Constructors / Destructor
90 SymbolEditorFsm() = delete;
91 SymbolEditorFsm(const SymbolEditorFsm& other) = delete;
92 explicit SymbolEditorFsm(const Context& context) noexcept;
93 virtual ~SymbolEditorFsm() noexcept;
94
95 // Getters
96 EditorWidgetBase::Tool getCurrentTool() const noexcept;
97 const QSet<EditorWidgetBase::Feature>& getAvailableFeatures() const noexcept {
98 return mAvailableFeatures;
99 }
100
101 // General Methods
102 void updateAvailableFeatures() noexcept;
103
104 // Event Handlers
105 bool processKeyPressed(const QKeyEvent& e) noexcept;
106 bool processKeyReleased(const QKeyEvent& e) noexcept;
107 bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent& e) noexcept;
109 QGraphicsSceneMouseEvent& e) noexcept;
111 QGraphicsSceneMouseEvent& e) noexcept;
113 QGraphicsSceneMouseEvent& e) noexcept;
115 QGraphicsSceneMouseEvent& e) noexcept;
116 bool processSelectAll() noexcept;
117 bool processCut() noexcept;
118 bool processCopy() noexcept;
119 bool processPaste() noexcept;
120 bool processMove(const Point& delta) noexcept;
121 bool processRotate(const Angle& rotation) noexcept;
122 bool processMirror(Qt::Orientation orientation) noexcept;
123 bool processSnapToGrid() noexcept;
124 bool processRemove() noexcept;
125 bool processEditProperties() noexcept;
126 bool processAbortCommand() noexcept;
127 bool processStartSelecting() noexcept;
128 bool processStartAddingSymbolPins() noexcept;
129 bool processStartAddingNames() noexcept;
130 bool processStartAddingValues() noexcept;
131 bool processStartDrawLines() noexcept;
132 bool processStartDrawArcs() noexcept;
133 bool processStartDrawRects() noexcept;
134 bool processStartDrawPolygons() noexcept;
135 bool processStartDrawCircles() noexcept;
136 bool processStartDrawTexts() noexcept;
137 bool processStartDxfImport() noexcept;
138 bool processStartMeasure() noexcept;
139
140 // Operator Overloadings
141 SymbolEditorState& operator=(const SymbolEditorState& rhs) = delete;
142
143signals:
144 void toolChanged(EditorWidgetBase::Tool newTool);
146 void statusBarMessageChanged(const QString& message, int timeoutMs = -1);
147
148private: // Methods
149 SymbolEditorState* getCurrentState() const noexcept;
150 bool setNextState(State state) noexcept;
151 bool leaveCurrentState() noexcept;
152 bool enterNextState(State state) noexcept;
153 bool switchToPreviousState() noexcept;
154 void handlePasteRequest() noexcept;
155
156private: // 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 LengthUnit class represents a length unit (millimeters, inches,...) and provides some useful meth...
Definition lengthunit.h:60
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
The GraphicsScene class.
Definition graphicsscene.h:45
The GraphicsView class.
Definition graphicsview.h:52
The SymbolEditorFsm class is the finit state machine (FSM) of the symbol editor.
Definition symboleditorfsm.h:56
bool processGraphicsSceneRightMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexcept
Definition symboleditorfsm.cpp:187
bool processKeyReleased(const QKeyEvent &e) noexcept
Definition symboleditorfsm.cpp:142
SymbolEditorFsm(const SymbolEditorFsm &other)=delete
bool processStartAddingNames() noexcept
Definition symboleditorfsm.cpp:300
bool setNextState(State state) noexcept
Definition symboleditorfsm.cpp:354
bool processStartAddingValues() noexcept
Definition symboleditorfsm.cpp:304
bool processKeyPressed(const QKeyEvent &e) noexcept
Definition symboleditorfsm.cpp:134
bool processGraphicsSceneLeftMouseButtonDoubleClicked(QGraphicsSceneMouseEvent &e) noexcept
Definition symboleditorfsm.cpp:177
void statusBarMessageChanged(const QString &message, int timeoutMs=-1)
EditorWidgetBase::Tool getCurrentTool() const noexcept
Definition symboleditorfsm.cpp:83
bool processStartSelecting() noexcept
Definition symboleditorfsm.cpp:292
bool processStartDrawLines() noexcept
Definition symboleditorfsm.cpp:308
bool processSelectAll() noexcept
Definition symboleditorfsm.cpp:204
bool processStartDrawRects() noexcept
Definition symboleditorfsm.cpp:316
void handlePasteRequest() noexcept
Definition symboleditorfsm.cpp:409
QMap< State, SymbolEditorState * > mStates
Definition symboleditorfsm.h:157
bool processRemove() noexcept
Definition symboleditorfsm.cpp:268
QSet< EditorWidgetBase::Feature > mAvailableFeatures
Definition symboleditorfsm.h:160
bool processCopy() noexcept
Definition symboleditorfsm.cpp:220
SymbolEditorState * getCurrentState() const noexcept
Definition symboleditorfsm.cpp:350
bool processEditProperties() noexcept
Definition symboleditorfsm.cpp:276
State mPreviousState
Definition symboleditorfsm.h:159
State
Definition symboleditorfsm.h:60
bool processCut() noexcept
Definition symboleditorfsm.cpp:212
bool leaveCurrentState() noexcept
Definition symboleditorfsm.cpp:366
bool switchToPreviousState() noexcept
Definition symboleditorfsm.cpp:401
bool processStartDrawTexts() noexcept
Definition symboleditorfsm.cpp:328
virtual ~SymbolEditorFsm() noexcept
Definition symboleditorfsm.cpp:73
bool processStartDxfImport() noexcept
Definition symboleditorfsm.cpp:332
bool processAbortCommand() noexcept
Definition symboleditorfsm.cpp:284
void toolChanged(EditorWidgetBase::Tool newTool)
bool processGraphicsSceneLeftMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexcept
Definition symboleditorfsm.cpp:168
bool processGraphicsSceneLeftMouseButtonPressed(QGraphicsSceneMouseEvent &e) noexcept
Definition symboleditorfsm.cpp:159
bool processStartDrawCircles() noexcept
Definition symboleditorfsm.cpp:324
bool processMove(const Point &delta) noexcept
Definition symboleditorfsm.cpp:236
void updateAvailableFeatures() noexcept
Definition symboleditorfsm.cpp:119
bool enterNextState(State state) noexcept
Definition symboleditorfsm.cpp:385
State mCurrentState
Definition symboleditorfsm.h:158
bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent &e) noexcept
Definition symboleditorfsm.cpp:150
bool processRotate(const Angle &rotation) noexcept
Definition symboleditorfsm.cpp:244
const QSet< EditorWidgetBase::Feature > & getAvailableFeatures() const noexcept
Definition symboleditorfsm.h:97
bool processStartMeasure() noexcept
Definition symboleditorfsm.cpp:342
bool processMirror(Qt::Orientation orientation) noexcept
Definition symboleditorfsm.cpp:252
bool processStartDrawArcs() noexcept
Definition symboleditorfsm.cpp:312
bool processStartAddingSymbolPins() noexcept
Definition symboleditorfsm.cpp:296
bool processStartDrawPolygons() noexcept
Definition symboleditorfsm.cpp:320
bool processPaste() noexcept
Definition symboleditorfsm.cpp:228
bool processSnapToGrid() noexcept
Definition symboleditorfsm.cpp:260
The SymbolEditorState class is the base class of all symbol editor FSM states.
Definition symboleditorstate.h:54
The SymbolEditorWidget class.
Definition symboleditorwidget.h:63
The SymbolGraphicsItem class.
Definition symbolgraphicsitem.h:56
The ToolBarProxy class allows to map a list of QAction's to one QToolBar.
Definition toolbarproxy.h:45
The UndoStack class holds UndoCommand objects and provides undo/redo commands.
Definition undostack.h:106
Definition occmodel.cpp:76
Definition editorwidgetbase.h:67
Definition symboleditorfsm.h:76
LengthUnit & lengthUnit
Definition symboleditorfsm.h:82
Symbol & symbol
Definition symboleditorfsm.h:83
GraphicsView & graphicsView
Definition symboleditorfsm.h:81
ToolBarProxy & commandToolBar
Definition symboleditorfsm.h:85
SymbolEditorWidget & editorWidget
Definition symboleditorfsm.h:78
GraphicsScene & graphicsScene
Definition symboleditorfsm.h:80
SymbolGraphicsItem & symbolGraphicsItem
Definition symboleditorfsm.h:84
EditorWidgetBase::Context & editorContext
Definition symboleditorfsm.h:77
UndoStack & undoStack
Definition symboleditorfsm.h:79