]> Creatis software - creaImageIO.git/blobdiff - src/creaImageIOWxOutputDlg.cpp
additional document for output
[creaImageIO.git] / src / creaImageIOWxOutputDlg.cpp
diff --git a/src/creaImageIOWxOutputDlg.cpp b/src/creaImageIOWxOutputDlg.cpp
new file mode 100644 (file)
index 0000000..a927191
--- /dev/null
@@ -0,0 +1,147 @@
+#include <creaImageIOWxOutputDlg.h>
+
+namespace creaImageIO
+{
+       // CTor
+   WxOutputDlg::WxOutputDlg(wxWindow *parent, const std::vector<std::string> filenames, int i_dim, bool single)
+    : wxDialog(parent, -1,_T("OUTPUT FORMAT"), wxDefaultPosition, wxSize(350,450))
+   {
+
+               int size = filenames.size();
+               
+               int deflt = 1;
+
+               std::string sentence;
+               sentence = "You select";
+               std::string sentence2 = "You have the possibility to select output format :";
+               int nbsent= 0;
+               std::vector<std::string> outsentences;
+               if (size == 1)
+               {
+                  sentence += " 1 ";
+               }
+               else
+               {
+                  sentence += " n ";
+               }
+               if(single)
+               {
+                       sentence += " single frames";
+               }
+               else
+               {
+                       sentence += " multi-frames"; 
+               }
+               sentence += " as output";
+         
+               
+               if (size == 1)
+               {
+                       if(single)
+                       {
+                               outsentences.push_back("It shall be a single file with a single 2D frmae");
+                       }
+                       else
+                       {
+                               outsentences.push_back("It shall be  multiple files with 2D frames");
+                               outsentences.push_back("It shall be a single file with 3D frames");
+                       }                       
+               }
+               else
+               {
+                       if(single)
+                       {
+                               outsentences.push_back("It shall be a single file with 3D frames");
+                               outsentences.push_back("It shall be  multiple files with 2D frames");
+                       }
+                       else
+                       {
+                               outsentences.push_back("It shall be a single file with (3D+t) frames");
+                               outsentences.push_back("It shall be  multiple (n+t) files with 2D frames");
+                               outsentences.push_back("It shall be  multiple (n) files with (2D+t) frames");
+                               outsentences.push_back("It shall be a multiple (t) files with (2D+n) frames");
+                               deflt = 3;
+                       }
+               
+               }
+               if(i_dim != -1)
+               {
+                       deflt = i_dim;
+               }
+
+
+         int start_point = 45;
+         wxStaticText * ExportText=new wxStaticText(this,-1,_T(sentence), wxPoint(5,10));
+         
+         std::vector<std::string>::iterator it = outsentences.begin();
+         for(int i = 0;it != outsentences.end(); it++, i++, start_point += 45)
+         {
+                wxCheckBox *check = new wxCheckBox(this, -1, _T((*it)), wxPoint(5,start_point) );
+                if(i == deflt)
+                        check->SetValue(true);
+                else
+                        check->SetValue(false);
+                 Connect( check->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &WxOutputDlg::OnChange );
+                 checkOut.push_back(check);
+         }
+         
+        checkAsking = new wxCheckBox(this, -1, _T(("Do you want to save this output and no more asking")), wxPoint(5,start_point) );
+
+         // VALIDATION BUTTON
+         wxButton *Ok = new wxButton(this, -1,_T("OK"), wxPoint(5,start_point+20) );
+         Connect( Ok->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxOutputDlg::OnOk ); 
+       
+         wxButton *Cancel = new wxButton(this, wxID_CANCEL,_T("CANCEL"), wxPoint(100,start_point+20) );
+         Layout(); 
+         
+       }
+
+       WxOutputDlg::~WxOutputDlg(){}
+
+       void WxOutputDlg::OnOk(wxCommandEvent &event)
+       {
+               Close();
+               SetReturnCode(wxID_OK);
+       }       
+
+       void WxOutputDlg::OnChange(wxCommandEvent& event)
+       {
+               std::vector<wxCheckBox*>::iterator it = checkOut.begin();
+
+               for(int i = 0;it != checkOut.end(); it++, i++)
+               {
+                       if( (*it)->GetId() == event.GetId())
+                       {
+                       }
+                       else
+                       {
+                               (*it)->SetValue(false);
+                       }
+               }
+       }
+
+       const std::string WxOutputDlg::getDim()
+       {
+               char res[2];
+               std::vector<wxCheckBox*>::iterator it = checkOut.begin();
+           for(int i = 1;it != checkOut.end(); it++, i++)
+           {
+                       if( (*it)->GetValue() )
+                       {
+                               sprintf(res,"%d", i);
+                       }
+                       else
+                       {
+                               
+                       }
+               }
+               return res;
+       }
+       const std::string WxOutputDlg::getAsking()
+       { 
+               if(checkAsking->GetValue())
+                       return "false"; 
+               else
+                       return "true";
+       }
+}