MeshLib Documentation
Loading...
Searching...
No Matches
MRChangeXfAction.h
Go to the documentation of this file.
1#pragma once
2#include "MRHistoryAction.h"
3#include "MRObject.h"
4#include "MRAffineXf3.h"
5#include <memory>
6
7namespace MR
8{
9
13{
14public:
16 ChangeXfAction( const std::string& name, const std::shared_ptr<Object>& obj ) :
17 obj_{ obj },
18 xf_{ obj->xf() },
19 name_{ name }
20 {
21 }
22
23 virtual std::string name() const override
24 {
25 return name_;
26 }
27
28 virtual void action( HistoryAction::Type ) override
29 {
30 if ( !obj_ )
31 return;
32 auto tmpXf = obj_->xf();
33 obj_->setXf( xf_ );
34 xf_ = tmpXf;
35 }
36
37 [[nodiscard]] virtual size_t heapBytes() const override
38 {
39 return name_.capacity();
40 }
41
42private:
43 std::shared_ptr<Object> obj_;
44 AffineXf3f xf_;
45 std::string name_;
46};
47
48}
Definition MRChangeXfAction.h:13
virtual std::string name() const override
Definition MRChangeXfAction.h:23
virtual size_t heapBytes() const override
returns the amount of memory this object occupies on heap
Definition MRChangeXfAction.h:37
ChangeXfAction(const std::string &name, const std::shared_ptr< Object > &obj)
Constructed from original obj.
Definition MRChangeXfAction.h:16
virtual void action(HistoryAction::Type) override
This function is called on history action (undo, redo, etc.)
Definition MRChangeXfAction.h:28
Definition MRHistoryAction.h:12
Type
Definition MRHistoryAction.h:19
Definition MRCameraOrientationPlugin.h:8