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