]> Creatis software - creaImageIO.git/blob - src/creaImageIOWxGimmickTools.cpp
#3131 creaImageIO Feature New Normal - branch changeWx28to30 compilation with wxWid...
[creaImageIO.git] / src / creaImageIOWxGimmickTools.cpp
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
29 #include <creaImageIOWxGimmickTools.h>
30
31
32 namespace creaImageIO
33 {
34         /**
35         ** Begin of the threshold panel
36         **/
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 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
60 #if wxMAJOR_VERSION <= 2
61                 wxFlexGridSizer *textSizer = new wxFlexGridSizer(1,2);
62 #else
63                 wxFlexGridSizer *textSizer = new wxFlexGridSizer(2);
64 #endif
65
66                 textSizer->Add( new wxStaticText(this, -1, _T("Transform a Bruker 'Serie'/'Study'/'set of Studies' directory into Dicom / MHD format.")), 1, wxGROW );
67                 textSizer->Add( new wxStaticText(this, -1, _T("If checkbox is selected images will be loaded into the DB.")), 1, wxGROW );
68
69 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
70 #if wxMAJOR_VERSION <= 2
71                 wxFlexGridSizer *sizer  = new wxFlexGridSizer(2,5);
72 #else
73                 wxFlexGridSizer *sizer  = new wxFlexGridSizer(5);
74 #endif
75                 sizer->Add( new wxStaticText(this, -1, _T(" ")), 1, wxGROW );
76                 sizer->Add( new wxStaticText(this, -1, _T(" ")), 1, wxGROW );
77                 sizer->Add( _inputPath,   1, wxGROW );
78                 sizer->Add( inputDir,     1, wxGROW );
79                 sizer->Add( _outputPath,  1, wxGROW );
80                 sizer->Add( outputDir,    1, wxGROW );
81                 sizer->Add( new wxStaticText(this, -1, _T(" ")), 1, wxGROW );
82                 sizer->Add( new wxStaticText(this, -1, _T(" ")), 1, wxGROW );
83                 sizer->Add( _addCheckBox, 1, wxGROW );
84                 sizer->Add( _mhdCheckBox, 1, wxGROW );
85                 
86 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
87 #if wxMAJOR_VERSION <= 2
88                 wxFlexGridSizer *topSizer = new wxFlexGridSizer(1, 2);
89 #else
90                 wxFlexGridSizer *topSizer = new wxFlexGridSizer(2);
91 #endif
92                 topSizer->Add( textSizer, 1, wxGROW );
93                 topSizer->Add( sizer,     1, wxGROW );
94                 this->SetSizer( topSizer );
95                 this->SetAutoLayout( true );
96                 this->Layout();
97         }
98
99         WxGimmickTools::~WxGimmickTools()
100         {
101
102         }
103
104         wxString WxGimmickTools::getInputDir()
105         {
106                 return _inputPath->GetValue();
107         }
108
109         wxString WxGimmickTools::getOutputDir()
110         {
111                 return _outputPath->GetValue();
112         }
113
114         bool WxGimmickTools::getAddToDBCheckBoxValue()
115         {
116                 return _addCheckBox->GetValue();
117         }
118         
119         bool WxGimmickTools::getMHDCheckBoxValue()
120         {
121                 return _mhdCheckBox->GetValue();
122         }       
123
124         void WxGimmickTools::onInputDir(wxCommandEvent& event)
125         {
126                 long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
127                 wxDirDialog* FD = new wxDirDialog( 0, _T("Select the Input Directory"), _currentDir, style);
128                               
129                 if (FD->ShowModal()==wxID_OK)
130                 {  
131                         _inputPath->SetValue(FD->GetPath());
132                 }
133         }
134
135         void WxGimmickTools::onOutputDir(wxCommandEvent& event)
136         {
137                 long style = wxDD_DEFAULT_STYLE;
138                 wxDirDialog* FD = new wxDirDialog( 0, _T("Select the Output Directory"), _currentDir, style);
139             
140                 if (FD->ShowModal()==wxID_OK)
141                 {
142                         _outputPath->SetValue(FD->GetPath());
143                 }
144         }
145
146         void WxGimmickTools::onAddToDatabase(wxCommandEvent& event)
147         {
148                 _addFiles = _addCheckBox->GetValue();
149         }
150         
151         void WxGimmickTools::onMHD(wxCommandEvent& event)
152         {
153                 _mhd = _mhdCheckBox->GetValue();
154         }       
155
156 } // EO namespace creaImageIO
157
158