2 #include "ui_ImageMPR.h"
4 #include <vtkRenderWindow.h>
10 # define PLUGIN_EXT "dll"
11 # define PLUGIN_REGEX "Plugins file (*.dll);;All files (*)"
13 # define PLUGIN_EXT "so"
14 # define PLUGIN_REGEX "Plugins file (*.so);;All files (*)"
17 // -------------------------------------------------------------------------
18 ImageMPR::ImageMPR( QWidget* parent )
19 : QMainWindow( parent ),
20 m_UI( new Ui::ImageMPR ),
23 this->m_UI->setupUi( this );
25 // Create and associate renderers
26 this->m_MPR = new TMPR(
27 this->m_UI->m_XPlaneVTK->GetRenderWindow( ),
28 this->m_UI->m_YPlaneVTK->GetRenderWindow( ),
29 this->m_UI->m_ZPlaneVTK->GetRenderWindow( ),
30 this->m_UI->m_3DVTK->GetRenderWindow( )
35 this->m_UI->actionOpenPlugins, SIGNAL( triggered( ) ),
36 this, SLOT( _triggered_actionOpenPlugins( ) )
39 this->m_UI->actionOpenInputImage, SIGNAL( triggered( ) ),
40 this, SLOT( _triggered_actionOpenInputImage( ) )
43 // Start: load all disponible plugins
44 this->_triggered_actionOpenPlugins( );
47 // -------------------------------------------------------------------------
51 // Close all connections
52 this->m_Plugins.UnloadAll( );
59 // -------------------------------------------------------------------------
61 _triggered_actionOpenPlugins( )
63 // Show dialog and check if it was accepted
64 QFileDialog dialog( this );
65 dialog.setFileMode( QFileDialog::ExistingFile );
66 dialog.setDirectory( "." );
67 dialog.setNameFilter( tr( PLUGIN_REGEX ) );
68 dialog.setDefaultSuffix( tr( PLUGIN_EXT ) );
69 if( !( dialog.exec( ) ) )
72 std::string fname = dialog.selectedFiles( ).at( 0 ).toStdString( );
73 this->m_Plugins.UnloadAll( );
74 if( !( this->m_Plugins.Load( fname ) ) )
76 QMessageBox::critical(
78 tr( "Ignoring plugin" ),
81 this->m_Plugins.UnloadAll( );
86 this->m_BaseClasses[ "ImageReader" ] =
87 "cpPlugins::Plugins::ImageReader";
88 this->m_BaseClasses[ "ImageSeriesReader" ] =
89 "cpPlugins::Plugins::ImageSeriesReader";
92 // -------------------------------------------------------------------------
94 _triggered_actionOpenInputImage( )
96 // Show dialog and check if it was accepted
97 QFileDialog dialog( this );
98 dialog.setFileMode( QFileDialog::ExistingFiles );
99 dialog.setDirectory( tr( "." ) );
100 dialog.setNameFilter(
101 tr( "Medical image files (*.mhd *.bin *.dcm);;All files (*)" )
103 dialog.setDefaultSuffix( tr( "mhd" ) );
104 if( !( dialog.exec( ) ) )
107 this->m_InputImage = NULL;
108 unsigned int nFiles = dialog.selectedFiles( ).size( );
111 std::string fname = dialog.selectedFiles( ).at( 0 ).toStdString( );
113 TPlugin::Pointer reader =
114 this->m_Plugins.CreateProcessObject(
115 this->m_BaseClasses[ "ImageReader" ]
118 TParameters reader_params = reader->GetDefaultParameters( );
119 reader_params.SetValueAsString( "FileName", fname );
120 reader_params.SetValueAsString( "PixelType", "short" );
121 reader_params.SetValueAsUint( "ImageDimension", 3 );
122 reader_params.SetValueAsUint( "IsColorImage", 0 );
123 reader->SetParameters( reader_params );
124 std::string err = reader->Update( );
129 dynamic_cast< TPluginImage* >( reader->GetOutput( 0 ) );
130 reader->DisconnectOutputs( );
133 QMessageBox::critical(
135 tr( "Error reading single image" ),
139 else if( nFiles > 1 )
142 if( this->m_ImageSeriesReaderClassName == "" )
144 QMessageBox::critical(
146 tr( "No plugin to read an image series found!" ),
147 tr( "No plugin to read an image series found!" )
152 std::string fname = dialog.selectedFiles( ).at( 0 ).toStdString( );
153 this->m_LastOpenedFile = fname;
159 if( this->m_InputImage.IsNotNull( ) )
160 this->m_MPR->SetImage( this->m_InputImage->GetVTKImageData( ) );