MeshLib C++ Docs
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
12class ChangeXfAction : public HistoryAction
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
24 ChangeXfAction( const std::string& name, const std::shared_ptr<Object>& obj, const AffineXf3f& newXf ) :
25 obj_{ obj },
26 xf_{ obj->xf() },
27 name_{ name }
28 {
29 if ( obj_ )
30 obj_->setXf( newXf );
31 }
32
33 virtual std::string name() const override
34 {
35 return name_;
36 }
37
38 virtual void action( HistoryAction::Type ) override
39 {
40 if ( !obj_ )
41 return;
42 auto tmpXf = obj_->xf();
43 obj_->setXf( xf_ );
44 xf_ = tmpXf;
45 }
46
47 [[nodiscard]] virtual size_t heapBytes() const override
48 {
49 return name_.capacity();
50 }
51
52 const std::shared_ptr<Object> & obj() const
53 {
54 return obj_;
55 }
56
57private:
58 std::shared_ptr<Object> obj_;
59 AffineXf3f xf_;
60 std::string name_;
61};
62
63} //namespace MR
unsafe void action(MR.HistoryAction.Type _1)
unsafe ChangeXfAction(MR._ByValue_ChangeXfAction _other)
std::string name(const T &primitive)
Definition MRFeatures.h:309
Definition MRCameraOrientationPlugin.h:8