// -------------------------------------------------------------------------
std::string ImageMPR::
-_LoadImage( TPluginImage::Pointer& image, const QStringList& names )
+_LoadImage( TPluginImage::Pointer& image )
{
- // Block application
- QApplication::setOverrideCursor( Qt::WaitCursor );
- this->setEnabled( false );
-
std::string ret = "";
image = NULL;
this->m_Plugins.CreateProcessObject( this->m_ImageReaderClass );
if( reader.IsNotNull( ) )
{
- // Configure reader
- TParameters params = reader->GetDefaultParameters( );
- QStringList::const_iterator qIt = names.begin( );
- for( ; qIt != names.end( ); ++qIt )
- params.AddValueToStringList( "FileNames", qIt->toStdString( ) );
- params.SetValueAsBool( "VectorType", false );
- reader->SetParameters( params );
-
- // Execute and get error message, if any
- ret = reader->Update( );
-
- // Assign fresh image, if any
- if( ret == "" )
+ if( reader->ExecConfigurationDialog( this ) )
{
- image = reader->GetOutput< TPluginImage >( 0 );
- reader->DisconnectOutputs( );
+ // Block application
+ QApplication::setOverrideCursor( Qt::WaitCursor );
+ this->setEnabled( false );
+
+ // Execute and get error message, if any
+ ret = reader->Update( );
+
+ // Assign fresh image, if any
+ if( ret == "" )
+ {
+ image = reader->GetOutput< TPluginImage >( 0 );
+ reader->DisconnectOutputs( );
+
+ } // fi
+
+ // Unblock application
+ QApplication::restoreOverrideCursor( );
+ this->setEnabled( true );
} // fi
}
else
ret = "No suitable reader object found in loaded plugins.";
- // Finish reading
- QApplication::restoreOverrideCursor( );
- this->setEnabled( true );
return( ret );
}
void ImageMPR::
_triggered_actionOpenInputImage( )
{
- // Show dialog and check if it was accepted
- QFileDialog dialog( this );
- dialog.setFileMode( QFileDialog::ExistingFiles );
- dialog.setDirectory( tr( "." ) );
- dialog.setNameFilter(
- tr( "Medical image files (*.mhd *.bin *.dcm);;All files (*)" )
- );
- dialog.setDefaultSuffix( tr( "mhd" ) );
- if( !( dialog.exec( ) ) )
- return;
-
// Read image
- std::string err =
- this->_LoadImage( this->m_InputImage, dialog.selectedFiles( ) );
+ std::string err = this->_LoadImage( this->m_InputImage );
if( err == "" )
{
vtkImageData* vtk_id = this->m_InputImage->GetVTKImageData( );
} // fi
- // Show dialog and check if it was accepted
- QFileDialog dialog( this );
- dialog.setFileMode( QFileDialog::ExistingFiles );
- dialog.setDirectory( tr( "." ) );
- dialog.setNameFilter(
- tr( "Medical image files (*.mhd *.bin *.dcm);;All files (*)" )
- );
- dialog.setDefaultSuffix( tr( "mhd" ) );
- if( !( dialog.exec( ) ) )
- return;
-
// Read image
- std::string err =
- this->_LoadImage( this->m_InputSegmentation, dialog.selectedFiles( ) );
+ std::string err = this->_LoadImage( this->m_InputSegmentation );
if( err == "" )
{
vtkImageData* vtk_id = this->m_InputSegmentation->GetVTKImageData( );
void ImageMPR::
_triggered_actionOpenInputPolyData( )
{
- // Show dialog and check if it was accepted
- QFileDialog dialog( this );
- dialog.setFileMode( QFileDialog::ExistingFile );
- dialog.setDirectory( tr( "." ) );
- dialog.setNameFilter(
- tr( "Mesh files (*.vtk *.obj);;All files (*)" )
- );
- dialog.setDefaultSuffix( tr( "vtk" ) );
- if( !( dialog.exec( ) ) )
- return;
-
this->m_InputMesh = NULL;
// Get a reader from plugins
TPluginFilter::Pointer reader =
this->m_Plugins.CreateProcessObject( this->m_MeshReaderClass );
- // Configure reader
- TParameters reader_params = reader->GetDefaultParameters( );
- QStringList q_fnames = dialog.selectedFiles( );
- QStringList::const_iterator qIt = q_fnames.begin( );
- for( ; qIt != q_fnames.end( ); ++qIt )
- reader_params.SetValueAsString( "FileName", qIt->toStdString( ) );
- reader->SetParameters( reader_params );
-
- // Execute and get error message, if any
- QApplication::setOverrideCursor( Qt::WaitCursor );
- this->setEnabled( false );
- std::string err = reader->Update( );
- QApplication::restoreOverrideCursor( );
- this->setEnabled( true );
-
-
- // Assign fresh image, if any
- if( err == "" )
+ if( reader.IsNotNull( ) )
{
- this->m_InputMesh = reader->GetOutput< TPluginMesh >( 0 );
- reader->DisconnectOutputs( );
- if( this->m_InputMesh.IsNotNull( ) )
+ // Configure reader
+ if( reader->ExecConfigurationDialog( this ) )
{
- vtkActor* vtk_actor = this->m_InputMesh->GetVTKActor( );
- if( vtk_actor != NULL )
+ // Execute and get error message, if any
+ QApplication::setOverrideCursor( Qt::WaitCursor );
+ this->setEnabled( false );
+ std::string err = reader->Update( );
+ QApplication::restoreOverrideCursor( );
+ this->setEnabled( true );
+
+ // Assign fresh mesh, if any
+ if( err == "" )
{
- this->m_MPRObjects->Get3DRenderer( )->AddActor( vtk_actor );
- this->m_MPRObjects->Render( 4 );
+ this->m_InputMesh = reader->GetOutput< TPluginMesh >( 0 );
+ reader->DisconnectOutputs( );
+ if( this->m_InputMesh.IsNotNull( ) )
+ {
+ vtkActor* vtk_actor = this->m_InputMesh->GetVTKActor( );
+ if( vtk_actor != NULL )
+ {
+ this->m_MPRObjects->Get3DRenderer( )->AddActor( vtk_actor );
+ this->m_MPRObjects->Render( 4 );
+ }
+ else
+ QMessageBox::critical(
+ this,
+ tr( "Error message" ),
+ tr( "Read mesh does not have a valid vtkActor." )
+ );
+
+ } // fi
}
else
QMessageBox::critical(
this,
- tr( "Error message" ),
- tr( "Read mesh does not have a valid vtkActor." )
+ tr( "Error reading mesh" ),
+ tr( err.c_str( ) )
);
} // fi
else
QMessageBox::critical(
this,
- tr( "Error reading mesh" ),
- tr( err.c_str( ) )
+ tr( "Error reading single mesh" ),
+ tr( "No suitable mesh reader found in loaded plugins." )
);
}
#include <itkImageFileReader.h>
#include <itkImageSeriesReader.h>
+#ifdef cpPlugins_Interface_QT4
+#include <QFileDialog>
+#endif // cpPlugins_Interface_QT4
+
+// -------------------------------------------------------------------------
+bool cpPlugins::IO::ImageReader::
+ExecConfigurationDialog( QWidget* parent )
+{
+ bool r = false;
+
+#ifdef cpPlugins_Interface_QT4
+
+ // Show dialog and check if it was accepted
+ QFileDialog dialog( parent );
+ dialog.setFileMode( QFileDialog::ExistingFiles );
+ dialog.setDirectory( QFileDialog::tr( "." ) );
+ dialog.setNameFilter( QFileDialog::tr( "All files (*)" ) );
+ if( dialog.exec( ) )
+ {
+ this->m_Parameters = this->m_DefaultParameters;
+ QStringList names = dialog.selectedFiles( );
+ QStringList::const_iterator qIt = names.begin( );
+ for( ; qIt != names.end( ); ++qIt )
+ this->m_Parameters.AddValueToStringList(
+ "FileNames", qIt->toStdString( )
+ );
+ this->m_Parameters.SetValueAsBool( "VectorType", false );
+ r = true;
+
+ } // fi
+
+#endif // cpPlugins_Interface_QT4
+
+ return( r );
+}
+
// -------------------------------------------------------------------------
cpPlugins::IO::ImageReader::
ImageReader( )
#include <vtkPolyData.h>
#include <vtkPolyDataReader.h>
+#ifdef cpPlugins_Interface_QT4
+#include <QFileDialog>
+#endif // cpPlugins_Interface_QT4
+
+// -------------------------------------------------------------------------
+bool cpPlugins::IO::MeshReader::
+ExecConfigurationDialog( QWidget* parent )
+{
+ bool r = false;
+
+#ifdef cpPlugins_Interface_QT4
+
+ // Show dialog and check if it was accepted
+ QFileDialog dialog( parent );
+ dialog.setFileMode( QFileDialog::ExistingFile );
+ dialog.setDirectory( QFileDialog::tr( "." ) );
+ dialog.setNameFilter( QFileDialog::tr( "All files (*)" ) );
+ if( dialog.exec( ) )
+ {
+ this->m_Parameters = this->m_DefaultParameters;
+ QStringList names = dialog.selectedFiles( );
+ this->m_Parameters.AddValueToStringList(
+ "FileNames", names[ 0 ].toStdString( )
+ );
+
+ /* TODO
+ this->m_Parameters.SetValueAsString( "PixelType", "float" );
+ this->m_Parameters.SetValueAsUint( "Dimension", 3 );
+ */
+
+ r = true;
+
+ } // fi
+
+#endif // cpPlugins_Interface_QT4
+
+ return( r );
+}
+
// -------------------------------------------------------------------------
cpPlugins::IO::MeshReader::
MeshReader( )