LibrePCB Developers Documentation
boardeditorstate_adddevice.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_BOARDEDITORSTATE_ADDDEVICE_H
21 #define LIBREPCB_EDITOR_BOARDEDITORSTATE_ADDDEVICE_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "boardeditorstate.h"
27 
28 #include <QtCore>
29 
30 /*******************************************************************************
31  * Namespace / Forward Declarations
32  ******************************************************************************/
33 namespace librepcb {
34 
35 class Angle;
36 class BI_Device;
37 class Board;
38 class ComponentInstance;
39 
40 namespace editor {
41 
42 class CmdDeviceInstanceEditAll;
43 
44 /*******************************************************************************
45  * Class BoardEditorState_AddDevice
46  ******************************************************************************/
47 
52  Q_OBJECT
53 
54 public:
55  // Constructors / Destructor
56  BoardEditorState_AddDevice() = delete;
58  BoardEditorState_AddDevice(const Context& context) noexcept;
59  virtual ~BoardEditorState_AddDevice() noexcept;
60 
61  // General Methods
62  virtual bool entry() noexcept override;
63  virtual bool exit() noexcept override;
64 
65  // Event Handlers
66  virtual bool processAddDevice(ComponentInstance& component,
67  const Uuid& device,
68  const Uuid& footprint) noexcept override;
69  virtual bool processRotate(const Angle& rotation) noexcept override;
70  virtual bool processFlip(Qt::Orientation orientation) noexcept override;
71  virtual bool processGraphicsSceneMouseMoved(
72  QGraphicsSceneMouseEvent& e) noexcept override;
74  QGraphicsSceneMouseEvent& e) noexcept override;
76  QGraphicsSceneMouseEvent& e) noexcept override;
78  QGraphicsSceneMouseEvent& e) noexcept override;
79 
80  // Operator Overloadings
82  delete;
83 
84 private:
85  // Private Methods
86  bool addDevice(ComponentInstance& cmp, const Uuid& dev,
87  const Uuid& fpt) noexcept;
88  bool rotateDevice(const Angle& angle) noexcept;
89  bool mirrorDevice(Qt::Orientation orientation) noexcept;
90  bool abortCommand(bool showErrMsgBox) noexcept;
91 
92  // State
94 
95  // Information about the current device to place. Only valid if
96  // mIsUndoCmdActive == true.
98  QScopedPointer<CmdDeviceInstanceEditAll> mCurrentDeviceEditCmd;
99 };
100 
101 /*******************************************************************************
102  * End of File
103  ******************************************************************************/
104 
105 } // namespace editor
106 } // namespace librepcb
107 
108 #endif
virtual bool processRotate(const Angle &rotation) noexcept override
Definition: boardeditorstate_adddevice.cpp:83
FSM Context.
Definition: boardeditorfsm.h:88
virtual bool entry() noexcept override
Definition: boardeditorstate_adddevice.cpp:61
Definition: occmodel.cpp:77
The BI_Device class.
Definition: bi_device.h:57
bool mIsUndoCmdActive
Definition: boardeditorstate_adddevice.h:93
virtual bool exit() noexcept override
Definition: boardeditorstate_adddevice.cpp:66
virtual bool processGraphicsSceneLeftMouseButtonDoubleClicked(QGraphicsSceneMouseEvent &e) noexcept override
Definition: boardeditorstate_adddevice.cpp:131
QScopedPointer< CmdDeviceInstanceEditAll > mCurrentDeviceEditCmd
Definition: boardeditorstate_adddevice.h:98
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
bool mirrorDevice(Qt::Orientation orientation) noexcept
Definition: boardeditorstate_adddevice.cpp:201
virtual bool processFlip(Qt::Orientation orientation) noexcept override
Definition: boardeditorstate_adddevice.cpp:87
BoardEditorState_AddDevice & operator=(const BoardEditorState_AddDevice &rhs)=delete
The "add device" state/tool of the board editor.
Definition: boardeditorstate_adddevice.h:51
bool addDevice(ComponentInstance &cmp, const Uuid &dev, const Uuid &fpt) noexcept
Definition: boardeditorstate_adddevice.cpp:152
virtual bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent &e) noexcept override
Definition: boardeditorstate_adddevice.cpp:92
virtual bool processGraphicsSceneRightMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexcept override
Definition: boardeditorstate_adddevice.cpp:136
BI_Device * mCurrentDeviceToPlace
Definition: boardeditorstate_adddevice.h:97
bool abortCommand(bool showErrMsgBox) noexcept
Definition: boardeditorstate_adddevice.cpp:218
bool rotateDevice(const Angle &angle) noexcept
Definition: boardeditorstate_adddevice.cpp:192
virtual bool processAddDevice(ComponentInstance &component, const Uuid &device, const Uuid &footprint) noexcept override
Definition: boardeditorstate_adddevice.cpp:75
The ComponentInstance class.
Definition: componentinstance.h:54
virtual bool processGraphicsSceneLeftMouseButtonPressed(QGraphicsSceneMouseEvent &e) noexcept override
Definition: boardeditorstate_adddevice.cpp:106
virtual ~BoardEditorState_AddDevice() noexcept
Definition: boardeditorstate_adddevice.cpp:54
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
The board editor state base class.
Definition: boardeditorstate.h:59