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