MeshLib C++ Docs
Loading...
Searching...
No Matches
MRChangeLabelAction.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
MRSymbolMeshFwd.h
"
4
#include "
MRObjectLabel.h
"
5
6
#include "
MRMesh/MRHistoryAction.h
"
7
#include "
MRMesh/MRPositionedText.h
"
8
#include "
MRMesh/MRVector2.h
"
9
10
namespace
MR
11
{
14
15
16
class
ChangeLabelAction
:
public
HistoryAction
17
{
18
public
:
19
ChangeLabelAction
(
const
std::string& actionName, std::shared_ptr<ObjectLabel> obj ) :
20
obj_( std::move( obj ) ),
21
actionName_( actionName )
22
{
23
label_ = obj_->getLabel();
24
pivotPoint_ = obj_->getPivotPoint();
25
}
26
27
28
virtual
std::string
name
()
const override
{
return
actionName_; }
29
30
virtual
void
action
(
HistoryAction::Type
)
override
31
{
32
if
( !obj_ )
33
return
;
34
35
auto
label = obj_->getLabel();
36
obj_->setLabel( std::move( label_ ) );
37
label_ = std::move( label );
38
39
40
auto
pivotPoint = obj_->getPivotPoint();
41
obj_->setPivotPoint( std::move( pivotPoint_ ) );
42
pivotPoint_ = std::move( pivotPoint );
43
}
44
45
[[nodiscard]]
virtual
size_t
heapBytes
()
const override
46
{
47
return
label_.text.capacity() +
sizeof
( float ) * 5 + actionName_.capacity();
48
}
49
private
:
50
std::shared_ptr<ObjectLabel> obj_;
51
PositionedText
label_;
52
Vector2f pivotPoint_;
53
54
std::string actionName_;
55
};
56
57
}
MRHistoryAction.h
MRObjectLabel.h
MRPositionedText.h
MRSymbolMeshFwd.h
MRVector2.h
MR::HistoryAction
Definition
MRHistoryAction.h:15
MR::ChangeLabelAction::ChangeLabelAction
ChangeLabelAction(const std::string &actionName, std::shared_ptr< ObjectLabel > obj)
Definition
MRChangeLabelAction.h:19
MR::ChangeLabelAction::heapBytes
virtual size_t heapBytes() const override
returns the amount of memory this object occupies on heap
Definition
MRChangeLabelAction.h:45
MR::ChangeLabelAction::name
virtual std::string name() const override
Definition
MRChangeLabelAction.h:28
MR::ChangeLabelAction::action
virtual void action(HistoryAction::Type) override
This function is called on history action (undo, redo, etc.)
Definition
MRChangeLabelAction.h:30
MR::HistoryAction::Type
Type
Definition
MRHistoryAction.h:22
MR
only for bindings generation
Definition
MRCameraOrientationPlugin.h:8
MR::PositionedText
Definition
MRPositionedText.h:13
MRSymbolMesh
MRChangeLabelAction.h
Generated by
1.14.0