MeshLib Documentation
Loading...
Searching...
No Matches
MRChangeVoxelSelectionAction.h
Go to the documentation of this file.
1#pragma once
2#include "MRVoxelsFwd.h"
3
5#include "MRObjectVoxels.h"
6
7namespace MR
8{
11
14{
15public:
17
19 ChangVoxelSelectionAction( const std::string& name, const std::shared_ptr<Obj>& objVoxels ) :
20 name_{ name },
21 objVoxels_{ objVoxels }
22 {
23 if ( !objVoxels_ )
24 return;
25 selection_ = objVoxels_->getSelectedVoxels();
26 }
27
28 virtual std::string name() const override
29 {
30 return name_;
31 }
32
33 virtual void action( Type ) override
34 {
35 if ( !objVoxels_ )
36 return;
37 auto tmp = objVoxels_->getSelectedVoxels();
38 objVoxels_->selectVoxels( selection_ );
39 selection_ = std::move( tmp );
40 }
41
42 const VoxelBitSet& selection() const
43 {
44 return selection_;
45 }
46
48 static void setObjectDirty( const std::shared_ptr<Obj>& )
49 {}
50
51 [[nodiscard]] virtual size_t heapBytes() const override
52 {
53 return name_.capacity() + selection_.heapBytes();
54 }
55
56private:
57 std::string name_;
58 std::shared_ptr<Obj> objVoxels_;
59 VoxelBitSet selection_;
60};
61
62}
Undo action for ObjectVoxels face selection.
Definition MRChangeVoxelSelectionAction.h:14
Definition MRHistoryAction.h:12
Type
Definition MRHistoryAction.h:19
Definition MRObjectVoxels.h:17
virtual std::string name() const override
Definition MRChangeVoxelSelectionAction.h:28
static void setObjectDirty(const std::shared_ptr< Obj > &)
empty because set dirty is inside selectFaces
Definition MRChangeVoxelSelectionAction.h:48
const VoxelBitSet & selection() const
Definition MRChangeVoxelSelectionAction.h:42
virtual size_t heapBytes() const override
returns the amount of memory this object occupies on heap
Definition MRChangeVoxelSelectionAction.h:51
ChangVoxelSelectionAction(const std::string &name, const std::shared_ptr< Obj > &objVoxels)
use this constructor to remember object's face selection before making any changes in it
Definition MRChangeVoxelSelectionAction.h:19
virtual void action(Type) override
This function is called on history action (undo, redo, etc.)
Definition MRChangeVoxelSelectionAction.h:33
Definition MRCameraOrientationPlugin.h:8