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 Polygon;
42
43namespace editor {
44
45class CmdDragSelectedSymbolItems;
46class CmdPolygonEdit;
47class SymbolClipboardData;
48
49/*******************************************************************************
50 * Class SymbolEditorState_Select
51 ******************************************************************************/
52
57 Q_OBJECT
58
59 enum class SubState {
60 IDLE,
62 MOVING,
63 PASTING,
65 };
66
67public:
68 // Constructors / Destructor
71 explicit SymbolEditorState_Select(const Context& context) noexcept;
73
74 // General Methods
75 bool entry() noexcept override;
76 bool exit() noexcept override;
77
78 // Event Handlers
80 const GraphicsSceneMouseEvent& e) noexcept override;
82 const GraphicsSceneMouseEvent& e) noexcept override;
84 const GraphicsSceneMouseEvent& e) noexcept override;
86 const GraphicsSceneMouseEvent& e) noexcept override;
88 const GraphicsSceneMouseEvent& e) noexcept override;
89 bool processSelectAll() noexcept override;
90 bool processCut() noexcept override;
91 bool processCopy() noexcept override;
92 bool processPaste(
93 std::unique_ptr<SymbolClipboardData> data = nullptr) noexcept override;
94 bool processMove(const Point& delta) noexcept override;
95 bool processRotate(const Angle& rotation) noexcept override;
96 bool processMirror(Qt::Orientation orientation) noexcept override;
97 bool processSnapToGrid() noexcept override;
98 bool processRemove() noexcept override;
99 bool processEditProperties() noexcept override;
100 bool processImportDxf() noexcept override;
101 bool processAbortCommand() noexcept override;
103 const PositiveLength& inverval) noexcept override;
104
105 // Operator Overloadings
107 delete;
108
109private: // Methods
110 bool openContextMenuAtPos(const Point& pos) noexcept;
111 bool openPropertiesDialogOfItem(std::shared_ptr<QGraphicsItem> item) noexcept;
112 bool openPropertiesDialogOfItemAtPos(const Point& pos) noexcept;
113 bool copySelectedItemsToClipboard() noexcept;
114 bool startPaste(std::unique_ptr<SymbolClipboardData> data,
115 const std::optional<Point>& fixedPosition);
116 bool rotateSelectedItems(const Angle& angle) noexcept;
117 bool mirrorSelectedItems(Qt::Orientation orientation) noexcept;
118 bool snapSelectedItemsToGrid() noexcept;
119 bool removeSelectedItems() noexcept;
120 void removePolygonVertices(std::shared_ptr<Polygon> polygon,
121 const QVector<int> vertices) noexcept;
122 void startAddingPolygonVertex(std::shared_ptr<Polygon> polygon, int vertex,
123 const Point& pos) noexcept;
124 void setSelectionRect(const Point& p1, const Point& p2) noexcept;
125 void clearSelectionRect(bool updateItemsSelectionState) noexcept;
126 QList<std::shared_ptr<QGraphicsItem>> findItemsAtPosition(
127 const Point& pos) noexcept;
128 bool findPolygonVerticesAtPosition(const Point& pos) noexcept;
129 void setState(SubState state) noexcept;
130 void scheduleUpdateAvailableFeatures() noexcept;
132
133private: // Types / Data
137
144
146 QList<QMetaObject::Connection> mConnections;
147
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 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:52
The CmdPolygonEdit class.
Definition cmdpolygonedit.h:51
The SymbolClipboardData class.
Definition symbolclipboarddata.h:49
Interface for the integration of the Symbol editor FSM.
Definition symboleditorfsmadapter.h:61
The SymbolEditorState_Select class.
Definition symboleditorstate_select.h:56
void setState(SubState state) noexcept
Definition symboleditorstate_select.cpp:1014
void clearSelectionRect(bool updateItemsSelectionState) noexcept
Definition symboleditorstate_select.cpp:971
bool processEditProperties() noexcept override
Definition symboleditorstate_select.cpp:475
bool processGraphicsSceneMouseMoved(const GraphicsSceneMouseEvent &e) noexcept override
Definition symboleditorstate_select.cpp:120
bool mirrorSelectedItems(Qt::Orientation orientation) noexcept
Definition symboleditorstate_select.cpp:866
bool processGraphicsSceneRightMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept override
Definition symboleditorstate_select.cpp:311
SubState mState
Definition symboleditorstate_select.h:134
bool copySelectedItemsToClipboard() noexcept
Definition symboleditorstate_select.cpp:769
bool processRemove() noexcept override
Definition symboleditorstate_select.cpp:464
bool rotateSelectedItems(const Angle &angle) noexcept
Definition symboleditorstate_select.cpp:846
bool processGraphicsSceneLeftMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept override
Definition symboleditorstate_select.cpp:259
SymbolEditorFsmAdapter::Features updateAvailableFeatures() noexcept
Definition symboleditorstate_select.cpp:1026
bool startPaste(std::unique_ptr< SymbolClipboardData > data, const std::optional< Point > &fixedPosition)
Definition symboleditorstate_select.cpp:806
std::unique_ptr< CmdPolygonEdit > mCmdPolygonEdit
The polygon edit command (nullptr if not editing)
Definition symboleditorstate_select.h:143
bool processGraphicsSceneLeftMouseButtonPressed(const GraphicsSceneMouseEvent &e) noexcept override
Definition symboleditorstate_select.cpp:167
bool processAbortCommand() noexcept override
Definition symboleditorstate_select.cpp:560
bool removeSelectedItems() noexcept
Definition symboleditorstate_select.cpp:901
bool openPropertiesDialogOfItem(std::shared_ptr< QGraphicsItem > item) noexcept
Definition symboleditorstate_select.cpp:719
~SymbolEditorState_Select() noexcept
Definition symboleditorstate_select.cpp:71
std::unique_ptr< CmdDragSelectedSymbolItems > mCmdDragSelectedItems
Definition symboleditorstate_select.h:136
bool processRotate(const Angle &rotation) noexcept override
Definition symboleditorstate_select.cpp:424
std::shared_ptr< Polygon > mSelectedPolygon
The current polygon selected for editing (nullptr if none)
Definition symboleditorstate_select.h:139
bool processSelectAll() noexcept override
Definition symboleditorstate_select.cpp:327
std::unique_ptr< QTimer > mUpdateAvailableFeaturesTimer
Delay timer for updateAvailableFeatures(), only when in this state.
Definition symboleditorstate_select.h:149
bool processGraphicsSceneLeftMouseButtonDoubleClicked(const GraphicsSceneMouseEvent &e) noexcept override
Definition symboleditorstate_select.cpp:296
bool processImportDxf() noexcept override
Definition symboleditorstate_select.cpp:502
bool openContextMenuAtPos(const Point &pos) noexcept
Definition symboleditorstate_select.cpp:601
void startAddingPolygonVertex(std::shared_ptr< Polygon > polygon, int vertex, const Point &pos) noexcept
Definition symboleditorstate_select.cpp:940
bool openPropertiesDialogOfItemAtPos(const Point &pos) noexcept
Definition symboleditorstate_select.cpp:758
QList< QMetaObject::Connection > mConnections
Signal/slot connections only when in this state.
Definition symboleditorstate_select.h:146
bool findPolygonVerticesAtPosition(const Point &pos) noexcept
Definition symboleditorstate_select.cpp:993
bool processCut() noexcept override
Definition symboleditorstate_select.cpp:348
bool exit() noexcept override
Definition symboleditorstate_select.cpp:99
void scheduleUpdateAvailableFeatures() noexcept
Definition symboleditorstate_select.cpp:1021
QVector< int > mSelectedPolygonVertices
The polygon vertex indices selected for editing (empty if none)
Definition symboleditorstate_select.h:141
QList< std::shared_ptr< QGraphicsItem > > findItemsAtPosition(const Point &pos) noexcept
Definition symboleditorstate_select.cpp:982
bool processSnapToGrid() noexcept override
Definition symboleditorstate_select.cpp:451
bool processPaste(std::unique_ptr< SymbolClipboardData > data=nullptr) noexcept override
Definition symboleditorstate_select.cpp:374
bool processGridIntervalChanged(const PositiveLength &inverval) noexcept override
Definition symboleditorstate_select.cpp:590
Point mStartPos
Definition symboleditorstate_select.h:135
void setSelectionRect(const Point &p1, const Point &p2) noexcept
Definition symboleditorstate_select.cpp:961
SymbolEditorState_Select(const SymbolEditorState_Select &other)=delete
bool processMirror(Qt::Orientation orientation) noexcept override
Definition symboleditorstate_select.cpp:437
void removePolygonVertices(std::shared_ptr< Polygon > polygon, const QVector< int > vertices) noexcept
Definition symboleditorstate_select.cpp:914
bool snapSelectedItemsToGrid() noexcept
Definition symboleditorstate_select.cpp:886
SubState
Definition symboleditorstate_select.h:59
bool processMove(const Point &delta) noexcept override
Definition symboleditorstate_select.cpp:401
bool processCopy() noexcept override
Definition symboleditorstate_select.cpp:363
bool entry() noexcept override
Definition symboleditorstate_select.cpp:79
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:75