MeshLib Documentation
Loading...
Searching...
No Matches
MRChangeObjectFields.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 ChangeVisualizePropertyAction( const std::string& name, const std::shared_ptr<VisualObject>& obj, AnyVisualizeMaskEnum visualizeMaskType ) :
18 obj_{ obj },
19 maskType_{ visualizeMaskType },
20 name_{ name }
21 {
22 if ( obj )
23 visualMask_ = obj_->getVisualizePropertyMask( maskType_ );
24 }
25
27 ChangeVisualizePropertyAction( const std::string& name, const std::shared_ptr<VisualObject>& obj, AnyVisualizeMaskEnum visualizeMaskType, ViewportMask newMask ) :
28 obj_{ obj },
29 maskType_{ visualizeMaskType },
30 name_{ name }
31 {
32 if ( obj )
33 {
34 visualMask_ = obj_->getVisualizePropertyMask( maskType_ );
35 obj_->setVisualizePropertyMask( maskType_, newMask );
36 }
37 }
38
39 virtual std::string name() const override
40 {
41 return name_;
42 }
43
44 virtual void action( HistoryAction::Type ) override
45 {
46 if ( !obj_ )
47 return;
48 auto bufMask = obj_->getVisualizePropertyMask( maskType_ );
49 obj_->setVisualizePropertyMask( maskType_, visualMask_ );
50 visualMask_ = bufMask;
51 }
52
53 static void setObjectDirty( const std::shared_ptr<VisualObject>& ){ }
54
55 [[nodiscard]] virtual size_t heapBytes() const override
56 {
57 return name_.capacity();
58 }
59
60private:
61 std::shared_ptr<VisualObject> obj_;
62 ViewportMask visualMask_;
63 AnyVisualizeMaskEnum maskType_;
64 std::string name_;
65};
66
70{
71public:
72 using Obj = Object;
74 ChangeObjectSelectedAction( const std::string& name, const std::shared_ptr<Object>& obj ) :
75 obj_{ obj },
76 name_{ name }
77 {
78 if ( obj )
79 selected_ = obj_->isSelected();
80 }
81
82 virtual std::string name() const override
83 {
84 return name_;
85 }
86
87 virtual void action( HistoryAction::Type ) override
88 {
89 if ( !obj_ )
90 return;
91 auto bufSel = obj_->isSelected();
92 obj_->select( selected_ );
93 selected_ = bufSel;
94 }
95
96 static void setObjectDirty( const std::shared_ptr<Object>& )
97 {}
98
99 [[nodiscard]] virtual size_t heapBytes() const override
100 {
101 return name_.capacity();
102 }
103
104private:
105 std::shared_ptr<Object> obj_;
106 bool selected_{ false };
107 std::string name_;
108};
109
113{
114public:
115 using Obj = Object;
117 ChangeObjectVisibilityAction( const std::string& name, const std::shared_ptr<Object>& obj ) :
118 obj_{ obj },
119 name_{ name }
120 {
121 if ( obj )
122 visibilityMask_ = obj_->visibilityMask();
123 }
124
125 virtual std::string name() const override
126 {
127 return name_;
128 }
129
130 virtual void action( HistoryAction::Type ) override
131 {
132 if ( !obj_ )
133 return;
134 auto bufVisMask = obj_->visibilityMask();
135 obj_->setVisibilityMask( visibilityMask_ );
136 visibilityMask_ = bufVisMask;
137 }
138
139 static void setObjectDirty( const std::shared_ptr<Object>& )
140 {}
141
142 [[nodiscard]] virtual size_t heapBytes() const override
143 {
144 return name_.capacity();
145 }
146
147private:
148 std::shared_ptr<Object> obj_;
149 ViewportMask visibilityMask_;
150 std::string name_;
151};
152
153}
Definition MRVisualObject.h:67
Definition MRChangeObjectFields.h:70
static void setObjectDirty(const std::shared_ptr< Object > &)
Definition MRChangeObjectFields.h:96
virtual size_t heapBytes() const override
returns the amount of memory this object occupies on heap
Definition MRChangeObjectFields.h:99
ChangeObjectSelectedAction(const std::string &name, const std::shared_ptr< Object > &obj)
Constructed from original obj.
Definition MRChangeObjectFields.h:74
virtual void action(HistoryAction::Type) override
This function is called on history action (undo, redo, etc.)
Definition MRChangeObjectFields.h:87
virtual std::string name() const override
Definition MRChangeObjectFields.h:82
Definition MRChangeObjectFields.h:113
virtual size_t heapBytes() const override
returns the amount of memory this object occupies on heap
Definition MRChangeObjectFields.h:142
ChangeObjectVisibilityAction(const std::string &name, const std::shared_ptr< Object > &obj)
Constructed from original obj.
Definition MRChangeObjectFields.h:117
virtual void action(HistoryAction::Type) override
This function is called on history action (undo, redo, etc.)
Definition MRChangeObjectFields.h:130
static void setObjectDirty(const std::shared_ptr< Object > &)
Definition MRChangeObjectFields.h:139
virtual std::string name() const override
Definition MRChangeObjectFields.h:125
Definition MRChangeObjectFields.h:12
static void setObjectDirty(const std::shared_ptr< VisualObject > &)
Definition MRChangeObjectFields.h:53
ChangeVisualizePropertyAction(const std::string &name, const std::shared_ptr< VisualObject > &obj, AnyVisualizeMaskEnum visualizeMaskType, ViewportMask newMask)
use this constructor to remember object's visualize property mask and immediately set new value
Definition MRChangeObjectFields.h:27
ChangeVisualizePropertyAction(const std::string &name, const std::shared_ptr< VisualObject > &obj, AnyVisualizeMaskEnum visualizeMaskType)
use this constructor to remember object's visualize property mask before making any changes in it
Definition MRChangeObjectFields.h:17
virtual void action(HistoryAction::Type) override
This function is called on history action (undo, redo, etc.)
Definition MRChangeObjectFields.h:44
virtual size_t heapBytes() const override
returns the amount of memory this object occupies on heap
Definition MRChangeObjectFields.h:55
virtual std::string name() const override
Definition MRChangeObjectFields.h:39
Definition MRHistoryAction.h:12
Type
Definition MRHistoryAction.h:19
named object in the data model
Definition MRObject.h:60
stores mask of viewport unique identifiers
Definition MRViewportId.h:38
Visual Object.
Definition MRVisualObject.h:131
Definition MRCameraOrientationPlugin.h:8