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() noexcept override;
95 bool processMove(Qt::ArrowType direction) noexcept override;
96 bool processRotate(const Angle& rotation) noexcept override;
97 bool processMirror(Qt::Orientation orientation) noexcept override;
98 bool processSnapToGrid() noexcept override;
99 bool processRemove() noexcept override;
100 bool processEditProperties() noexcept override;
101 bool processImportDxf() noexcept override;
102 bool processAbortCommand() noexcept override;
103
104 // Operator Overloadings
106 delete;
107
108private: // Methods
109 bool openContextMenuAtPos(const Point& pos) noexcept;
110 bool openPropertiesDialogOfItem(std::shared_ptr<QGraphicsItem> item) noexcept;
111 bool openPropertiesDialogOfItemAtPos(const Point& pos) noexcept;
112 bool copySelectedItemsToClipboard() noexcept;
113 bool startPaste(std::unique_ptr<SymbolClipboardData> data,
114 const tl::optional<Point>& fixedPosition);
115 bool rotateSelectedItems(const Angle& angle) noexcept;
116 bool mirrorSelectedItems(Qt::Orientation orientation) noexcept;
117 bool snapSelectedItemsToGrid() noexcept;
118 bool removeSelectedItems() noexcept;
119 void removePolygonVertices(std::shared_ptr<Polygon> polygon,
120 const QVector<int> vertices) noexcept;
121 void startAddingPolygonVertex(std::shared_ptr<Polygon> polygon, int vertex,
122 const Point& pos) noexcept;
123 void setSelectionRect(const Point& p1, const Point& p2) noexcept;
124 void clearSelectionRect(bool updateItemsSelectionState) noexcept;
125 QList<std::shared_ptr<QGraphicsItem>> findItemsAtPosition(
126 const Point& pos) noexcept;
127 bool findPolygonVerticesAtPosition(const Point& pos) noexcept;
128 void setState(SubState state) noexcept;
129
130private: // Types / Data
134
136 std::shared_ptr<Polygon> mSelectedPolygon;
141};
142
143/*******************************************************************************
144 * End of File
145 ******************************************************************************/
146
147} // namespace editor
148} // namespace librepcb
149
150#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:1003
void clearSelectionRect(bool updateItemsSelectionState) noexcept
Definition: symboleditorstate_select.cpp:968
bool processEditProperties() noexcept override
Definition: symboleditorstate_select.cpp:495
bool mirrorSelectedItems(Qt::Orientation orientation) noexcept
Definition: symboleditorstate_select.cpp:876
bool processGraphicsSceneLeftMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexcept override
Definition: symboleditorstate_select.cpp:261
SubState mState
Definition: symboleditorstate_select.h:131
bool copySelectedItemsToClipboard() noexcept
Definition: symboleditorstate_select.cpp:785
bool processRemove() noexcept override
Definition: symboleditorstate_select.cpp:484
bool rotateSelectedItems(const Angle &angle) noexcept
Definition: symboleditorstate_select.cpp:859
bool processAbortCommand() noexcept override
Definition: symboleditorstate_select.cpp:586
bool processPaste() noexcept override
Definition: symboleditorstate_select.cpp:374
bool removeSelectedItems() noexcept
Definition: symboleditorstate_select.cpp:905
bool openPropertiesDialogOfItem(std::shared_ptr< QGraphicsItem > item) noexcept
Definition: symboleditorstate_select.cpp:735
~SymbolEditorState_Select() noexcept
Definition: symboleditorstate_select.cpp:74
bool processRotate(const Angle &rotation) noexcept override
Definition: symboleditorstate_select.cpp:444
std::shared_ptr< Polygon > mSelectedPolygon
The current polygon selected for editing (nullptr if none)
Definition: symboleditorstate_select.h:136
bool processSelectAll() noexcept override
Definition: symboleditorstate_select.cpp:331
bool processImportDxf() noexcept override
Definition: symboleditorstate_select.cpp:519
bool openContextMenuAtPos(const Point &pos) noexcept
Definition: symboleditorstate_select.cpp:620
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:774
bool findPolygonVerticesAtPosition(const Point &pos) noexcept
Definition: symboleditorstate_select.cpp:985
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:822
QVector< int > mSelectedPolygonVertices
The polygon vertex indices selected for editing (empty if none)
Definition: symboleditorstate_select.h:138
QList< std::shared_ptr< QGraphicsItem > > findItemsAtPosition(const Point &pos) noexcept
Definition: symboleditorstate_select.cpp:977
bool processSnapToGrid() noexcept override
Definition: symboleditorstate_select.cpp:471
QScopedPointer< CmdDragSelectedSymbolItems > mCmdDragSelectedItems
Definition: symboleditorstate_select.h:133
bool processMove(Qt::ArrowType direction) noexcept override
Definition: symboleditorstate_select.cpp:399
bool processGraphicsSceneRightMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexcept override
Definition: symboleditorstate_select.cpp:315
Point mStartPos
Definition: symboleditorstate_select.h:132
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:457
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:914
bool snapSelectedItemsToGrid() noexcept
Definition: symboleditorstate_select.cpp:893
bool processGraphicsSceneLeftMouseButtonPressed(QGraphicsSceneMouseEvent &e) noexcept override
Definition: symboleditorstate_select.cpp:168
SubState
Definition: symboleditorstate_select.h:60
QScopedPointer< CmdPolygonEdit > mCmdPolygonEdit
The polygon edit command (nullptr if not editing)
Definition: symboleditorstate_select.h:140
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:52
Definition: occmodel.cpp:77
Definition: uuid.h:183
Definition: symboleditorfsm.h:76