MeshLib Documentation
Loading...
Searching...
No Matches
MRChangeSelectionAction.h
Go to the documentation of this file.
1#pragma once
2#include "MRHistoryAction.h"
3#include "MRObjectMesh.h"
4#include "MRObjectPoints.h"
5
6namespace MR
7{
8
11
14{
15public:
16 using Obj = ObjectMesh;
17
19 ChangeMeshFaceSelectionAction( const std::string& name, const std::shared_ptr<ObjectMesh>& objMesh ):
20 name_{name},
21 objMesh_{objMesh}
22 {
23 if ( !objMesh_ )
24 return;
25 selection_ = objMesh_->getSelectedFaces();
26 }
27
29 ChangeMeshFaceSelectionAction( const std::string& name, const std::shared_ptr<ObjectMesh>& objMesh, FaceBitSet&& newSelection ):
30 name_{name},
31 objMesh_{objMesh}
32 {
33 if ( !objMesh_ )
34 return;
35 selection_ = objMesh_->getSelectedFaces();
36 objMesh_->selectFaces( std::move( newSelection ) );
37 }
38
39 virtual std::string name() const override { return name_; }
40
41 virtual void action( Type ) override
42 {
43 if ( !objMesh_ )
44 return;
45 auto tmp = objMesh_->getSelectedFaces();
46 objMesh_->selectFaces( selection_ );
47 selection_ = std::move( tmp );
48 }
49
50 const FaceBitSet & selection() const { return selection_; }
51
53 static void setObjectDirty( const std::shared_ptr<ObjectMesh>& ) {}
54
55 [[nodiscard]] virtual size_t heapBytes() const override
56 {
57 return name_.capacity() + selection_.heapBytes();
58 }
59
60private:
61 std::string name_;
62 std::shared_ptr<ObjectMesh> objMesh_;
63 FaceBitSet selection_;
64};
65
68{
69public:
70 using Obj = ObjectMesh;
71
73 ChangeMeshEdgeSelectionAction( const std::string& name, const std::shared_ptr<ObjectMesh>& objMesh ) :
74 name_{ name },
75 objMesh_{ objMesh }
76 {
77 if( !objMesh_ )
78 return;
79 selection_ = objMesh_->getSelectedEdges();
80 }
81
83 ChangeMeshEdgeSelectionAction( const std::string& name, const std::shared_ptr<ObjectMesh>& objMesh, UndirectedEdgeBitSet&& newSelection ) :
84 name_{ name },
85 objMesh_{ objMesh }
86 {
87 if( !objMesh_ )
88 return;
89 selection_ = objMesh_->getSelectedEdges();
90 objMesh_->selectEdges( std::move( newSelection ) );
91 }
92
93 virtual std::string name() const override { return name_; }
94
95 virtual void action( Type ) override
96 {
97 if( !objMesh_ )
98 return;
99 auto tmp = objMesh_->getSelectedEdges();
100 objMesh_->selectEdges( std::move( selection_ ) );
101 selection_ = std::move( tmp );
102 }
103
104 const UndirectedEdgeBitSet & selection() const { return selection_; }
105
107 static void setObjectDirty( const std::shared_ptr<ObjectMesh>& ) {}
108
109 [[nodiscard]] virtual size_t heapBytes() const override
110 {
111 return name_.capacity() + selection_.heapBytes();
112 }
113
114private:
115 std::string name_;
116 std::shared_ptr<ObjectMesh> objMesh_;
117 UndirectedEdgeBitSet selection_;
118};
119
122{
123public:
125
127 ChangeMeshCreasesAction( const std::string& name, const std::shared_ptr<ObjectMesh>& objMesh ) :
128 name_{ name },
129 objMesh_{ objMesh }
130 {
131 if( !objMesh_ )
132 return;
133 creases_ = objMesh_->creases();
134 }
135
136 virtual std::string name() const override { return name_; }
137
138 virtual void action( Type ) override
139 {
140 if( !objMesh_ )
141 return;
142 auto tmp = objMesh_->creases();
143 objMesh_->setCreases( std::move( creases_ ) );
144 creases_ = std::move( tmp );
145 }
146
147 const UndirectedEdgeBitSet & creases() const { return creases_; }
148
150 static void setObjectDirty( const std::shared_ptr<ObjectMesh>& ) {}
151
152 [[nodiscard]] virtual size_t heapBytes() const override
153 {
154 return name_.capacity() + creases_.heapBytes();
155 }
156
157private:
158 std::string name_;
159 std::shared_ptr<ObjectMesh> objMesh_;
160 UndirectedEdgeBitSet creases_;
161};
162
165{
166public:
168
170 ChangePointPointSelectionAction( const std::string& name, const std::shared_ptr<ObjectPoints>& objPoints ) :
171 name_{ name },
172 objPoints_{ objPoints }
173 {
174 if ( !objPoints_ )
175 return;
176 selection_ = objPoints_->getSelectedPoints();
177 }
178
179 virtual std::string name() const override { return name_; }
180
181 virtual void action( Type ) override
182 {
183 if ( !objPoints_ )
184 return;
185 auto tmp = objPoints_->getSelectedPoints();
186 objPoints_->selectPoints( selection_ );
187 selection_ = std::move( tmp );
188 }
189
190 const VertBitSet& selection() const { return selection_; }
191
193 static void setObjectDirty( const std::shared_ptr<ObjectPoints>& )
194 {}
195
196 [[nodiscard]] virtual size_t heapBytes() const override
197 {
198 return name_.capacity() + selection_.heapBytes();
199 }
200
201private:
202 std::string name_;
203 std::shared_ptr<ObjectPoints> objPoints_;
204 VertBitSet selection_;
205};
206
208
209}
Undo action for ObjectMesh creases.
Definition MRChangeSelectionAction.h:122
virtual void action(Type) override
This function is called on history action (undo, redo, etc.)
Definition MRChangeSelectionAction.h:138
ChangeMeshCreasesAction(const std::string &name, const std::shared_ptr< ObjectMesh > &objMesh)
use this constructor to remember object's creases before making any changes in it
Definition MRChangeSelectionAction.h:127
static void setObjectDirty(const std::shared_ptr< ObjectMesh > &)
empty because set dirty is inside setCreases
Definition MRChangeSelectionAction.h:150
virtual size_t heapBytes() const override
returns the amount of memory this object occupies on heap
Definition MRChangeSelectionAction.h:152
const UndirectedEdgeBitSet & creases() const
Definition MRChangeSelectionAction.h:147
virtual std::string name() const override
Definition MRChangeSelectionAction.h:136
Undo action for ObjectMesh edge selection.
Definition MRChangeSelectionAction.h:68
virtual size_t heapBytes() const override
returns the amount of memory this object occupies on heap
Definition MRChangeSelectionAction.h:109
static void setObjectDirty(const std::shared_ptr< ObjectMesh > &)
empty because set dirty is inside selectEdges
Definition MRChangeSelectionAction.h:107
ChangeMeshEdgeSelectionAction(const std::string &name, const std::shared_ptr< ObjectMesh > &objMesh)
use this constructor to remember object's edge selection before making any changes in it
Definition MRChangeSelectionAction.h:73
virtual std::string name() const override
Definition MRChangeSelectionAction.h:93
const UndirectedEdgeBitSet & selection() const
Definition MRChangeSelectionAction.h:104
ChangeMeshEdgeSelectionAction(const std::string &name, const std::shared_ptr< ObjectMesh > &objMesh, UndirectedEdgeBitSet &&newSelection)
use this constructor to remember object's edge selection and immediate set new selection
Definition MRChangeSelectionAction.h:83
virtual void action(Type) override
This function is called on history action (undo, redo, etc.)
Definition MRChangeSelectionAction.h:95
Undo action for ObjectMesh face selection.
Definition MRChangeSelectionAction.h:14
virtual size_t heapBytes() const override
returns the amount of memory this object occupies on heap
Definition MRChangeSelectionAction.h:55
const FaceBitSet & selection() const
Definition MRChangeSelectionAction.h:50
virtual void action(Type) override
This function is called on history action (undo, redo, etc.)
Definition MRChangeSelectionAction.h:41
virtual std::string name() const override
Definition MRChangeSelectionAction.h:39
ChangeMeshFaceSelectionAction(const std::string &name, const std::shared_ptr< ObjectMesh > &objMesh)
use this constructor to remember object's face selection before making any changes in it
Definition MRChangeSelectionAction.h:19
ChangeMeshFaceSelectionAction(const std::string &name, const std::shared_ptr< ObjectMesh > &objMesh, FaceBitSet &&newSelection)
use this constructor to remember object's face selection and immediate set new value
Definition MRChangeSelectionAction.h:29
static void setObjectDirty(const std::shared_ptr< ObjectMesh > &)
empty because set dirty is inside selectFaces
Definition MRChangeSelectionAction.h:53
Undo action for ObjectPoints point selection.
Definition MRChangeSelectionAction.h:165
const VertBitSet & selection() const
Definition MRChangeSelectionAction.h:190
ChangePointPointSelectionAction(const std::string &name, const std::shared_ptr< ObjectPoints > &objPoints)
use this constructor to remember object's vertex selection before making any changes in it
Definition MRChangeSelectionAction.h:170
static void setObjectDirty(const std::shared_ptr< ObjectPoints > &)
empty because set dirty is inside selectPoints
Definition MRChangeSelectionAction.h:193
virtual std::string name() const override
Definition MRChangeSelectionAction.h:179
virtual void action(Type) override
This function is called on history action (undo, redo, etc.)
Definition MRChangeSelectionAction.h:181
virtual size_t heapBytes() const override
returns the amount of memory this object occupies on heap
Definition MRChangeSelectionAction.h:196
Definition MRHistoryAction.h:12
Type
Definition MRHistoryAction.h:19
Definition MRObjectMesh.h:11
Definition MRObjectPoints.h:11
Definition MRCameraOrientationPlugin.h:8