LibrePCB Developers Documentation
Loading...
Searching...
No Matches
packageeditorfsm.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_PACKAGEEDITORFSM_H
21#define LIBREPCB_EDITOR_PACKAGEEDITORFSM_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 Footprint;
38class LengthUnit;
39class Package;
40
41namespace editor {
42
43class FootprintGraphicsItem;
44class GraphicsLayerList;
45class PackageEditorFsmAdapter;
46class PackageEditorState;
47class UndoStack;
48struct GraphicsSceneKeyEvent;
49struct GraphicsSceneMouseEvent;
50
51/*******************************************************************************
52 * Class PackageEditorFsm
53 ******************************************************************************/
54
59class PackageEditorFsm final : public QObject {
60 Q_OBJECT
61
62private: // Types
87
88public: // Types
89 struct Context {
92 const bool readOnly;
96
97 // Set by PackageEditorFsm::processChangeCurrentFootprint()
98 std::shared_ptr<Footprint> currentFootprint;
99 std::shared_ptr<FootprintGraphicsItem> currentGraphicsItem;
100 };
101
102public:
103 // Constructors / Destructor
105 PackageEditorFsm(const PackageEditorFsm& other) = delete;
106 explicit PackageEditorFsm(const Context& context) noexcept;
107 ~PackageEditorFsm() noexcept;
108
109 // Getters
110 const std::shared_ptr<Footprint>& getCurrentFootprint() noexcept;
111 const std::shared_ptr<FootprintGraphicsItem>&
112 getCurrentGraphicsItem() noexcept;
113
114 // Event Handlers
116 const std::shared_ptr<Footprint>& fpt,
117 const std::shared_ptr<FootprintGraphicsItem>& item) 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 bool processSelectAll() noexcept;
131 bool processCut() noexcept;
132 bool processCopy() noexcept;
133 bool processPaste() noexcept;
134 bool processMove(const Point& delta) noexcept;
135 bool processRotate(const Angle& rotation) noexcept;
136 bool processMirror(Qt::Orientation orientation) noexcept;
137 bool processFlip(Qt::Orientation orientation) noexcept;
138 bool processMoveAlign() noexcept;
139 bool processSnapToGrid() noexcept;
140 bool processRemove() noexcept;
141 bool processEditProperties() noexcept;
142 bool processGenerateOutline() noexcept;
143 bool processGenerateCourtyard() noexcept;
144 bool processAcceptCommand() noexcept;
145 bool processAbortCommand() noexcept;
146 bool processStartSelecting() noexcept;
148 bool processStartAddingFootprintSmtPads(Pad::Function function) noexcept;
149 bool processStartAddingNames() noexcept;
150 bool processStartAddingValues() noexcept;
151 bool processStartDrawLines() noexcept;
152 bool processStartDrawArcs() noexcept;
153 bool processStartDrawRects() noexcept;
154 bool processStartDrawPolygons() noexcept;
155 bool processStartDrawCircles() noexcept;
156 bool processStartDrawTexts() noexcept;
157 bool processStartDrawZones() noexcept;
158 bool processStartAddingHoles() noexcept;
159 bool processStartDxfImport() noexcept;
160 bool processStartMeasure() noexcept;
161 bool processStartReNumberPads() noexcept;
162 bool processGridIntervalChanged(const PositiveLength& interval) noexcept;
163
164 // Operator Overloadings
165 PackageEditorFsm& operator=(const PackageEditorFsm& rhs) = delete;
166
167private: // Methods
168 PackageEditorState* getCurrentState() const noexcept;
169 bool setNextState(State state) noexcept;
170 bool leaveCurrentState() noexcept;
171 bool enterNextState(State state) noexcept;
172 bool switchToPreviousState() noexcept;
173
174private: // Data
179};
180
181/*******************************************************************************
182 * End of File
183 ******************************************************************************/
184
185} // namespace editor
186} // namespace librepcb
187
188#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition angle.h:76
The Footprint class represents one footprint variant of a package.
Definition footprint.h:56
The LengthUnit class represents a length unit (millimeters, inches,...) and provides some useful meth...
Definition lengthunit.h:62
The Package class represents a package of a component (including footprint and 3D model)
Definition package.h:59
Base class for pads, extended in derived classes.
Definition pad.h:53
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition point.h:78
The FootprintGraphicsItem class.
Definition footprintgraphicsitem.h:66
The GraphicsLayerList class.
Definition graphicslayerlist.h:48
Interface for the integration of the Package editor FSM.
Definition packageeditorfsmadapter.h:64
The PackageEditorFsm class is the finit state machine (FSM) of the package editor.
Definition packageeditorfsm.h:59
Context mContext
Definition packageeditorfsm.h:175
bool processStartAddingNames() noexcept
Definition packageeditorfsm.cpp:391
bool processStartAddingHoles() noexcept
Definition packageeditorfsm.cpp:427
bool setNextState(State state) noexcept
Definition packageeditorfsm.cpp:467
bool processStartAddingValues() noexcept
Definition packageeditorfsm.cpp:395
PackageEditorState * getCurrentState() const noexcept
Definition packageeditorfsm.cpp:463
bool processStartSelecting() noexcept
Definition packageeditorfsm.cpp:363
bool processStartDrawLines() noexcept
Definition packageeditorfsm.cpp:399
bool processSelectAll() noexcept
Definition packageeditorfsm.cpp:230
bool processStartAddingFootprintSmtPads(Pad::Function function) noexcept
Definition packageeditorfsm.cpp:371
bool processStartDrawRects() noexcept
Definition packageeditorfsm.cpp:407
const std::shared_ptr< FootprintGraphicsItem > & getCurrentGraphicsItem() noexcept
Definition packageeditorfsm.cpp:121
bool processRemove() noexcept
Definition packageeditorfsm.cpp:314
bool processKeyPressed(const GraphicsSceneKeyEvent &e) noexcept
Definition packageeditorfsm.cpp:151
bool processCopy() noexcept
Definition packageeditorfsm.cpp:246
bool processEditProperties() noexcept
Definition packageeditorfsm.cpp:323
State mPreviousState
Definition packageeditorfsm.h:178
State
Definition packageeditorfsm.h:63
bool processCut() noexcept
Definition packageeditorfsm.cpp:238
QMap< State, PackageEditorState * > mStates
Definition packageeditorfsm.h:176
bool leaveCurrentState() noexcept
Definition packageeditorfsm.cpp:481
bool switchToPreviousState() noexcept
Definition packageeditorfsm.cpp:510
bool processStartDrawTexts() noexcept
Definition packageeditorfsm.cpp:419
bool processChangeCurrentFootprint(const std::shared_ptr< Footprint > &fpt, const std::shared_ptr< FootprintGraphicsItem > &item) noexcept
Definition packageeditorfsm.cpp:129
bool processStartDxfImport() noexcept
Definition packageeditorfsm.cpp:431
bool processGraphicsSceneRightMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept
Definition packageeditorfsm.cpp:212
bool processGenerateOutline() noexcept
Definition packageeditorfsm.cpp:331
bool processAbortCommand() noexcept
Definition packageeditorfsm.cpp:355
bool processKeyReleased(const GraphicsSceneKeyEvent &e) noexcept
Definition packageeditorfsm.cpp:161
bool processGridIntervalChanged(const PositiveLength &interval) noexcept
Definition packageeditorfsm.cpp:449
bool processFlip(Qt::Orientation orientation) noexcept
Definition packageeditorfsm.cpp:289
bool processGraphicsSceneLeftMouseButtonPressed(const GraphicsSceneMouseEvent &e) noexcept
Definition packageeditorfsm.cpp:181
bool processGraphicsSceneLeftMouseButtonDoubleClicked(const GraphicsSceneMouseEvent &e) noexcept
Definition packageeditorfsm.cpp:201
bool processStartDrawCircles() noexcept
Definition packageeditorfsm.cpp:415
bool processMove(const Point &delta) noexcept
Definition packageeditorfsm.cpp:262
bool enterNextState(State state) noexcept
Definition packageeditorfsm.cpp:497
State mCurrentState
Definition packageeditorfsm.h:177
bool processGraphicsSceneMouseMoved(const GraphicsSceneMouseEvent &e) noexcept
Definition packageeditorfsm.cpp:171
bool processRotate(const Angle &rotation) noexcept
Definition packageeditorfsm.cpp:271
bool processAcceptCommand() noexcept
Definition packageeditorfsm.cpp:347
bool processStartMeasure() noexcept
Definition packageeditorfsm.cpp:441
PackageEditorFsm(const PackageEditorFsm &other)=delete
const std::shared_ptr< Footprint > & getCurrentFootprint() noexcept
Definition packageeditorfsm.cpp:116
~PackageEditorFsm() noexcept
Definition packageeditorfsm.cpp:109
bool processStartDrawZones() noexcept
Definition packageeditorfsm.cpp:423
bool processStartReNumberPads() noexcept
Definition packageeditorfsm.cpp:445
bool processMoveAlign() noexcept
Definition packageeditorfsm.cpp:298
bool processGenerateCourtyard() noexcept
Definition packageeditorfsm.cpp:339
bool processMirror(Qt::Orientation orientation) noexcept
Definition packageeditorfsm.cpp:280
bool processStartDrawArcs() noexcept
Definition packageeditorfsm.cpp:403
bool processGraphicsSceneLeftMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept
Definition packageeditorfsm.cpp:191
bool processStartAddingFootprintThtPads() noexcept
Definition packageeditorfsm.cpp:367
bool processStartDrawPolygons() noexcept
Definition packageeditorfsm.cpp:411
bool processPaste() noexcept
Definition packageeditorfsm.cpp:254
bool processSnapToGrid() noexcept
Definition packageeditorfsm.cpp:306
The PackageEditorState class is the base class of all package editor FSM states.
Definition packageeditorstate.h:52
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
Definition packageeditorfsm.h:89
const bool readOnly
Definition packageeditorfsm.h:92
LengthUnit & lengthUnit
Definition packageeditorfsm.h:93
Package & package
Definition packageeditorfsm.h:90
PackageEditorFsmAdapter & adapter
Definition packageeditorfsm.h:95
std::shared_ptr< FootprintGraphicsItem > currentGraphicsItem
Definition packageeditorfsm.h:99
const GraphicsLayerList & layers
Definition packageeditorfsm.h:94
std::shared_ptr< Footprint > currentFootprint
Definition packageeditorfsm.h:98
UndoStack & undoStack
Definition packageeditorfsm.h:91