MeshLib C++ Docs
Loading...
Searching...
No Matches
MRChangeScaleAction.h
Go to the documentation of this file.
1#pragma once
2#include "MRHistoryAction.h"
3#include "MRObject.h"
4#include "MRVisualObject.h"
5#include "MRHeapBytes.h"
6#include <memory>
7
8namespace MR
9{
12
13
17{
18public:
20 ChangeScaleAction( const std::string& name, const std::shared_ptr<Object>& obj, float scale ) :
21 obj_{ obj },
22 name_{ name }
23 {
24 if ( obj )
25 {
26 obj->applyScale(scale);
27 scale_ = 1.0f / scale;
28 }
29 }
30
31 virtual std::string name() const override
32 {
33 return name_;
34 }
35
36 virtual void action( HistoryAction::Type ) override
37 {
38 if ( !obj_ )
39 return;
40
41 obj_->applyScale( scale_ );
42 scale_ = 1.0f / scale_;
43 }
44
45 [[nodiscard]] virtual size_t heapBytes() const override
46 {
47 return name_.capacity();
48 }
49
50private:
51 std::shared_ptr<Object> obj_;
52 float scale_ = 1.0f;
53 std::string name_;
54};
55
56}
Definition MRChangeScaleAction.h:17
Definition MRHistoryAction.h:15
virtual std::string name() const override
Definition MRChangeScaleAction.h:31
virtual size_t heapBytes() const override
returns the amount of memory this object occupies on heap
Definition MRChangeScaleAction.h:45
virtual void action(HistoryAction::Type) override
This function is called on history action (undo, redo, etc.)
Definition MRChangeScaleAction.h:36
ChangeScaleAction(const std::string &name, const std::shared_ptr< Object > &obj, float scale)
Constructor that performs object scaling, and remembers inverted scale value for undoing.
Definition MRChangeScaleAction.h:20
Type
Definition MRHistoryAction.h:22
only for bindings generation
Definition MRCameraOrientationPlugin.h:8