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