Enzo
Loading...
Searching...
No Matches
MoveNodeCommand.h
1#pragma once
2
3#include "Engine/UndoRedo/UndoCommand.h"
4#include "Engine/Network/NetworkManager.h"
5#include "Engine/Types.h"
6
7namespace enzo::nt {
8
10{
11public:
12 MoveNodeCommand(OpId opId, bt::Vector2f oldPos, bt::Vector2f newPos)
13 : opId_(opId), oldPos_(oldPos), newPos_(newPos) {}
14
15 void undo() override
16 {
17 nm().getGeoOperator(opId_).setPosition(oldPos_);
18 nm().nodePositionChanged(opId_, oldPos_);
19 }
20
21 void redo() override
22 {
23 nm().getGeoOperator(opId_).setPosition(newPos_);
24 nm().nodePositionChanged(opId_, newPos_);
25 }
26
27 UndoCommandType type() const override { return UndoCommandType::MoveNode; }
28
29private:
30 OpId opId_;
31 bt::Vector2f oldPos_;
32 bt::Vector2f newPos_;
33};
34
35}
Basic attribute, parameter, and node types for Enzo.
uint64_t OpId
The unique ID assigned to each node in the network.
Definition Types.h:87
void setPosition(bt::Vector2f pos)
Sets the node's position in the network graph.
Definition GeometryOperator.h:158
Definition MoveNodeCommand.h:10
GeometryOperator & getGeoOperator(nt::OpId opId)
Returns a reference to the GeometryOperator with the given OpId.
Definition NetworkManager.cpp:140
Definition UndoCommand.h:8