LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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_LIBRARY_EDITOR_SYMBOLEDITORSTATE_SELECT_H
21 #define LIBREPCB_LIBRARY_EDITOR_SYMBOLEDITORSTATE_SELECT_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "symboleditorstate.h"
27 
28 #include <QtCore>
29 #include <QtWidgets>
30 
31 /*******************************************************************************
32  * Namespace / Forward Declarations
33  ******************************************************************************/
34 namespace librepcb {
35 namespace library {
36 namespace editor {
37 
38 class CmdDragSelectedSymbolItems;
39 
40 /*******************************************************************************
41  * Class SymbolEditorState_Select
42  ******************************************************************************/
43 
48  Q_OBJECT
49 
50 public:
51  // Constructors / Destructor
52  SymbolEditorState_Select() = delete;
54  explicit SymbolEditorState_Select(const Context& context) noexcept;
55  ~SymbolEditorState_Select() noexcept;
56 
57  // General Methods
58  bool exit() noexcept override {
60  return true;
61  }
62 
63  // Event Handlers
65  QGraphicsSceneMouseEvent& e) noexcept override;
67  QGraphicsSceneMouseEvent& e) noexcept override;
69  QGraphicsSceneMouseEvent& e) noexcept override;
71  QGraphicsSceneMouseEvent& e) noexcept override;
73  QGraphicsSceneMouseEvent& e) noexcept override;
74  bool processCut() noexcept override;
75  bool processCopy() noexcept override;
76  bool processPaste() noexcept override;
77  bool processRotateCw() noexcept override;
78  bool processRotateCcw() noexcept override;
79  bool processMirror() noexcept override;
80  bool processRemove() noexcept override;
81  bool processAbortCommand() noexcept override;
82 
83  // Operator Overloadings
84  SymbolEditorState_Select& operator=(const SymbolEditorState_Select& rhs) =
85  delete;
86 
87 private: // Methods
88  bool openContextMenuAtPos(const Point& pos) noexcept;
89  bool openPropertiesDialogOfItemAtPos(const Point& pos) noexcept;
90  bool copySelectedItemsToClipboard() noexcept;
91  bool pasteFromClipboard() noexcept;
92  bool rotateSelectedItems(const Angle& angle) noexcept;
93  bool mirrorSelectedItems(Qt::Orientation orientation) noexcept;
94  bool removeSelectedItems() noexcept;
95  void setSelectionRect(const Point& p1, const Point& p2) noexcept;
96  void clearSelectionRect(bool updateItemsSelectionState) noexcept;
97 
98 private: // Types / Data
99  enum class SubState { IDLE, SELECTING, MOVING, PASTING };
102  QScopedPointer<CmdDragSelectedSymbolItems> mCmdDragSelectedItems;
103 };
104 
105 /*******************************************************************************
106  * End of File
107  ******************************************************************************/
108 
109 } // namespace editor
110 } // namespace library
111 } // namespace librepcb
112 
113 #endif // LIBREPCB_LIBRARY_EDITOR_SYMBOLEDITORSTATE_SELECT_H
bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent &e) noexceptoverride
Definition: symboleditorstate_select.cpp:71
bool processCut() noexceptoverride
Definition: symboleditorstate_select.cpp:227
bool openPropertiesDialogOfItemAtPos(const Point &pos) noexcept
Definition: symboleditorstate_select.cpp:362
The SymbolEditorState class is the base class of all symbol editor FSM states.
Definition: symboleditorstate.h:49
bool processPaste() noexceptoverride
Definition: symboleditorstate_select.cpp:249
SubState mState
Definition: symboleditorstate_select.h:100
bool openContextMenuAtPos(const Point &pos) noexcept
Definition: symboleditorstate_select.cpp:335
bool pasteFromClipboard() noexcept
Definition: symboleditorstate_select.cpp:450
bool processMirror() noexceptoverride
Definition: symboleditorstate_select.cpp:286
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
bool processRemove() noexceptoverride
Definition: symboleditorstate_select.cpp:300
SubState
Definition: symboleditorstate_select.h:99
The SymbolEditorState_Select class.
Definition: symboleditorstate_select.h:47
bool copySelectedItemsToClipboard() noexcept
Definition: symboleditorstate_select.cpp:414
void clearSelectionRect(bool updateItemsSelectionState) noexcept
Definition: symboleditorstate_select.cpp:531
bool processRotateCw() noexceptoverride
Definition: symboleditorstate_select.cpp:258
bool exit() noexceptoverride
Definition: symboleditorstate_select.h:58
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
bool processRotateCcw() noexceptoverride
Definition: symboleditorstate_select.cpp:272
bool mirrorSelectedItems(Qt::Orientation orientation) noexcept
Definition: symboleditorstate_select.cpp:502
Point mStartPos
Definition: symboleditorstate_select.h:101
bool processGraphicsSceneLeftMouseButtonDoubleClicked(QGraphicsSceneMouseEvent &e) noexceptoverride
Definition: symboleditorstate_select.cpp:195
QScopedPointer< CmdDragSelectedSymbolItems > mCmdDragSelectedItems
Definition: symboleditorstate_select.h:102
bool processAbortCommand() noexceptoverride
Definition: symboleditorstate_select.cpp:309
bool rotateSelectedItems(const Angle &angle) noexcept
Definition: symboleditorstate_select.cpp:489
bool processGraphicsSceneLeftMouseButtonPressed(QGraphicsSceneMouseEvent &e) noexceptoverride
Definition: symboleditorstate_select.cpp:93
bool removeSelectedItems() noexcept
Definition: symboleditorstate_select.cpp:515
bool processGraphicsSceneRightMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexceptoverride
Definition: symboleditorstate_select.cpp:212
bool processCopy() noexceptoverride
Definition: symboleditorstate_select.cpp:240
void setSelectionRect(const Point &p1, const Point &p2) noexcept
Definition: symboleditorstate_select.cpp:524
bool processGraphicsSceneLeftMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexceptoverride
Definition: symboleditorstate_select.cpp:170
~SymbolEditorState_Select() noexcept
Definition: symboleditorstate_select.cpp:63