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

Generated on 25 May 2016 for Hugintrunk by  doxygen 1.4.7