LibrePCB Developers Documentation
Loading...
Searching...
No Matches
symboleditorstate_select.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_SELECT_H
21#define LIBREPCB_EDITOR_SYMBOLEDITORSTATE_SELECT_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "symboleditorstate.h"
27
29
30#include <QtCore>
31
32#include <memory>
33#include <optional>
34
35/*******************************************************************************
36 * Namespace / Forward Declarations
37 ******************************************************************************/
38namespace librepcb {
39
40class Angle;
41class Image;
42class Polygon;
43
44namespace editor {
45
46class CmdDragSelectedSymbolItems;
47class CmdImageEdit;
48class CmdPolygonEdit;
49class SymbolClipboardData;
50
51/*******************************************************************************
52 * Class SymbolEditorState_Select
53 ******************************************************************************/
54
59 Q_OBJECT
60
61 enum class SubState {
62 IDLE,
64 MOVING,
65 PASTING,
68 };
69
70public:
71 // Constructors / Destructor
74 explicit SymbolEditorState_Select(const Context& context) noexcept;
76
77 // General Methods
78 bool entry() noexcept override;
79 bool exit() noexcept override;
80
81 // Event Handlers
83 const GraphicsSceneMouseEvent& e) noexcept override;
85 const GraphicsSceneMouseEvent& e) noexcept override;
87 const GraphicsSceneMouseEvent& e) noexcept override;
89 const GraphicsSceneMouseEvent& e) noexcept override;
91 const GraphicsSceneMouseEvent& e) noexcept override;
92 bool processSelectAll() noexcept override;
93 bool processCut() noexcept override;
94 bool processCopy() noexcept override;
95 bool processPaste(
96 std::unique_ptr<SymbolClipboardData> data = nullptr) noexcept override;
97 bool processMove(const Point& delta) noexcept override;
98 bool processRotate(const Angle& rotation) noexcept override;
99 bool processMirror(Qt::Orientation orientation) noexcept override;
100 bool processSnapToGrid() noexcept override;
101 bool processRemove() noexcept override;
102 bool processEditProperties() noexcept override;
103 bool processImportDxf() noexcept override;
104 bool processAbortCommand() noexcept override;
106 const PositiveLength& interval) noexcept override;
107
108 // Operator Overloadings
110 delete;
111
112private: // Methods
113 bool openContextMenuAtPos(const Point& pos) noexcept;
114 bool openPropertiesDialogOfItem(std::shared_ptr<QGraphicsItem> item) noexcept;
115 bool openPropertiesDialogOfItemAtPos(const Point& pos) noexcept;
116 bool copySelectedItemsToClipboard() noexcept;
117 bool startPaste(std::unique_ptr<SymbolClipboardData> data,
118 const std::optional<Point>& fixedPosition);
119 bool rotateSelectedItems(const Angle& angle) noexcept;
120 bool mirrorSelectedItems(Qt::Orientation orientation) noexcept;
121 bool snapSelectedItemsToGrid() noexcept;
122 bool removeSelectedItems() noexcept;
123 void removePolygonVertices(std::shared_ptr<Polygon> polygon,
124 const QVector<int> vertices) noexcept;
125 void startAddingPolygonVertex(std::shared_ptr<Polygon> polygon, int vertex,
126 const Point& pos) noexcept;
127 void setSelectionRect(const Point& p1, const Point& p2) noexcept;
128 void clearSelectionRect(bool updateItemsSelectionState) noexcept;
129 QList<std::shared_ptr<QGraphicsItem>> findItemsAtPosition(
130 const Point& pos) noexcept;
131 bool findPolygonVerticesAtPosition(const Point& pos) noexcept;
132 bool findImageHandleAtPosition(const Point& pos) noexcept;
133 void setState(SubState state) noexcept;
134 void scheduleUpdateAvailableFeatures() noexcept;
136
137private: // Types / Data
141
148
155
157 QList<QMetaObject::Connection> mConnections;
158
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 Image class.
Definition image.h:49
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition point.h:78
The Polygon class.
Definition polygon.h:45
The CmdDragSelectedSymbolItems class.
Definition cmddragselectedsymbolitems.h:53
The CmdImageEdit class.
Definition cmdimageedit.h:45
The CmdPolygonEdit class.
Definition cmdpolygonedit.h:51
The SymbolClipboardData class.
Definition symbolclipboarddata.h:54
Interface for the integration of the Symbol editor FSM.
Definition symboleditorfsmadapter.h:62
The SymbolEditorState_Select class.
Definition symboleditorstate_select.h:58
void setState(SubState state) noexcept
Definition symboleditorstate_select.cpp:1091
void clearSelectionRect(bool updateItemsSelectionState) noexcept
Definition symboleditorstate_select.cpp:1028
bool processEditProperties() noexcept override
Definition symboleditorstate_select.cpp:515
bool processGraphicsSceneMouseMoved(const GraphicsSceneMouseEvent &e) noexcept override
Definition symboleditorstate_select.cpp:124
bool mirrorSelectedItems(Qt::Orientation orientation) noexcept
Definition symboleditorstate_select.cpp:923
std::unique_ptr< CmdImageEdit > mCmdImageEdit
The image edit command (nullptr if not editing)
Definition symboleditorstate_select.h:154
bool processGridIntervalChanged(const PositiveLength &interval) noexcept override
Definition symboleditorstate_select.cpp:635
bool processGraphicsSceneRightMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept override
Definition symboleditorstate_select.cpp:351
SubState mState
Definition symboleditorstate_select.h:138
bool copySelectedItemsToClipboard() noexcept
Definition symboleditorstate_select.cpp:814
bool processRemove() noexcept override
Definition symboleditorstate_select.cpp:504
bool rotateSelectedItems(const Angle &angle) noexcept
Definition symboleditorstate_select.cpp:903
bool processGraphicsSceneLeftMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept override
Definition symboleditorstate_select.cpp:288
SymbolEditorFsmAdapter::Features updateAvailableFeatures() noexcept
Definition symboleditorstate_select.cpp:1103
bool startPaste(std::unique_ptr< SymbolClipboardData > data, const std::optional< Point > &fixedPosition)
Definition symboleditorstate_select.cpp:863
std::unique_ptr< CmdPolygonEdit > mCmdPolygonEdit
The polygon edit command (nullptr if not editing)
Definition symboleditorstate_select.h:147
bool processGraphicsSceneLeftMouseButtonPressed(const GraphicsSceneMouseEvent &e) noexcept override
Definition symboleditorstate_select.cpp:194
std::shared_ptr< Image > mSelectedImage
The current image selected for editing (nullptr if none)
Definition symboleditorstate_select.h:150
bool processAbortCommand() noexcept override
Definition symboleditorstate_select.cpp:600
bool removeSelectedItems() noexcept
Definition symboleditorstate_select.cpp:958
bool openPropertiesDialogOfItem(std::shared_ptr< QGraphicsItem > item) noexcept
Definition symboleditorstate_select.cpp:764
~SymbolEditorState_Select() noexcept
Definition symboleditorstate_select.cpp:75
std::unique_ptr< CmdDragSelectedSymbolItems > mCmdDragSelectedItems
Definition symboleditorstate_select.h:140
bool processRotate(const Angle &rotation) noexcept override
Definition symboleditorstate_select.cpp:464
std::shared_ptr< Polygon > mSelectedPolygon
The current polygon selected for editing (nullptr if none)
Definition symboleditorstate_select.h:143
bool processSelectAll() noexcept override
Definition symboleditorstate_select.cpp:367
std::unique_ptr< QTimer > mUpdateAvailableFeaturesTimer
Delay timer for updateAvailableFeatures(), only when in this state.
Definition symboleditorstate_select.h:160
bool processGraphicsSceneLeftMouseButtonDoubleClicked(const GraphicsSceneMouseEvent &e) noexcept override
Definition symboleditorstate_select.cpp:336
bool processImportDxf() noexcept override
Definition symboleditorstate_select.cpp:542
bool openContextMenuAtPos(const Point &pos) noexcept
Definition symboleditorstate_select.cpp:646
void startAddingPolygonVertex(std::shared_ptr< Polygon > polygon, int vertex, const Point &pos) noexcept
Definition symboleditorstate_select.cpp:997
bool openPropertiesDialogOfItemAtPos(const Point &pos) noexcept
Definition symboleditorstate_select.cpp:803
QList< QMetaObject::Connection > mConnections
Signal/slot connections only when in this state.
Definition symboleditorstate_select.h:157
bool findPolygonVerticesAtPosition(const Point &pos) noexcept
Definition symboleditorstate_select.cpp:1050
bool processCut() noexcept override
Definition symboleditorstate_select.cpp:388
bool exit() noexcept override
Definition symboleditorstate_select.cpp:103
void scheduleUpdateAvailableFeatures() noexcept
Definition symboleditorstate_select.cpp:1098
QVector< int > mSelectedPolygonVertices
The polygon vertex indices selected for editing (empty if none)
Definition symboleditorstate_select.h:145
QList< std::shared_ptr< QGraphicsItem > > findItemsAtPosition(const Point &pos) noexcept
Definition symboleditorstate_select.cpp:1039
bool processSnapToGrid() noexcept override
Definition symboleditorstate_select.cpp:491
bool processPaste(std::unique_ptr< SymbolClipboardData > data=nullptr) noexcept override
Definition symboleditorstate_select.cpp:414
qreal mSelectedImageAspectRatio
The original aspect ratio of the currently selected image.
Definition symboleditorstate_select.h:152
Point mStartPos
Definition symboleditorstate_select.h:139
void setSelectionRect(const Point &p1, const Point &p2) noexcept
Definition symboleditorstate_select.cpp:1018
bool findImageHandleAtPosition(const Point &pos) noexcept
Definition symboleditorstate_select.cpp:1071
SymbolEditorState_Select(const SymbolEditorState_Select &other)=delete
bool processMirror(Qt::Orientation orientation) noexcept override
Definition symboleditorstate_select.cpp:477
void removePolygonVertices(std::shared_ptr< Polygon > polygon, const QVector< int > vertices) noexcept
Definition symboleditorstate_select.cpp:971
bool snapSelectedItemsToGrid() noexcept
Definition symboleditorstate_select.cpp:943
SubState
Definition symboleditorstate_select.h:61
bool processMove(const Point &delta) noexcept override
Definition symboleditorstate_select.cpp:441
bool processCopy() noexcept override
Definition symboleditorstate_select.cpp:403
bool entry() noexcept override
Definition symboleditorstate_select.cpp:83
The SymbolEditorState class is the base class of all symbol editor FSM states.
Definition symboleditorstate.h:56
Definition occmodel.cpp:77
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition length.h:810
Definition uuid.h:186
Definition graphicsscene.h:45
Definition symboleditorfsm.h:79