MeshLib C++ Docs
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
11class ChangeVisualizePropertyAction : public HistoryAction
12{
13public:
14 using Obj = VisualObject;
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
69class ChangeObjectSelectedAction : public HistoryAction
70{
71public:
72 using Obj = Object;
73
75 ChangeObjectSelectedAction( const std::string& name, const std::shared_ptr<Object>& obj ) :
76 obj_{ obj },
77 name_{ name }
78 {
79 if ( obj )
80 selected_ = obj_->isSelected();
81 }
82
84 ChangeObjectSelectedAction( const std::string& name, const std::shared_ptr<Object>& obj, bool newValue ) :
85 obj_{ obj },
86 name_{ name }
87 {
88 if ( obj )
89 {
90 selected_ = obj_->isSelected();
91 obj_->select( newValue );
92 }
93 }
94
95 virtual std::string name() const override
96 {
97 return name_;
98 }
99
100 virtual void action( HistoryAction::Type ) override
101 {
102 if ( !obj_ )
103 return;
104 auto bufSel = obj_->isSelected();
105 obj_->select( selected_ );
106 selected_ = bufSel;
107 }
108
109 static void setObjectDirty( const std::shared_ptr<Object>& )
110 {}
111
112 [[nodiscard]] virtual size_t heapBytes() const override
113 {
114 return name_.capacity();
115 }
116
117private:
118 std::shared_ptr<Object> obj_;
119 bool selected_{ false };
120 std::string name_;
121};
122
125class ChangeObjectVisibilityAction : public HistoryAction
126{
127public:
128 using Obj = Object;
129
131 ChangeObjectVisibilityAction( const std::string& name, const std::shared_ptr<Object>& obj ) :
132 obj_{ obj },
133 name_{ name }
134 {
135 if ( obj )
136 visibilityMask_ = obj_->visibilityMask();
137 }
138
140 ChangeObjectVisibilityAction( const std::string& name, const std::shared_ptr<Object>& obj, ViewportMask newVisibilityMask ) :
141 obj_{ obj },
142 name_{ name }
143 {
144 if ( obj )
145 {
146 visibilityMask_ = obj_->visibilityMask();
147 obj_->setVisibilityMask( newVisibilityMask );
148 }
149 }
150
151 virtual std::string name() const override
152 {
153 return name_;
154 }
155
156 virtual void action( HistoryAction::Type ) override
157 {
158 if ( !obj_ )
159 return;
160 auto bufVisMask = obj_->visibilityMask();
161 obj_->setVisibilityMask( visibilityMask_ );
162 visibilityMask_ = bufVisMask;
163 }
164
165 static void setObjectDirty( const std::shared_ptr<Object>& )
166 {}
167
168 [[nodiscard]] virtual size_t heapBytes() const override
169 {
170 return name_.capacity();
171 }
172
173private:
174 std::shared_ptr<Object> obj_;
175 ViewportMask visibilityMask_;
176 std::string name_;
177};
178
179}
unsafe void action(MR.HistoryAction.Type _1)
unsafe ChangeObjectSelectedAction(MR._ByValue_ChangeObjectSelectedAction _other)
unsafe void action(MR.HistoryAction.Type _1)
unsafe ChangeObjectVisibilityAction(MR._ByValue_ChangeObjectVisibilityAction _other)
unsafe void action(MR.HistoryAction.Type _1)
unsafe ChangeVisualizePropertyAction(MR._ByValue_ChangeVisualizePropertyAction _other)
std::string name(const T &primitive)
Definition MRFeatures.h:309
Definition MRCameraOrientationPlugin.h:8