MeshLib C++ Docs
Loading...
Searching...
No Matches
MRChangeVertsColorMapAction.h
Go to the documentation of this file.
1#pragma once
2#include "MRHistoryAction.h"
3#include "MRVisualObject.h"
4#include <memory>
5
6namespace MR
7{
10
11
14template<typename T>
16{
17public:
18 using Obj = T;
19
21 ChangeVertsColorMapAction( const std::string& name, const std::shared_ptr<T>& obj ) :
22 obj_{ obj },
23 name_{ name }
24 {
25 if ( obj )
26 vertsColorMap_ = obj->getVertsColorMap();
27 }
28
30 ChangeVertsColorMapAction( const std::string& name, const std::shared_ptr<T>& obj, VertColors&& newVertsColorMap ) :
31 obj_{ obj },
32 name_{ name }
33 {
34 if ( obj_ )
35 {
36 vertsColorMap_ = std::move( newVertsColorMap );
37 obj_->updateVertsColorMap( vertsColorMap_ );
38 }
39 }
40
41 virtual std::string name() const override
42 {
43 return name_;
44 }
45
46 virtual void action( HistoryAction::Type ) override
47 {
48 if ( !obj_ )
49 return;
50 obj_->updateVertsColorMap( vertsColorMap_ );
51 }
52
53 static void setObjectDirty( const std::shared_ptr<T>& obj )
54 {
55 if ( obj )
56 obj->setDirtyFlags( DIRTY_VERTS_COLORMAP );
57 }
58
59 [[nodiscard]] virtual size_t heapBytes() const override
60 {
61 return name_.capacity() + vertsColorMap_.capacity();
62 }
63
64private:
65 std::shared_ptr<T> obj_;
66 VertColors vertsColorMap_;
67 std::string name_;
68};
69
70}
Definition MRChangeVertsColorMapAction.h:16
Definition MRHistoryAction.h:15
static void setObjectDirty(const std::shared_ptr< T > &obj)
Definition MRChangeVertsColorMapAction.h:53
ChangeVertsColorMapAction(const std::string &name, const std::shared_ptr< T > &obj, VertColors &&newVertsColorMap)
use this constructor to remember object's vertex colors and immediate set new value
Definition MRChangeVertsColorMapAction.h:30
virtual std::string name() const override
Definition MRChangeVertsColorMapAction.h:41
T Obj
Definition MRChangeVertsColorMapAction.h:18
virtual size_t heapBytes() const override
returns the amount of memory this object occupies on heap
Definition MRChangeVertsColorMapAction.h:59
virtual void action(HistoryAction::Type) override
This function is called on history action (undo, redo, etc.)
Definition MRChangeVertsColorMapAction.h:46
Type
Definition MRHistoryAction.h:22
ChangeVertsColorMapAction(const std::string &name, const std::shared_ptr< T > &obj)
use this constructor to remember object's vertex colors before making any changes in them
Definition MRChangeVertsColorMapAction.h:21
@ DIRTY_VERTS_COLORMAP
Definition MRVisualObject.h:86
only for bindings generation
Definition MRCameraOrientationPlugin.h:8