ImageMPR( QWidget* parent )
: QMainWindow( parent ),
m_UI( new Ui::ImageMPR ),
- m_Plugins( new TPlugins ),
- m_MainImage( NULL )
+ m_Plugins( new TPlugins )
{
this->m_UI->setupUi( this );
this->m_Plugins->SetWidget( this );
void ImageMPR::
_aOpenImage( )
{
- if( this->m_MainImage.IsNotNull( ) )
+ // Clear all, since we are loading the main image
+ if( this->m_Objects.size( ) > 0 )
+ {
this->m_UI->MPR->ClearAll( );
- if( this->m_Plugins->ReadImage( this->m_MainImage, true ) )
+ this->m_Objects.clear( );
+
+ } // fi
+
+ // Read and show image, if possible
+ TPlugins::TImage::Pointer image;
+ if( this->m_Plugins->ReadImage( image, true ) )
{
- vtkImageData* vimage = this->m_MainImage->GetVTK< vtkImageData >( );
+ vtkImageData* vimage = image->GetVTK< vtkImageData >( );
if( vimage == NULL )
QMessageBox::critical(
this,
)
);
else
- this->m_UI->MPR->ShowImage( vimage );
+ this->m_UI->MPR->ShowImage( vimage, image->GetName( ) );
+
+ // Keep a track on a local data tree
+ this->m_Objects[ image->GetName( ) ] =
+ TTreeNode( "", image.GetPointer( ) );
} // fi
}
void ImageMPR::
_aOpenDICOMSeries( )
{
- if( this->m_MainImage.IsNotNull( ) )
+ // Clear all, since we are loading the main image
+ if( this->m_Objects.size( ) > 0 )
+ {
this->m_UI->MPR->ClearAll( );
- if( this->m_Plugins->ReadDicomSeries( this->m_MainImage ) )
+ this->m_Objects.clear( );
+
+ } // fi
+
+ // Read and show image, if possible
+ TPlugins::TImage::Pointer image;
+ if( this->m_Plugins->ReadDicomSeries( image ) )
{
- vtkImageData* vimage = this->m_MainImage->GetVTK< vtkImageData >( );
+ vtkImageData* vimage = image->GetVTK< vtkImageData >( );
if( vimage == NULL )
QMessageBox::critical(
this,
)
);
else
- this->m_UI->MPR->ShowImage( vimage );
+ this->m_UI->MPR->ShowImage( vimage, image->GetName( ) );
+
+ // Keep a track on a local data tree
+ this->m_Objects[ image->GetName( ) ] =
+ TTreeNode( "", image.GetPointer( ) );
} // fi
}
void ImageMPR::
_aSaveImage( )
{
- if( this->m_MainImage.IsNotNull( ) )
+ /*
+ if( this->m_MainImage.IsNotNull( ) )
this->m_Plugins->WriteImage( this->m_MainImage, true );
+ */
}
// -------------------------------------------------------------------------
void ImageMPR::
_execPlugin( )
{
+ /*
+ typedef std::map< std::string, TPlugins::TImage::Pointer > _TImages;
+ typedef std::map< std::string, TPlugins::TMesh::Pointer > _TMeshes;
+
+ // Get selected data
+ // std::string data_name = this->m_UI->MPR->GetSelectedData( );
+
// Get filter name
QAction* action = dynamic_cast< QAction* >( this->sender( ) );
if( action == NULL )
QMenu* menu = dynamic_cast< QMenu* >( action->parentWidget( ) );
if( menu == NULL )
return;
- std::string cate = menu->title( ).toStdString( );
- std::string name = action->text( ).toStdString( );
- std::string err = "";
+ std::string filter_cate = menu->title( ).toStdString( );
+ std::string filter_name = action->text( ).toStdString( );
+ // Create filter
TPlugins::TProcessObject::Pointer filter;
- if( this->m_Plugins->CreateFilter( filter, name ) )
+ if( !( this->m_Plugins->CreateFilter( filter, filter_name ) ) )
+ {
+ QMessageBox::critical(
+ this,
+ tr( "Error creating filter" ),
+ tr( (
+ std::string( "No valid filter \"" ) +
+ filter_name +
+ std::string( "\"defined." )
+ ).c_str( ) )
+ );
+ return;
+
+ } // fi
+
+ // Assign inputs
+ std::vector< std::string > inputs_names = filter->GetInputsNames( );
+ if( inputs_names.size( ) == 1 )
+ {
+ std::string data_name = this->m_UI->MPR->GetSelectedData( );
+ _TImages::iterator iIt = this->m_Images.find( data_name );
+ _TImages::iterator mIt = this->m_Meshes.find( data_name );
+ filter->SetInput( inputs_names[ 0 ]);
+ }
+ else if( inputs_names.size( ) > 1 )
+ {
+ } // fi
+
+ // Get outputs
+ std::vector< std::string > outputs_names = filter->GetOutputsNames( );
+ */
+
+ /*
+
+ // Choose inputs
+ if( filter_cate == "ImageToMeshFilter" )
{
- if( cate == "ImageToMeshFilter" )
+ // Check inputs
+ _TImages::iterator iIt = this->m_Images.find( data_name );
+ if( iIt == this->m_Images.end( ) )
{
- if( filter->ExecConfigurationDialog( this ) )
- {
- filter->SetInput( "Input", this->m_MainImage );
- this->_Block( );
- err = filter->Update( );
- this->_Unblock( );
- TPlugins::TMesh::Pointer mesh =
- filter->GetOutput< TPlugins::TMesh >( "Input" );
- mesh->Print( std::cout );
+ QMessageBox::critical(
+ this,
+ tr( "Error creating filter" ),
+ tr( "No valid input selected." )
+ );
+ return;
- } // fi
+ } // fi
+
+ // Execute configuration dialog
+ if( !( filter->ExecConfigurationDialog( this ) ) )
+ return;
+
+ // Execute filter
+ filter->SetInput( "Input", iIt->second );
+ this->_Block( );
+ std::string filter_err = filter->Update( );
+ this->_Unblock( );
+ if( filter_err != "" )
+ {
+ QMessageBox::critical(
+ this,
+ tr( "Error executing" ),
+ tr( filter_err.c_str( ) )
+ );
+ return;
} // fi
- }
- else
- QMessageBox::critical(
- this,
- tr( "Error creating filter" ),
- tr( "No valid filter defined." )
+
+ // Keep and show results
+ TPlugins::TMesh::Pointer mesh =
+ filter->GetOutput< TPlugins::TMesh >( "Output" );
+ this->m_Meshes[ filter_name ] = mesh;
+ this->_Block( );
+ this->m_UI->MPR->ShowMesh(
+ mesh->GetVTK< vtkPolyData >( ),
+ filter_name,
+ data_name
);
+ this->_Unblock( );
+ } // fi
+ */
+
+ /*
+ if( this->m_Plugins->CreateFilter( filter, name ) )
+ {
+ if( filter->ExecConfigurationDialog( this ) )
+ {
+ filter->SetInput( "Input", this->m_MainImage );
+ this->_Block( );
+ err = filter->Update( );
+ this->_Unblock( );
+ TPlugins::TMesh::Pointer mesh =
+ filter->GetOutput< TPlugins::TMesh >( "Output" );
+ this->m_Meshes.push_back( mesh );
+ mesh->CreateVTKActor( );
+ vtkActor* actor = mesh->GetVTKActor( );
+ if( actor != NULL )
+ this->m_UI->MPR->Add3DActor( actor );
+
+ } // fi
+
+ } // fi
+ }
+ else
+ QMessageBox::critical(
+ this,
+ tr( "Error creating filter" ),
+ tr( "No valid filter defined." )
+ );
+ */
/*
if( name == "cpPlugins::BasicFilters::FloodFillImageFilter" )
{