]> Creatis software - creaImageIO.git/blob - src/creaImageIOWxGimmickTools.cpp
809c46de38fcf557195ed9b34f139796f2d29c72
[creaImageIO.git] / src / creaImageIOWxGimmickTools.cpp
1 #include <creaImageIOWxGimmickTools.h>
2
3
4 namespace creaImageIO
5 {
6         /**
7         ** Begin of the threshold panel
8         **/
9         WxGimmickTools::WxGimmickTools(wxWindow* parent, wxString mCurrentDirectory)
10          : wxPanel(parent, -1, wxDefaultPosition, wxSize(300,250), wxBORDER_SUNKEN)
11         {
12                 _currentDir = mCurrentDirectory;
13                 _addFiles = true;
14                 _mhd      = false;
15
16                 _inputPath      = new wxTextCtrl(this, wxID_ANY, _T(""), wxDefaultPosition, wxSize(400,30));
17                 _outputPath     = new wxTextCtrl(this, wxID_ANY, _T(""), wxDefaultPosition, wxSize(400,30));
18                 _addCheckBox    = new wxCheckBox(this, -1,       _T("Add Images to Database?") );
19                 _mhdCheckBox    = new wxCheckBox(this, -1,       _T("Convert to MHD?") );
20                 _addCheckBox->SetValue(_addFiles);
21                 _mhdCheckBox->SetValue(_mhd);           
22
23                 wxButton *inputDir  = new wxButton(this, wxID_ANY,_T("Input Directory"),  wxDefaultPosition, wxSize(140,30) );
24                 wxButton *outputDir = new wxButton(this, wxID_ANY,_T("Output Directory"), wxDefaultPosition, wxSize(140,30) );
25
26                 Connect( inputDir->GetId(),     wxEVT_COMMAND_BUTTON_CLICKED ,  (wxObjectEventFunction) &WxGimmickTools::onInputDir ); 
27                 Connect( outputDir->GetId(),    wxEVT_COMMAND_BUTTON_CLICKED ,  (wxObjectEventFunction) &WxGimmickTools::onOutputDir );
28                 Connect( _addCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &WxGimmickTools::onAddToDatabase );
29                 Connect( _mhdCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &WxGimmickTools::onMHD );
30                 
31                 wxFlexGridSizer *textSizer = new wxFlexGridSizer(1,2);
32                 textSizer->Add( new wxStaticText(this, -1, _T("Transform a Bruker 'Serie'/'Study'/'set of Studies' directory into Dicom / MHD format.")), 1, wxGROW );
33                 textSizer->Add( new wxStaticText(this, -1, _T("If checkbox is selected images will be loaded into the DB.")), 1, wxGROW );
34
35                 wxFlexGridSizer *sizer  = new wxFlexGridSizer(2,5);
36                 sizer->Add( new wxStaticText(this, -1, _T(" ")), 1, wxGROW );
37                 sizer->Add( new wxStaticText(this, -1, _T(" ")), 1, wxGROW );
38                 sizer->Add( _inputPath,   1, wxGROW );
39                 sizer->Add( inputDir,     1, wxGROW );
40                 sizer->Add( _outputPath,  1, wxGROW );
41                 sizer->Add( outputDir,    1, wxGROW );
42                 sizer->Add( new wxStaticText(this, -1, _T(" ")), 1, wxGROW );
43                 sizer->Add( new wxStaticText(this, -1, _T(" ")), 1, wxGROW );
44                 sizer->Add( _addCheckBox, 1, wxGROW );
45                 sizer->Add( _mhdCheckBox, 1, wxGROW );
46                 
47                 wxFlexGridSizer *topSizer = new wxFlexGridSizer(1, 2);
48                 topSizer->Add( textSizer, 1, wxGROW );
49                 topSizer->Add( sizer,     1, wxGROW );
50                 this->SetSizer( topSizer );
51                 this->SetAutoLayout( true );
52                 this->Layout();
53         }
54
55         WxGimmickTools::~WxGimmickTools()
56         {
57
58         }
59
60         wxString WxGimmickTools::getInputDir()
61         {
62                 return _inputPath->GetValue();
63         }
64
65         wxString WxGimmickTools::getOutputDir()
66         {
67                 return _outputPath->GetValue();
68         }
69
70         bool WxGimmickTools::getAddToDBCheckBoxValue()
71         {
72                 return _addCheckBox->GetValue();
73         }
74         
75         bool WxGimmickTools::getMHDCheckBoxValue()
76         {
77                 return _mhdCheckBox->GetValue();
78         }       
79
80         void WxGimmickTools::onInputDir(wxCommandEvent& event)
81         {
82                 long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
83                 wxDirDialog* FD = new wxDirDialog( 0, _T("Select the Input Directory"), _currentDir, style);
84                               
85                 if (FD->ShowModal()==wxID_OK)
86                 {  
87                         _inputPath->SetValue(FD->GetPath());
88                 }
89         }
90
91         void WxGimmickTools::onOutputDir(wxCommandEvent& event)
92         {
93                 long style = wxDD_DEFAULT_STYLE;
94                 wxDirDialog* FD = new wxDirDialog( 0, _T("Select the Output Directory"), _currentDir, style);
95             
96                 if (FD->ShowModal()==wxID_OK)
97                 {
98                         _outputPath->SetValue(FD->GetPath());
99                 }
100         }
101
102         void WxGimmickTools::onAddToDatabase(wxCommandEvent& event)
103         {
104                 _addFiles = _addCheckBox->GetValue();
105         }
106         
107         void WxGimmickTools::onMHD(wxCommandEvent& event)
108         {
109                 _mhd = _mhdCheckBox->GetValue();
110         }       
111
112 } // EO namespace creaImageIO
113
114