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 ******************************************************************************/
27
28#include <QtCore>
29
30#include <memory>
31
32/*******************************************************************************
33 * Namespace / Forward Declarations
34 ******************************************************************************/
35namespace librepcb {
36
37class Angle;
38class LengthUnit;
39class Point;
40class Symbol;
41
42namespace editor {
43
44class SymbolEditorFsmAdapter;
45class SymbolEditorState;
46class UndoStack;
47struct GraphicsSceneKeyEvent;
48struct GraphicsSceneMouseEvent;
49
50/*******************************************************************************
51 * Class SymbolEditorFsm
52 ******************************************************************************/
53
58class SymbolEditorFsm final : public QObject {
59 Q_OBJECT
60
61private: // Types
62 enum class State {
63 IDLE,
64 SELECT,
75 MEASURE,
76 };
77
78public: // Types
86
87public:
88 // Constructors / Destructor
89 SymbolEditorFsm() = delete;
90 SymbolEditorFsm(const SymbolEditorFsm& other) = delete;
91 explicit SymbolEditorFsm(const Context& context) noexcept;
92 ~SymbolEditorFsm() noexcept;
93
94 // Event Handlers
95 bool processKeyPressed(const GraphicsSceneKeyEvent& e) noexcept;
96 bool processKeyReleased(const GraphicsSceneKeyEvent& e) noexcept;
98 const GraphicsSceneMouseEvent& e) noexcept;
100 const GraphicsSceneMouseEvent& e) noexcept;
102 const GraphicsSceneMouseEvent& e) noexcept;
104 const GraphicsSceneMouseEvent& e) noexcept;
106 const GraphicsSceneMouseEvent& e) 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 processRemove() noexcept;
116 bool processEditProperties() noexcept;
117 bool processAbortCommand() noexcept;
118 bool processStartSelecting() noexcept;
119 bool processStartAddingSymbolPins(bool import) noexcept;
120 bool processStartAddingNames() noexcept;
121 bool processStartAddingValues() noexcept;
122 bool processStartDrawLines() noexcept;
123 bool processStartDrawArcs() noexcept;
124 bool processStartDrawRects() noexcept;
125 bool processStartDrawPolygons() noexcept;
126 bool processStartDrawCircles() noexcept;
127 bool processStartDrawTexts() noexcept;
128 bool processStartAddingImage(const QByteArray& data = QByteArray(),
129 const QString& format = QString(),
130 const QString& basename = QString()) noexcept;
131 bool processStartDxfImport() noexcept;
132 bool processStartMeasure() noexcept;
133 bool processGridIntervalChanged(const PositiveLength& interval) noexcept;
134
135 // Operator Overloadings
136 SymbolEditorState& operator=(const SymbolEditorState& rhs) = delete;
137
138private: // Methods
139 SymbolEditorState* getCurrentState() const noexcept;
140 bool setNextState(State state) noexcept;
141 bool leaveCurrentState() noexcept;
142 bool enterNextState(State state) noexcept;
143 bool switchToPreviousState() noexcept;
144 void handlePasteRequest() noexcept;
145
146private: // Data
150};
151
152/*******************************************************************************
153 * End of File
154 ******************************************************************************/
155
156} // namespace editor
157} // namespace librepcb
158
159#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:56
Interface for the integration of the Symbol editor FSM.
Definition symboleditorfsmadapter.h:62
The SymbolEditorFsm class is the finit state machine (FSM) of the symbol editor.
Definition symboleditorfsm.h:58
SymbolEditorFsm(const SymbolEditorFsm &other)=delete
bool processStartAddingNames() noexcept
Definition symboleditorfsm.cpp:255
bool setNextState(State state) noexcept
Definition symboleditorfsm.cpp:335
bool processStartAddingValues() noexcept
Definition symboleditorfsm.cpp:259
bool processStartSelecting() noexcept
Definition symboleditorfsm.cpp:240
bool processStartDrawLines() noexcept
Definition symboleditorfsm.cpp:263
bool processSelectAll() noexcept
Definition symboleditorfsm.cpp:152
bool processStartDrawRects() noexcept
Definition symboleditorfsm.cpp:271
void handlePasteRequest() noexcept
Definition symboleditorfsm.cpp:390
QMap< State, SymbolEditorState * > mStates
Definition symboleditorfsm.h:147
bool processRemove() noexcept
Definition symboleditorfsm.cpp:216
bool processKeyPressed(const GraphicsSceneKeyEvent &e) noexcept
Definition symboleditorfsm.cpp:80
bool processCopy() noexcept
Definition symboleditorfsm.cpp:168
SymbolEditorState * getCurrentState() const noexcept
Definition symboleditorfsm.cpp:331
bool processEditProperties() noexcept
Definition symboleditorfsm.cpp:224
State mPreviousState
Definition symboleditorfsm.h:149
State
Definition symboleditorfsm.h:62
bool processCut() noexcept
Definition symboleditorfsm.cpp:160
bool leaveCurrentState() noexcept
Definition symboleditorfsm.cpp:349
bool switchToPreviousState() noexcept
Definition symboleditorfsm.cpp:382
bool processStartDrawTexts() noexcept
Definition symboleditorfsm.cpp:283
~SymbolEditorFsm() noexcept
Definition symboleditorfsm.cpp:70
bool processStartDxfImport() noexcept
Definition symboleditorfsm.cpp:303
bool processGraphicsSceneRightMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept
Definition symboleditorfsm.cpp:135
bool processAbortCommand() noexcept
Definition symboleditorfsm.cpp:232
bool processKeyReleased(const GraphicsSceneKeyEvent &e) noexcept
Definition symboleditorfsm.cpp:89
bool processGridIntervalChanged(const PositiveLength &interval) noexcept
Definition symboleditorfsm.cpp:317
bool processGraphicsSceneLeftMouseButtonPressed(const GraphicsSceneMouseEvent &e) noexcept
Definition symboleditorfsm.cpp:107
bool processGraphicsSceneLeftMouseButtonDoubleClicked(const GraphicsSceneMouseEvent &e) noexcept
Definition symboleditorfsm.cpp:125
bool processStartDrawCircles() noexcept
Definition symboleditorfsm.cpp:279
bool processMove(const Point &delta) noexcept
Definition symboleditorfsm.cpp:184
bool enterNextState(State state) noexcept
Definition symboleditorfsm.cpp:367
State mCurrentState
Definition symboleditorfsm.h:148
bool processStartAddingSymbolPins(bool import) noexcept
Definition symboleditorfsm.cpp:244
bool processGraphicsSceneMouseMoved(const GraphicsSceneMouseEvent &e) noexcept
Definition symboleditorfsm.cpp:98
bool processRotate(const Angle &rotation) noexcept
Definition symboleditorfsm.cpp:192
bool processStartMeasure() noexcept
Definition symboleditorfsm.cpp:313
bool processStartAddingImage(const QByteArray &data=QByteArray(), const QString &format=QString(), const QString &basename=QString()) noexcept
Definition symboleditorfsm.cpp:287
bool processMirror(Qt::Orientation orientation) noexcept
Definition symboleditorfsm.cpp:200
bool processStartDrawArcs() noexcept
Definition symboleditorfsm.cpp:267
bool processGraphicsSceneLeftMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept
Definition symboleditorfsm.cpp:116
bool processStartDrawPolygons() noexcept
Definition symboleditorfsm.cpp:275
bool processPaste() noexcept
Definition symboleditorfsm.cpp:176
bool processSnapToGrid() noexcept
Definition symboleditorfsm.cpp:208
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:79
const bool readOnly
Definition symboleditorfsm.h:82
Symbol & symbol
Definition symboleditorfsm.h:80
SymbolEditorFsmAdapter & adapter
Definition symboleditorfsm.h:84
const LengthUnit & lengthUnit
Definition symboleditorfsm.h:83
UndoStack & undoStack
Definition symboleditorfsm.h:81