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 ******************************************************************************/
26#include "../../editorwidgetbase.h"
27
29
30#include <QtCore>
31
32#include <memory>
33
34/*******************************************************************************
35 * Namespace / Forward Declarations
36 ******************************************************************************/
37namespace librepcb {
38
39class Footprint;
40class Package;
41
42namespace editor {
43
44class FootprintGraphicsItem;
45class GraphicsScene;
46class GraphicsView;
47class PackageEditorState;
48class PackageEditorWidget;
49class PrimitiveTextGraphicsItem;
50class UndoStack;
51struct GraphicsSceneKeyEvent;
52struct GraphicsSceneMouseEvent;
53
54/*******************************************************************************
55 * Class PackageEditorFsm
56 ******************************************************************************/
57
62class PackageEditorFsm final : public QObject {
63 Q_OBJECT
64
65private: // Types
90
91public: // Types
104
105public:
106 // Constructors / Destructor
108 PackageEditorFsm(const PackageEditorFsm& other) = delete;
109 explicit PackageEditorFsm(const Context& context) noexcept;
110 virtual ~PackageEditorFsm() noexcept;
111
112 // Getters
113 EditorWidgetBase::Tool getCurrentTool() const noexcept;
114 std::shared_ptr<Footprint> getCurrentFootprint() const noexcept;
115 const QSet<EditorWidgetBase::Feature>& getAvailableFeatures() const noexcept {
116 return mAvailableFeatures;
117 }
118
119 // General Methods
120 void updateAvailableFeatures() noexcept;
121
122 // Event Handlers
124 const std::shared_ptr<Footprint>& fpt) noexcept;
125 bool processKeyPressed(const GraphicsSceneKeyEvent& e) noexcept;
126 bool processKeyReleased(const GraphicsSceneKeyEvent& e) noexcept;
128 const GraphicsSceneMouseEvent& e) noexcept;
130 const GraphicsSceneMouseEvent& e) noexcept;
132 const GraphicsSceneMouseEvent& e) noexcept;
134 const GraphicsSceneMouseEvent& e) noexcept;
136 const GraphicsSceneMouseEvent& e) noexcept;
137 bool processSelectAll() noexcept;
138 bool processCut() noexcept;
139 bool processCopy() noexcept;
140 bool processPaste() noexcept;
141 bool processMove(const Point& delta) noexcept;
142 bool processRotate(const Angle& rotation) noexcept;
143 bool processMirror(Qt::Orientation orientation) noexcept;
144 bool processFlip(Qt::Orientation orientation) noexcept;
145 bool processMoveAlign() noexcept;
146 bool processSnapToGrid() noexcept;
147 bool processRemove() noexcept;
148 bool processEditProperties() noexcept;
149 bool processGenerateOutline() noexcept;
150 bool processGenerateCourtyard() noexcept;
151 bool processAbortCommand() noexcept;
152 bool processStartSelecting() noexcept;
155 FootprintPad::Function function) noexcept;
156 bool processStartAddingNames() noexcept;
157 bool processStartAddingValues() noexcept;
158 bool processStartDrawLines() noexcept;
159 bool processStartDrawArcs() noexcept;
160 bool processStartDrawRects() noexcept;
161 bool processStartDrawPolygons() noexcept;
162 bool processStartDrawCircles() noexcept;
163 bool processStartDrawTexts() noexcept;
164 bool processStartDrawZones() noexcept;
165 bool processStartAddingHoles() noexcept;
166 bool processStartDxfImport() noexcept;
167 bool processStartMeasure() noexcept;
168 bool processStartReNumberPads() noexcept;
169
170 // Operator Overloadings
171 PackageEditorFsm& operator=(const PackageEditorFsm& rhs) = delete;
172
173signals:
174 void toolChanged(EditorWidgetBase::Tool newTool);
176 void statusBarMessageChanged(const QString& message, int timeoutMs = -1);
177
178private: // Methods
179 PackageEditorState* getCurrentState() const noexcept;
180 bool setNextState(State state) noexcept;
181 bool leaveCurrentState() noexcept;
182 bool enterNextState(State state) noexcept;
183 bool switchToPreviousState() noexcept;
184
185private: // Data
192};
193
194/*******************************************************************************
195 * End of File
196 ******************************************************************************/
197
198} // namespace editor
199} // namespace librepcb
200
201#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:55
The FootprintPad class represents a pad of a footprint.
Definition footprintpad.h:54
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
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition point.h:78
The EditorWidgetBase class.
Definition editorwidgetbase.h:61
The GraphicsScene class.
Definition graphicsscene.h:64
The GraphicsView class.
Definition graphicsview.h:48
The PackageEditorFsm class is the finit state machine (FSM) of the package editor.
Definition packageeditorfsm.h:62
Context mContext
Definition packageeditorfsm.h:186
bool processStartAddingNames() noexcept
Definition packageeditorfsm.cpp:474
bool processStartAddingHoles() noexcept
Definition packageeditorfsm.cpp:510
bool setNextState(State state) noexcept
Definition packageeditorfsm.cpp:540
bool processStartAddingValues() noexcept
Definition packageeditorfsm.cpp:478
void statusBarMessageChanged(const QString &message, int timeoutMs=-1)
PackageEditorState * getCurrentState() const noexcept
Definition packageeditorfsm.cpp:536
bool processChangeCurrentFootprint(const std::shared_ptr< Footprint > &fpt) noexcept
Definition packageeditorfsm.cpp:203
EditorWidgetBase::Tool getCurrentTool() const noexcept
Definition packageeditorfsm.cpp:133
bool processStartSelecting() noexcept
Definition packageeditorfsm.cpp:446
bool processStartDrawLines() noexcept
Definition packageeditorfsm.cpp:482
bool processSelectAll() noexcept
Definition packageeditorfsm.cpp:321
bool processStartDrawRects() noexcept
Definition packageeditorfsm.cpp:490
bool processRemove() noexcept
Definition packageeditorfsm.cpp:405
QSet< EditorWidgetBase::Feature > mAvailableFeatures
Definition packageeditorfsm.h:191
bool processKeyPressed(const GraphicsSceneKeyEvent &e) noexcept
Definition packageeditorfsm.cpp:242
bool processCopy() noexcept
Definition packageeditorfsm.cpp:337
bool processStartAddingFootprintSmtPads(FootprintPad::Function function) noexcept
Definition packageeditorfsm.cpp:454
bool processEditProperties() noexcept
Definition packageeditorfsm.cpp:414
State mPreviousState
Definition packageeditorfsm.h:189
State
Definition packageeditorfsm.h:66
bool processCut() noexcept
Definition packageeditorfsm.cpp:329
QMap< State, PackageEditorState * > mStates
Definition packageeditorfsm.h:187
bool leaveCurrentState() noexcept
Definition packageeditorfsm.cpp:556
bool switchToPreviousState() noexcept
Definition packageeditorfsm.cpp:591
bool processStartDrawTexts() noexcept
Definition packageeditorfsm.cpp:502
bool processStartDxfImport() noexcept
Definition packageeditorfsm.cpp:514
bool processGraphicsSceneRightMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept
Definition packageeditorfsm.cpp:303
bool processGenerateOutline() noexcept
Definition packageeditorfsm.cpp:422
bool processAbortCommand() noexcept
Definition packageeditorfsm.cpp:438
bool processKeyReleased(const GraphicsSceneKeyEvent &e) noexcept
Definition packageeditorfsm.cpp:252
bool processFlip(Qt::Orientation orientation) noexcept
Definition packageeditorfsm.cpp:380
void toolChanged(EditorWidgetBase::Tool newTool)
bool processGraphicsSceneLeftMouseButtonPressed(const GraphicsSceneMouseEvent &e) noexcept
Definition packageeditorfsm.cpp:272
QScopedPointer< PrimitiveTextGraphicsItem > mSelectFootprintGraphicsItem
Definition packageeditorfsm.h:190
bool processGraphicsSceneLeftMouseButtonDoubleClicked(const GraphicsSceneMouseEvent &e) noexcept
Definition packageeditorfsm.cpp:292
bool processStartDrawCircles() noexcept
Definition packageeditorfsm.cpp:498
bool processMove(const Point &delta) noexcept
Definition packageeditorfsm.cpp:353
void updateAvailableFeatures() noexcept
Definition packageeditorfsm.cpp:188
bool enterNextState(State state) noexcept
Definition packageeditorfsm.cpp:575
State mCurrentState
Definition packageeditorfsm.h:188
bool processGraphicsSceneMouseMoved(const GraphicsSceneMouseEvent &e) noexcept
Definition packageeditorfsm.cpp:262
bool processRotate(const Angle &rotation) noexcept
Definition packageeditorfsm.cpp:362
const QSet< EditorWidgetBase::Feature > & getAvailableFeatures() const noexcept
Definition packageeditorfsm.h:115
bool processStartMeasure() noexcept
Definition packageeditorfsm.cpp:524
PackageEditorFsm(const PackageEditorFsm &other)=delete
std::shared_ptr< Footprint > getCurrentFootprint() const noexcept
Definition packageeditorfsm.cpp:179
virtual ~PackageEditorFsm() noexcept
Definition packageeditorfsm.cpp:123
bool processStartDrawZones() noexcept
Definition packageeditorfsm.cpp:506
bool processStartReNumberPads() noexcept
Definition packageeditorfsm.cpp:528
bool processMoveAlign() noexcept
Definition packageeditorfsm.cpp:389
bool processGenerateCourtyard() noexcept
Definition packageeditorfsm.cpp:430
bool processMirror(Qt::Orientation orientation) noexcept
Definition packageeditorfsm.cpp:371
bool processStartDrawArcs() noexcept
Definition packageeditorfsm.cpp:486
bool processGraphicsSceneLeftMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept
Definition packageeditorfsm.cpp:282
bool processStartAddingFootprintThtPads() noexcept
Definition packageeditorfsm.cpp:450
bool processStartDrawPolygons() noexcept
Definition packageeditorfsm.cpp:494
bool processPaste() noexcept
Definition packageeditorfsm.cpp:345
bool processSnapToGrid() noexcept
Definition packageeditorfsm.cpp:397
The PackageEditorState class is the base class of all package editor FSM states.
Definition packageeditorstate.h:53
The PackageEditorWidget class.
Definition packageeditorwidget.h:81
The PrimitiveTextGraphicsItem class is the graphical representation of a text.
Definition primitivetextgraphicsitem.h:52
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:77
Definition uuid.h:186
Definition editorwidgetbase.h:67
Definition graphicsscene.h:52
Definition graphicsscene.h:45
Definition packageeditorfsm.h:92
LengthUnit & lengthUnit
Definition packageeditorfsm.h:98
PackageEditorWidget & editorWidget
Definition packageeditorfsm.h:94
Package & package
Definition packageeditorfsm.h:99
GraphicsView & graphicsView
Definition packageeditorfsm.h:97
std::shared_ptr< FootprintGraphicsItem > currentGraphicsItem
Definition packageeditorfsm.h:101
ToolBarProxy & commandToolBar
Definition packageeditorfsm.h:102
GraphicsScene & graphicsScene
Definition packageeditorfsm.h:96
EditorWidgetBase::Context & editorContext
Definition packageeditorfsm.h:93
std::shared_ptr< Footprint > currentFootprint
Definition packageeditorfsm.h:100
UndoStack & undoStack
Definition packageeditorfsm.h:95