MeshLib Documentation
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{
8
12{
13public:
15
17 ChangeVertsColorMapAction( const std::string& name, const std::shared_ptr<VisualObject>& obj ) :
18 obj_{ obj },
19 name_{ name }
20 {
21 if ( obj )
22 vertsColorMap_ = obj->getVertsColorMap();
23 }
24
26 ChangeVertsColorMapAction( const std::string& name, const std::shared_ptr<VisualObject>& obj, VertColors&& newVertsColorMap ) :
27 obj_{ obj },
28 name_{ name }
29 {
30 if ( obj_ )
31 {
32 vertsColorMap_ = std::move( newVertsColorMap );
33 obj_->updateVertsColorMap( vertsColorMap_ );
34 }
35 }
36
37 virtual std::string name() const override
38 {
39 return name_;
40 }
41
42 virtual void action( HistoryAction::Type ) override
43 {
44 if ( !obj_ )
45 return;
46 obj_->updateVertsColorMap( vertsColorMap_ );
47 }
48
49 static void setObjectDirty( const std::shared_ptr<VisualObject>& obj )
50 {
51 if ( obj )
52 obj->setDirtyFlags( DIRTY_VERTS_COLORMAP );
53 }
54
55 [[nodiscard]] virtual size_t heapBytes() const override
56 {
57 return name_.capacity() + vertsColorMap_.capacity();
58 }
59
60private:
61 std::shared_ptr<VisualObject> obj_;
62 VertColors vertsColorMap_;
63 std::string name_;
64};
65
66}
Definition MRChangeVertsColorMapAction.h:12
virtual void action(HistoryAction::Type) override
This function is called on history action (undo, redo, etc.)
Definition MRChangeVertsColorMapAction.h:42
virtual size_t heapBytes() const override
returns the amount of memory this object occupies on heap
Definition MRChangeVertsColorMapAction.h:55
ChangeVertsColorMapAction(const std::string &name, const std::shared_ptr< VisualObject > &obj)
use this constructor to remember object's vertex colors before making any changes in them
Definition MRChangeVertsColorMapAction.h:17
static void setObjectDirty(const std::shared_ptr< VisualObject > &obj)
Definition MRChangeVertsColorMapAction.h:49
ChangeVertsColorMapAction(const std::string &name, const std::shared_ptr< VisualObject > &obj, VertColors &&newVertsColorMap)
use this constructor to remember object's vertex colors and immediate set new value
Definition MRChangeVertsColorMapAction.h:26
virtual std::string name() const override
Definition MRChangeVertsColorMapAction.h:37
Definition MRHistoryAction.h:12
Type
Definition MRHistoryAction.h:19
Visual Object.
Definition MRVisualObject.h:131
@ DIRTY_VERTS_COLORMAP
Definition MRVisualObject.h:100
Definition MRCameraOrientationPlugin.h:8