creaImageIOWxOutputDlg.cpp

Go to the documentation of this file.
00001 #include <creaImageIOWxOutputDlg.h>
00002 
00003 namespace creaImageIO
00004 {
00005         // CTor
00006    WxOutputDlg::WxOutputDlg(wxWindow *parent, const std::vector<std::string> filenames, int i_dim, bool single)
00007     : wxDialog(parent, -1,_T("OUTPUT FORMAT"), wxDefaultPosition, wxSize(350,450))
00008    {
00009 
00010                 int size = filenames.size();
00011                 
00012                 int deflt = 1;
00013 
00014                 std::string sentence;
00015                 sentence = "You select";
00016                 std::string sentence2 = "You have the possibility to select output format :";
00017                 int nbsent= 0;
00018                 std::vector<std::string> outsentences;
00019                 if (size == 1)
00020                 {
00021                    sentence += " 1 ";
00022                 }
00023                 else
00024                 {
00025                    sentence += " n ";
00026                 }
00027                 if(single)
00028                 {
00029                         sentence += " single frames";
00030                 }
00031                 else
00032                 {
00033                         sentence += " multi-frames"; 
00034                 }
00035                 sentence += " as output";
00036           
00037                 
00038                 if (size == 1)
00039                 {
00040                         if(single)
00041                         {
00042                                 outsentences.push_back("It shall be a single file with a single 2D frmae");
00043                         }
00044                         else
00045                         {
00046                                 outsentences.push_back("It shall be  multiple files with 2D frames");
00047                                 outsentences.push_back("It shall be a single file with 3D frames");
00048                         }                       
00049                 }
00050                 else
00051                 {
00052                         if(single)
00053                         {
00054                                 outsentences.push_back("It shall be a single file with 3D frames");
00055                                 outsentences.push_back("It shall be  multiple files with 2D frames");
00056                         }
00057                         else
00058                         {
00059                                 outsentences.push_back("It shall be a single file with (3D+t) frames");
00060                                 outsentences.push_back("It shall be  multiple (n+t) files with 2D frames");
00061                                 outsentences.push_back("It shall be  multiple (n) files with (2D+t) frames");
00062                                 outsentences.push_back("It shall be a multiple (t) files with (2D+n) frames");
00063                                 deflt = 3;
00064                         }
00065                 
00066                 }
00067                 if(i_dim != -1)
00068                 {
00069                         deflt = i_dim;
00070                 }
00071 
00072 
00073           int start_point = 45;
00074           wxStaticText * ExportText=new wxStaticText(this,-1,crea::std2wx(sentence), wxPoint(5,10));
00075           
00076           std::vector<std::string>::iterator it = outsentences.begin();
00077           for(int i = 0;it != outsentences.end(); it++, i++, start_point += 45)
00078           {
00079                  wxCheckBox *check = new wxCheckBox(this, -1, crea::std2wx((*it)), wxPoint(5,start_point) );
00080                  if(i == deflt)
00081                          check->SetValue(true);
00082                  else
00083                          check->SetValue(false);
00084                   Connect( check->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &WxOutputDlg::OnChange );
00085                   checkOut.push_back(check);
00086           }
00087           
00088          checkAsking = new wxCheckBox(this, -1, _T("Do you want to save this output and no more asking"), wxPoint(5,start_point) );
00089 
00090           // VALIDATION BUTTON
00091           wxButton *Ok = new wxButton(this, -1,_T("OK"), wxPoint(5,start_point+20) );
00092           Connect( Ok->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxOutputDlg::OnOk ); 
00093         
00094           wxButton *Cancel = new wxButton(this, wxID_CANCEL,_T("CANCEL"), wxPoint(100,start_point+20) );
00095           Layout(); 
00096           
00097         }
00098 
00099         WxOutputDlg::~WxOutputDlg(){}
00100 
00101         void WxOutputDlg::OnOk(wxCommandEvent &event)
00102         {
00103                 Close();
00104                 SetReturnCode(wxID_OK);
00105         }       
00106 
00107         void WxOutputDlg::OnChange(wxCommandEvent& event)
00108         {
00109                 std::vector<wxCheckBox*>::iterator it = checkOut.begin();
00110 
00111                 for(int i = 0;it != checkOut.end(); it++, i++)
00112                 {
00113                         if( (*it)->GetId() == event.GetId())
00114                         {
00115                         }
00116                         else
00117                         {
00118                                 (*it)->SetValue(false);
00119                         }
00120                 }
00121         }
00122 
00123         const std::string WxOutputDlg::getDim()
00124         {
00125                 char res[2];
00126                 std::vector<wxCheckBox*>::iterator it = checkOut.begin();
00127             for(int i = 1;it != checkOut.end(); it++, i++)
00128             {
00129                         if( (*it)->GetValue() )
00130                         {
00131                                 sprintf(res,"%d", i);
00132                         }
00133                         else
00134                         {
00135                                 
00136                         }
00137                 }
00138                 return res;
00139         }
00140         const std::string WxOutputDlg::getAsking()
00141         { 
00142                 if(checkAsking->GetValue())
00143                         return "false"; 
00144                 else
00145                         return "true";
00146         }
00147 }