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( );
51 // -------------------------------------------------------------------------
53 _triggered_actionOpenPlugins( )
55 // Show dialog and check if it was accepted
56 QFileDialog dialog( this );
57 dialog.setFileMode( QFileDialog::ExistingFile );
58 dialog.setDirectory( "." );
60 tr( "Plugins file (*.so);;All files (*)" )
62 dialog.setDefaultSuffix( tr( "so" ) );
63 if( !( dialog.exec( ) ) )
66 std::string fname = dialog.selectedFiles( ).at( 0 ).toStdString( );
67 this->m_Plugins.UnloadAll( );
68 if( !( this->m_Plugins.Load( fname ) ) )
70 QMessageBox::critical(
72 tr( "Ignoring plugin" ),
75 this->m_Plugins.UnloadAll( );
80 this->m_BaseClasses[ "ImageReader" ] =
81 "cpPlugins::Plugins::ImageReader";
82 this->m_BaseClasses[ "ImageSeriesReader" ] =
83 "cpPlugins::Plugins::ImageSeriesReader";
86 // -------------------------------------------------------------------------
88 _triggered_actionOpenInputImage( )
90 // Show dialog and check if it was accepted
91 QFileDialog dialog( this );
92 dialog.setFileMode( QFileDialog::ExistingFiles );
93 dialog.setDirectory( tr( "." ) );
95 tr( "Medical image files (*.mhd *.bin *.dcm);;All files (*)" )
97 dialog.setDefaultSuffix( tr( "mhd" ) );
98 if( !( dialog.exec( ) ) )
101 this->m_InputImage = NULL;
102 unsigned int nFiles = dialog.selectedFiles( ).size( );
105 std::string fname = dialog.selectedFiles( ).at( 0 ).toStdString( );
107 TPlugin::Pointer reader =
108 this->m_Plugins.CreateProcessObject(
109 this->m_BaseClasses[ "ImageReader" ]
112 TParameters reader_params = reader->GetDefaultParameters( );
113 reader_params[ "FileName" ].second = fname;
114 reader_params[ "PixelType" ].second = "short";
115 reader_params[ "ImageDimension" ].second = "3";
116 reader_params[ "IsColorImage" ].second = "0";
117 reader->SetParameters( reader_params );
118 std::string err = reader->Update( );
123 dynamic_cast< TPluginImage* >( reader->GetOutput( 0 ) );
124 reader->DisconnectOutputs( );
127 QMessageBox::critical(
129 tr( "Error reading single image" ),
133 else if( nFiles > 1 )
136 if( this->m_ImageSeriesReaderClassName == "" )
138 QMessageBox::critical(
140 tr( "No plugin to read an image series found!" ),
141 tr( "No plugin to read an image series found!" )
146 std::string fname = dialog.selectedFiles( ).at( 0 ).toStdString( );
147 this->m_LastOpenedFile = fname;
153 if( this->m_InputImage.IsNotNull( ) )
154 this->m_MPR->SetImage( this->m_InputImage->GetVTKImageData( ) );