creaImageIO_lib
creaImageIOWxGimmickTools.cpp
Go to the documentation of this file.
1 /*
2 # ---------------------------------------------------------------------
3 #
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # pour la Santé)
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 #
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
16 #
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
21 # liability.
22 #
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------
26 */
27 
28 
30 
31 
32 namespace creaImageIO
33 {
37  WxGimmickTools::WxGimmickTools(wxWindow* parent, wxString mCurrentDirectory)
38  : wxPanel(parent, -1, wxDefaultPosition, wxSize(300,250), wxBORDER_SUNKEN)
39  {
40  _currentDir = mCurrentDirectory;
41  _addFiles = true;
42  _mhd = false;
43 
44  _inputPath = new wxTextCtrl(this, wxID_ANY, _T(""), wxDefaultPosition, wxSize(400,30));
45  _outputPath = new wxTextCtrl(this, wxID_ANY, _T(""), wxDefaultPosition, wxSize(400,30));
46  _addCheckBox = new wxCheckBox(this, -1, _T("Add Images to Database?") );
47  _mhdCheckBox = new wxCheckBox(this, -1, _T("Convert to MHD?") );
48  _addCheckBox->SetValue(_addFiles);
49  _mhdCheckBox->SetValue(_mhd);
50 
51  wxButton *inputDir = new wxButton(this, wxID_ANY,_T("Input Directory"), wxDefaultPosition, wxSize(140,30) );
52  wxButton *outputDir = new wxButton(this, wxID_ANY,_T("Output Directory"), wxDefaultPosition, wxSize(140,30) );
53 
54  Connect( inputDir->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxGimmickTools::onInputDir );
55  Connect( outputDir->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxGimmickTools::onOutputDir );
56  Connect( _addCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &WxGimmickTools::onAddToDatabase );
57  Connect( _mhdCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &WxGimmickTools::onMHD );
58 
59  wxFlexGridSizer *textSizer = new wxFlexGridSizer(1,2);
60  textSizer->Add( new wxStaticText(this, -1, _T("Transform a Bruker 'Serie'/'Study'/'set of Studies' directory into Dicom / MHD format.")), 1, wxGROW );
61  textSizer->Add( new wxStaticText(this, -1, _T("If checkbox is selected images will be loaded into the DB.")), 1, wxGROW );
62 
63  wxFlexGridSizer *sizer = new wxFlexGridSizer(2,5);
64  sizer->Add( new wxStaticText(this, -1, _T(" ")), 1, wxGROW );
65  sizer->Add( new wxStaticText(this, -1, _T(" ")), 1, wxGROW );
66  sizer->Add( _inputPath, 1, wxGROW );
67  sizer->Add( inputDir, 1, wxGROW );
68  sizer->Add( _outputPath, 1, wxGROW );
69  sizer->Add( outputDir, 1, wxGROW );
70  sizer->Add( new wxStaticText(this, -1, _T(" ")), 1, wxGROW );
71  sizer->Add( new wxStaticText(this, -1, _T(" ")), 1, wxGROW );
72  sizer->Add( _addCheckBox, 1, wxGROW );
73  sizer->Add( _mhdCheckBox, 1, wxGROW );
74 
75  wxFlexGridSizer *topSizer = new wxFlexGridSizer(1, 2);
76  topSizer->Add( textSizer, 1, wxGROW );
77  topSizer->Add( sizer, 1, wxGROW );
78  this->SetSizer( topSizer );
79  this->SetAutoLayout( true );
80  this->Layout();
81  }
82 
84  {
85 
86  }
87 
89  {
90  return _inputPath->GetValue();
91  }
92 
94  {
95  return _outputPath->GetValue();
96  }
97 
99  {
100  return _addCheckBox->GetValue();
101  }
102 
104  {
105  return _mhdCheckBox->GetValue();
106  }
107 
108  void WxGimmickTools::onInputDir(wxCommandEvent& event)
109  {
110  long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
111  wxDirDialog* FD = new wxDirDialog( 0, _T("Select the Input Directory"), _currentDir, style);
112 
113  if (FD->ShowModal()==wxID_OK)
114  {
115  _inputPath->SetValue(FD->GetPath());
116  }
117  }
118 
119  void WxGimmickTools::onOutputDir(wxCommandEvent& event)
120  {
121  long style = wxDD_DEFAULT_STYLE;
122  wxDirDialog* FD = new wxDirDialog( 0, _T("Select the Output Directory"), _currentDir, style);
123 
124  if (FD->ShowModal()==wxID_OK)
125  {
126  _outputPath->SetValue(FD->GetPath());
127  }
128  }
129 
130  void WxGimmickTools::onAddToDatabase(wxCommandEvent& event)
131  {
132  _addFiles = _addCheckBox->GetValue();
133  }
134 
135  void WxGimmickTools::onMHD(wxCommandEvent& event)
136  {
137  _mhd = _mhdCheckBox->GetValue();
138  }
139 
140 } // EO namespace creaImageIO
141 
142