2 #include "ui_ImageMPR.h"
4 #include <vtkRenderWindow.h>
9 // -------------------------------------------------------------------------
10 ImageMPR::ImageMPR( QWidget* parent )
11 : QMainWindow( parent ),
12 m_UI( new Ui::ImageMPR ),
15 this->m_UI->setupUi( this );
17 // Create and associate renderers
18 this->m_MPR = new TMPR(
19 this->m_UI->m_XPlaneVTK->GetRenderWindow( ),
20 this->m_UI->m_YPlaneVTK->GetRenderWindow( ),
21 this->m_UI->m_ZPlaneVTK->GetRenderWindow( ),
22 this->m_UI->m_3DVTK->GetRenderWindow( )
27 this->m_UI->actionOpenPlugins, SIGNAL( triggered( ) ),
28 this, SLOT( _triggered_actionOpenPlugins( ) )
31 this->m_UI->actionOpenInputImage, SIGNAL( triggered( ) ),
32 this, SLOT( _triggered_actionOpenInputImage( ) )
35 // Start: load all disponible plugins
36 this->_triggered_actionOpenPlugins( );
39 // -------------------------------------------------------------------------
43 // Close all connections
44 this->m_Plugins.UnloadAll( );
49 if( this->m_InputImage != NULL ) delete this->m_InputImage;
52 // -------------------------------------------------------------------------
54 _triggered_actionOpenPlugins( )
56 // Show dialog and check if it was accepted
57 QFileDialog dialog( this );
58 dialog.setFileMode( QFileDialog::ExistingFile );
59 dialog.setDirectory( "." );
61 tr( "Plugins file (*.so);;All files (*)" )
63 dialog.setDefaultSuffix( tr( "so" ) );
64 if( !( dialog.exec( ) ) )
67 std::string fname = dialog.selectedFiles( ).at( 0 ).toStdString( );
68 this->m_Plugins.UnloadAll( );
69 if( !( this->m_Plugins.Load( fname ) ) )
71 QMessageBox::critical(
73 tr( "Ignoring plugin" ),
76 this->m_Plugins.UnloadAll( );
81 this->m_BaseClasses[ "ImageReader" ] =
82 "cpPlugins::Plugins::ImageReader";
83 this->m_BaseClasses[ "ImageSeriesReader" ] =
84 "cpPlugins::Plugins::ImageSeriesReader";
87 // -------------------------------------------------------------------------
89 _triggered_actionOpenInputImage( )
91 // Show dialog and check if it was accepted
92 QFileDialog dialog( this );
93 dialog.setFileMode( QFileDialog::ExistingFiles );
94 dialog.setDirectory( tr( "." ) );
96 tr( "Medical image files (*.mhd *.bin *.dcm);;All files (*)" )
98 dialog.setDefaultSuffix( tr( "mhd" ) );
99 if( !( dialog.exec( ) ) )
102 if( this->m_InputImage != NULL )
103 delete this->m_InputImage;
104 this->m_InputImage = NULL;
105 unsigned int nFiles = dialog.selectedFiles( ).size( );
108 std::string fname = dialog.selectedFiles( ).at( 0 ).toStdString( );
111 dynamic_cast< TPlugin* >(
112 this->m_Plugins.CreateObject( this->m_BaseClasses[ "ImageReader" ] )
115 TParameters reader_params = reader->GetDefaultParameters( );
116 reader_params[ "FileName" ].second = fname;
117 reader_params[ "PixelType" ].second = "short";
118 reader_params[ "ImageDimension" ].second = "3";
119 reader_params[ "IsColorImage" ].second = "0";
120 reader->SetParameters( reader_params );
121 std::string err = reader->Update( );
126 dynamic_cast< TPluginImage* >( reader->GetOutput( 0 ) );
127 reader->DisconnectOutputs( );
130 QMessageBox::critical(
132 tr( "Error reading single image" ),
137 else if( nFiles > 1 )
140 if( this->m_ImageSeriesReaderClassName == "" )
142 QMessageBox::critical(
144 tr( "No plugin to read an image series found!" ),
145 tr( "No plugin to read an image series found!" )
150 std::string fname = dialog.selectedFiles( ).at( 0 ).toStdString( );
151 this->m_LastOpenedFile = fname;
157 if( this->m_InputImage != NULL )
158 this->m_MPR->SetImage( this->m_InputImage->GetVTKImageData( ) );