00001 #include <creaImageIOWxGimmickTools.h>
00002
00003
00004 namespace creaImageIO
00005 {
00009 WxGimmickTools::WxGimmickTools(wxWindow* parent, wxString mCurrentDirectory)
00010 : wxPanel(parent, -1, wxDefaultPosition, wxSize(300,250), wxBORDER_SUNKEN)
00011 {
00012 _currentDir = mCurrentDirectory;
00013 _addFiles = true;
00014 _mhd = false;
00015
00016 _inputPath = new wxTextCtrl(this, wxID_ANY, _T(""), wxDefaultPosition, wxSize(400,30));
00017 _outputPath = new wxTextCtrl(this, wxID_ANY, _T(""), wxDefaultPosition, wxSize(400,30));
00018 _addCheckBox = new wxCheckBox(this, -1, _T("Add Images to Database?") );
00019 _mhdCheckBox = new wxCheckBox(this, -1, _T("Convert to MHD?") );
00020 _addCheckBox->SetValue(_addFiles);
00021 _mhdCheckBox->SetValue(_mhd);
00022
00023 wxButton *inputDir = new wxButton(this, wxID_ANY,_T("Input Directory"), wxDefaultPosition, wxSize(140,30) );
00024 wxButton *outputDir = new wxButton(this, wxID_ANY,_T("Output Directory"), wxDefaultPosition, wxSize(140,30) );
00025
00026 Connect( inputDir->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxGimmickTools::onInputDir );
00027 Connect( outputDir->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxGimmickTools::onOutputDir );
00028 Connect( _addCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &WxGimmickTools::onAddToDatabase );
00029 Connect( _mhdCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &WxGimmickTools::onMHD );
00030
00031 wxFlexGridSizer *textSizer = new wxFlexGridSizer(1,2);
00032 textSizer->Add( new wxStaticText(this, -1, _T("Transform a Bruker 'Serie'/'Study'/'set of Studies' directory into Dicom / MHD format.")), 1, wxGROW );
00033 textSizer->Add( new wxStaticText(this, -1, _T("If checkbox is selected images will be loaded into the DB.")), 1, wxGROW );
00034
00035 wxFlexGridSizer *sizer = new wxFlexGridSizer(2,5);
00036 sizer->Add( new wxStaticText(this, -1, _T(" ")), 1, wxGROW );
00037 sizer->Add( new wxStaticText(this, -1, _T(" ")), 1, wxGROW );
00038 sizer->Add( _inputPath, 1, wxGROW );
00039 sizer->Add( inputDir, 1, wxGROW );
00040 sizer->Add( _outputPath, 1, wxGROW );
00041 sizer->Add( outputDir, 1, wxGROW );
00042 sizer->Add( new wxStaticText(this, -1, _T(" ")), 1, wxGROW );
00043 sizer->Add( new wxStaticText(this, -1, _T(" ")), 1, wxGROW );
00044 sizer->Add( _addCheckBox, 1, wxGROW );
00045 sizer->Add( _mhdCheckBox, 1, wxGROW );
00046
00047 wxFlexGridSizer *topSizer = new wxFlexGridSizer(1, 2);
00048 topSizer->Add( textSizer, 1, wxGROW );
00049 topSizer->Add( sizer, 1, wxGROW );
00050 this->SetSizer( topSizer );
00051 this->SetAutoLayout( true );
00052 this->Layout();
00053 }
00054
00055 WxGimmickTools::~WxGimmickTools()
00056 {
00057
00058 }
00059
00060 wxString WxGimmickTools::getInputDir()
00061 {
00062 return _inputPath->GetValue();
00063 }
00064
00065 wxString WxGimmickTools::getOutputDir()
00066 {
00067 return _outputPath->GetValue();
00068 }
00069
00070 bool WxGimmickTools::getAddToDBCheckBoxValue()
00071 {
00072 return _addCheckBox->GetValue();
00073 }
00074
00075 bool WxGimmickTools::getMHDCheckBoxValue()
00076 {
00077 return _mhdCheckBox->GetValue();
00078 }
00079
00080 void WxGimmickTools::onInputDir(wxCommandEvent& event)
00081 {
00082 long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
00083 wxDirDialog* FD = new wxDirDialog( 0, _T("Select the Input Directory"), _currentDir, style);
00084
00085 if (FD->ShowModal()==wxID_OK)
00086 {
00087 _inputPath->SetValue(FD->GetPath());
00088 }
00089 }
00090
00091 void WxGimmickTools::onOutputDir(wxCommandEvent& event)
00092 {
00093 long style = wxDD_DEFAULT_STYLE;
00094 wxDirDialog* FD = new wxDirDialog( 0, _T("Select the Output Directory"), _currentDir, style);
00095
00096 if (FD->ShowModal()==wxID_OK)
00097 {
00098 _outputPath->SetValue(FD->GetPath());
00099 }
00100 }
00101
00102 void WxGimmickTools::onAddToDatabase(wxCommandEvent& event)
00103 {
00104 _addFiles = _addCheckBox->GetValue();
00105 }
00106
00107 void WxGimmickTools::onMHD(wxCommandEvent& event)
00108 {
00109 _mhd = _mhdCheckBox->GetValue();
00110 }
00111
00112 }
00113
00114