PreferencesDialog.cpp

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
00002 
00027 #include <config.h>
00028 #include "panoinc_WX.h"
00029 #include "wx/listbook.h"
00030 #include <wx/stdpaths.h> 
00031 #include "panoinc.h"
00032 
00033 #include "base_wx/wxPlatform.h"
00034 #include "base_wx/LensTools.h"
00035 
00036 #include "hugin/huginApp.h"
00037 #include "hugin/config_defaults.h"
00038 #include "hugin/PreferencesDialog.h"
00039 #include "hugin/CPDetectorDialog.h"
00040 #include "hugin/MainFrame.h"
00041 #include "base_wx/huginConfig.h"
00042 
00043 // validators are working different somehow...
00044 //#define MY_STR_VAL(id, filter) { XRCCTRL(*this, "prefs_" #id, wxTextCtrl)->SetValidator(wxTextValidator(filter, &id)); }
00045 //#define MY_SPIN_VAL(id) {     XRCCTRL(*this, "prefs_" #id, wxSpinCtrl)->SetValidator(wxGenericValidator(&id)); }
00046 
00047 #define MY_STR_VAL(id, val) { XRCCTRL(*this, id, wxTextCtrl)->SetValue(val); };
00048 #define MY_SPIN_VAL(id, val) { XRCCTRL(*this, id, wxSpinCtrl)->SetValue(val); };
00049 #define MY_BOOL_VAL(id, val) { XRCCTRL(*this, id, wxCheckBox)->SetValue(val); };
00050 #define MY_CHOICE_VAL(id, val) { XRCCTRL(*this, id, wxChoice)->SetSelection(val); };
00051 #define MY_STATIC_VAL(id, val) { XRCCTRL(*this, id, wxStaticText)->SetLabel(val); };
00052 
00053 #define MY_G_STR_VAL(id)  XRCCTRL(*this, id, wxTextCtrl)->GetValue()
00054 #define MY_G_SPIN_VAL(id)  XRCCTRL(*this, id, wxSpinCtrl)->GetValue()
00055 #define MY_G_BOOL_VAL(id)  XRCCTRL(*this, id, wxCheckBox)->GetValue()
00056 #define MY_G_CHOICE_VAL(id)  XRCCTRL(*this, id, wxChoice)->GetSelection()
00057 
00058 
00059 
00060 BEGIN_EVENT_TABLE(PreferencesDialog, wxDialog)
00061     EVT_BUTTON(wxID_OK, PreferencesDialog::OnOk)
00062     EVT_BUTTON(wxID_HELP, PreferencesDialog::OnHelp)
00063     EVT_BUTTON(wxID_CANCEL, PreferencesDialog::OnCancel)
00064     EVT_BUTTON(XRCID("prefs_defaults"), PreferencesDialog::OnRestoreDefaults)
00065     EVT_BUTTON(XRCID("prefs_enblend_select"), PreferencesDialog::OnEnblendExe)
00066     EVT_BUTTON(XRCID("prefs_enblend_enfuse_select"), PreferencesDialog::OnEnfuseExe)
00067     EVT_BUTTON(XRCID("pref_exiftool_argfile_choose"), PreferencesDialog::OnExifArgfile)
00068     EVT_BUTTON(XRCID("pref_exiftool_argfile_edit"), PreferencesDialog::OnExifArgfileEdit)
00069     EVT_BUTTON(XRCID("pref_exiftool_argfile2_choose"), PreferencesDialog::OnExifArgfile2)
00070     EVT_BUTTON(XRCID("pref_exiftool_argfile2_edit"), PreferencesDialog::OnExifArgfileEdit2)
00071     EVT_CHECKBOX(XRCID("pref_exiftool_metadata"), PreferencesDialog::OnExifTool)
00072     EVT_CHECKBOX(XRCID("prefs_ft_RotationSearch"), PreferencesDialog::OnRotationCheckBox)
00073     EVT_CHECKBOX(XRCID("prefs_enblend_Custom"), PreferencesDialog::OnCustomEnblend)
00074     EVT_CHECKBOX(XRCID("prefs_enblend_enfuseCustom"), PreferencesDialog::OnCustomEnfuse)
00075     EVT_BUTTON(XRCID("pref_cpdetector_new"), PreferencesDialog::OnCPDetectorAdd)
00076     EVT_BUTTON(XRCID("pref_cpdetector_edit"), PreferencesDialog::OnCPDetectorEdit)
00077     EVT_BUTTON(XRCID("pref_cpdetector_del"), PreferencesDialog::OnCPDetectorDelete)
00078     EVT_BUTTON(XRCID("pref_cpdetector_moveup"), PreferencesDialog::OnCPDetectorMoveUp)
00079     EVT_BUTTON(XRCID("pref_cpdetector_movedown"), PreferencesDialog::OnCPDetectorMoveDown)
00080     EVT_BUTTON(XRCID("pref_cpdetector_default"), PreferencesDialog::OnCPDetectorDefault)
00081     EVT_LISTBOX_DCLICK(XRCID("pref_cpdetector_list"), PreferencesDialog::OnCPDetectorListDblClick)
00082     EVT_BUTTON(XRCID("pref_cpdetector_load"), PreferencesDialog::OnCPDetectorLoad)
00083     EVT_BUTTON(XRCID("pref_cpdetector_save"), PreferencesDialog::OnCPDetectorSave)
00084     EVT_CHOICE(XRCID("pref_ldr_output_file_format"), PreferencesDialog::OnFileFormatChanged)
00085     EVT_CHOICE(XRCID("pref_processor_gui"), PreferencesDialog::OnProcessorChanged)
00086     EVT_CHOICE(XRCID("pref_default_blender"), PreferencesDialog::OnBlenderChanged)
00087     EVT_TEXT(XRCID("prefs_project_filename"), PreferencesDialog::OnUpdateProjectFilename)
00088     EVT_TEXT(XRCID("prefs_output_filename"), PreferencesDialog::OnUpdateOutputFilename)
00089 END_EVENT_TABLE()
00090 
00091 
00092 PreferencesDialog::PreferencesDialog(wxWindow* parent)
00093 //: wxDialog(parent, -1, _("Preferences - hugin"))
00094 {
00095     DEBUG_TRACE("");
00096     // load our children. some children might need special
00097     // initialization. this will be done later.
00098     wxXmlResource::Get()->LoadDialog(this, parent, wxT("pref_dialog"));
00099 
00100 #ifdef __WXMSW__
00101     wxIcon myIcon(huginApp::Get()->GetXRCPath() + wxT("data/hugin.ico"),wxBITMAP_TYPE_ICO);
00102 #else
00103     wxIcon myIcon(huginApp::Get()->GetXRCPath() + wxT("data/hugin.png"),wxBITMAP_TYPE_PNG);
00104 #endif
00105     SetIcon(myIcon);
00106 
00107     // Custom setup ( stuff that can not be done in XRC )
00108     XRCCTRL(*this, "prefs_ft_RotationStartAngle", wxSpinCtrl)->SetRange(-180,0);
00109     XRCCTRL(*this, "prefs_ft_RotationStopAngle", wxSpinCtrl)->SetRange(0,180);
00110     XRCCTRL(*this, "prefs_ass_nControlPoints", wxSpinCtrl)->SetRange(3,3000);
00111 
00112     wxChoice* lang_choice = XRCCTRL(*this, "prefs_gui_language", wxChoice);
00113     // add languages to choice
00114     long* lp = new long;
00115     *lp = wxLANGUAGE_DEFAULT;
00116     lang_choice->Append(_("System default"), lp);
00117     lp = new long;
00118     *lp = wxLANGUAGE_BASQUE;
00119     lang_choice->Append(_("Basque"), lp);
00125     lp = new long;
00126     *lp = wxLANGUAGE_CATALAN;
00127     lang_choice->Append(_("Catalan"), lp);
00128     lp = new long;
00129     *lp = wxLANGUAGE_CHINESE_SIMPLIFIED;
00130     lang_choice->Append(_("Chinese (Simplified)"), lp);
00131     lp = new long;
00132     *lp = wxLANGUAGE_CHINESE_TRADITIONAL;
00133     lang_choice->Append(_("Chinese (Traditional)"), lp);
00134     lp = new long;
00135     *lp = wxLANGUAGE_CZECH;
00136     lang_choice->Append(_("Czech"), lp);
00137     lp = new long;
00138     *lp = wxLANGUAGE_DANISH;
00139     lang_choice->Append(_("Danish"), lp);
00140     lp = new long;
00141     *lp = wxLANGUAGE_DUTCH;
00142     lang_choice->Append(_("Dutch"), lp);
00143     lp = new long;
00144     *lp = wxLANGUAGE_ENGLISH;
00145     lang_choice->Append(_("English"), lp);
00146     lp = new long;
00147     *lp = wxLANGUAGE_FRENCH;
00148     lang_choice->Append(_("French"), lp);
00149     lp = new long;
00150     *lp = wxLANGUAGE_GERMAN;
00151     lang_choice->Append(_("German"), lp);
00152     lp = new long;
00153     *lp = wxLANGUAGE_HUNGARIAN;
00154     lang_choice->Append(_("Hungarian"), lp);
00155     lp = new long;
00156     *lp = wxLANGUAGE_ITALIAN;
00157     lang_choice->Append(_("Italian"), lp);
00158     lp = new long;
00159     *lp = wxLANGUAGE_JAPANESE;
00160     lang_choice->Append(_("Japanese"), lp);
00166     lp = new long;
00167     *lp = wxLANGUAGE_POLISH;
00168     lang_choice->Append(_("Polish"), lp);
00169     lp = new long;
00170     *lp = wxLANGUAGE_PORTUGUESE_BRAZILIAN;
00171     lang_choice->Append(_("Portuguese (Brazilian)"), lp);
00172     lp = new long;
00173     *lp = wxLANGUAGE_RUSSIAN;
00174     lang_choice->Append(_("Russian"), lp);
00175     lp = new long;
00176     *lp = wxLANGUAGE_SLOVAK;
00177     lang_choice->Append(_("Slovak"), lp);
00183     lp = new long;
00184     *lp = wxLANGUAGE_SPANISH;
00185     lang_choice->Append(_("Spanish"), lp);
00186     lp = new long;
00187     *lp = wxLANGUAGE_SWEDISH;
00188     lang_choice->Append(_("Swedish"), lp);
00194     lp = new long;
00195     *lp = wxLANGUAGE_FINNISH;
00196     lang_choice->Append(_("Finnish"), lp);
00197     lp = new long;
00198     *lp = wxLANGUAGE_VALENCIAN;
00199     lang_choice->Append(_("Valencian (Southern Catalan)"), lp);
00200     lang_choice->SetSelection(0);
00201 
00202     // default blender settings
00203     FillBlenderList(XRCCTRL(*this, "pref_default_blender", wxChoice));
00204 
00205     wxStaticText* preview=XRCCTRL(*this, "prefs_project_filename_preview", wxStaticText);
00206     preview->SetWindowStyle(preview->GetWindowStyle() | wxST_ELLIPSIZE_START);
00207     preview=XRCCTRL(*this, "prefs_output_filename_preview", wxStaticText);
00208     preview->SetWindowStyle(preview->GetWindowStyle() | wxST_ELLIPSIZE_START);
00209     // enable auto-completion
00210     XRCCTRL(*this, "prefs_misc_tempdir", wxTextCtrl)->AutoCompleteDirectories();
00211     XRCCTRL(*this, "pref_exiftool_argfile", wxTextCtrl)->AutoCompleteFileNames();
00212     XRCCTRL(*this, "pref_exiftool_argfile2", wxTextCtrl)->AutoCompleteFileNames();
00213     XRCCTRL(*this, "prefs_enblend_EnblendExe", wxTextCtrl)->AutoCompleteFileNames();
00214     XRCCTRL(*this, "prefs_enblend_EnfuseExe", wxTextCtrl)->AutoCompleteFileNames();
00215     // load autopano settings
00216     wxConfigBase* cfg = wxConfigBase::Get();
00217     m_CPDetectorList = XRCCTRL(*this, "pref_cpdetector_list", wxListBox);
00218     cpdetector_config_edit.Read(cfg);
00219 
00220     // Load configuration values from wxConfig
00221     UpdateDisplayData(0);
00222 
00223 #ifdef __WXMSW__
00224     // wxFrame does have a strange background color on Windows, copy color from a child widget
00225     this->SetBackgroundColour(XRCCTRL(*this, "prefs_tab", wxNotebook)->GetBackgroundColour());
00226 #endif
00227 
00228     wxCheckBox* show_hints=XRCCTRL(*this,"pref_show_projection_hints",wxCheckBox);
00229     show_hints->Enable(true);
00230     show_hints->Show(true);
00231     show_hints->Update();
00232     Update();
00233 
00234     GetSizer()->SetSizeHints(this);
00235     //    GetSizer()->Layout();
00236 
00237 
00238     // only enable bundled if the build is actually bundled.
00239 #if defined __WXMSW__ || defined MAC_SELF_CONTAINED_BUNDLE
00240 
00241 #else
00242     MY_BOOL_VAL("prefs_enblend_Custom", HUGIN_ENBLEND_EXE_CUSTOM);
00243     XRCCTRL(*this, "prefs_enblend_Custom", wxCheckBox)->Hide();
00244     cfg->Write(wxT("/Enblend/Custom"), HUGIN_ENBLEND_EXE_CUSTOM);
00245 
00246     MY_BOOL_VAL("prefs_enblend_enfuseCustom", HUGIN_ENFUSE_EXE_CUSTOM);
00247     XRCCTRL(*this, "prefs_enblend_enfuseCustom", wxCheckBox)->Hide();
00248     cfg->Write(wxT("/Enfuse/Custom"), HUGIN_ENFUSE_EXE_CUSTOM);
00249 #endif
00250 
00251     RestoreFramePosition(this, wxT("PreferencesDialog"));
00252 }
00253 
00254 
00255 PreferencesDialog::~PreferencesDialog()
00256 {
00257     DEBUG_TRACE("begin dtor");
00258 
00259     StoreFramePosition(this, wxT("PreferencesDialog"));
00260 
00261     // delete custom list data
00262     wxChoice* lang_choice = XRCCTRL(*this, "prefs_gui_language", wxChoice);
00263     for (int i = 0; i < (int) lang_choice->GetCount(); i++)
00264     {
00265         delete static_cast<long*>(lang_choice->GetClientData(i));
00266     }
00267 
00268     DEBUG_TRACE("end dtor");
00269 }
00270 
00271 void PreferencesDialog::OnOk(wxCommandEvent& e)
00272 {
00273     UpdateConfigData();
00274     this->EndModal(wxOK);
00275 }
00276 
00277 void PreferencesDialog::OnCancel(wxCommandEvent& e)
00278 {
00279     this->EndModal(wxCANCEL);
00280 }
00281 
00282 void PreferencesDialog::OnHelp(wxCommandEvent& e)
00283 {
00284     MainFrame::Get()->DisplayHelp(wxT("Hugin_Preferences.html"));
00285 };
00286 
00287 void PreferencesDialog::OnRotationCheckBox(wxCommandEvent& e)
00288 {
00289     EnableRotationCtrls(e.IsChecked());
00290 }
00291 
00292 void PreferencesDialog::OnEnblendExe(wxCommandEvent& e)
00293 {
00294     wxFileDialog dlg(this,_("Select Enblend"),
00295                      wxT(""), wxT(HUGIN_ENBLEND_EXE),
00296 #ifdef __WXMSW__
00297                      _("Executables (*.exe)|*.exe"),
00298 #else
00299                      wxT("*"),
00300 #endif
00301                      wxFD_OPEN, wxDefaultPosition);
00302     if (dlg.ShowModal() == wxID_OK)
00303     {
00304         XRCCTRL(*this, "prefs_enblend_EnblendExe", wxTextCtrl)->SetValue(
00305             dlg.GetPath());
00306     }
00307 }
00308 
00309 void PreferencesDialog::OnEnfuseExe(wxCommandEvent& e)
00310 {
00311     wxFileDialog dlg(this,_("Select Enfuse"),
00312                      wxT(""), wxT(HUGIN_ENFUSE_EXE),
00313 #ifdef __WXMSW__
00314                      _("Executables (*.exe)|*.exe"),
00315 #else
00316                      wxT("*"),
00317 #endif
00318                      wxFD_OPEN, wxDefaultPosition);
00319     if (dlg.ShowModal() == wxID_OK)
00320     {
00321         XRCCTRL(*this, "prefs_enblend_EnfuseExe", wxTextCtrl)->SetValue(
00322             dlg.GetPath());
00323     }
00324 }
00325 
00326 void PreferencesDialog::OnCustomEnblend(wxCommandEvent& e)
00327 {
00328     XRCCTRL(*this, "prefs_enblend_EnblendExe", wxTextCtrl)->Enable(e.IsChecked());
00329     XRCCTRL(*this, "prefs_enblend_select", wxButton)->Enable(e.IsChecked());
00330 }
00331 
00332 void PreferencesDialog::OnCustomEnfuse(wxCommandEvent& e)
00333 {
00334     XRCCTRL(*this, "prefs_enblend_EnfuseExe", wxTextCtrl)->Enable(e.IsChecked());
00335     XRCCTRL(*this, "prefs_enblend_enfuse_select", wxButton)->Enable(e.IsChecked());
00336 }
00337 
00338 void PreferencesDialog::OnExifArgfile(wxCommandEvent & e)
00339 {
00340     wxFileDialog dlg(this,_("Select ExifTool argfile"),
00341                      wxT(""), XRCCTRL(*this, "pref_exiftool_argfile", wxTextCtrl)->GetValue(), 
00342                      _("ExifTool Argfiles (*.arg)|*.arg|All Files(*)|*"),
00343                      wxFD_OPEN, wxDefaultPosition);
00344     if (dlg.ShowModal() == wxID_OK)
00345     {
00346         XRCCTRL(*this, "pref_exiftool_argfile", wxTextCtrl)->SetValue(
00347             dlg.GetPath());
00348     }
00349 }
00350 
00351 void CreateNewArgFile(const wxString& newFilename)
00352 {
00353     wxTextFile defaultFile(MainFrame::Get()->GetDataPath()+wxT("hugin_exiftool_copy.arg"));
00354     defaultFile.Open();
00355     wxTextFile newFile(newFilename);
00356     newFile.Create();
00357     for(size_t i=0; i<defaultFile.GetLineCount(); ++i)
00358     {
00359         newFile.AddLine(defaultFile[i]);
00360     };
00361     newFile.Write();
00362     defaultFile.Close();
00363     newFile.Close();
00364 };
00365 
00366 void PreferencesDialog::OnExifArgfileEdit(wxCommandEvent & e)
00367 {
00368     wxString filename=XRCCTRL(*this, "pref_exiftool_argfile", wxTextCtrl)->GetValue();
00369     if(!filename.empty())
00370     {
00371         if(!wxFileName::FileExists(filename))
00372         {
00373             if( wxMessageBox(wxString::Format(_("File %s does not exist.\nShould the argfile be created with default tags?"),filename.c_str()),
00374                   _("Exiftool argfile"), wxYES_NO  | wxICON_EXCLAMATION,this)!=wxYES)
00375             {
00376                 return;
00377             };
00378             CreateNewArgFile(filename);
00379         };
00380     }
00381     else
00382     {
00383         if( wxMessageBox(_("No file selected.\nShould an argfile be created with default tags?"),
00384                 _("Exiftool argfile"), wxYES_NO  | wxICON_EXCLAMATION,this)!=wxYES)
00385         {
00386             return;
00387         };
00388         wxFileDialog dlg(this,_("Select new ExifTool argfile"),
00389             wxStandardPaths::Get().GetUserConfigDir(), wxT(""),
00390                          _("ExifTool Argfiles (*.arg)|*.arg|All Files(*)|*"),
00391                          wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition);
00392         if (dlg.ShowModal() != wxID_OK)
00393         {
00394             return;
00395         };
00396         filename=dlg.GetPath();
00397         CreateNewArgFile(filename);
00398     };
00399     XRCCTRL(*this, "pref_exiftool_argfile", wxTextCtrl)->SetValue(filename);
00400     wxDialog * edit_dlg = wxXmlResource::Get()->LoadDialog(this, wxT("pref_edit_argfile"));
00401     RestoreFramePosition(edit_dlg, wxT("EditArgfile"));
00402     wxTextCtrl* argfileControl=XRCCTRL(*edit_dlg, "pref_edit_textcontrol", wxTextCtrl);
00403     argfileControl->LoadFile(filename);
00404     if(edit_dlg->ShowModal() == wxID_OK)
00405     {
00406         if(!argfileControl->SaveFile(filename))
00407         {
00408             wxMessageBox(wxString::Format(_("Could not save file \"%s\"."), filename.c_str()),
00409                 _("Error"), wxOK | wxICON_ERROR);
00410         };
00411         StoreFramePosition(edit_dlg, wxT("EditArgfile"));
00412     };
00413 };
00414 
00415 void PreferencesDialog::OnExifArgfile2(wxCommandEvent & e)
00416 {
00417     wxFileDialog dlg(this, _("Select ExifTool argfile"),
00418         wxT(""), XRCCTRL(*this, "pref_exiftool_argfile2", wxTextCtrl)->GetValue(),
00419         _("ExifTool Argfiles (*.arg)|*.arg|All Files(*)|*"),
00420         wxFD_OPEN, wxDefaultPosition);
00421     if (dlg.ShowModal() == wxID_OK)
00422     {
00423         XRCCTRL(*this, "pref_exiftool_argfile2", wxTextCtrl)->SetValue(
00424             dlg.GetPath());
00425     }
00426 }
00427 
00428 void PreferencesDialog::OnExifArgfileEdit2(wxCommandEvent & e)
00429 {
00430     wxString filename = XRCCTRL(*this, "pref_exiftool_argfile2", wxTextCtrl)->GetValue();
00431     if (!filename.empty())
00432     {
00433         if (!wxFileName::FileExists(filename))
00434         {
00435             if (wxMessageBox(wxString::Format(_("File %s does not exist.\nShould an empty argfile be created?"), filename.c_str()),
00436                 _("Exiftool argfile"), wxYES_NO | wxICON_EXCLAMATION, this) != wxYES)
00437             {
00438                 return;
00439             };
00440             wxTextFile newFile(filename);
00441             newFile.Create();
00442             newFile.Write();
00443             newFile.Close();
00444         };
00445     }
00446     else
00447     {
00448         if (wxMessageBox(_("No file selected.\nShould an empty argfile be created?"),
00449             _("Exiftool argfile"), wxYES_NO | wxICON_EXCLAMATION, this) != wxYES)
00450         {
00451             return;
00452         };
00453         wxFileDialog dlg(this, _("Select new ExifTool argfile"),
00454             wxStandardPaths::Get().GetUserConfigDir(), wxT(""),
00455             _("ExifTool Argfiles (*.arg)|*.arg|All Files(*)|*"),
00456             wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition);
00457         if (dlg.ShowModal() != wxID_OK)
00458         {
00459             return;
00460         };
00461         filename = dlg.GetPath();
00462         wxTextFile newFile(filename);
00463         newFile.Create();
00464         newFile.Write();
00465         newFile.Close();
00466     };
00467     XRCCTRL(*this, "pref_exiftool_argfile2", wxTextCtrl)->SetValue(filename);
00468     wxDialog * edit_dlg = wxXmlResource::Get()->LoadDialog(this, wxT("pref_edit_argfile_placeholders"));
00469     RestoreFramePosition(edit_dlg, wxT("EditArgfilePlaceholders"));
00470     wxTextCtrl* argfileControl = XRCCTRL(*edit_dlg, "pref_edit_textcontrol", wxTextCtrl);
00471     argfileControl->LoadFile(filename);
00472     if (edit_dlg->ShowModal() == wxID_OK)
00473     {
00474         if (!argfileControl->SaveFile(filename))
00475         {
00476             wxMessageBox(wxString::Format(_("Could not save file \"%s\"."), filename.c_str()),
00477                 _("Error"), wxOK | wxICON_ERROR);
00478         };
00479         StoreFramePosition(edit_dlg, wxT("EditArgfilePlaceholders"));
00480     };
00481 };
00482 
00483 void PreferencesDialog::OnExifTool(wxCommandEvent & e)
00484 {
00485     bool copyMetadata=XRCCTRL(*this, "pref_exiftool_metadata", wxCheckBox)->GetValue();
00486     XRCCTRL(*this, "pref_exiftool_argfile_intermediate_label", wxStaticText)->Enable(copyMetadata);
00487     XRCCTRL(*this, "pref_exiftool_argfile_label", wxStaticText)->Enable(copyMetadata);
00488     XRCCTRL(*this, "pref_exiftool_argfile", wxTextCtrl)->Enable(copyMetadata);
00489     XRCCTRL(*this, "pref_exiftool_argfile_choose", wxButton)->Enable(copyMetadata);
00490     XRCCTRL(*this, "pref_exiftool_argfile_edit", wxButton)->Enable(copyMetadata);
00491     XRCCTRL(*this, "pref_exiftool_argfile_final_label", wxStaticText)->Enable(copyMetadata);
00492     XRCCTRL(*this, "pref_exiftool_argfile2_label", wxStaticText)->Enable(copyMetadata);
00493     XRCCTRL(*this, "pref_exiftool_argfile2", wxTextCtrl)->Enable(copyMetadata);
00494     XRCCTRL(*this, "pref_exiftool_argfile2_choose", wxButton)->Enable(copyMetadata);
00495     XRCCTRL(*this, "pref_exiftool_argfile2_edit", wxButton)->Enable(copyMetadata);
00496     XRCCTRL(*this, "pref_exiftool_gpano", wxCheckBox)->Enable(copyMetadata);
00497 };
00498 
00499 void PreferencesDialog::EnableRotationCtrls(bool enable)
00500 {
00501     XRCCTRL(*this, "prefs_ft_rot_panel", wxPanel)->Enable(enable);
00502 }
00503 
00504 void PreferencesDialog::UpdateDisplayData(int panel)
00505 {
00506     DEBUG_DEBUG("Updating display data");
00507 
00508     double d;
00509     bool t;
00510     wxString tstr;
00511     wxConfigBase* cfg = wxConfigBase::Get();
00512 
00513     if (panel==0 || panel == 1)
00514     {
00515         // memory setting
00516         unsigned long long mem = cfg->Read(wxT("/ImageCache/UpperBound"), HUGIN_IMGCACHE_UPPERBOUND);
00517 #ifdef __WXMSW__
00518         unsigned long mem_low = cfg->Read(wxT("/ImageCache/UpperBound"), HUGIN_IMGCACHE_UPPERBOUND);
00519         unsigned long mem_high = cfg->Read(wxT("/ImageCache/UpperBoundHigh"), (long) 0);
00520         if (mem_high > 0)
00521         {
00522             mem = ((unsigned long long) mem_high << 32) + mem_low;
00523         }
00524         else
00525         {
00526             mem = mem_low;
00527         }
00528 #endif
00529         MY_SPIN_VAL("prefs_cache_UpperBound", mem >> 20);
00530 
00531         // language
00532         // check if current language is in list and activate it then.
00533         wxChoice* lang_choice = XRCCTRL(*this, "prefs_gui_language", wxChoice);
00534         int curlang = cfg->Read(wxT("language"), HUGIN_LANGUAGE);
00535         bool found = false;
00536         int idx = 0;
00537         for (int i = 0; i < (int)lang_choice->GetCount(); i++)
00538         {
00539             long lang = * static_cast<long*>(lang_choice->GetClientData(i));
00540             if (curlang == lang)
00541             {
00542                 found = true;
00543                 idx = i;
00544             }
00545         }
00546         if (found)
00547         {
00548             DEBUG_DEBUG("wxChoice language updated:" << curlang);
00549             // update language
00550             lang_choice->SetSelection(idx);
00551         }
00552         else
00553         {
00554             // unknown language selected..
00555             DEBUG_WARN("Unknown language configured");
00556         }
00557 
00558         // smart undo
00559         t = cfg->Read(wxT("smartUndo"), HUGIN_SMART_UNDO) == 1;
00560         MY_BOOL_VAL("prefs_smart_undo", t);
00561 
00562         // copy log to clipboard
00563         t = cfg->Read(wxT("CopyLogToClipboard"), 0l) == 1;
00564         MY_BOOL_VAL("prefs_copy_log", t);
00565 
00566         t = cfg->Read(wxT("/GLPreviewFrame/ShowProjectionHints"), HUGIN_SHOW_PROJECTION_HINTS) == 1;
00567         MY_BOOL_VAL("pref_show_projection_hints", t)
00568     };
00569 
00570     // filename panel
00571     if(panel==0 || panel==2)
00572     {
00573         // tempdir
00574         MY_STR_VAL("prefs_misc_tempdir", cfg->Read(wxT("tempDir"),wxT("")));
00575         // default filenames
00576         wxString filename=cfg->Read(wxT("ProjectFilename"), wxT(HUGIN_DEFAULT_PROJECT_NAME));
00577 #ifdef __WXMSW__
00578         filename.Replace(wxT("/"),wxT("\\"),true);
00579 #endif
00580         MY_STR_VAL("prefs_project_filename", filename);
00581         filename=cfg->Read(wxT("OutputFilename"), wxT(HUGIN_DEFAULT_OUTPUT_NAME));
00582 #ifdef __WXMSW__
00583         filename.Replace(wxT("/"),wxT("\\"),true);
00584 #endif
00585         MY_STR_VAL("prefs_output_filename", filename);
00586     }
00587 
00588     if (panel==0 || panel == 3)
00589     {
00590         // Assistant settings
00591         t = cfg->Read(wxT("/Assistant/autoAlign"), HUGIN_ASS_AUTO_ALIGN) == 1;
00592         MY_BOOL_VAL("prefs_ass_autoAlign", t);
00593         MY_SPIN_VAL("prefs_ass_nControlPoints",
00594                     cfg->Read(wxT("/Assistant/nControlPoints"), HUGIN_ASS_NCONTROLPOINTS));
00595         double factor = HUGIN_ASS_PANO_DOWNSIZE_FACTOR;
00596         cfg->Read(wxT("/Assistant/panoDownsizeFactor"), &factor);
00597         MY_SPIN_VAL("prefs_ass_panoDownsizeFactor",(int)(factor*100.0));
00598         t = cfg->Read(wxT("/Assistant/Linefind"), HUGIN_ASS_LINEFIND) == 1;
00599         MY_BOOL_VAL("prefs_ass_linefind", t);
00600         t = cfg->Read(wxT("/Celeste/Auto"), HUGIN_CELESTE_AUTO) == 1;
00601         MY_BOOL_VAL("prefs_celeste_auto", t);
00602         t = cfg->Read(wxT("/Assistant/AutoCPClean"), HUGIN_ASS_AUTO_CPCLEAN) == 1;
00603         MY_BOOL_VAL("prefs_auto_cpclean", t);
00604     }
00605     // Fine tune settings
00606 
00607     if (panel==0 || panel == 4)
00608     {
00609         // hdr display settings
00610         MY_CHOICE_VAL("prefs_misc_hdr_mapping", cfg->Read(wxT("/ImageCache/Mapping"), HUGIN_IMGCACHE_MAPPING_FLOAT));
00611         //MY_CHOICE_VAL("prefs_misc_hdr_range", cfg->Read(wxT("/ImageCache/Range"), HUGIN_IMGCACHE_RANGE));
00612 
00613         MY_SPIN_VAL("prefs_ft_TemplateSize",
00614                     cfg->Read(wxT("/Finetune/TemplateSize"),HUGIN_FT_TEMPLATE_SIZE));
00615         MY_SPIN_VAL("prefs_ft_SearchAreaPercent",cfg->Read(wxT("/Finetune/SearchAreaPercent"),
00616                     HUGIN_FT_SEARCH_AREA_PERCENT));
00617         MY_SPIN_VAL("prefs_ft_LocalSearchWidth", cfg->Read(wxT("/Finetune/LocalSearchWidth"),
00618                     HUGIN_FT_LOCAL_SEARCH_WIDTH));
00619 
00620         d=HUGIN_FT_CORR_THRESHOLD;
00621         cfg->Read(wxT("/Finetune/CorrThreshold"), &d, HUGIN_FT_CORR_THRESHOLD);
00622         tstr = hugin_utils::doubleTowxString(d);
00623         MY_STR_VAL("prefs_ft_CorrThreshold", tstr);
00624 
00625         cfg->Read(wxT("/Finetune/CurvThreshold"), &d, HUGIN_FT_CURV_THRESHOLD);
00626         tstr = hugin_utils::doubleTowxString(d);
00627         MY_STR_VAL("prefs_ft_CurvThreshold", tstr);
00628 
00629         t = cfg->Read(wxT("/Finetune/RotationSearch"), HUGIN_FT_ROTATION_SEARCH) == 1;
00630         MY_BOOL_VAL("prefs_ft_RotationSearch", t);
00631         EnableRotationCtrls(t);
00632 
00633         d = HUGIN_FT_ROTATION_START_ANGLE;
00634         cfg->Read(wxT("/Finetune/RotationStartAngle"),&d,HUGIN_FT_ROTATION_START_ANGLE);
00635         MY_SPIN_VAL("prefs_ft_RotationStartAngle", hugin_utils::roundi(d))
00636 
00637         d = HUGIN_FT_ROTATION_STOP_ANGLE;
00638         cfg->Read(wxT("/Finetune/RotationStopAngle"), &d, HUGIN_FT_ROTATION_STOP_ANGLE);
00639         MY_SPIN_VAL("prefs_ft_RotationStopAngle", hugin_utils::roundi(d));
00640 
00641         MY_SPIN_VAL("prefs_ft_RotationSteps", cfg->Read(wxT("/Finetune/RotationSteps"),
00642                     HUGIN_FT_ROTATION_STEPS));
00643     }
00644 
00647 
00650 
00651     if (panel==0 || panel == 5)
00652     {
00653         cpdetector_config_edit.FillControl(m_CPDetectorList,true,true);
00654     }
00655 
00656     if (panel == 0 || panel == 6)
00657     {
00660         MY_CHOICE_VAL("pref_ldr_output_file_format", cfg->Read(wxT("/output/ldr_format"), HUGIN_LDR_OUTPUT_FORMAT));
00662         // MY_CHOICE_VAL("pref_hdr_output_file_format", cfg->Read(wxT("/output/hdr_format"), HUGIN_HDR_OUTPUT_FORMAT));
00663         MY_CHOICE_VAL("pref_tiff_compression", cfg->Read(wxT("/output/tiff_compression"), HUGIN_TIFF_COMPRESSION));
00664         MY_SPIN_VAL("pref_jpeg_quality", cfg->Read(wxT("/output/jpeg_quality"), HUGIN_JPEG_QUALITY));
00665         UpdateFileFormatControls();
00666 
00667         // default blender
00668         SelectListValue(XRCCTRL(*this, "pref_default_blender", wxChoice), cfg->Read(wxT("/default_blender"), HUGIN_DEFAULT_BLENDER));
00669         // default verdandi parameters
00670         const wxString defaultVerdandiArgs = cfg->Read(wxT("/VerdandiDefaultArgs"), wxEmptyString);
00671         if (defaultVerdandiArgs.Find(wxT("--seam=blend")) != wxNOT_FOUND)
00672         {
00673             XRCCTRL(*this, "pref_internal_blender_seam", wxChoice)->SetSelection(1);
00674         }
00675         else
00676         {
00677             XRCCTRL(*this, "pref_internal_blender_seam", wxChoice)->SetSelection(0);
00678         };
00679         UpdateBlenderControls();
00680 
00683         MY_CHOICE_VAL("pref_processor_gui", cfg->Read(wxT("/Processor/gui"), HUGIN_PROCESSOR_GUI));
00684         t = cfg->Read(wxT("/Processor/start"), HUGIN_PROCESSOR_START) == 1;
00685         MY_BOOL_VAL("pref_processor_start", t);
00686         t = cfg->Read(wxT("/Processor/overwrite"), HUGIN_PROCESSOR_OVERWRITE) == 1;
00687         MY_BOOL_VAL("pref_processor_overwrite", t);
00688         t = cfg->Read(wxT("/Processor/verbose"), HUGIN_PROCESSOR_VERBOSE) == 1;
00689         MY_BOOL_VAL("pref_processor_verbose", t);
00690         UpdateProcessorControls();
00691     }
00692 
00693     if (panel == 0 || panel == 7)
00694     {
00695         // stitching (2) panel
00696         t = cfg->Read(wxT("/output/useExiftool"), HUGIN_USE_EXIFTOOL) == 1;
00697         MY_BOOL_VAL("pref_exiftool_metadata", t);
00698         MY_STR_VAL("pref_exiftool_argfile", cfg->Read(wxT("/output/CopyArgfile"), wxT("")));
00699         MY_STR_VAL("pref_exiftool_argfile2", cfg->Read(wxT("/output/FinalArgfile"), wxT("")));
00700         t = cfg->Read(wxT("/output/writeGPano"), HUGIN_EXIFTOOL_CREATE_GPANO) == 1;
00701         MY_BOOL_VAL("pref_exiftool_gpano", t);
00702         wxCommandEvent dummy;
00703         OnExifTool(dummy);
00704         // number of threads
00705         int nThreads = cfg->Read(wxT("/output/NumberOfThreads"), 0l);
00706         MY_SPIN_VAL("prefs_output_NumberOfThreads", nThreads);
00707     }
00708 
00709     if (panel==0 || panel == 8)
00710     {
00711 
00714         MY_CHOICE_VAL("prefs_nona_interpolator", cfg->Read(wxT("/Nona/Interpolator"), HUGIN_NONA_INTERPOLATOR));
00715         t = cfg->Read(wxT("/Nona/CroppedImages"), HUGIN_NONA_CROPPEDIMAGES) == 1;
00716         MY_BOOL_VAL("prefs_nona_createCroppedImages", t);
00717         t = cfg->Read(wxT("/Nona/UseGPU"), HUGIN_NONA_USEGPU) == 1;
00718         MY_BOOL_VAL("prefs_nona_useGpu", t);
00719 
00722         MY_STR_VAL("prefs_enblend_EnblendExe", cfg->Read(wxT("/Enblend/Exe"),
00723                    wxT(HUGIN_ENBLEND_EXE)));
00724         bool customEnblendExe = HUGIN_ENBLEND_EXE_CUSTOM;
00725         cfg->Read(wxT("/Enblend/Custom"), &customEnblendExe);
00726         MY_BOOL_VAL("prefs_enblend_Custom", customEnblendExe);
00727         XRCCTRL(*this, "prefs_enblend_EnblendExe", wxTextCtrl)->Enable(customEnblendExe);
00728         XRCCTRL(*this, "prefs_enblend_select", wxButton)->Enable(customEnblendExe);
00729         MY_STR_VAL("prefs_enblend_EnblendArgs", cfg->Read(wxT("/Enblend/Args"),
00730                    wxT(HUGIN_ENBLEND_ARGS)));
00733         MY_STR_VAL("prefs_enblend_EnfuseExe", cfg->Read(wxT("/Enfuse/Exe"),
00734                    wxT(HUGIN_ENFUSE_EXE)));
00735         bool customEnfuseExe = HUGIN_ENFUSE_EXE_CUSTOM;
00736         cfg->Read(wxT("/Enfuse/Custom"), &customEnfuseExe);
00737         MY_BOOL_VAL("prefs_enblend_enfuseCustom", customEnfuseExe);
00738         XRCCTRL(*this, "prefs_enblend_EnfuseExe", wxTextCtrl)->Enable(customEnfuseExe);
00739         XRCCTRL(*this, "prefs_enblend_enfuse_select", wxButton)->Enable(customEnfuseExe);
00740         MY_STR_VAL("prefs_enblend_EnfuseArgs", cfg->Read(wxT("/Enfuse/Args"),
00741                    wxT(HUGIN_ENFUSE_ARGS)));
00742     }
00743 
00744     if (panel==0 || panel == 9)
00745     {
00746         // Celeste settings
00747         d=HUGIN_CELESTE_THRESHOLD;
00748         cfg->Read(wxT("/Celeste/Threshold"), &d, HUGIN_CELESTE_THRESHOLD);
00749         tstr = hugin_utils::doubleTowxString(d);
00750         MY_STR_VAL("prefs_celeste_threshold", tstr);
00751         MY_CHOICE_VAL("prefs_celeste_filter", cfg->Read(wxT("/Celeste/Filter"), HUGIN_CELESTE_FILTER));
00752         // photometric optimizer settings
00753         MY_SPIN_VAL("prefs_photo_optimizer_nr_points", cfg->Read(wxT("/OptimizePhotometric/nRandomPointsPerImage"), HUGIN_PHOTOMETRIC_OPTIMIZER_NRPOINTS));
00754         // warnings
00755         t = cfg->Read(wxT("/ShowSaveMessage"), 1l) == 1;
00756         MY_BOOL_VAL("prefs_warning_save", t);
00757         t = cfg->Read(wxT("/ShowExposureWarning"), 1l) == 1;
00758         MY_BOOL_VAL("prefs_warning_exposure", t);
00759         MY_CHOICE_VAL("pref_editcp_action", cfg->Read(wxT("/EditCPAfterAction"), 0l));
00760     }
00761 }
00762 
00763 void PreferencesDialog::OnRestoreDefaults(wxCommandEvent& e)
00764 {
00765     DEBUG_TRACE("");
00766     wxConfigBase* cfg = wxConfigBase::Get();
00767     // check which tab is enabled
00768     wxNotebook* noteb = XRCCTRL(*this, "prefs_tab", wxNotebook);
00769     int really = wxMessageBox(_("Really reset displayed preferences to default values?"), _("Load Defaults"),
00770                               wxYES_NO, this);
00771     if ( really == wxYES)
00772     {
00773         if (noteb->GetSelection() == 0)
00774         {
00775             // MISC
00776             // cache
00777             /*
00778              * special treatment for windows not necessary here since we know the value of
00779              * HUGIN_IMGCACHE_UPPERBOUND must fit into 32bit to be compatible with 32bit systems.
00780              * However, just as a reminder:
00781             #ifdef __WXMSW__
00782                 cfg->Write(wxT("/ImageCache/UpperBoundHigh"), HUGIN_IMGCACHE_UPPERBOUND >> 32);
00783             #endif
00784             */
00785             cfg->Write(wxT("/ImageCache/UpperBound"), HUGIN_IMGCACHE_UPPERBOUND);
00786             // locale
00787             cfg->Write(wxT("language"), int(HUGIN_LANGUAGE));
00788             // smart undo
00789             cfg->Write(wxT("smartUndo"), HUGIN_SMART_UNDO);
00790             cfg->Write(wxT("CopyLogToClipboard"), 0l);
00791             // projection hints
00792             cfg->Write(wxT("/GLPreviewFrame/ShowProjectionHints"), HUGIN_SHOW_PROJECTION_HINTS);
00793         }
00794         if(noteb->GetSelection() == 1)
00795         {
00796             cfg->Write(wxT("tempDir"), wxT(""));
00797             cfg->Write(wxT("ProjectFilename"), wxT(HUGIN_DEFAULT_PROJECT_NAME));
00798             cfg->Write(wxT("OutputFilename"), wxT(HUGIN_DEFAULT_OUTPUT_NAME));
00799         };
00800         if (noteb->GetSelection() == 2)
00801         {
00802             cfg->Write(wxT("/Assistant/autoAlign"), HUGIN_ASS_AUTO_ALIGN);
00803             cfg->Write(wxT("/Assistant/nControlPoints"), HUGIN_ASS_NCONTROLPOINTS);
00804             cfg->Write(wxT("/Assistant/panoDownsizeFactor"),HUGIN_ASS_PANO_DOWNSIZE_FACTOR);
00805             cfg->Write(wxT("/Assistant/Linefind"), HUGIN_ASS_LINEFIND);
00806             cfg->Write(wxT("/Celeste/Auto"), HUGIN_CELESTE_AUTO);
00807             cfg->Write(wxT("/Assistant/AutoCPClean"), HUGIN_ASS_AUTO_CPCLEAN);
00808         }
00809         if (noteb->GetSelection() == 3)
00810         {
00811             // hdr
00812             cfg->Write(wxT("/ImageCache/Mapping"), HUGIN_IMGCACHE_MAPPING_FLOAT);
00813             //cfg->Write(wxT("/ImageCache/Range"), HUGIN_IMGCACHE_RANGE);
00814             // Fine tune settings
00815             cfg->Write(wxT("/Finetune/SearchAreaPercent"), HUGIN_FT_SEARCH_AREA_PERCENT);
00816             cfg->Write(wxT("/Finetune/TemplateSize"), HUGIN_FT_TEMPLATE_SIZE);
00817             cfg->Write(wxT("/Finetune/LocalSearchWidth"), HUGIN_FT_LOCAL_SEARCH_WIDTH);
00818 
00819             cfg->Write(wxT("/Finetune/CorrThreshold"), HUGIN_FT_CORR_THRESHOLD);
00820             cfg->Write(wxT("/Finetune/CurvThreshold"), HUGIN_FT_CURV_THRESHOLD);
00821 
00822             cfg->Write(wxT("/Finetune/RotationSearch"), HUGIN_FT_ROTATION_SEARCH);
00823             cfg->Write(wxT("/Finetune/RotationStartAngle"), HUGIN_FT_ROTATION_START_ANGLE);
00824             cfg->Write(wxT("/Finetune/RotationStopAngle"), HUGIN_FT_ROTATION_STOP_ANGLE);
00825             cfg->Write(wxT("/Finetune/RotationSteps"), HUGIN_FT_ROTATION_STEPS);
00826         }
00827         if (noteb->GetSelection() == 4)
00828         {
00831             cpdetector_config_edit.ReadFromFile(huginApp::Get()->GetDataPath()+wxT("default.setting"));
00832             cpdetector_config_edit.Write(cfg);
00833         }
00834         if (noteb->GetSelection() == 5)
00835         {
00837             cfg->Write(wxT("/output/ldr_format"), HUGIN_LDR_OUTPUT_FORMAT);
00839             // cfg->Write(wxT("/output/hdr_format"), HUGIN_HDR_OUTPUT_FORMAT);
00840             cfg->Write(wxT("/output/tiff_compression"), HUGIN_TIFF_COMPRESSION);
00841             cfg->Write(wxT("/output/jpeg_quality"), HUGIN_JPEG_QUALITY);
00842             // default blender
00843             cfg->Write(wxT("/default_blender"), static_cast<long>(HUGIN_DEFAULT_BLENDER));
00844             cfg->Write(wxT("/VerdandiDefaultArgs"), wxEmptyString);
00845             // stitching engine
00846             cfg->Write(wxT("/Processor/gui"), HUGIN_PROCESSOR_GUI);
00847             cfg->Write(wxT("/Processor/start"), HUGIN_PROCESSOR_START);
00848             cfg->Write(wxT("/Processor/overwrite"), HUGIN_PROCESSOR_OVERWRITE);
00849             cfg->Write(wxT("/Processor/verbose"), HUGIN_PROCESSOR_VERBOSE);
00850         }
00851         if (noteb->GetSelection() == 6)
00852         {
00853             cfg->Write(wxT("/output/useExiftool"), HUGIN_USE_EXIFTOOL);
00854             cfg->Write(wxT("/output/CopyArgfile"), wxT(""));
00855             cfg->Write(wxT("/output/FinalArgfile"), wxT(""));
00856             cfg->Write(wxT("/output/writeGPano"), HUGIN_EXIFTOOL_CREATE_GPANO);
00857             cfg->Write(wxT("/output/NumberOfThreads"), 0l);
00858         }
00859         if (noteb->GetSelection() == 7)
00860         {
00862             cfg->Write(wxT("/Enblend/Exe"), wxT(HUGIN_ENBLEND_EXE));
00863             cfg->Write(wxT("/Enblend/Custom"), HUGIN_ENBLEND_EXE_CUSTOM);
00864             cfg->Write(wxT("/Enblend/Args"), wxT(HUGIN_ENBLEND_ARGS));
00865 
00866             cfg->Write(wxT("/Enfuse/Exe"), wxT(HUGIN_ENFUSE_EXE));
00867             cfg->Write(wxT("/Enfuse/Custom"), HUGIN_ENFUSE_EXE_CUSTOM);
00868             cfg->Write(wxT("/Enfuse/Args"), wxT(HUGIN_ENFUSE_ARGS));
00869         }
00870 
00871         if (noteb->GetSelection() == 8)
00872         {
00874             cfg->Write(wxT("/Celeste/Threshold"), HUGIN_CELESTE_THRESHOLD);
00875             cfg->Write(wxT("/Celeste/Filter"), HUGIN_CELESTE_FILTER);
00876             cfg->Write(wxT("/OptimizePhotometric/nRandomPointsPerImage"), HUGIN_PHOTOMETRIC_OPTIMIZER_NRPOINTS);
00877             cfg->Write(wxT("/ShowSaveMessage"), 1l);
00878             cfg->Write(wxT("/ShowExposureWarning"), 1l);
00879             cfg->Write(wxT("/EditCPAfterAction"), 0l);
00880         }
00881 
00882         /*
00883                 if (noteb->GetSelection() == 5) {
00884                     cfg->Write(wxT("/PTmender/Exe"), wxT(HUGIN_PT_MENDER_EXE) );
00885                     cfg->Write(wxT("/PTmender/Custom"),HUGIN_PT_MENDER_EXE_CUSTOM);
00886                     cfg->Write(wxT("/PanoTools/ScriptFile"), wxT("PT_script.txt"));
00887                 }
00888         */
00889         UpdateDisplayData(noteb->GetSelection() + 1);
00890     }
00891 }
00892 
00893 void PreferencesDialog::UpdateConfigData()
00894 {
00895     DEBUG_TRACE("");
00896     wxConfigBase* cfg = wxConfigBase::Get();
00897     // Assistant
00898     cfg->Write(wxT("/Assistant/autoAlign"),MY_G_BOOL_VAL("prefs_ass_autoAlign"));
00899     cfg->Write(wxT("/Assistant/nControlPoints"), MY_G_SPIN_VAL("prefs_ass_nControlPoints"));
00900     cfg->Write(wxT("/Assistant/panoDownsizeFactor"), MY_G_SPIN_VAL("prefs_ass_panoDownsizeFactor") / 100.0);
00901     cfg->Write(wxT("/Assistant/Linefind"), MY_G_BOOL_VAL("prefs_ass_linefind"));
00902     cfg->Write(wxT("/Celeste/Auto"), MY_G_BOOL_VAL("prefs_celeste_auto"));
00903     cfg->Write(wxT("/Assistant/AutoCPClean"), MY_G_BOOL_VAL("prefs_auto_cpclean"));
00904 
00905     // hdr display
00906     cfg->Write(wxT("/ImageCache/Mapping"),MY_G_CHOICE_VAL("prefs_misc_hdr_mapping"));
00907     //cfg->Write(wxT("/ImageCache/Range"),MY_G_CHOICE_VAL("prefs_misc_hdr_range"));
00908 
00909     // Fine tune settings
00910     cfg->Write(wxT("/Finetune/SearchAreaPercent"), MY_G_SPIN_VAL("prefs_ft_SearchAreaPercent"));
00911     cfg->Write(wxT("/Finetune/TemplateSize"), MY_G_SPIN_VAL("prefs_ft_TemplateSize"));
00912     cfg->Write(wxT("/Finetune/LocalSearchWidth"), MY_G_SPIN_VAL("prefs_ft_LocalSearchWidth"));
00913     wxString t = MY_G_STR_VAL("prefs_ft_CorrThreshold");
00914     double td= HUGIN_FT_CORR_THRESHOLD;
00915     hugin_utils::stringToDouble(std::string(t.mb_str(wxConvLocal)), td);
00916     cfg->Write(wxT("/Finetune/CorrThreshold"), td);
00917 
00918     t = MY_G_STR_VAL("prefs_ft_CurvThreshold");
00919     td = HUGIN_FT_CURV_THRESHOLD;
00920     hugin_utils::stringToDouble(std::string(t.mb_str(wxConvLocal)), td);
00921     cfg->Write(wxT("/Finetune/CurvThreshold"), td);
00922 
00923     cfg->Write(wxT("/Finetune/RotationSearch"), MY_G_BOOL_VAL("prefs_ft_RotationSearch"));
00924     cfg->Write(wxT("/Finetune/RotationStartAngle"), (double) MY_G_SPIN_VAL("prefs_ft_RotationStartAngle"));
00925     cfg->Write(wxT("/Finetune/RotationStopAngle"), (double) MY_G_SPIN_VAL("prefs_ft_RotationStopAngle"));
00926     cfg->Write(wxT("/Finetune/RotationSteps"), MY_G_SPIN_VAL("prefs_ft_RotationSteps"));
00927 
00930     // cache
00931 #ifdef __WXMSW__
00932     // shifting only 12 bits rights: 32-20=12 and the prefs_cache_UpperBound is in GB
00933     cfg->Write(wxT("/ImageCache/UpperBoundHigh"), (long) MY_G_SPIN_VAL("prefs_cache_UpperBound") >> 12);
00934 #endif
00935     cfg->Write(wxT("/ImageCache/UpperBound"), (long) MY_G_SPIN_VAL("prefs_cache_UpperBound") << 20);
00936     // locale
00937     // language
00938     wxChoice* lang = XRCCTRL(*this, "prefs_gui_language", wxChoice);
00939     // DEBUG_TRACE("Language Selection Name: " << huginApp::Get()->GetLocale().GetLanguageName((int) lang->GetClientData(lang->GetSelection())).mb_str(wxConvLocal));
00940     //DEBUG_INFO("Language Selection locale: " << ((huginApp::Get()->GetLocale().GetLanguageInfo((int) lang->GetClientData(lang->GetSelection())))->CanonicalName).mb_str(wxConvLocal));
00941     //DEBUG_INFO("Current System Language ID: " << huginApp::Get()->GetLocale().GetSystemLanguage());
00942 
00943     void* tmplp = lang->GetClientData(lang->GetSelection());
00944     long templ =  * static_cast<long*>(tmplp);
00945     cfg->Write(wxT("language"), templ);
00946     DEBUG_INFO("Language Selection ID: " << templ);
00947     // smart undo
00948     cfg->Write(wxT("smartUndo"), MY_G_BOOL_VAL("prefs_smart_undo"));
00949     cfg->Write(wxT("CopyLogToClipboard"), MY_G_BOOL_VAL("prefs_copy_log"));
00950     // show projections hints
00951     cfg->Write(wxT("/GLPreviewFrame/ShowProjectionHints"), MY_G_BOOL_VAL("pref_show_projection_hints"));
00952     // tempdir
00953     cfg->Write(wxT("tempDir"),MY_G_STR_VAL("prefs_misc_tempdir"));
00954     // filename templates
00955     wxString filename=XRCCTRL(*this, "prefs_project_filename", wxTextCtrl)->GetValue();
00956 #ifdef __WXMSW__
00957     filename.Replace(wxT("\\"), wxT("/"), true);
00958 #endif
00959     cfg->Write(wxT("ProjectFilename"), filename);
00960     filename=XRCCTRL(*this, "prefs_output_filename", wxTextCtrl)->GetValue();
00961 #ifdef __WXMSW__
00962     filename.Replace(wxT("\\"), wxT("/"), true);
00963 #endif
00964     cfg->Write(wxT("OutputFilename"), filename);
00967     cpdetector_config_edit.Write(cfg);
00968 
00971     cfg->Write(wxT("/output/ldr_format"), MY_G_CHOICE_VAL("pref_ldr_output_file_format"));
00973     // cfg->Write(wxT("/output/hdr_format"), MY_G_CHOICE_VAL("pref_hdr_output_file_format"));
00974     cfg->Write(wxT("/output/tiff_compression"), MY_G_CHOICE_VAL("pref_tiff_compression"));
00975     cfg->Write(wxT("/output/jpeg_quality"), MY_G_SPIN_VAL("pref_jpeg_quality"));
00976 
00977     cfg->Write(wxT("/default_blender"), static_cast<long>(GetSelectedValue(XRCCTRL(*this, "pref_default_blender", wxChoice))));
00978     if (XRCCTRL(*this, "pref_internal_blender_seam", wxChoice)->GetSelection() == 1)
00979     {
00980         cfg->Write(wxT("/VerdandiDefaultArgs"), wxT("--seam=blend"));
00981     }
00982     else
00983     {
00984         cfg->Write(wxT("/VerdandiDefaultArgs"), wxEmptyString);
00985     };
00986 
00989     cfg->Write(wxT("/Processor/gui"), MY_G_CHOICE_VAL("pref_processor_gui"));
00990     cfg->Write(wxT("/Processor/start"), MY_G_BOOL_VAL("pref_processor_start"));
00991     cfg->Write(wxT("/Processor/overwrite"), MY_G_BOOL_VAL("pref_processor_overwrite"));
00992     cfg->Write(wxT("/Processor/verbose"), MY_G_BOOL_VAL("pref_processor_verbose"));
00993 
00994     cfg->Write(wxT("/output/useExiftool"), MY_G_BOOL_VAL("pref_exiftool_metadata"));
00995     cfg->Write(wxT("/output/CopyArgfile"), MY_G_STR_VAL("pref_exiftool_argfile"));
00996     cfg->Write(wxT("/output/FinalArgfile"), MY_G_STR_VAL("pref_exiftool_argfile2"));
00997     cfg->Write(wxT("/output/writeGPano"), MY_G_BOOL_VAL("pref_exiftool_gpano"));
00998     cfg->Write(wxT("/output/NumberOfThreads"), MY_G_SPIN_VAL("prefs_output_NumberOfThreads"));
01001     cfg->Write(wxT("/Nona/Interpolator"), MY_G_CHOICE_VAL("prefs_nona_interpolator"));
01002     cfg->Write(wxT("/Nona/CroppedImages"), MY_G_BOOL_VAL("prefs_nona_createCroppedImages"));
01003     cfg->Write(wxT("/Nona/UseGPU"), MY_G_BOOL_VAL("prefs_nona_useGpu"));
01004 
01007     cfg->Write(wxT("/Enblend/Custom"), MY_G_BOOL_VAL("prefs_enblend_Custom"));
01008     cfg->Write(wxT("/Enblend/Exe"), MY_G_STR_VAL("prefs_enblend_EnblendExe"));
01009     cfg->Write(wxT("/Enblend/Args"), MY_G_STR_VAL("prefs_enblend_EnblendArgs"));
01010 
01011     cfg->Write(wxT("/Enfuse/Custom"), MY_G_BOOL_VAL("prefs_enblend_enfuseCustom"));
01012     cfg->Write(wxT("/Enfuse/Exe"), MY_G_STR_VAL("prefs_enblend_EnfuseExe"));
01013     cfg->Write(wxT("/Enfuse/Args"), MY_G_STR_VAL("prefs_enblend_EnfuseArgs"));
01014 
01015     // Celeste
01016     t = MY_G_STR_VAL("prefs_celeste_threshold");
01017     td = HUGIN_CELESTE_THRESHOLD;
01018     hugin_utils::stringToDouble(std::string(t.mb_str(wxConvLocal)), td);
01019     cfg->Write(wxT("/Celeste/Threshold"), td);
01020     cfg->Write(wxT("/Celeste/Filter"), MY_G_CHOICE_VAL("prefs_celeste_filter"));
01021     //photometric optimizer
01022     cfg->Write(wxT("/OptimizePhotometric/nRandomPointsPerImage"), MY_G_SPIN_VAL("prefs_photo_optimizer_nr_points"));
01023     cfg->Write(wxT("/ShowSaveMessage"), MY_G_BOOL_VAL("prefs_warning_save"));
01024     cfg->Write(wxT("/ShowExposureWarning"), MY_G_BOOL_VAL("prefs_warning_exposure"));
01025     cfg->Write(wxT("/EditCPAfterAction"), MY_G_CHOICE_VAL("pref_editcp_action"));
01026 
01027     cfg->Flush();
01028     UpdateDisplayData(0);
01029 }
01030 
01031 void PreferencesDialog::OnCPDetectorAdd(wxCommandEvent& e)
01032 {
01033     CPDetectorDialog cpdetector_dlg(this);
01034     if(cpdetector_dlg.ShowModal()==wxOK)
01035     {
01036         cpdetector_config_edit.settings.Add(new CPDetectorSetting);
01037         cpdetector_dlg.UpdateSettings(&cpdetector_config_edit,cpdetector_config_edit.GetCount()-1);
01038         cpdetector_config_edit.FillControl(m_CPDetectorList,false,true);
01039         m_CPDetectorList->SetSelection(cpdetector_config_edit.GetCount()-1);
01040     };
01041 };
01042 
01043 void PreferencesDialog::OnCPDetectorEdit(wxCommandEvent& e)
01044 {
01045     CPDetectorDialog autopano_dlg(this);
01046     int selection=m_CPDetectorList->GetSelection();
01047     if (selection == wxNOT_FOUND)
01048     {
01049         wxMessageBox(_("Please select an entry first"),_("Select Entry"),wxOK |
01050                      wxICON_EXCLAMATION,this);
01051     }
01052     else
01053     {
01054         autopano_dlg.UpdateFields(&cpdetector_config_edit, selection);
01055         if(autopano_dlg.ShowModal()==wxOK)
01056         {
01057             autopano_dlg.UpdateSettings(&cpdetector_config_edit, selection);
01058             cpdetector_config_edit.FillControl(m_CPDetectorList,false,true);
01059             m_CPDetectorList->SetSelection(selection);
01060         };
01061     }
01062 };
01063 
01064 void PreferencesDialog::OnCPDetectorDelete(wxCommandEvent& e)
01065 {
01066     unsigned int selection=m_CPDetectorList->GetSelection();
01067     if(m_CPDetectorList->GetCount()==1)
01068     {
01069         wxMessageBox(_("You can't delete the last setting.\nAt least one setting is required."),_("Warning"),wxOK | wxICON_EXCLAMATION,this);
01070     }
01071     else
01072     {
01073         if(wxMessageBox(wxString::Format(_("Do you really want to remove control point detector setting \"%s\"?"),cpdetector_config_edit.settings[selection].GetCPDetectorDesc().c_str())
01074                         ,_("Delete control point detector setting"),wxYES_NO | wxICON_QUESTION,this)==wxYES)
01075         {
01076             if(cpdetector_config_edit.GetDefaultGenerator()==selection)
01077             {
01078                 cpdetector_config_edit.SetDefaultGenerator(0);
01079             }
01080             cpdetector_config_edit.settings.RemoveAt(selection);
01081             cpdetector_config_edit.FillControl(m_CPDetectorList,false,true);
01082             if(selection>=m_CPDetectorList->GetCount())
01083             {
01084                 selection=m_CPDetectorList->GetCount()-1;
01085             }
01086             m_CPDetectorList->SetSelection(selection);
01087         };
01088     };
01089 };
01090 
01091 void PreferencesDialog::OnCPDetectorMoveUp(wxCommandEvent& e)
01092 {
01093     unsigned int selection=m_CPDetectorList->GetSelection();
01094     if(selection>0)
01095     {
01096         cpdetector_config_edit.Swap(selection-1);
01097         cpdetector_config_edit.FillControl(m_CPDetectorList,false,true);
01098         m_CPDetectorList->SetSelection(selection-1);
01099     };
01100 };
01101 
01102 void PreferencesDialog::OnCPDetectorMoveDown(wxCommandEvent& e)
01103 {
01104     unsigned int selection=m_CPDetectorList->GetSelection();
01105     if(selection<m_CPDetectorList->GetCount()-1)
01106     {
01107         cpdetector_config_edit.Swap(selection);
01108         cpdetector_config_edit.FillControl(m_CPDetectorList,false,true);
01109         m_CPDetectorList->SetSelection(selection+1);
01110     };
01111 };
01112 
01113 void PreferencesDialog::OnCPDetectorDefault(wxCommandEvent& e)
01114 {
01115     unsigned int selection=m_CPDetectorList->GetSelection();
01116     if(selection!=cpdetector_config_edit.GetDefaultGenerator())
01117     {
01118         cpdetector_config_edit.SetDefaultGenerator(selection);
01119         cpdetector_config_edit.FillControl(m_CPDetectorList,false,true);
01120         m_CPDetectorList->SetSelection(selection);
01121     };
01122 };
01123 
01124 void PreferencesDialog::OnCPDetectorListDblClick(wxCommandEvent& e)
01125 {
01126     OnCPDetectorEdit(e);
01127 };
01128 
01129 void PreferencesDialog::OnCPDetectorLoad(wxCommandEvent& e)
01130 {
01131     wxFileDialog dlg(this,_("Load control point detector settings"),
01132                      wxConfigBase::Get()->Read(wxT("/actualPath"),wxT("")), wxEmptyString,
01133                      _("Control point detector settings (*.setting)|*.setting"),wxFD_OPEN | wxFD_FILE_MUST_EXIST);
01134     if (dlg.ShowModal() == wxID_OK)
01135     {
01136         wxConfig::Get()->Write(wxT("/actualPath"), dlg.GetDirectory());  // remember for later
01137         wxString fn = dlg.GetPath();
01138         cpdetector_config_edit.ReadFromFile(fn);
01139         cpdetector_config_edit.Write();
01140         UpdateDisplayData(4);
01141     };
01142 };
01143 
01144 void PreferencesDialog::OnCPDetectorSave(wxCommandEvent& e)
01145 {
01146     wxFileDialog dlg(this,_("Save control point detector settings"),
01147                      wxConfigBase::Get()->Read(wxT("/actualPath"),wxT("")), wxEmptyString,
01148                      _("Control point detector settings (*.setting)|*.setting"),wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
01149     if (dlg.ShowModal() == wxID_OK)
01150     {
01151         wxConfig::Get()->Write(wxT("/actualPath"), dlg.GetDirectory());  // remember for later
01152         wxString fn = dlg.GetPath();
01153 #ifndef __WXMSW__
01154         //append extension if not given
01155         //not necessary on Windows, the wxFileDialog appends it automatic
01156         if(fn.Right(8)!=wxT(".setting"))
01157         {
01158             fn.Append(wxT(".setting"));
01159         };
01160 #endif
01161         cpdetector_config_edit.WriteToFile(fn);
01162     };
01163 };
01164 
01165 void PreferencesDialog::OnFileFormatChanged(wxCommandEvent& e)
01166 {
01167     UpdateFileFormatControls();
01168 };
01169 
01170 void PreferencesDialog::UpdateFileFormatControls()
01171 {
01172     int i=MY_G_CHOICE_VAL("pref_ldr_output_file_format");
01173     XRCCTRL(*this,"pref_tiff_compression_label",wxStaticText)->Show(i==0);
01174     XRCCTRL(*this,"pref_tiff_compression",wxChoice)->Show(i==0);
01175     XRCCTRL(*this,"pref_jpeg_quality_label",wxStaticText)->Show(i==1);
01176     XRCCTRL(*this,"pref_jpeg_quality",wxSpinCtrl)->Show(i==1);
01177     XRCCTRL(*this,"pref_tiff_compression",wxChoice)->GetParent()->Layout();
01178 };
01179 
01180 void PreferencesDialog::OnProcessorChanged(wxCommandEvent& e)
01181 {
01182     UpdateProcessorControls();
01183 };
01184 
01185 void PreferencesDialog::UpdateProcessorControls()
01186 {
01187     int i=MY_G_CHOICE_VAL("pref_processor_gui");
01188     XRCCTRL(*this,"pref_processor_start",wxCheckBox)->Enable(i==0);
01189     XRCCTRL(*this,"pref_processor_verbose",wxCheckBox)->Enable(i==0);
01190     switch(i)
01191     {
01192         case 0:
01193             //PTBatcherGUI
01194             {
01195                 wxConfigBase* config=wxConfigBase::Get();
01196                 XRCCTRL(*this,"pref_processor_start",wxCheckBox)->SetValue(config->Read(wxT("/Processor/start"), HUGIN_PROCESSOR_START) == 1);
01197                 XRCCTRL(*this,"pref_processor_verbose",wxCheckBox)->SetValue(config->Read(wxT("/Processor/verbose"), HUGIN_PROCESSOR_VERBOSE) == 1);
01198             }
01199             break;
01200         case 1:
01201             //Hugin_stitch_project
01202             XRCCTRL(*this,"pref_processor_start",wxCheckBox)->SetValue(true);
01203             XRCCTRL(*this,"pref_processor_verbose",wxCheckBox)->SetValue(true);
01204             break;
01205     };
01206 };
01207 
01208 void PreferencesDialog::OnBlenderChanged(wxCommandEvent & e)
01209 {
01210     UpdateBlenderControls();
01211 };
01212 
01213 void PreferencesDialog::UpdateBlenderControls()
01214 {
01215     const int blender = MY_G_CHOICE_VAL("pref_default_blender");
01216     XRCCTRL(*this, "pref_internal_blender_seam_label", wxStaticText)->Show(blender == 1);
01217     wxChoice* seamChoice = XRCCTRL(*this, "pref_internal_blender_seam", wxChoice);
01218     seamChoice->Show(blender == 1);
01219     seamChoice->Enable(blender == 1);
01220 };
01221 
01222 void PreferencesDialog::OnUpdateProjectFilename(wxCommandEvent& e)
01223 {
01224     XRCCTRL(*this, "prefs_project_filename_preview", wxStaticText)->SetLabel(
01225         getDefaultProjectName(MainFrame::Get()->getPanorama(), XRCCTRL(*this, "prefs_project_filename", wxTextCtrl)->GetValue())
01226     );
01227 };
01228 
01229 void PreferencesDialog::OnUpdateOutputFilename(wxCommandEvent& e)
01230 {
01231     XRCCTRL(*this, "prefs_output_filename_preview", wxStaticText)->SetLabel(
01232         getDefaultOutputName(MainFrame::Get()->getProjectName(), MainFrame::Get()->getPanorama(), XRCCTRL(*this, "prefs_output_filename", wxTextCtrl)->GetValue())
01233     );
01234 };
01235 

Generated on 10 Dec 2016 for Hugintrunk by  doxygen 1.4.7