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 ******************************************************************************/
36namespace librepcb {
37
38class BI_Device;
39class Uuid;
40
41namespace editor {
42
43class CmdDeviceInstanceEditAll;
44
45/*******************************************************************************
46 * Class CmdDeviceInstanceEdit
47 ******************************************************************************/
48
52class CmdDeviceInstanceEdit final : public UndoCommand {
53public:
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
69private:
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
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
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
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:79
The CmdDeviceInstanceEditAll class.
Definition: cmddeviceinstanceeditall.h:51
The CmdDeviceInstanceEdit class.
Definition: cmddeviceinstanceedit.h:52
void performRedo() override
Redo the command.
Definition: cmddeviceinstanceedit.cpp:161
bool mOldLocked
Definition: cmddeviceinstanceedit.h:93
void setPosition(const Point &pos, bool immediate) noexcept
Definition: cmddeviceinstanceedit.cpp:71
BI_Device & mDevice
Definition: cmddeviceinstanceedit.h:84
tl::optional< Uuid > mNewModelUuid
Definition: cmddeviceinstanceedit.h:96
void translate(const Point &deltaPos, bool immediate) noexcept
Definition: cmddeviceinstanceedit.cpp:78
void setLocked(bool locked)
Definition: cmddeviceinstanceedit.cpp:122
CmdDeviceInstanceEdit(BI_Device &dev) noexcept
Definition: cmddeviceinstanceedit.cpp:40
Point mOldPos
Definition: cmddeviceinstanceedit.h:87
tl::optional< Uuid > mOldModelUuid
Definition: cmddeviceinstanceedit.h:95
void setMirrored(bool mirrored, bool immediate)
Definition: cmddeviceinstanceedit.cpp:103
bool mOldMirrored
Definition: cmddeviceinstanceedit.h:91
Angle mNewRotation
Definition: cmddeviceinstanceedit.h:90
void setModel(const tl::optional< Uuid > &uuid) noexcept
Definition: cmddeviceinstanceedit.cpp:127
void performUndo() override
Undo the command.
Definition: cmddeviceinstanceedit.cpp:147
bool mNewMirrored
Definition: cmddeviceinstanceedit.h:92
Point mNewPos
Definition: cmddeviceinstanceedit.h:88
void snapToGrid(const PositiveLength &gridInterval, bool immediate) noexcept
Definition: cmddeviceinstanceedit.cpp:85
void mirror(const Point &center, Qt::Orientation orientation, bool immediate)
Definition: cmddeviceinstanceedit.cpp:111
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:89
~CmdDeviceInstanceEdit() noexcept
Definition: cmddeviceinstanceedit.cpp:55
bool mNewLocked
Definition: cmddeviceinstanceedit.h:94
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:77
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:812