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
#include "
MRMesh/MRHeapBytes.h
"
10
11
namespace
MR
12
{
15
16
17
class
ChangeLabelAction
:
public
HistoryAction
18
{
19
public
:
20
ChangeLabelAction
(
const
std::string& actionName, std::shared_ptr<ObjectLabel> obj ) :
21
obj_( std::move( obj ) ),
22
actionName_( actionName )
23
{
24
label_ = obj_->getLabel();
25
pivotPoint_ = obj_->getPivotPoint();
26
}
27
28
29
virtual
std::string
name
()
const override
{
return
actionName_; }
30
31
virtual
void
action
(
HistoryAction::Type
)
override
32
{
33
if
( !obj_ )
34
return
;
35
36
auto
label = obj_->getLabel();
37
obj_->setLabel( std::move( label_ ) );
38
label_ = std::move( label );
39
40
41
auto
pivotPoint = obj_->getPivotPoint();
42
obj_->setPivotPoint( std::move( pivotPoint_ ) );
43
pivotPoint_ = std::move( pivotPoint );
44
}
45
46
[[nodiscard]]
virtual
size_t
heapBytes
()
const override
47
{
48
return
label_.text.capacity() +
sizeof
( float ) * 5 + actionName_.capacity();
49
}
50
private
:
51
std::shared_ptr<ObjectLabel> obj_;
52
PositionedText
label_;
53
Vector2f pivotPoint_;
54
55
std::string actionName_;
56
};
57
58
}
MRHeapBytes.h
MRHistoryAction.h
MRObjectLabel.h
MRPositionedText.h
MRSymbolMeshFwd.h
MRVector2.h
MR::ChangeLabelAction::ChangeLabelAction
ChangeLabelAction(const std::string &actionName, std::shared_ptr< ObjectLabel > obj)
Definition
MRChangeLabelAction.h:20
MR::ChangeLabelAction::heapBytes
virtual size_t heapBytes() const override
returns the amount of memory this object occupies on heap
Definition
MRChangeLabelAction.h:46
MR::ChangeLabelAction::name
virtual std::string name() const override
Definition
MRChangeLabelAction.h:29
MR::ChangeLabelAction::action
virtual void action(HistoryAction::Type) override
This function is called on history action (undo, redo, etc.)
Definition
MRChangeLabelAction.h:31
MR::HistoryAction::Type
Type
Definition
MRHistoryAction.h:27
MR::HistoryAction::HistoryAction
HistoryAction()=default
explicitly define ctors to avoid warning C5267: definition of implicit copy constructor is deprecated...
MR
only for bindings generation
Definition
MRCameraOrientationPlugin.h:8
MR::PositionedText
Definition
MRPositionedText.h:13
MRSymbolMesh
MRChangeLabelAction.h
Generated by
1.14.0