LibrePCB Developers Documentation
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#include <QtWidgets>
32
33#include <memory>
34#include <optional.hpp>
35
36/*******************************************************************************
37 * Namespace / Forward Declarations
38 ******************************************************************************/
39namespace librepcb {
40
41class Angle;
42class Polygon;
43
44namespace editor {
45
46class CmdDragSelectedSymbolItems;
47class CmdPolygonEdit;
48class SymbolClipboardData;
49
50/*******************************************************************************
51 * Class SymbolEditorState_Select
52 ******************************************************************************/
53
58 Q_OBJECT
59
60 enum class SubState {
61 IDLE,
62 SELECTING,
63 MOVING,
64 PASTING,
65 MOVING_POLYGON_VERTEX
66 };
67
68public:
69 // Constructors / Destructor
72 explicit SymbolEditorState_Select(const Context& context) noexcept;
74
75 // General Methods
76 bool exit() noexcept override;
78 const noexcept override;
79
80 // Event Handlers
82 QGraphicsSceneMouseEvent& e) noexcept override;
84 QGraphicsSceneMouseEvent& e) noexcept override;
86 QGraphicsSceneMouseEvent& e) noexcept override;
88 QGraphicsSceneMouseEvent& e) noexcept override;
90 QGraphicsSceneMouseEvent& e) noexcept override;
91 bool processSelectAll() noexcept override;
92 bool processCut() noexcept override;
93 bool processCopy() noexcept override;
94 bool processPaste(
95 std::unique_ptr<SymbolClipboardData> data = nullptr) noexcept override;
96 bool processMove(const Point& delta) noexcept override;
97 bool processRotate(const Angle& rotation) noexcept override;
98 bool processMirror(Qt::Orientation orientation) noexcept override;
99 bool processSnapToGrid() noexcept override;
100 bool processRemove() noexcept override;
101 bool processEditProperties() noexcept override;
102 bool processImportDxf() noexcept override;
103 bool processAbortCommand() 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 tl::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
131private: // Types / Data
135
137 std::shared_ptr<Polygon> mSelectedPolygon;
142};
143
144/*******************************************************************************
145 * End of File
146 ******************************************************************************/
147
148} // namespace editor
149} // namespace librepcb
150
151#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition: point.h:79
The Polygon class.
Definition: polygon.h:45
The CmdDragSelectedSymbolItems class.
Definition: cmddragselectedsymbolitems.h:52
The CmdPolygonEdit class.
Definition: cmdpolygonedit.h:51
The EditorWidgetBase class.
Definition: editorwidgetbase.h:62
The SymbolClipboardData class.
Definition: symbolclipboarddata.h:52
The SymbolEditorState_Select class.
Definition: symboleditorstate_select.h:57
bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent &e) noexcept override
Definition: symboleditorstate_select.cpp:125
void setState(SubState state) noexcept
Definition: symboleditorstate_select.cpp:979
void clearSelectionRect(bool updateItemsSelectionState) noexcept
Definition: symboleditorstate_select.cpp:944
bool processEditProperties() noexcept override
Definition: symboleditorstate_select.cpp:472
bool mirrorSelectedItems(Qt::Orientation orientation) noexcept
Definition: symboleditorstate_select.cpp:852
bool processGraphicsSceneLeftMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexcept override
Definition: symboleditorstate_select.cpp:261
SubState mState
Definition: symboleditorstate_select.h:132
bool copySelectedItemsToClipboard() noexcept
Definition: symboleditorstate_select.cpp:762
bool processRemove() noexcept override
Definition: symboleditorstate_select.cpp:461
bool rotateSelectedItems(const Angle &angle) noexcept
Definition: symboleditorstate_select.cpp:835
bool processAbortCommand() noexcept override
Definition: symboleditorstate_select.cpp:563
bool removeSelectedItems() noexcept
Definition: symboleditorstate_select.cpp:881
bool openPropertiesDialogOfItem(std::shared_ptr< QGraphicsItem > item) noexcept
Definition: symboleditorstate_select.cpp:712
~SymbolEditorState_Select() noexcept
Definition: symboleditorstate_select.cpp:74
bool processRotate(const Angle &rotation) noexcept override
Definition: symboleditorstate_select.cpp:421
std::shared_ptr< Polygon > mSelectedPolygon
The current polygon selected for editing (nullptr if none)
Definition: symboleditorstate_select.h:137
bool processSelectAll() noexcept override
Definition: symboleditorstate_select.cpp:331
bool processImportDxf() noexcept override
Definition: symboleditorstate_select.cpp:496
bool openContextMenuAtPos(const Point &pos) noexcept
Definition: symboleditorstate_select.cpp:597
void startAddingPolygonVertex(std::shared_ptr< Polygon > polygon, int vertex, const Point &pos) noexcept
Definition: symboleditorstate_select.cpp:916
bool openPropertiesDialogOfItemAtPos(const Point &pos) noexcept
Definition: symboleditorstate_select.cpp:751
bool findPolygonVerticesAtPosition(const Point &pos) noexcept
Definition: symboleditorstate_select.cpp:961
bool processCut() noexcept override
Definition: symboleditorstate_select.cpp:348
bool exit() noexcept override
Definition: symboleditorstate_select.cpp:82
bool startPaste(std::unique_ptr< SymbolClipboardData > data, const tl::optional< Point > &fixedPosition)
Definition: symboleditorstate_select.cpp:798
QVector< int > mSelectedPolygonVertices
The polygon vertex indices selected for editing (empty if none)
Definition: symboleditorstate_select.h:139
QList< std::shared_ptr< QGraphicsItem > > findItemsAtPosition(const Point &pos) noexcept
Definition: symboleditorstate_select.cpp:953
bool processSnapToGrid() noexcept override
Definition: symboleditorstate_select.cpp:448
bool processPaste(std::unique_ptr< SymbolClipboardData > data=nullptr) noexcept override
Definition: symboleditorstate_select.cpp:374
QScopedPointer< CmdDragSelectedSymbolItems > mCmdDragSelectedItems
Definition: symboleditorstate_select.h:134
bool processGraphicsSceneRightMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexcept override
Definition: symboleditorstate_select.cpp:315
Point mStartPos
Definition: symboleditorstate_select.h:133
void setSelectionRect(const Point &p1, const Point &p2) noexcept
Definition: symboleditorstate_select.cpp:937
SymbolEditorState_Select(const SymbolEditorState_Select &other)=delete
bool processMirror(Qt::Orientation orientation) noexcept override
Definition: symboleditorstate_select.cpp:434
QSet< EditorWidgetBase::Feature > getAvailableFeatures() const noexcept override
Definition: symboleditorstate_select.cpp:91
void removePolygonVertices(std::shared_ptr< Polygon > polygon, const QVector< int > vertices) noexcept
Definition: symboleditorstate_select.cpp:890
bool snapSelectedItemsToGrid() noexcept
Definition: symboleditorstate_select.cpp:869
bool processGraphicsSceneLeftMouseButtonPressed(QGraphicsSceneMouseEvent &e) noexcept override
Definition: symboleditorstate_select.cpp:168
SubState
Definition: symboleditorstate_select.h:60
bool processMove(const Point &delta) noexcept override
Definition: symboleditorstate_select.cpp:401
QScopedPointer< CmdPolygonEdit > mCmdPolygonEdit
The polygon edit command (nullptr if not editing)
Definition: symboleditorstate_select.h:141
bool processCopy() noexcept override
Definition: symboleditorstate_select.cpp:363
bool processGraphicsSceneLeftMouseButtonDoubleClicked(QGraphicsSceneMouseEvent &e) noexcept override
Definition: symboleditorstate_select.cpp:300
The SymbolEditorState class is the base class of all symbol editor FSM states.
Definition: symboleditorstate.h:54
Definition: occmodel.cpp:77
Definition: uuid.h:183
Definition: symboleditorfsm.h:76