MeshLib C++ Docs
Loading...
Searching...
No Matches
MRChangeColoringType.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 <memory>
6
7namespace MR
8{
11
12
16{
17public:
19
21 ChangeColoringType( const std::string& name, const std::shared_ptr<VisualObject>& obj ) :
22 obj_{ obj },
23 name_{ name }
24 {
25 if ( obj )
26 coloringType_ = obj->getColoringType();
27 }
28
30 ChangeColoringType( const std::string& name, const std::shared_ptr<VisualObject>& obj, ColoringType newType ) :
31 obj_{ obj },
32 name_{ name }
33 {
34 if ( obj_ )
35 {
36 coloringType_ = obj_->getColoringType();
37 obj_->setColoringType( newType );
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 auto c = obj_->getColoringType();
51 obj_->setColoringType( coloringType_ );
52 coloringType_ = c;
53 }
54
55 static void setObjectDirty( const std::shared_ptr<VisualObject>& 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();
64 }
65
66private:
67 std::shared_ptr<VisualObject> obj_;
69 std::string name_;
70};
71
72}
Visual Object.
Definition MRVisualObject.h:116
ColoringType
Definition MREnums.h:86
static void setObjectDirty(const std::shared_ptr< VisualObject > &obj)
Definition MRChangeColoringType.h:55
VisualObject Obj
Definition MRChangeColoringType.h:18
virtual size_t heapBytes() const override
returns the amount of memory this object occupies on heap
Definition MRChangeColoringType.h:61
virtual std::string name() const override
Definition MRChangeColoringType.h:41
ChangeColoringType(const std::string &name, const std::shared_ptr< VisualObject > &obj, ColoringType newType)
use this constructor to remember object's coloring type and immediate set new value
Definition MRChangeColoringType.h:30
ChangeColoringType(const std::string &name, const std::shared_ptr< VisualObject > &obj)
use this constructor to remember object's coloring type before making any changes in it
Definition MRChangeColoringType.h:21
Type
Definition MRHistoryAction.h:27
HistoryAction()=default
explicitly define ctors to avoid warning C5267: definition of implicit copy constructor is deprecated...
virtual void action(HistoryAction::Type) override
This function is called on history action (undo, redo, etc.)
Definition MRChangeColoringType.h:46
@ SolidColor
Use one color for whole object.
Definition MREnums.h:87
@ DIRTY_VERTS_COLORMAP
Definition MRVisualObject.h:86
only for bindings generation
Definition MRCameraOrientationPlugin.h:8