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{
11
12
16{
17public:
19 ChangeXfAction( const std::string& name, const std::shared_ptr<Object>& obj ) :
20 obj_{ obj },
21 xf_{ obj->xf() },
22 name_{ name }
23 {
24 }
25
27 ChangeXfAction( const std::string& name, const std::shared_ptr<Object>& obj, const AffineXf3f& newXf ) :
28 obj_{ obj },
29 xf_{ obj->xf() },
30 name_{ name }
31 {
32 if ( obj_ )
33 obj_->setXf( newXf );
34 }
35
36 virtual std::string name() const override
37 {
38 return name_;
39 }
40
41 virtual void action( HistoryAction::Type ) override
42 {
43 if ( !obj_ )
44 return;
45 auto tmpXf = obj_->xf();
46 obj_->setXf( xf_ );
47 xf_ = tmpXf;
48 }
49
50 [[nodiscard]] virtual size_t heapBytes() const override
51 {
52 return name_.capacity();
53 }
54
55 const std::shared_ptr<Object> & obj() const
56 {
57 return obj_;
58 }
59
60private:
61 std::shared_ptr<Object> obj_;
62 AffineXf3f xf_;
63 std::string name_;
64};
65
66}
Definition MRChangeXfAction.h:16
Definition MRHistoryAction.h:15
virtual std::string name() const override
Definition MRChangeXfAction.h:36
const std::shared_ptr< Object > & obj() const
Definition MRChangeXfAction.h:55
virtual size_t heapBytes() const override
returns the amount of memory this object occupies on heap
Definition MRChangeXfAction.h:50
Type
Definition MRHistoryAction.h:22
ChangeXfAction(const std::string &name, const std::shared_ptr< Object > &obj, const AffineXf3f &newXf)
use this constructor to remember object's transformation and immediately set new mesh
Definition MRChangeXfAction.h:27
ChangeXfAction(const std::string &name, const std::shared_ptr< Object > &obj)
use this constructor to remember object's transformation before making any changes in it
Definition MRChangeXfAction.h:19
virtual void action(HistoryAction::Type) override
This function is called on history action (undo, redo, etc.)
Definition MRChangeXfAction.h:41
only for bindings generation
Definition MRCameraOrientationPlugin.h:8