#include <mitkUndoController.h>
Public Types | |
enum | UndoType { LIMITEDLINEARUNDO = 10, VERBOSE_LIMITEDLINEARUNDO = 11, TREEUNDO = 20 } |
typedef std::map< UndoType, UndoModel::Pointer > | UndoModelMap |
typedef std::map< UndoType, UndoModel::Pointer >::iterator | UndoModelMapIter |
Public Member Functions | |
UndoController (UndoType undoType=DEFAULTUNDOMODEL) | |
virtual | ~UndoController () |
bool | SetOperationEvent (UndoStackItem *operationEvent) |
bool | Undo () |
calls the UndoMechanism to undo the last change | |
bool | Undo (bool fine) |
calls the UndoMechanism to undo the last change | |
bool | Redo () |
calls the RedoMechanism to redo the operations undone | |
bool | Redo (bool fine) |
calls the RedoMechanism to redo the operations undone | |
void | Clear () |
Clears the Undo and the RedoList. | |
void | ClearRedoList () |
Clears the RedoList. | |
bool | RedoListEmpty () |
returns true, if the RedoList is empty | |
bool | SwitchUndoModel (UndoType undoType) |
bool | AddUndoModel (UndoType undoType) |
bool | RemoveUndoModel (UndoType undoType) |
int | GetLastObjectEventIdInList () |
returns the ObjectEventId of the top Element in the OperationHistory of the selected UndoModel | |
int | GetLastGroupEventIdInList () |
returns the GroupEventId of the top Element in the OperationHistory of the selected UndoModel | |
OperationEvent * | GetLastOfType (OperationActor *destination, OperationType opType) |
returns the last specified OperationEvent in Undo-list corresponding to the given value; if nothing found, then returns NULL | |
Static Public Member Functions | |
static UndoModel * | GetCurrentUndoModel () |
gives access to the currently used UndoModel Introduced to access special functions of more specific UndoModels, especially to retrieve text descriptions of the undo/redo stack | |
Static Public Attributes | |
static const UndoType | DEFAULTUNDOMODEL = VERBOSE_LIMITEDLINEARUNDO |
Default UndoModel to use. |
Definition at line 31 of file mitkUndoController.h.
typedef std::map<UndoType, UndoModel::Pointer> mitk::UndoController::UndoModelMap |
Definition at line 37 of file mitkUndoController.h.
typedef std::map<UndoType, UndoModel::Pointer>::iterator mitk::UndoController::UndoModelMapIter |
Definition at line 38 of file mitkUndoController.h.
Definition at line 35 of file mitkUndoController.h.
{LIMITEDLINEARUNDO=10, VERBOSE_LIMITEDLINEARUNDO=11, TREEUNDO=20};
mitk::UndoController::UndoController | ( | UndoType | undoType = DEFAULTUNDOMODEL ) |
Constructor; Adds the new UndoType or if undoType exists , switches it to undoType; for UndoTypes see definitionmitkInteractionConst.h
Definition at line 34 of file mitkUndoController.cpp.
References LIMITEDLINEARUNDO, mitk::VerboseLimitedLinearUndo::New(), mitk::LimitedLinearUndo::New(), SwitchUndoModel(), and VERBOSE_LIMITEDLINEARUNDO.
{ if (SwitchUndoModel(undoType)==false) //existiert noch nicht in static-Liste { switch (undoType) { case LIMITEDLINEARUNDO: m_CurUndoModel = mitk::LimitedLinearUndo::New(); m_CurUndoType = undoType; m_UndoModelList.insert(UndoModelMap::value_type(undoType, m_CurUndoModel)); break; case VERBOSE_LIMITEDLINEARUNDO: m_CurUndoModel = mitk::VerboseLimitedLinearUndo::New(); m_CurUndoType = undoType; m_UndoModelList.insert(UndoModelMap::value_type(undoType, m_CurUndoModel)); break; //case ### //insert here, in add- and RemoveUndoModel new sets of UndoModels! //break; default : m_CurUndoModel = VerboseLimitedLinearUndo::New(); m_CurUndoType = undoType; m_UndoModelList.insert(UndoModelMap::value_type(undoType, m_CurUndoModel)); } } }
mitk::UndoController::~UndoController | ( | ) | [virtual] |
Definition at line 61 of file mitkUndoController.cpp.
{ }
bool mitk::UndoController::AddUndoModel | ( | UndoType | undoType ) |
adds a new kind of UndoModel to the set of UndoModels and switches to that UndoModel if the UndoModel exists already in the List, then nothing is done
Definition at line 141 of file mitkUndoController.cpp.
References mitk::VerboseLimitedLinearUndo::New(), and mitk::LimitedLinearUndo::New().
Referenced by mitkUndoControllerTest().
{ if (m_UndoModelList.find(undoType) != m_UndoModelList.end()) { //UndoModel already exists return false; } //doesn't already exist in list switch (undoType) { case LIMITEDLINEARUNDO: m_CurUndoModel = LimitedLinearUndo::New(); m_CurUndoType = undoType; m_UndoModelList.insert(UndoModelMap::value_type(undoType, m_CurUndoModel)); break; case VERBOSE_LIMITEDLINEARUNDO: m_CurUndoModel = VerboseLimitedLinearUndo::New(); m_CurUndoType = undoType; m_UndoModelList.insert(UndoModelMap::value_type(undoType, m_CurUndoModel)); break; default: //that undoType is not implemented! return false; } return true; }
void mitk::UndoController::Clear | ( | ) |
Clears the Undo and the RedoList.
Definition at line 100 of file mitkUndoController.cpp.
Referenced by mitkVerboseLimitedLinearUndoTest().
{ m_CurUndoModel->Clear(); }
void mitk::UndoController::ClearRedoList | ( | ) |
Clears the RedoList.
Definition at line 105 of file mitkUndoController.cpp.
Referenced by mitkVerboseLimitedLinearUndoTest().
{ m_CurUndoModel->ClearRedoList(); }
mitk::UndoModel * mitk::UndoController::GetCurrentUndoModel | ( | ) | [static] |
gives access to the currently used UndoModel Introduced to access special functions of more specific UndoModels, especially to retrieve text descriptions of the undo/redo stack
Definition at line 219 of file mitkUndoController.cpp.
Referenced by QmitkSlicesInterpolator::AcceptAllInterpolations(), QmitkPointBasedRegistrationView::calculateLandmarkWarping(), QmitkImageCropper::CropImage(), mitk::OverwriteSliceImageFilter::GenerateData(), mitkUndoControllerTest(), QmitkExtWorkbenchWindowAdvisorHack::onRedo(), and QmitkExtWorkbenchWindowAdvisorHack::onUndo().
{
return m_CurUndoModel;
}
int mitk::UndoController::GetLastGroupEventIdInList | ( | ) |
returns the GroupEventId of the top Element in the OperationHistory of the selected UndoModel
Definition at line 208 of file mitkUndoController.cpp.
{
return m_CurUndoModel->GetLastGroupEventIdInList();
}
int mitk::UndoController::GetLastObjectEventIdInList | ( | ) |
returns the ObjectEventId of the top Element in the OperationHistory of the selected UndoModel
Definition at line 203 of file mitkUndoController.cpp.
{
return m_CurUndoModel->GetLastObjectEventIdInList();
}
mitk::OperationEvent * mitk::UndoController::GetLastOfType | ( | OperationActor * | destination, |
OperationType | opType | ||
) |
returns the last specified OperationEvent in Undo-list corresponding to the given value; if nothing found, then returns NULL
Definition at line 214 of file mitkUndoController.cpp.
{
return m_CurUndoModel->GetLastOfType(destination, opType);
}
bool mitk::UndoController::Redo | ( | bool | fine ) |
calls the RedoMechanism to redo the operations undone
read the Documentation of Undo! only with the possibility to fine redo, like fine undo
Definition at line 91 of file mitkUndoController.cpp.
References mitk::RenderingManager::GetInstance(), and mitk::RenderingManager::RequestUpdateAll().
{ bool ret = m_CurUndoModel->Redo(fine); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); return ret; }
bool mitk::UndoController::Redo | ( | ) |
calls the RedoMechanism to redo the operations undone
read the Documentation of Undo!
Definition at line 86 of file mitkUndoController.cpp.
{ return this->Redo(true); }
bool mitk::UndoController::RedoListEmpty | ( | ) |
returns true, if the RedoList is empty
Definition at line 110 of file mitkUndoController.cpp.
{
return m_CurUndoModel->RedoListEmpty();
}
bool mitk::UndoController::RemoveUndoModel | ( | UndoType | undoType ) |
Removes an UndoModel from the set of UndoModels If that UndoModel is currently selected, then the DefaultUndoModel(const) is set. If the default is not in List, then the first UndoModel is set. UndoList may not be empty, so if the UndoType is the last, then return false;
Definition at line 172 of file mitkUndoController.cpp.
Referenced by mitkUndoControllerTest().
{ if (m_UndoModelList.size() < 2) {//for no empty m_UndoModelList return false; } //try deleting Element int ok = m_UndoModelList.erase(undoType); if (ok == 0) {//delete unsucessful; Element of undoType not found return false; } //if m_CurUndoModel is the one removed, then change it to default or to the next or first if (m_CurUndoType == undoType) {//we have to change m_CurUndoModel and m_CurUndoType to an existing Model //if defaultUndoModel exists, then set to default UndoModelMapIter undoModelIter = m_UndoModelList.find(DEFAULTUNDOMODEL); if (undoModelIter == m_UndoModelList.end()) {//DefaultUndoModel does not exists in m_CurUndoModelList undoModelIter = m_UndoModelList.begin(); } m_CurUndoModel = (undoModelIter)->second; m_CurUndoType = (undoModelIter)->first; return true; } //m_CurUndoType was not undoType and is not changed return true; }
bool mitk::UndoController::SetOperationEvent | ( | UndoStackItem * | operationEvent ) |
Definition at line 66 of file mitkUndoController.cpp.
Referenced by mitkVerboseLimitedLinearUndoTest().
{ m_CurUndoModel->SetOperationEvent(operationEvent); return true; }
bool mitk::UndoController::SwitchUndoModel | ( | UndoType | undoType ) |
Switches the UndoModel to the given Type if there is no equal Type in List, then return false
Definition at line 118 of file mitkUndoController.cpp.
Referenced by mitkUndoControllerTest(), mitkVerboseLimitedLinearUndoTest(), and UndoController().
{ if (m_CurUndoType == undoType) { return true;//already switched, don't need to be switched! } UndoModelMapIter undoModelIter = m_UndoModelList.find(undoType); if (undoModelIter == m_UndoModelList.end()) {//undoType not found in List return false; } //found-> switch to UndoModel m_CurUndoModel = (undoModelIter)->second; m_CurUndoType = (undoModelIter)->first; return true; }
bool mitk::UndoController::Undo | ( | bool | fine ) |
calls the UndoMechanism to undo the last change
the UndoMechanism has the possibility to undo the last changes in two different ways: first it can Undo a group of operations done at last (e.g. build up a new object; Undo leads to deleting that object); or it can Undo a set of operations, that belong together(statechange with Action), that way it is possible recall the last set point after you have finished to build up a new object
fine,: | if set to true, then undo all operations with the same objectEventId if set to false, then undo all operations with the same GroupEventId |
Definition at line 77 of file mitkUndoController.cpp.
References mitk::RenderingManager::GetInstance(), and mitk::RenderingManager::RequestUpdateAll().
{ bool ret = m_CurUndoModel->Undo(fine); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); return ret; }
bool mitk::UndoController::Undo | ( | ) |
calls the UndoMechanism to undo the last change
Definition at line 72 of file mitkUndoController.cpp.
Referenced by mitkVerboseLimitedLinearUndoTest().
{ return this->Undo(true); }
const mitk::UndoController::UndoType mitk::UndoController::DEFAULTUNDOMODEL = VERBOSE_LIMITEDLINEARUNDO [static] |
Default UndoModel to use.
Definition at line 41 of file mitkUndoController.h.