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
8#include "MRMesh/MRVector2.h"
10
11namespace MR
12{
15
16
18{
19public:
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 }
50private:
51 std::shared_ptr<ObjectLabel> obj_;
52 PositionedText label_;
53 Vector2f pivotPoint_;
54
55 std::string actionName_;
56};
57
58}
ChangeLabelAction(const std::string &actionName, std::shared_ptr< ObjectLabel > obj)
Definition MRChangeLabelAction.h:20
virtual size_t heapBytes() const override
returns the amount of memory this object occupies on heap
Definition MRChangeLabelAction.h:46
virtual std::string name() const override
Definition MRChangeLabelAction.h:29
virtual void action(HistoryAction::Type) override
This function is called on history action (undo, redo, etc.)
Definition MRChangeLabelAction.h:31
Type
Definition MRHistoryAction.h:27
HistoryAction()=default
explicitly define ctors to avoid warning C5267: definition of implicit copy constructor is deprecated...
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRPositionedText.h:13