#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(0),
+ m_max_state(0)
{
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(
{
if( this->m_Mesh.IsNull( ) )
return( "Valid mesh not found." );
-
+
+ this->m_Mesh->CreateVTKActor( );
vtkActor* vtk_actor = this->m_Mesh->GetVTKActor( );
if( vtk_actor != NULL )
{
std::string lerr = this->m_Cutters[ i ]->Update( );
if( lerr == "" )
{
+ this->m_Cutters[ i ]->GetOutput< TPluginMesh >( 0 )->CreateVTKActor( );
vtkActor* actor = this->m_Cutters[ i ]->GetOutput< TPluginMesh >( 0 )->GetVTKActor( );
- mprActors->GetSliceActors( i )->AddActor( this->m_Cutters[ i ]->GetVTKAlgorithm( ), actor );
+ mprActors->GetSliceActors( i )->AddActor( this->m_Cutters[ i ]->GetVTK< vtkAlgorithm >( ), actor );
if( i == 0 )
this->m_MPRObjects->GetXRenderer( )->AddActor( actor );
else if( i == 1 )
std::string err = this->_LoadImage( this->m_Image );
if( err == "" )
{
- vtkImageData* vtk_id = this->m_Image->GetVTKImageData( );
+ vtkImageData* vtk_id = this->m_Image->GetVTK< vtkImageData >( );
if( vtk_id != NULL )
{
this->m_MPRObjects->SetImage( vtk_id );
this->m_MPRObjects->ActivateInteractors( );
this->m_MPRObjects->ResetCameras( );
this->m_MPRObjects->RenderAll( );
+
+ MementoState(m_state, this->m_Image);
+ this->m_state++;
}
else
QMessageBox::critical(
std::string err = this->_LoadImage( this->m_Segmentation );
if( err == "" )
{
- vtkImageData* vtk_id = this->m_Segmentation->GetVTKImageData( );
+ vtkImageData* vtk_id = this->m_Segmentation->GetVTK< vtkImageData >( );
if( vtk_id != NULL )
{
this->m_MPRObjects->AddAuxiliaryImage( vtk_id );
result->DisconnectPipeline( );
this->m_Image = result;
if( this->m_Image.IsNotNull( ) )
- this->m_MPRObjects->SetImage( this->m_Image->GetVTKImageData( ) );
+ this->m_MPRObjects->SetImage(
+ this->m_Image->GetVTK< vtkImageData >( )
+
+ );
+
+
+ MementoState(this->m_state, this->m_Image);
+ this->m_state++;
+ if (this->m_state > this->m_max_state)
+ {
+ this->m_max_state = this->m_state;
+ }
}
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::warning(
+ this,
+ tr("message"),
+ tr("No history to undo")
+ );
+ }
+
+}
+
+// -------------------------------------------------------------------------
+void ImageMPR::
+_triggered_actionRedo()
+{
+ MementoState memento = MementoState();
+ if (this->m_state + 1 <= m_max_state)
+ {
+ this->m_state++;
+ this->m_MPRObjects->SetImage(
+ memento.getMemento(this->m_state)->GetOutput()
+ );
+ } else
+ {
+ QMessageBox::warning(
+ this,
+ tr("message"),
+ tr("No history to redo")
+ );
+ }
+
+}
+
+
// eof - $RCSfile$