#include "ImageMPR.h"
+#include "MementoState.h"
#include "ui_ImageMPR.h"
#include <vtkProperty.h>
#include <vtkRenderWindow.h>
+#include <vtkMetaImageReader.h>
#include <QFileDialog>
#include <QMessageBox>
m_MeshReaderClass( "" ),
m_MeshWriterClass( "" ),
m_MeshCutterClass( "" ),
- m_Image( NULL )
+ m_Image( NULL ),
+ m_state(1)
{
this->m_UI->setupUi( this );
this->m_UI->actionOpenInputPolyData, SIGNAL( triggered( ) ),
this, SLOT( _triggered_actionOpenInputPolyData( ) )
);
+ QObject::connect(
+ this->m_UI->actionUndo, SIGNAL(triggered()),
+ this, SLOT(_triggered_actionUndo())
+ );
+ QObject::connect(
+ this->m_UI->actionRedo, SIGNAL(triggered()),
+ this, SLOT(_triggered_actionRedo())
+ );
// Start: load all disponible plugins
this->_LoadPlugins(
this->m_MPRObjects->ActivateInteractors( );
this->m_MPRObjects->ResetCameras( );
this->m_MPRObjects->RenderAll( );
+
+ MementoState(m_state, this->m_Image);
}
else
QMessageBox::critical(
if( this->m_Image.IsNotNull( ) )
this->m_MPRObjects->SetImage(
this->m_Image->GetVTK< vtkImageData >( )
- );
+
+ );
+ m_state++;
+ MementoState(m_state, this->m_Image);
}
else
QMessageBox::critical(
);
}
+// -------------------------------------------------------------------------
+void ImageMPR::
+_triggered_actionUndo()
+{
+ MementoState memento = MementoState();
+
+ if (this->m_state>1)
+ {
+ this->m_state--;
+ this->m_MPRObjects->SetImage(
+ memento.getMemento(this->m_state)->GetOutput()
+ );
+ } else
+ {
+ QMessageBox::critical(
+ this,
+ tr("Error message"),
+ tr("No history to undo")
+ );
+ }
+
+}
+
+// -------------------------------------------------------------------------
+void ImageMPR::
+_triggered_actionRedo()
+{
+ MementoState memento = MementoState();
+ try
+ {
+ this->m_state++;
+ this->m_MPRObjects->SetImage(
+ memento.getMemento(this->m_state)->GetOutput()
+ );
+ }
+ catch (int err)
+ {
+ QMessageBox::critical(
+ this,
+ tr("Error message"),
+ tr("No history to redo")
+ );
+ }
+}
+
+
// eof - $RCSfile$