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
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
Definition MRChangeXfAction.h:13
virtual std::string name() const override
Definition MRChangeXfAction.h:33
const std::shared_ptr< Object > & obj() const
Definition MRChangeXfAction.h:52
virtual size_t heapBytes() const override
returns the amount of memory this object occupies on heap
Definition MRChangeXfAction.h:47
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:24
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:16
virtual void action(HistoryAction::Type) override
This function is called on history action (undo, redo, etc.)
Definition MRChangeXfAction.h:38
Definition MRHistoryAction.h:12
Type
Definition MRHistoryAction.h:19
Definition MRCameraOrientationPlugin.h:8