MeshLib Documentation
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"
9
10namespace MR
11{
12
14{
15public:
16 ChangeLabelAction( const std::string& actionName, std::shared_ptr<ObjectLabel> obj ) :
17 obj_( std::move( obj ) ),
18 actionName_( actionName )
19 {
20 label_ = obj_->getLabel();
21 pivotPoint_ = obj_->getPivotPoint();
22 }
23
24
25 virtual std::string name() const override { return actionName_; }
26
27 virtual void action( HistoryAction::Type ) override
28 {
29 if ( !obj_ )
30 return;
31
32 auto label = obj_->getLabel();
33 obj_->setLabel( std::move( label_ ) );
34 label_ = std::move( label );
35
36
37 auto pivotPoint = obj_->getPivotPoint();
38 obj_->setPivotPoint( std::move( pivotPoint_ ) );
39 pivotPoint_ = std::move( pivotPoint );
40 }
41
42 [[nodiscard]] virtual size_t heapBytes() const override
43 {
44 return label_.text.capacity() + sizeof( float ) * 5 + actionName_.capacity();
45 }
46private:
47 std::shared_ptr<ObjectLabel> obj_;
48 PositionedText label_;
49 Vector2f pivotPoint_;
50
51 std::string actionName_;
52};
53
54}
Definition MRChangeLabelAction.h:14
ChangeLabelAction(const std::string &actionName, std::shared_ptr< ObjectLabel > obj)
Definition MRChangeLabelAction.h:16
virtual size_t heapBytes() const override
returns the amount of memory this object occupies on heap
Definition MRChangeLabelAction.h:42
virtual std::string name() const override
Definition MRChangeLabelAction.h:25
virtual void action(HistoryAction::Type) override
This function is called on history action (undo, redo, etc.)
Definition MRChangeLabelAction.h:27
Definition MRHistoryAction.h:12
Type
Definition MRHistoryAction.h:19
Definition MRCameraOrientationPlugin.h:8
Definition MRPositionedText.h:9
std::string text
Definition MRPositionedText.h:13