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 "MRHeapBytes.h"
5#include "MRVector.h"
6#include <memory>
7
8namespace MR
9{
12
13
16template<typename T>
18{
19public:
20 using Obj = T;
21
23 ChangeVertsColorMapAction( const std::string& name, const std::shared_ptr<T>& obj ) :
24 obj_{ obj },
25 name_{ name }
26 {
27 if ( obj )
28 vertsColorMap_ = obj->getVertsColorMap();
29 }
30
32 ChangeVertsColorMapAction( const std::string& name, const std::shared_ptr<T>& obj, VertColors&& newVertsColorMap ) :
33 obj_{ obj },
34 name_{ name }
35 {
36 if ( obj_ )
37 {
38 vertsColorMap_ = std::move( newVertsColorMap );
39 obj_->updateVertsColorMap( vertsColorMap_ );
40 }
41 }
42
43 virtual std::string name() const override
44 {
45 return name_;
46 }
47
48 virtual void action( HistoryAction::Type ) override
49 {
50 if ( !obj_ )
51 return;
52 obj_->updateVertsColorMap( vertsColorMap_ );
53 }
54
55 static void setObjectDirty( const std::shared_ptr<T>& obj )
56 {
57 if ( obj )
58 obj->setDirtyFlags( DIRTY_VERTS_COLORMAP );
59 }
60
61 [[nodiscard]] virtual size_t heapBytes() const override
62 {
63 return name_.capacity() + vertsColorMap_.capacity();
64 }
65
66private:
67 std::shared_ptr<T> obj_;
68 VertColors vertsColorMap_;
69 std::string name_;
70};
71
72}
static void setObjectDirty(const std::shared_ptr< T > &obj)
Definition MRChangeVertsColorMapAction.h:55
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:32
virtual std::string name() const override
Definition MRChangeVertsColorMapAction.h:43
T Obj
Definition MRChangeVertsColorMapAction.h:20
virtual size_t heapBytes() const override
returns the amount of memory this object occupies on heap
Definition MRChangeVertsColorMapAction.h:61
virtual void action(HistoryAction::Type) override
This function is called on history action (undo, redo, etc.)
Definition MRChangeVertsColorMapAction.h:48
Type
Definition MRHistoryAction.h:27
HistoryAction()=default
explicitly define ctors to avoid warning C5267: definition of implicit copy constructor is deprecated...
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:23
@ DIRTY_VERTS_COLORMAP
Definition MRVisualObject.h:86
only for bindings generation
Definition MRCameraOrientationPlugin.h:8