LibrePCB Developers Documentation
cmddeviceinstanceedit.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_CMDDEVICEINSTANCEEDIT_H
21 #define LIBREPCB_EDITOR_CMDDEVICEINSTANCEEDIT_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../../undocommand.h"
27 
31 #include <optional/tl/optional.hpp>
32 
33 /*******************************************************************************
34  * Namespace / Forward Declarations
35  ******************************************************************************/
36 namespace librepcb {
37 
38 class BI_Device;
39 class Uuid;
40 
41 namespace editor {
42 
43 class CmdDeviceInstanceEditAll;
44 
45 /*******************************************************************************
46  * Class CmdDeviceInstanceEdit
47  ******************************************************************************/
48 
52 class CmdDeviceInstanceEdit final : public UndoCommand {
53 public:
54  // Constructors / Destructor
55  explicit CmdDeviceInstanceEdit(BI_Device& dev) noexcept;
56  ~CmdDeviceInstanceEdit() noexcept;
57 
58  // General Methods
59  void setPosition(const Point& pos, bool immediate) noexcept;
60  void translate(const Point& deltaPos, bool immediate) noexcept;
61  void snapToGrid(const PositiveLength& gridInterval, bool immediate) noexcept;
62  void setRotation(const Angle& angle, bool immediate) noexcept;
63  void rotate(const Angle& angle, const Point& center, bool immediate) noexcept;
64  void setMirrored(bool mirrored, bool immediate);
65  void mirror(const Point& center, Qt::Orientation orientation, bool immediate);
66  void setLocked(bool locked);
67  void setModel(const tl::optional<Uuid>& uuid) noexcept;
68 
69 private:
70  // Private Methods
71 
73  bool performExecute() override;
74 
76  void performUndo() override;
77 
79  void performRedo() override;
80 
81  // Private Member Variables
82 
83  // Attributes from the constructor
85 
86  // General Attributes
93  bool mOldLocked;
94  bool mNewLocked;
95  tl::optional<Uuid> mOldModelUuid;
96  tl::optional<Uuid> mNewModelUuid;
97 
99 };
100 
101 /*******************************************************************************
102  * End of File
103  ******************************************************************************/
104 
105 } // namespace editor
106 } // namespace librepcb
107 
108 #endif
void setPosition(const Point &pos, bool immediate) noexcept
Definition: cmddeviceinstanceedit.cpp:71
bool mNewMirrored
Definition: cmddeviceinstanceedit.h:92
bool mNewLocked
Definition: cmddeviceinstanceedit.h:94
void performUndo() override
Undo the command.
Definition: cmddeviceinstanceedit.cpp:147
The CmdDeviceInstanceEditAll class.
Definition: cmddeviceinstanceeditall.h:51
Definition: occmodel.cpp:77
The BI_Device class.
Definition: bi_device.h:57
bool mOldMirrored
Definition: cmddeviceinstanceedit.h:91
void translate(const Point &deltaPos, bool immediate) noexcept
Definition: cmddeviceinstanceedit.cpp:78
tl::optional< Uuid > mOldModelUuid
Definition: cmddeviceinstanceedit.h:95
Angle mOldRotation
Definition: cmddeviceinstanceedit.h:89
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
bool performExecute() override
Execute the command the first time.
Definition: cmddeviceinstanceedit.cpp:136
bool mOldLocked
Definition: cmddeviceinstanceedit.h:93
The CmdDeviceInstanceEdit class.
Definition: cmddeviceinstanceedit.h:52
void snapToGrid(const PositiveLength &gridInterval, bool immediate) noexcept
Definition: cmddeviceinstanceedit.cpp:85
BI_Device & mDevice
Definition: cmddeviceinstanceedit.h:84
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:79
The UndoCommand class represents a command which you can undo/redo.
Definition: undocommand.h:46
CmdDeviceInstanceEdit(BI_Device &dev) noexcept
Definition: cmddeviceinstanceedit.cpp:40
void setModel(const tl::optional< Uuid > &uuid) noexcept
Definition: cmddeviceinstanceedit.cpp:127
void setRotation(const Angle &angle, bool immediate) noexcept
Definition: cmddeviceinstanceedit.cpp:90
void rotate(const Angle &angle, const Point &center, bool immediate) noexcept
Definition: cmddeviceinstanceedit.cpp:97
void mirror(const Point &center, Qt::Orientation orientation, bool immediate)
Definition: cmddeviceinstanceedit.cpp:111
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:812
void setMirrored(bool mirrored, bool immediate)
Definition: cmddeviceinstanceedit.cpp:103
Point mOldPos
Definition: cmddeviceinstanceedit.h:87
Point mNewPos
Definition: cmddeviceinstanceedit.h:88
Angle mNewRotation
Definition: cmddeviceinstanceedit.h:90
void setLocked(bool locked)
Definition: cmddeviceinstanceedit.cpp:122
~CmdDeviceInstanceEdit() noexcept
Definition: cmddeviceinstanceedit.cpp:55
void performRedo() override
Redo the command.
Definition: cmddeviceinstanceedit.cpp:161
tl::optional< Uuid > mNewModelUuid
Definition: cmddeviceinstanceedit.h:96