LibrePCB Developers Documentation
packageeditorstate_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_PACKAGEEDITORSTATE_SELECT_H
21 #define LIBREPCB_LIBRARY_EDITOR_PACKAGEEDITORSTATE_SELECT_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "packageeditorstate.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 CmdDragSelectedFootprintItems;
39 
40 /*******************************************************************************
41  * Class PackageEditorState_Select
42  ******************************************************************************/
43 
48  Q_OBJECT
49 
50 public:
51  // Constructors / Destructor
52  PackageEditorState_Select() = delete;
54  explicit PackageEditorState_Select(Context& context) noexcept;
55  ~PackageEditorState_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 processSelectAll() noexcept override;
75  bool processCut() noexcept override;
76  bool processCopy() noexcept override;
77  bool processPaste() noexcept override;
78  bool processRotateCw() noexcept override;
79  bool processRotateCcw() noexcept override;
80  bool processMirror() noexcept override;
81  bool processFlip() noexcept override;
82  bool processRemove() noexcept override;
83  bool processAbortCommand() noexcept override;
84 
85  // Operator Overloadings
87  delete;
88 
89 private: // Methods
90  bool openContextMenuAtPos(const Point& pos) noexcept;
91  bool openPropertiesDialogOfItemAtPos(const Point& pos) noexcept;
92  bool copySelectedItemsToClipboard() noexcept;
93  bool pasteFromClipboard() noexcept;
94  bool rotateSelectedItems(const Angle& angle) noexcept;
95  bool mirrorSelectedItems(Qt::Orientation orientation,
96  bool flipLayers) noexcept;
97  bool removeSelectedItems() noexcept;
98  void setSelectionRect(const Point& p1, const Point& p2) noexcept;
99  void clearSelectionRect(bool updateItemsSelectionState) noexcept;
100 
101 private: // Types / Data
102  enum class SubState { IDLE, SELECTING, MOVING, PASTING };
105  QScopedPointer<CmdDragSelectedFootprintItems> mCmdDragSelectedItems;
106 };
107 
108 /*******************************************************************************
109  * End of File
110  ******************************************************************************/
111 
112 } // namespace editor
113 } // namespace library
114 } // namespace librepcb
115 
116 #endif // LIBREPCB_LIBRARY_EDITOR_PACKAGEEDITORSTATE_SELECT_H
bool processGraphicsSceneLeftMouseButtonPressed(QGraphicsSceneMouseEvent &e) noexcept override
Definition: packageeditorstate_select.cpp:95
SubState
Definition: packageeditorstate_select.h:102
bool mirrorSelectedItems(Qt::Orientation orientation, bool flipLayers) noexcept
Definition: packageeditorstate_select.cpp:577
bool copySelectedItemsToClipboard() noexcept
Definition: packageeditorstate_select.cpp:471
bool processCut() noexcept override
Definition: packageeditorstate_select.cpp:249
bool exit() noexcept override
Definition: packageeditorstate_select.h:58
bool processMirror() noexcept override
Definition: packageeditorstate_select.cpp:308
bool openContextMenuAtPos(const Point &pos) noexcept
Definition: packageeditorstate_select.cpp:372
void clearSelectionRect(bool updateItemsSelectionState) noexcept
Definition: packageeditorstate_select.cpp:609
Definition: airwiresbuilder.cpp:32
bool processPaste() noexcept override
Definition: packageeditorstate_select.cpp:271
bool processGraphicsSceneLeftMouseButtonDoubleClicked(QGraphicsSceneMouseEvent &e) noexcept override
Definition: packageeditorstate_select.cpp:201
void setSelectionRect(const Point &p1, const Point &p2) noexcept
Definition: packageeditorstate_select.cpp:602
bool processCopy() noexcept override
Definition: packageeditorstate_select.cpp:262
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
bool pasteFromClipboard() noexcept
Definition: packageeditorstate_select.cpp:519
QScopedPointer< CmdDragSelectedFootprintItems > mCmdDragSelectedItems
Definition: packageeditorstate_select.h:105
bool processGraphicsSceneRightMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexcept override
Definition: packageeditorstate_select.cpp:218
SubState mState
Definition: packageeditorstate_select.h:103
bool processGraphicsSceneLeftMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexcept override
Definition: packageeditorstate_select.cpp:175
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent &e) noexcept override
Definition: packageeditorstate_select.cpp:72
bool processRotateCw() noexcept override
Definition: packageeditorstate_select.cpp:280
bool processAbortCommand() noexcept override
Definition: packageeditorstate_select.cpp:346
The PackageEditorState class is the base class of all package editor FSM states.
Definition: packageeditorstate.h:49
bool processSelectAll() noexcept override
Definition: packageeditorstate_select.cpp:233
bool processRotateCcw() noexcept override
Definition: packageeditorstate_select.cpp:294
bool processFlip() noexcept override
Definition: packageeditorstate_select.cpp:322
bool openPropertiesDialogOfItemAtPos(const Point &pos) noexcept
Definition: packageeditorstate_select.cpp:403
bool rotateSelectedItems(const Angle &angle) noexcept
Definition: packageeditorstate_select.cpp:564
Point mStartPos
Definition: packageeditorstate_select.h:104
~PackageEditorState_Select() noexcept
Definition: packageeditorstate_select.cpp:64
The PackageEditorState_Select class.
Definition: packageeditorstate_select.h:47
PackageEditorState_Select & operator=(const PackageEditorState_Select &rhs)=delete
bool removeSelectedItems() noexcept
Definition: packageeditorstate_select.cpp:593
bool processRemove() noexcept override
Definition: packageeditorstate_select.cpp:337