]> Creatis software - creaImageIO.git/blob - src/creaImageIOWxOutputDlg.cpp
3d2ac5117d0c96041fd2ca99f490188afd55d3f7
[creaImageIO.git] / src / creaImageIOWxOutputDlg.cpp
1 #include <creaImageIOWxOutputDlg.h>
2
3 namespace creaImageIO
4 {
5         // CTor
6    WxOutputDlg::WxOutputDlg(wxWindow *parent, const std::vector<std::string> filenames, int i_dim, bool single)
7     : wxDialog(parent, -1,_T("OUTPUT FORMAT"), wxDefaultPosition, wxSize(350,450))
8    {
9
10                 int size = filenames.size();
11                 
12                 int deflt = 1;
13
14                 std::string sentence;
15                 sentence = "You select";
16                 std::string sentence2 = "You have the possibility to select output format :";
17                 //int nbsent= 0;
18                 std::vector<std::string> outsentences;
19                 if (size == 1)
20                 {
21                    sentence += " 1 ";
22                 }
23                 else
24                 {
25                    sentence += " n ";
26                 }
27                 if(single)
28                 {
29                         sentence += " single frames";
30                 }
31                 else
32                 {
33                         sentence += " multi-frames"; 
34                 }
35                 sentence += " as output";
36           
37                 
38                 if (size == 1)
39                 {
40                         if(single)
41                         {
42                                 outsentences.push_back("It shall be a single file with a single 2D frmae");
43                         }
44                         else
45                         {
46                                 outsentences.push_back("It shall be  multiple files with 2D frames");
47                                 outsentences.push_back("It shall be a single file with 3D frames");
48                         }                       
49                 }
50                 else
51                 {
52                         if(single)
53                         {
54                                 outsentences.push_back("It shall be a single file with 3D frames");
55                                 outsentences.push_back("It shall be  multiple files with 2D frames");
56                         }
57                         else
58                         {
59                                 outsentences.push_back("It shall be a single file with (3D+t) frames");
60                                 outsentences.push_back("It shall be  multiple (n+t) files with 2D frames");
61                                 outsentences.push_back("It shall be  multiple (n) files with (2D+t) frames");
62                                 outsentences.push_back("It shall be a multiple (t) files with (2D+n) frames");
63                                 deflt = 3;
64                         }
65                 
66                 }
67                 if(i_dim != -1)
68                 {
69                         deflt = i_dim;
70                 }
71
72
73           int start_point = 45;
74           /// \TODO fix unused variable ExportText
75           wxStaticText * ExportText=new wxStaticText(this,-1,crea::std2wx(sentence), wxPoint(5,10));
76           
77           std::vector<std::string>::iterator it = outsentences.begin();
78           for(int i = 0;it != outsentences.end(); it++, i++, start_point += 45)
79           {
80                  wxCheckBox *check = new wxCheckBox(this, -1, crea::std2wx((*it)), wxPoint(5,start_point) );
81                  if(i == deflt)
82                          check->SetValue(true);
83                  else
84                          check->SetValue(false);
85                   Connect( check->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &WxOutputDlg::OnChange );
86                   checkOut.push_back(check);
87           }
88           
89          checkAsking = new wxCheckBox(this, -1, _T("Do you want to save this output and no more asking"), wxPoint(5,start_point) );
90
91           // VALIDATION BUTTON
92           wxButton *Ok = new wxButton(this, -1,_T("OK"), wxPoint(5,start_point+20) );
93           
94           Connect( Ok->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxOutputDlg::OnOk );
95           
96           /// \TODO fix unused variable Cancel
97           wxButton *Cancel = new wxButton(this, wxID_CANCEL,_T("CANCEL"), wxPoint(100,start_point+20) );
98           Layout(); 
99           
100         }
101
102         WxOutputDlg::~WxOutputDlg(){}
103
104         void WxOutputDlg::OnOk(wxCommandEvent &event)
105         {
106                 Close();
107                 SetReturnCode(wxID_OK);
108         }       
109
110         void WxOutputDlg::OnChange(wxCommandEvent& event)
111         {
112                 std::vector<wxCheckBox*>::iterator it = checkOut.begin();
113
114                 for(int i = 0;it != checkOut.end(); it++, i++)
115                 {
116                         if( (*it)->GetId() == event.GetId())
117                         {
118                         }
119                         else
120                         {
121                                 (*it)->SetValue(false);
122                         }
123                 }
124         }
125
126         const std::string WxOutputDlg::getDim()
127         {
128                 char res[2];
129                 std::vector<wxCheckBox*>::iterator it = checkOut.begin();
130             for(int i = 1;it != checkOut.end(); it++, i++)
131             {
132                         if( (*it)->GetValue() )
133                         {
134                                 sprintf(res,"%d", i);
135                         }
136                         else
137                         {
138                                 
139                         }
140                 }
141                 return res;
142         }
143         const std::string WxOutputDlg::getAsking()
144         { 
145                 if(checkAsking->GetValue())
146                         return "false"; 
147                 else
148                         return "true";
149         }
150 }