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{
10
13class ChangeScaleAction : public HistoryAction
14{
15public:
17 ChangeScaleAction( const std::string& name, const std::shared_ptr<Object>& obj, float scale ) :
18 obj_{ obj },
19 name_{ name }
20 {
21 if ( obj )
22 {
23 obj->applyScale(scale);
24 scale_ = 1.0f / scale;
25 }
26 }
27
28 virtual std::string name() const override
29 {
30 return name_;
31 }
32
33 virtual void action( HistoryAction::Type ) override
34 {
35 if ( !obj_ )
36 return;
37
38 obj_->applyScale( scale_ );
39 scale_ = 1.0f / scale_;
40 }
41
42 [[nodiscard]] virtual size_t heapBytes() const override
43 {
44 return name_.capacity();
45 }
46
47private:
48 std::shared_ptr<Object> obj_;
49 float scale_ = 1.0f;
50 std::string name_;
51};
52
53}
unsafe ChangeScaleAction(MR._ByValue_ChangeScaleAction _other)
unsafe void action(MR.HistoryAction.Type _1)
std::string name(const T &primitive)
Definition MRFeatures.h:309
MRVIEWER_API float scale()
Definition MRCameraOrientationPlugin.h:8