LibrePCB Developers Documentation
Loading...
Searching...
No Matches
symboleditorstate.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_SYMBOLEDITORSTATE_H
21#define LIBREPCB_EDITOR_SYMBOLEDITORSTATE_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../../utils/toolbarproxy.h"
27#include "symboleditorfsm.h"
28
30
31#include <QtCore>
32#include <QtWidgets>
33
34/*******************************************************************************
35 * Namespace / Forward Declarations
36 ******************************************************************************/
37namespace librepcb {
38
39class Layer;
40class LengthUnit;
41
42namespace editor {
43
44class SymbolClipboardData;
45
46/*******************************************************************************
47 * Class SymbolEditorState
48 ******************************************************************************/
49
54class SymbolEditorState : public QObject {
55 Q_OBJECT
56
57public:
59
60 // Constructors / Destructor
62 SymbolEditorState(const SymbolEditorState& other) = delete;
63 explicit SymbolEditorState(const Context& context) noexcept;
64 virtual ~SymbolEditorState() noexcept;
65
66 // General Methods
67 virtual bool entry() noexcept { return true; }
68 virtual bool exit() noexcept { return true; }
69 virtual QSet<EditorWidgetBase::Feature> getAvailableFeatures()
70 const noexcept = 0;
71 std::unique_ptr<SymbolClipboardData> takeDataToPaste() noexcept;
72
73 // Event Handlers
74 virtual bool processKeyPressed(const QKeyEvent& e) noexcept {
75 Q_UNUSED(e);
76 return false;
77 }
78 virtual bool processKeyReleased(const QKeyEvent& e) noexcept {
79 Q_UNUSED(e);
80 return false;
81 }
83 QGraphicsSceneMouseEvent& e) noexcept {
84 Q_UNUSED(e);
85 return false;
86 }
88 QGraphicsSceneMouseEvent& e) noexcept {
89 Q_UNUSED(e);
90 return false;
91 }
93 QGraphicsSceneMouseEvent& e) noexcept {
94 Q_UNUSED(e);
95 return false;
96 }
98 QGraphicsSceneMouseEvent& e) noexcept {
99 Q_UNUSED(e);
100 return false;
101 }
103 QGraphicsSceneMouseEvent& e) noexcept {
104 Q_UNUSED(e);
105 return false;
106 }
107 virtual bool processSelectAll() noexcept { return false; }
108 virtual bool processCut() noexcept { return false; }
109 virtual bool processCopy() noexcept { return false; }
110 virtual bool processPaste(
111 std::unique_ptr<SymbolClipboardData> data = nullptr) noexcept {
112 Q_UNUSED(data);
113 return false;
114 }
115 virtual bool processMove(const Point& delta) {
116 Q_UNUSED(delta);
117 return false;
118 }
119 virtual bool processRotate(const Angle& rotation) noexcept {
120 Q_UNUSED(rotation);
121 return false;
122 }
123 virtual bool processMirror(Qt::Orientation orientation) noexcept {
124 Q_UNUSED(orientation);
125 return false;
126 }
127 virtual bool processSnapToGrid() noexcept { return false; }
128 virtual bool processRemove() noexcept { return false; }
129 virtual bool processEditProperties() noexcept { return false; }
130 virtual bool processImportDxf() noexcept { return false; }
131 virtual bool processAbortCommand() noexcept { return false; }
132
133 // Operator Overloadings
135
136signals:
138 void statusBarMessageChanged(const QString& message, int timeoutMs = -1);
140
141protected: // Methods
142 void requestPaste(std::unique_ptr<SymbolClipboardData> data) noexcept;
143 const PositiveLength& getGridInterval() const noexcept;
144 const LengthUnit& getLengthUnit() const noexcept;
145 static const QSet<const Layer*>& getAllowedTextLayers() noexcept;
146 static const QSet<const Layer*>& getAllowedCircleAndPolygonLayers() noexcept;
147
148private: // Data
150
151protected: // Data
153};
154
155/*******************************************************************************
156 * End of File
157 ******************************************************************************/
158
159} // namespace editor
160} // namespace librepcb
161
162#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition angle.h:76
The Layer class provides all supported geometry layers.
Definition layer.h:42
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 SymbolClipboardData class.
Definition symbolclipboarddata.h:52
The SymbolEditorState class is the base class of all symbol editor FSM states.
Definition symboleditorstate.h:54
Context mContext
Definition symboleditorstate.h:152
virtual bool processEditProperties() noexcept
Definition symboleditorstate.h:129
const PositiveLength & getGridInterval() const noexcept
Definition symboleditorstate.cpp:69
virtual bool processAbortCommand() noexcept
Definition symboleditorstate.h:131
void requestPaste(std::unique_ptr< SymbolClipboardData > data) noexcept
Definition symboleditorstate.cpp:63
virtual bool processGraphicsSceneLeftMouseButtonDoubleClicked(QGraphicsSceneMouseEvent &e) noexcept
Definition symboleditorstate.h:97
virtual bool exit() noexcept
Definition symboleditorstate.h:68
void statusBarMessageChanged(const QString &message, int timeoutMs=-1)
const LengthUnit & getLengthUnit() const noexcept
Definition symboleditorstate.cpp:73
virtual bool processKeyPressed(const QKeyEvent &e) noexcept
Definition symboleditorstate.h:74
std::unique_ptr< SymbolClipboardData > takeDataToPaste() noexcept
Definition symboleditorstate.cpp:55
virtual bool processSnapToGrid() noexcept
Definition symboleditorstate.h:127
virtual QSet< EditorWidgetBase::Feature > getAvailableFeatures() const noexcept=0
virtual bool processMove(const Point &delta)
Definition symboleditorstate.h:115
static const QSet< const Layer * > & getAllowedCircleAndPolygonLayers() noexcept
Definition symboleditorstate.cpp:92
virtual bool entry() noexcept
Definition symboleditorstate.h:67
virtual bool processSelectAll() noexcept
Definition symboleditorstate.h:107
SymbolEditorState(const SymbolEditorState &other)=delete
virtual bool processPaste(std::unique_ptr< SymbolClipboardData > data=nullptr) noexcept
Definition symboleditorstate.h:110
virtual bool processGraphicsSceneRightMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexcept
Definition symboleditorstate.h:102
static const QSet< const Layer * > & getAllowedTextLayers() noexcept
Definition symboleditorstate.cpp:77
virtual bool processGraphicsSceneLeftMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexcept
Definition symboleditorstate.h:92
virtual bool processRotate(const Angle &rotation) noexcept
Definition symboleditorstate.h:119
virtual ~SymbolEditorState() noexcept
Definition symboleditorstate.cpp:47
virtual bool processImportDxf() noexcept
Definition symboleditorstate.h:130
SymbolEditorState & operator=(const SymbolEditorState &rhs)=delete
virtual bool processKeyReleased(const QKeyEvent &e) noexcept
Definition symboleditorstate.h:78
virtual bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent &e) noexcept
Definition symboleditorstate.h:82
virtual bool processGraphicsSceneLeftMouseButtonPressed(QGraphicsSceneMouseEvent &e) noexcept
Definition symboleditorstate.h:87
virtual bool processMirror(Qt::Orientation orientation) noexcept
Definition symboleditorstate.h:123
std::unique_ptr< SymbolClipboardData > mDataToPaste
Definition symboleditorstate.h:149
virtual bool processCopy() noexcept
Definition symboleditorstate.h:109
virtual bool processCut() noexcept
Definition symboleditorstate.h:108
virtual bool processRemove() noexcept
Definition symboleditorstate.h:128
Definition occmodel.cpp:76
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition length.h:810
Definition uuid.h:186
Definition symboleditorfsm.h:76