MeshLib Documentation
Loading...
Searching...
No Matches
MR::HistoryStore Class Reference

This class stores history stack for undo/redo. More...

#include <MRHistoryStore.h>

Public Types

enum class  ChangeType {
  AppendAction , Undo , Redo , Clear ,
  PopAction , Filter
}
 Signal is called after this store changed. More...
 
using HistoryStoreChangedSignal = boost::signals2::signal<void( const HistoryStore& store, ChangeType )>
 

Public Member Functions

virtual MRVIEWER_API ~HistoryStore ()
 
virtual MRVIEWER_API void appendAction (const std::shared_ptr< HistoryAction > &action)
 
HistoryActionsVectorgetScopeBlockPtr () const
 Returns current scope ptr.
 
void setScopeBlockPtr (HistoryActionsVector *scopedBlock)
 Sets pointer to current scope block.
 
bool isSceneModified () const
 Returns true if the current scene state does not match the saved state.
 
void setSavedState ()
 Consider the current scene state as saved.
 
MRVIEWER_API void clear ()
 Clears this HistoryStore.
 
void setMemoryLimit (size_t limit)
 Set memory limit for this store, if history stack exceed it - old actions are removed.
 
size_t getMemoryLimit () const
 Returns current memory limit for this store (by default uint64 max)
 
MRVIEWER_API size_t calcUsedMemory () const
 Compute amount of memory occupied by all actions in this store.
 
const HistoryActionsVectorgetHistoryStack () const
 Returns full history stack.
 
size_t getStackPointer () const
 Returns index of first redo action in stack.
 
MRVIEWER_API void filterStack (HistoryStackFilter filteringCondition, bool deepFiltering=true)
 remove some actions according to condition
 
virtual MRVIEWER_API bool undo ()
 
virtual MRVIEWER_API bool redo ()
 
MRVIEWER_API std::vector< std::string > getNActions (unsigned n, HistoryAction::Type type) const
 Returns names of last N undo actions or first N redo actions.
 
MRVIEWER_API std::string getLastActionName (HistoryAction::Type type) const
 Returns the name of last undo or redo action (or empty string if there is no such action)
 

Static Public Member Functions

static MRVIEWER_API const std::shared_ptr< HistoryStore > & getViewerInstance ()
 returns the instance (if any) of HistoryStore from the viewer
 

Public Attributes

HistoryStoreChangedSignal changedSignal
 

Detailed Description

This class stores history stack for undo/redo.

Member Typedef Documentation

◆ HistoryStoreChangedSignal

using MR::HistoryStore::HistoryStoreChangedSignal = boost::signals2::signal<void( const HistoryStore& store, ChangeType )>

Member Enumeration Documentation

◆ ChangeType

enum class MR::HistoryStore::ChangeType
strong

Signal is called after this store changed.

Enumerator
AppendAction 

additions in scoped block does not provide signal

Undo 
Redo 
Clear 
PopAction 

called after removing action that exceeds memory limit

Filter 

Constructor & Destructor Documentation

◆ ~HistoryStore()

virtual MRVIEWER_API MR::HistoryStore::~HistoryStore ( )
virtual

Member Function Documentation

◆ appendAction()

virtual MRVIEWER_API void MR::HistoryStore::appendAction ( const std::shared_ptr< HistoryAction > & action)
virtual

Adds action in history stack (clears available redo actions) adds actions to scope block if scope mode is active (do not affect main stack)

◆ calcUsedMemory()

MRVIEWER_API size_t MR::HistoryStore::calcUsedMemory ( ) const
nodiscard

Compute amount of memory occupied by all actions in this store.

◆ clear()

MRVIEWER_API void MR::HistoryStore::clear ( )

Clears this HistoryStore.

◆ filterStack()

MRVIEWER_API void MR::HistoryStore::filterStack ( HistoryStackFilter filteringCondition,
bool deepFiltering = true )

remove some actions according to condition

◆ getHistoryStack()

const HistoryActionsVector & MR::HistoryStore::getHistoryStack ( ) const
inlinenodiscard

Returns full history stack.

◆ getLastActionName()

MRVIEWER_API std::string MR::HistoryStore::getLastActionName ( HistoryAction::Type type) const
nodiscard

Returns the name of last undo or redo action (or empty string if there is no such action)

◆ getMemoryLimit()

size_t MR::HistoryStore::getMemoryLimit ( ) const
inlinenodiscard

Returns current memory limit for this store (by default uint64 max)

◆ getNActions()

MRVIEWER_API std::vector< std::string > MR::HistoryStore::getNActions ( unsigned n,
HistoryAction::Type type ) const
nodiscard

Returns names of last N undo actions or first N redo actions.

◆ getScopeBlockPtr()

HistoryActionsVector * MR::HistoryStore::getScopeBlockPtr ( ) const
inlinenodiscard

Returns current scope ptr.

◆ getStackPointer()

size_t MR::HistoryStore::getStackPointer ( ) const
inlinenodiscard

Returns index of first redo action in stack.

◆ getViewerInstance()

static MRVIEWER_API const std::shared_ptr< HistoryStore > & MR::HistoryStore::getViewerInstance ( )
staticnodiscard

returns the instance (if any) of HistoryStore from the viewer

◆ isSceneModified()

bool MR::HistoryStore::isSceneModified ( ) const
inlinenodiscard

Returns true if the current scene state does not match the saved state.

◆ redo()

virtual MRVIEWER_API bool MR::HistoryStore::redo ( )
virtual

◆ setMemoryLimit()

void MR::HistoryStore::setMemoryLimit ( size_t limit)
inline

Set memory limit for this store, if history stack exceed it - old actions are removed.

◆ setSavedState()

void MR::HistoryStore::setSavedState ( )
inline

Consider the current scene state as saved.

◆ setScopeBlockPtr()

void MR::HistoryStore::setScopeBlockPtr ( HistoryActionsVector * scopedBlock)
inline

Sets pointer to current scope block.

◆ undo()

virtual MRVIEWER_API bool MR::HistoryStore::undo ( )
virtual

Member Data Documentation

◆ changedSignal

HistoryStoreChangedSignal MR::HistoryStore::changedSignal

The documentation for this class was generated from the following file: