]> Creatis software - cpPlugins.git/blob - plugins/IO/DicomSeriesReader.cxx
a93759db9ff2eb5aa380e6becc5c5eb415672abd
[cpPlugins.git] / plugins / IO / DicomSeriesReader.cxx
1 #include <IO/DicomSeriesReader.h>
2 #include <IO/DicomSeriesReaderQDialog.h>
3
4 #ifdef cpPlugins_QT4
5
6 #include <QApplication>
7 #include <QFileInfo>
8 #include <IO/ui_DicomSeriesReaderQDialog.h>
9
10 // -------------------------------------------------------------------------
11 cpPluginsIO::DicomSeriesReaderQDialog::
12 DicomSeriesReaderQDialog( QWidget* parent )
13   : QDialog( parent ),
14     m_UI( new Ui::DicomSeriesReaderQDialog ),
15     m_ProcessObject( NULL )
16 {
17   this->m_UI->setupUi( this );
18   this->connect(
19     this, SIGNAL( accepted( ) ), this, SLOT( _dlg_Accepted( ) )
20     );
21   this->setWindowTitle( "Open DICOM series" );
22 }
23
24 // -------------------------------------------------------------------------
25 cpPluginsIO::DicomSeriesReaderQDialog::
26 ~DicomSeriesReaderQDialog( )
27 {
28   delete this->m_UI;
29 }
30
31 // -------------------------------------------------------------------------
32 void cpPluginsIO::DicomSeriesReaderQDialog::
33 setProcessObject( cpPlugins::BaseObjects::ProcessObject* obj )
34 {
35   if( obj == NULL )
36     return;
37   this->m_ProcessObject = obj;
38   auto param = this->m_ProcessObject->GetParameters( );
39   auto files = param->GetOpenFileNameList( "FileNames" );
40   if( files.size( ) > 0 )
41   {
42     QFileInfo info( files[ 0 ].c_str( ) );
43     this->m_UI->Selector->setStartDir( info.canonicalPath( ) );
44
45   } // fi
46 }
47
48 // -------------------------------------------------------------------------
49 void cpPluginsIO::DicomSeriesReaderQDialog::
50 _dlg_Accepted( )
51 {
52   if( this->m_ProcessObject != NULL )
53   {
54     auto param = this->m_ProcessObject->GetParameters( );
55     auto files = this->m_UI->Selector->selectedFilenames( );
56     param->ClearOpenFileNameList( "FileNames" );
57     for( auto fIt = files.begin( ); fIt != files.end( ); ++fIt )
58       param->AddToOpenFileNameList( "FileNames", *fIt );
59
60   } // fi
61 }
62
63 #endif // cpPlugins_QT4
64
65 // -------------------------------------------------------------------------
66 QDialog* cpPluginsIO::DicomSeriesReader::
67 CreateQDialog( )
68 {
69 #ifdef cpPlugins_QT4
70   DicomSeriesReaderQDialog* dlg = NULL;
71   if( QApplication::instance( ) != NULL )
72   {
73     dlg = new DicomSeriesReaderQDialog( );
74     dlg->setProcessObject( this );
75
76   } // fi
77   return( dlg );
78 #else // cpPlugins_QT4
79   return( NULL );
80 #endif // cpPlugins_QT4
81 }
82
83 // -------------------------------------------------------------------------
84 cpPluginsIO::DicomSeriesReader::
85 DicomSeriesReader( )
86   : Superclass( )
87 {
88 }
89 // -------------------------------------------------------------------------
90 cpPluginsIO::DicomSeriesReader::
91 ~DicomSeriesReader( )
92 {
93 }
94
95 // -------------------------------------------------------------------------
96 void cpPluginsIO::DicomSeriesReader::
97 _GenerateData( )
98 {
99   this->Superclass::_GenerateData( );
100 }
101
102 // eof - $RCSfile$