PreferencesDialog.cpp

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
00002 
00027 #include "hugin_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::OnExifArgfileChoose)
00068     EVT_BUTTON(XRCID("pref_exiftool_argfile_edit"), PreferencesDialog::OnExifArgfileEdit)
00069     EVT_BUTTON(XRCID("pref_exiftool_argfile2_choose"), PreferencesDialog::OnExifArgfile2Choose)
00070     EVT_BUTTON(XRCID("pref_exiftool_argfile2_edit"), PreferencesDialog::OnExifArgfile2Edit)
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::OnExifArgfileChoose(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, const wxString& sourceFile)
00352 {
00353     wxTextFile defaultFile(sourceFile);
00354     defaultFile.Open();
00355     wxTextFile newFile(newFilename);
00356     newFile.Create();
00357     if (defaultFile.IsOpened())
00358     {
00359         for (size_t i = 0; i < defaultFile.GetLineCount(); ++i)
00360         {
00361             newFile.AddLine(defaultFile[i]);
00362         };
00363     };
00364     newFile.Write();
00365     defaultFile.Close();
00366     newFile.Close();
00367 };
00368 
00369 void PreferencesDialog::OnExifArgfileEdit(wxCommandEvent & e)
00370 {
00371     wxString filename=XRCCTRL(*this, "pref_exiftool_argfile", wxTextCtrl)->GetValue();
00372     if(!filename.empty())
00373     {
00374         wxFileName file(filename);
00375         file.Normalize();
00376         if(!file.Exists())
00377         {
00378             if( wxMessageBox(wxString::Format(_("File %s does not exist.\nShould the argfile be created with default tags?"),filename.c_str()),
00379                   _("Exiftool argfile"), wxYES_NO  | wxICON_EXCLAMATION,this)!=wxYES)
00380             {
00381                 return;
00382             };
00383             filename = file.GetFullPath();
00384             CreateNewArgFile(filename, MainFrame::Get()->GetDataPath() + wxT("hugin_exiftool_copy.arg"));
00385         }
00386         else
00387         {
00388             filename = file.GetFullPath();
00389         };
00390     }
00391     else
00392     {
00393         if( wxMessageBox(_("No file selected.\nShould an argfile be created with default tags?"),
00394                 _("Exiftool argfile"), wxYES_NO  | wxICON_EXCLAMATION,this)!=wxYES)
00395         {
00396             return;
00397         };
00398         wxFileDialog dlg(this,_("Select new ExifTool argfile"),
00399             wxStandardPaths::Get().GetUserConfigDir(), wxT(""),
00400                          _("ExifTool Argfiles (*.arg)|*.arg|All Files(*)|*"),
00401                          wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition);
00402         if (dlg.ShowModal() != wxID_OK)
00403         {
00404             return;
00405         };
00406         filename=dlg.GetPath();
00407         CreateNewArgFile(filename, MainFrame::Get()->GetDataPath() + wxT("hugin_exiftool_copy.arg"));
00408     };
00409     XRCCTRL(*this, "pref_exiftool_argfile", wxTextCtrl)->SetValue(filename);
00410     wxDialog edit_dlg;
00411     wxXmlResource::Get()->LoadDialog(&edit_dlg, 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::OnExifArgfile2Choose(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::OnExifArgfile2Edit(wxCommandEvent & e)
00440 {
00441     wxString filename = XRCCTRL(*this, "pref_exiftool_argfile2", wxTextCtrl)->GetValue();
00442     if (!filename.empty())
00443     {
00444         wxFileName file(filename);
00445         file.Normalize();
00446         if (!file.Exists())
00447         {
00448             if (wxMessageBox(wxString::Format(_("File %s does not exist.\nShould an example argfile be created?"), filename.c_str()),
00449                 _("Exiftool argfile"), wxYES_NO | wxICON_EXCLAMATION, this) != wxYES)
00450             {
00451                 return;
00452             };
00453             filename = file.GetFullPath();
00454             CreateNewArgFile(filename, MainFrame::Get()->GetDataPath() + wxT("hugin_exiftool_final_example.arg"));
00455         }
00456         else
00457         {
00458             filename = file.GetFullPath();
00459         };
00460     }
00461     else
00462     {
00463         if (wxMessageBox(_("No file selected.\nShould an example argfile be created?"),
00464             _("Exiftool argfile"), wxYES_NO | wxICON_EXCLAMATION, this) != wxYES)
00465         {
00466             return;
00467         };
00468         wxFileDialog dlg(this, _("Select new ExifTool argfile"),
00469             wxStandardPaths::Get().GetUserConfigDir(), wxT(""),
00470             _("ExifTool Argfiles (*.arg)|*.arg|All Files(*)|*"),
00471             wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition);
00472         if (dlg.ShowModal() != wxID_OK)
00473         {
00474             return;
00475         };
00476         filename = dlg.GetPath();
00477         CreateNewArgFile(filename, MainFrame::Get()->GetDataPath() + wxT("hugin_exiftool_final_example.arg"));
00478     };
00479     XRCCTRL(*this, "pref_exiftool_argfile2", wxTextCtrl)->SetValue(filename);
00480     wxDialog edit_dlg;
00481     wxXmlResource::Get()->LoadDialog(&edit_dlg, this, wxT("pref_edit_argfile_placeholders"));
00482     RestoreFramePosition(&edit_dlg, wxT("EditArgfilePlaceholders"));
00483     wxTextCtrl* argfileControl = XRCCTRL(edit_dlg, "pref_edit_textcontrol", wxTextCtrl);
00484     argfileControl->LoadFile(filename);
00485     if (edit_dlg.ShowModal() == wxID_OK)
00486     {
00487         if (!argfileControl->SaveFile(filename))
00488         {
00489             wxMessageBox(wxString::Format(_("Could not save file \"%s\"."), filename.c_str()),
00490                 _("Error"), wxOK | wxICON_ERROR);
00491         };
00492         StoreFramePosition(&edit_dlg, wxT("EditArgfilePlaceholders"));
00493     };
00494 };
00495 
00496 void PreferencesDialog::OnExifTool(wxCommandEvent & e)
00497 {
00498     bool copyMetadata=XRCCTRL(*this, "pref_exiftool_metadata", wxCheckBox)->GetValue();
00499     XRCCTRL(*this, "pref_exiftool_argfile_general_label", wxStaticText)->Enable(copyMetadata);
00500     XRCCTRL(*this, "pref_exiftool_argfile_intermediate_label", wxStaticText)->Enable(copyMetadata);
00501     XRCCTRL(*this, "pref_exiftool_argfile_label", wxStaticText)->Enable(copyMetadata);
00502     XRCCTRL(*this, "pref_exiftool_argfile", wxTextCtrl)->Enable(copyMetadata);
00503     XRCCTRL(*this, "pref_exiftool_argfile_choose", wxButton)->Enable(copyMetadata);
00504     XRCCTRL(*this, "pref_exiftool_argfile_edit", wxButton)->Enable(copyMetadata);
00505     XRCCTRL(*this, "pref_exiftool_argfile_final_label", wxStaticText)->Enable(copyMetadata);
00506     XRCCTRL(*this, "pref_exiftool_argfile2_label", wxStaticText)->Enable(copyMetadata);
00507     XRCCTRL(*this, "pref_exiftool_argfile2", wxTextCtrl)->Enable(copyMetadata);
00508     XRCCTRL(*this, "pref_exiftool_argfile2_choose", wxButton)->Enable(copyMetadata);
00509     XRCCTRL(*this, "pref_exiftool_argfile2_edit", wxButton)->Enable(copyMetadata);
00510     XRCCTRL(*this, "pref_exiftool_gpano", wxCheckBox)->Enable(copyMetadata);
00511 };
00512 
00513 void PreferencesDialog::EnableRotationCtrls(bool enable)
00514 {
00515     XRCCTRL(*this, "prefs_ft_rot_panel", wxPanel)->Enable(enable);
00516 }
00517 
00518 void PreferencesDialog::UpdateDisplayData(int panel)
00519 {
00520     DEBUG_DEBUG("Updating display data");
00521 
00522     double d;
00523     bool t;
00524     wxString tstr;
00525     wxConfigBase* cfg = wxConfigBase::Get();
00526 
00527     if (panel==0 || panel == 1)
00528     {
00529         // memory setting
00530         unsigned long long mem = cfg->Read(wxT("/ImageCache/UpperBound"), HUGIN_IMGCACHE_UPPERBOUND);
00531 #ifdef __WXMSW__
00532         unsigned long mem_low = cfg->Read(wxT("/ImageCache/UpperBound"), HUGIN_IMGCACHE_UPPERBOUND);
00533         unsigned long mem_high = cfg->Read(wxT("/ImageCache/UpperBoundHigh"), (long) 0);
00534         if (mem_high > 0)
00535         {
00536             mem = ((unsigned long long) mem_high << 32) + mem_low;
00537         }
00538         else
00539         {
00540             mem = mem_low;
00541         }
00542 #endif
00543         MY_SPIN_VAL("prefs_cache_UpperBound", mem >> 20);
00544 
00545         // language
00546         // check if current language is in list and activate it then.
00547         wxChoice* lang_choice = XRCCTRL(*this, "prefs_gui_language", wxChoice);
00548         int curlang = cfg->Read(wxT("language"), HUGIN_LANGUAGE);
00549         bool found = false;
00550         int idx = 0;
00551         for (int i = 0; i < (int)lang_choice->GetCount(); i++)
00552         {
00553             long lang = * static_cast<long*>(lang_choice->GetClientData(i));
00554             if (curlang == lang)
00555             {
00556                 found = true;
00557                 idx = i;
00558             }
00559         }
00560         if (found)
00561         {
00562             DEBUG_DEBUG("wxChoice language updated:" << curlang);
00563             // update language
00564             lang_choice->SetSelection(idx);
00565         }
00566         else
00567         {
00568             // unknown language selected..
00569             DEBUG_WARN("Unknown language configured");
00570         }
00571 
00572         // smart undo
00573         t = cfg->Read(wxT("smartUndo"), HUGIN_SMART_UNDO) == 1;
00574         MY_BOOL_VAL("prefs_smart_undo", t);
00575 
00576         // copy log to clipboard
00577         t = cfg->Read(wxT("CopyLogToClipboard"), 0l) == 1;
00578         MY_BOOL_VAL("prefs_copy_log", t);
00579 
00580         t = cfg->Read(wxT("/GLPreviewFrame/ShowProjectionHints"), HUGIN_SHOW_PROJECTION_HINTS) == 1;
00581         MY_BOOL_VAL("pref_show_projection_hints", t);
00582         // auto-rotate
00583         t = cfg->Read("/CPEditorPanel/AutoRot", 1l) == 1;
00584         MY_BOOL_VAL("pref_autorotate", t);
00585     };
00586 
00587     // filename panel
00588     if(panel==0 || panel==2)
00589     {
00590         // tempdir
00591         MY_STR_VAL("prefs_misc_tempdir", cfg->Read(wxT("tempDir"),wxT("")));
00592         // default filenames
00593         wxString filename=cfg->Read(wxT("ProjectFilename"), wxT(HUGIN_DEFAULT_PROJECT_NAME));
00594 #ifdef __WXMSW__
00595         filename.Replace(wxT("/"),wxT("\\"),true);
00596 #endif
00597         MY_STR_VAL("prefs_project_filename", filename);
00598         filename=cfg->Read(wxT("OutputFilename"), wxT(HUGIN_DEFAULT_OUTPUT_NAME));
00599 #ifdef __WXMSW__
00600         filename.Replace(wxT("/"),wxT("\\"),true);
00601 #endif
00602         MY_STR_VAL("prefs_output_filename", filename);
00603     }
00604 
00605     if (panel==0 || panel == 3)
00606     {
00607         // Assistant settings
00608         t = cfg->Read(wxT("/Assistant/autoAlign"), HUGIN_ASS_AUTO_ALIGN) == 1;
00609         MY_BOOL_VAL("prefs_ass_autoAlign", t);
00610         MY_SPIN_VAL("prefs_ass_nControlPoints",
00611                     cfg->Read(wxT("/Assistant/nControlPoints"), HUGIN_ASS_NCONTROLPOINTS));
00612         double factor = HUGIN_ASS_PANO_DOWNSIZE_FACTOR;
00613         cfg->Read(wxT("/Assistant/panoDownsizeFactor"), &factor);
00614         MY_SPIN_VAL("prefs_ass_panoDownsizeFactor",(int)(factor*100.0));
00615         t = cfg->Read(wxT("/Assistant/Linefind"), HUGIN_ASS_LINEFIND) == 1;
00616         MY_BOOL_VAL("prefs_ass_linefind", t);
00617         t = cfg->Read(wxT("/Celeste/Auto"), HUGIN_CELESTE_AUTO) == 1;
00618         MY_BOOL_VAL("prefs_celeste_auto", t);
00619         t = cfg->Read(wxT("/Assistant/AutoCPClean"), HUGIN_ASS_AUTO_CPCLEAN) == 1;
00620         MY_BOOL_VAL("prefs_auto_cpclean", t);
00621     }
00622     // Fine tune settings
00623 
00624     if (panel==0 || panel == 4)
00625     {
00626         // hdr display settings
00627         MY_CHOICE_VAL("prefs_misc_hdr_mapping", cfg->Read(wxT("/ImageCache/Mapping"), HUGIN_IMGCACHE_MAPPING_FLOAT));
00628         //MY_CHOICE_VAL("prefs_misc_hdr_range", cfg->Read(wxT("/ImageCache/Range"), HUGIN_IMGCACHE_RANGE));
00629 
00630         MY_SPIN_VAL("prefs_ft_TemplateSize",
00631                     cfg->Read(wxT("/Finetune/TemplateSize"),HUGIN_FT_TEMPLATE_SIZE));
00632         MY_SPIN_VAL("prefs_ft_SearchAreaPercent",cfg->Read(wxT("/Finetune/SearchAreaPercent"),
00633                     HUGIN_FT_SEARCH_AREA_PERCENT));
00634         MY_SPIN_VAL("prefs_ft_LocalSearchWidth", cfg->Read(wxT("/Finetune/LocalSearchWidth"),
00635                     HUGIN_FT_LOCAL_SEARCH_WIDTH));
00636 
00637         d=HUGIN_FT_CORR_THRESHOLD;
00638         cfg->Read(wxT("/Finetune/CorrThreshold"), &d, HUGIN_FT_CORR_THRESHOLD);
00639         tstr = hugin_utils::doubleTowxString(d);
00640         MY_STR_VAL("prefs_ft_CorrThreshold", tstr);
00641 
00642         cfg->Read(wxT("/Finetune/CurvThreshold"), &d, HUGIN_FT_CURV_THRESHOLD);
00643         tstr = hugin_utils::doubleTowxString(d);
00644         MY_STR_VAL("prefs_ft_CurvThreshold", tstr);
00645 
00646         t = cfg->Read(wxT("/Finetune/RotationSearch"), HUGIN_FT_ROTATION_SEARCH) == 1;
00647         MY_BOOL_VAL("prefs_ft_RotationSearch", t);
00648         EnableRotationCtrls(t);
00649 
00650         d = HUGIN_FT_ROTATION_START_ANGLE;
00651         cfg->Read(wxT("/Finetune/RotationStartAngle"),&d,HUGIN_FT_ROTATION_START_ANGLE);
00652         MY_SPIN_VAL("prefs_ft_RotationStartAngle", hugin_utils::roundi(d))
00653 
00654         d = HUGIN_FT_ROTATION_STOP_ANGLE;
00655         cfg->Read(wxT("/Finetune/RotationStopAngle"), &d, HUGIN_FT_ROTATION_STOP_ANGLE);
00656         MY_SPIN_VAL("prefs_ft_RotationStopAngle", hugin_utils::roundi(d));
00657 
00658         MY_SPIN_VAL("prefs_ft_RotationSteps", cfg->Read(wxT("/Finetune/RotationSteps"),
00659                     HUGIN_FT_ROTATION_STEPS));
00660     }
00661 
00664 
00667 
00668     if (panel==0 || panel == 5)
00669     {
00670         cpdetector_config_edit.FillControl(m_CPDetectorList,true,true);
00671     }
00672 
00673     if (panel == 0 || panel == 6)
00674     {
00677         MY_CHOICE_VAL("pref_ldr_output_file_format", cfg->Read(wxT("/output/ldr_format"), HUGIN_LDR_OUTPUT_FORMAT));
00679         // MY_CHOICE_VAL("pref_hdr_output_file_format", cfg->Read(wxT("/output/hdr_format"), HUGIN_HDR_OUTPUT_FORMAT));
00680         MY_CHOICE_VAL("pref_tiff_compression", cfg->Read(wxT("/output/tiff_compression"), HUGIN_TIFF_COMPRESSION));
00681         MY_SPIN_VAL("pref_jpeg_quality", cfg->Read(wxT("/output/jpeg_quality"), HUGIN_JPEG_QUALITY));
00682         UpdateFileFormatControls();
00683 
00684         // default blender
00685         SelectListValue(XRCCTRL(*this, "pref_default_blender", wxChoice), cfg->Read(wxT("/default_blender"), HUGIN_DEFAULT_BLENDER));
00686         // default verdandi parameters
00687         const wxString defaultVerdandiArgs = cfg->Read(wxT("/VerdandiDefaultArgs"), wxEmptyString);
00688         if (defaultVerdandiArgs.Find(wxT("--seam=blend")) != wxNOT_FOUND)
00689         {
00690             XRCCTRL(*this, "pref_internal_blender_seam", wxChoice)->SetSelection(1);
00691         }
00692         else
00693         {
00694             XRCCTRL(*this, "pref_internal_blender_seam", wxChoice)->SetSelection(0);
00695         };
00696         UpdateBlenderControls();
00697 
00700         MY_CHOICE_VAL("pref_processor_gui", cfg->Read(wxT("/Processor/gui"), HUGIN_PROCESSOR_GUI));
00701         t = cfg->Read(wxT("/Processor/start"), HUGIN_PROCESSOR_START) == 1;
00702         MY_BOOL_VAL("pref_processor_start", t);
00703         t = cfg->Read(wxT("/Processor/overwrite"), HUGIN_PROCESSOR_OVERWRITE) == 1;
00704         MY_BOOL_VAL("pref_processor_overwrite", t);
00705         t = cfg->Read(wxT("/Processor/verbose"), HUGIN_PROCESSOR_VERBOSE) == 1;
00706         MY_BOOL_VAL("pref_processor_verbose", t);
00707         UpdateProcessorControls();
00708     }
00709 
00710     if (panel == 0 || panel == 7)
00711     {
00712         // stitching (2) panel
00713         t = cfg->Read(wxT("/output/useExiftool"), HUGIN_USE_EXIFTOOL) == 1;
00714         MY_BOOL_VAL("pref_exiftool_metadata", t);
00715         MY_STR_VAL("pref_exiftool_argfile", cfg->Read(wxT("/output/CopyArgfile"), wxT("")));
00716         MY_STR_VAL("pref_exiftool_argfile2", cfg->Read(wxT("/output/FinalArgfile"), wxT("")));
00717         t = cfg->Read(wxT("/output/writeGPano"), HUGIN_EXIFTOOL_CREATE_GPANO) == 1;
00718         MY_BOOL_VAL("pref_exiftool_gpano", t);
00719         wxCommandEvent dummy;
00720         OnExifTool(dummy);
00721         // number of threads
00722         int nThreads = cfg->Read(wxT("/output/NumberOfThreads"), 0l);
00723         MY_SPIN_VAL("prefs_output_NumberOfThreads", nThreads);
00724     }
00725 
00726     if (panel==0 || panel == 8)
00727     {
00728 
00731         MY_CHOICE_VAL("prefs_nona_interpolator", cfg->Read(wxT("/Nona/Interpolator"), HUGIN_NONA_INTERPOLATOR));
00732         t = cfg->Read(wxT("/Nona/CroppedImages"), HUGIN_NONA_CROPPEDIMAGES) == 1;
00733         MY_BOOL_VAL("prefs_nona_createCroppedImages", t);
00734         t = cfg->Read(wxT("/Nona/UseGPU"), HUGIN_NONA_USEGPU) == 1;
00735         MY_BOOL_VAL("prefs_nona_useGpu", t);
00736 
00739         MY_STR_VAL("prefs_enblend_EnblendExe", cfg->Read(wxT("/Enblend/Exe"),
00740                    wxT(HUGIN_ENBLEND_EXE)));
00741         bool customEnblendExe = HUGIN_ENBLEND_EXE_CUSTOM;
00742         cfg->Read(wxT("/Enblend/Custom"), &customEnblendExe);
00743         MY_BOOL_VAL("prefs_enblend_Custom", customEnblendExe);
00744         XRCCTRL(*this, "prefs_enblend_EnblendExe", wxTextCtrl)->Enable(customEnblendExe);
00745         XRCCTRL(*this, "prefs_enblend_select", wxButton)->Enable(customEnblendExe);
00746         MY_STR_VAL("prefs_enblend_EnblendArgs", cfg->Read(wxT("/Enblend/Args"),
00747                    wxT(HUGIN_ENBLEND_ARGS)));
00750         MY_STR_VAL("prefs_enblend_EnfuseExe", cfg->Read(wxT("/Enfuse/Exe"),
00751                    wxT(HUGIN_ENFUSE_EXE)));
00752         bool customEnfuseExe = HUGIN_ENFUSE_EXE_CUSTOM;
00753         cfg->Read(wxT("/Enfuse/Custom"), &customEnfuseExe);
00754         MY_BOOL_VAL("prefs_enblend_enfuseCustom", customEnfuseExe);
00755         XRCCTRL(*this, "prefs_enblend_EnfuseExe", wxTextCtrl)->Enable(customEnfuseExe);
00756         XRCCTRL(*this, "prefs_enblend_enfuse_select", wxButton)->Enable(customEnfuseExe);
00757         MY_STR_VAL("prefs_enblend_EnfuseArgs", cfg->Read(wxT("/Enfuse/Args"),
00758                    wxT(HUGIN_ENFUSE_ARGS)));
00759     }
00760 
00761     if (panel==0 || panel == 9)
00762     {
00763         // Celeste settings
00764         d=HUGIN_CELESTE_THRESHOLD;
00765         cfg->Read(wxT("/Celeste/Threshold"), &d, HUGIN_CELESTE_THRESHOLD);
00766         tstr = hugin_utils::doubleTowxString(d);
00767         MY_STR_VAL("prefs_celeste_threshold", tstr);
00768         MY_CHOICE_VAL("prefs_celeste_filter", cfg->Read(wxT("/Celeste/Filter"), HUGIN_CELESTE_FILTER));
00769         // photometric optimizer settings
00770         MY_SPIN_VAL("prefs_photo_optimizer_nr_points", cfg->Read(wxT("/OptimizePhotometric/nRandomPointsPerImage"), HUGIN_PHOTOMETRIC_OPTIMIZER_NRPOINTS));
00771         // warnings
00772         t = cfg->Read(wxT("/ShowSaveMessage"), 1l) == 1;
00773         MY_BOOL_VAL("prefs_warning_save", t);
00774         t = cfg->Read(wxT("/ShowExposureWarning"), 1l) == 1;
00775         MY_BOOL_VAL("prefs_warning_exposure", t);
00776         MY_CHOICE_VAL("pref_editcp_action", cfg->Read(wxT("/EditCPAfterAction"), 0l));
00777     }
00778 }
00779 
00780 void PreferencesDialog::OnRestoreDefaults(wxCommandEvent& e)
00781 {
00782     DEBUG_TRACE("");
00783     wxConfigBase* cfg = wxConfigBase::Get();
00784     // check which tab is enabled
00785     wxNotebook* noteb = XRCCTRL(*this, "prefs_tab", wxNotebook);
00786     int really = wxMessageBox(_("Really reset displayed preferences to default values?"), _("Load Defaults"),
00787                               wxYES_NO, this);
00788     if ( really == wxYES)
00789     {
00790         if (noteb->GetSelection() == 0)
00791         {
00792             // MISC
00793             // cache
00794             /*
00795              * special treatment for windows not necessary here since we know the value of
00796              * HUGIN_IMGCACHE_UPPERBOUND must fit into 32bit to be compatible with 32bit systems.
00797              * However, just as a reminder:
00798             #ifdef __WXMSW__
00799                 cfg->Write(wxT("/ImageCache/UpperBoundHigh"), HUGIN_IMGCACHE_UPPERBOUND >> 32);
00800             #endif
00801             */
00802             cfg->Write(wxT("/ImageCache/UpperBound"), HUGIN_IMGCACHE_UPPERBOUND);
00803             // locale
00804             cfg->Write(wxT("language"), int(HUGIN_LANGUAGE));
00805             // smart undo
00806             cfg->Write(wxT("smartUndo"), HUGIN_SMART_UNDO);
00807             cfg->Write(wxT("CopyLogToClipboard"), 0l);
00808             // projection hints
00809             cfg->Write(wxT("/GLPreviewFrame/ShowProjectionHints"), HUGIN_SHOW_PROJECTION_HINTS);
00810             cfg->Write("/CPEditorPanel/AutoRot", 1l);
00811         }
00812         if(noteb->GetSelection() == 1)
00813         {
00814             cfg->Write(wxT("tempDir"), wxT(""));
00815             cfg->Write(wxT("ProjectFilename"), wxT(HUGIN_DEFAULT_PROJECT_NAME));
00816             cfg->Write(wxT("OutputFilename"), wxT(HUGIN_DEFAULT_OUTPUT_NAME));
00817         };
00818         if (noteb->GetSelection() == 2)
00819         {
00820             cfg->Write(wxT("/Assistant/autoAlign"), HUGIN_ASS_AUTO_ALIGN);
00821             cfg->Write(wxT("/Assistant/nControlPoints"), HUGIN_ASS_NCONTROLPOINTS);
00822             cfg->Write(wxT("/Assistant/panoDownsizeFactor"),HUGIN_ASS_PANO_DOWNSIZE_FACTOR);
00823             cfg->Write(wxT("/Assistant/Linefind"), HUGIN_ASS_LINEFIND);
00824             cfg->Write(wxT("/Celeste/Auto"), HUGIN_CELESTE_AUTO);
00825             cfg->Write(wxT("/Assistant/AutoCPClean"), HUGIN_ASS_AUTO_CPCLEAN);
00826         }
00827         if (noteb->GetSelection() == 3)
00828         {
00829             // hdr
00830             cfg->Write(wxT("/ImageCache/Mapping"), HUGIN_IMGCACHE_MAPPING_FLOAT);
00831             //cfg->Write(wxT("/ImageCache/Range"), HUGIN_IMGCACHE_RANGE);
00832             // Fine tune settings
00833             cfg->Write(wxT("/Finetune/SearchAreaPercent"), HUGIN_FT_SEARCH_AREA_PERCENT);
00834             cfg->Write(wxT("/Finetune/TemplateSize"), HUGIN_FT_TEMPLATE_SIZE);
00835             cfg->Write(wxT("/Finetune/LocalSearchWidth"), HUGIN_FT_LOCAL_SEARCH_WIDTH);
00836 
00837             cfg->Write(wxT("/Finetune/CorrThreshold"), HUGIN_FT_CORR_THRESHOLD);
00838             cfg->Write(wxT("/Finetune/CurvThreshold"), HUGIN_FT_CURV_THRESHOLD);
00839 
00840             cfg->Write(wxT("/Finetune/RotationSearch"), HUGIN_FT_ROTATION_SEARCH);
00841             cfg->Write(wxT("/Finetune/RotationStartAngle"), HUGIN_FT_ROTATION_START_ANGLE);
00842             cfg->Write(wxT("/Finetune/RotationStopAngle"), HUGIN_FT_ROTATION_STOP_ANGLE);
00843             cfg->Write(wxT("/Finetune/RotationSteps"), HUGIN_FT_ROTATION_STEPS);
00844         }
00845         if (noteb->GetSelection() == 4)
00846         {
00849             cpdetector_config_edit.ReadFromFile(huginApp::Get()->GetDataPath()+wxT("default.setting"));
00850             cpdetector_config_edit.Write(cfg);
00851         }
00852         if (noteb->GetSelection() == 5)
00853         {
00855             cfg->Write(wxT("/output/ldr_format"), HUGIN_LDR_OUTPUT_FORMAT);
00857             // cfg->Write(wxT("/output/hdr_format"), HUGIN_HDR_OUTPUT_FORMAT);
00858             cfg->Write(wxT("/output/tiff_compression"), HUGIN_TIFF_COMPRESSION);
00859             cfg->Write(wxT("/output/jpeg_quality"), HUGIN_JPEG_QUALITY);
00860             // default blender
00861             cfg->Write(wxT("/default_blender"), static_cast<long>(HUGIN_DEFAULT_BLENDER));
00862             cfg->Write(wxT("/VerdandiDefaultArgs"), wxEmptyString);
00863             // stitching engine
00864             cfg->Write(wxT("/Processor/gui"), HUGIN_PROCESSOR_GUI);
00865             cfg->Write(wxT("/Processor/start"), HUGIN_PROCESSOR_START);
00866             cfg->Write(wxT("/Processor/overwrite"), HUGIN_PROCESSOR_OVERWRITE);
00867             cfg->Write(wxT("/Processor/verbose"), HUGIN_PROCESSOR_VERBOSE);
00868         }
00869         if (noteb->GetSelection() == 6)
00870         {
00871             cfg->Write(wxT("/output/useExiftool"), HUGIN_USE_EXIFTOOL);
00872             cfg->Write(wxT("/output/CopyArgfile"), wxT(""));
00873             cfg->Write(wxT("/output/FinalArgfile"), wxT(""));
00874             cfg->Write(wxT("/output/writeGPano"), HUGIN_EXIFTOOL_CREATE_GPANO);
00875             cfg->Write(wxT("/output/NumberOfThreads"), 0l);
00876         }
00877         if (noteb->GetSelection() == 7)
00878         {
00880             cfg->Write(wxT("/Enblend/Exe"), wxT(HUGIN_ENBLEND_EXE));
00881             cfg->Write(wxT("/Enblend/Custom"), HUGIN_ENBLEND_EXE_CUSTOM);
00882             cfg->Write(wxT("/Enblend/Args"), wxT(HUGIN_ENBLEND_ARGS));
00883 
00884             cfg->Write(wxT("/Enfuse/Exe"), wxT(HUGIN_ENFUSE_EXE));
00885             cfg->Write(wxT("/Enfuse/Custom"), HUGIN_ENFUSE_EXE_CUSTOM);
00886             cfg->Write(wxT("/Enfuse/Args"), wxT(HUGIN_ENFUSE_ARGS));
00887         }
00888 
00889         if (noteb->GetSelection() == 8)
00890         {
00892             cfg->Write(wxT("/Celeste/Threshold"), HUGIN_CELESTE_THRESHOLD);
00893             cfg->Write(wxT("/Celeste/Filter"), HUGIN_CELESTE_FILTER);
00894             cfg->Write(wxT("/OptimizePhotometric/nRandomPointsPerImage"), HUGIN_PHOTOMETRIC_OPTIMIZER_NRPOINTS);
00895             cfg->Write(wxT("/ShowSaveMessage"), 1l);
00896             cfg->Write(wxT("/ShowExposureWarning"), 1l);
00897             cfg->Write(wxT("/EditCPAfterAction"), 0l);
00898         }
00899 
00900         /*
00901                 if (noteb->GetSelection() == 5) {
00902                     cfg->Write(wxT("/PTmender/Exe"), wxT(HUGIN_PT_MENDER_EXE) );
00903                     cfg->Write(wxT("/PTmender/Custom"),HUGIN_PT_MENDER_EXE_CUSTOM);
00904                     cfg->Write(wxT("/PanoTools/ScriptFile"), wxT("PT_script.txt"));
00905                 }
00906         */
00907         UpdateDisplayData(noteb->GetSelection() + 1);
00908     }
00909 }
00910 
00911 void PreferencesDialog::UpdateConfigData()
00912 {
00913     DEBUG_TRACE("");
00914     wxConfigBase* cfg = wxConfigBase::Get();
00915     // Assistant
00916     cfg->Write(wxT("/Assistant/autoAlign"),MY_G_BOOL_VAL("prefs_ass_autoAlign"));
00917     cfg->Write(wxT("/Assistant/nControlPoints"), MY_G_SPIN_VAL("prefs_ass_nControlPoints"));
00918     cfg->Write(wxT("/Assistant/panoDownsizeFactor"), MY_G_SPIN_VAL("prefs_ass_panoDownsizeFactor") / 100.0);
00919     cfg->Write(wxT("/Assistant/Linefind"), MY_G_BOOL_VAL("prefs_ass_linefind"));
00920     cfg->Write(wxT("/Celeste/Auto"), MY_G_BOOL_VAL("prefs_celeste_auto"));
00921     cfg->Write(wxT("/Assistant/AutoCPClean"), MY_G_BOOL_VAL("prefs_auto_cpclean"));
00922 
00923     // hdr display
00924     cfg->Write(wxT("/ImageCache/Mapping"),MY_G_CHOICE_VAL("prefs_misc_hdr_mapping"));
00925     //cfg->Write(wxT("/ImageCache/Range"),MY_G_CHOICE_VAL("prefs_misc_hdr_range"));
00926 
00927     // Fine tune settings
00928     cfg->Write(wxT("/Finetune/SearchAreaPercent"), MY_G_SPIN_VAL("prefs_ft_SearchAreaPercent"));
00929     cfg->Write(wxT("/Finetune/TemplateSize"), MY_G_SPIN_VAL("prefs_ft_TemplateSize"));
00930     cfg->Write(wxT("/Finetune/LocalSearchWidth"), MY_G_SPIN_VAL("prefs_ft_LocalSearchWidth"));
00931     wxString t = MY_G_STR_VAL("prefs_ft_CorrThreshold");
00932     double td= HUGIN_FT_CORR_THRESHOLD;
00933     hugin_utils::stringToDouble(std::string(t.mb_str(wxConvLocal)), td);
00934     cfg->Write(wxT("/Finetune/CorrThreshold"), td);
00935 
00936     t = MY_G_STR_VAL("prefs_ft_CurvThreshold");
00937     td = HUGIN_FT_CURV_THRESHOLD;
00938     hugin_utils::stringToDouble(std::string(t.mb_str(wxConvLocal)), td);
00939     cfg->Write(wxT("/Finetune/CurvThreshold"), td);
00940 
00941     cfg->Write(wxT("/Finetune/RotationSearch"), MY_G_BOOL_VAL("prefs_ft_RotationSearch"));
00942     cfg->Write(wxT("/Finetune/RotationStartAngle"), (double) MY_G_SPIN_VAL("prefs_ft_RotationStartAngle"));
00943     cfg->Write(wxT("/Finetune/RotationStopAngle"), (double) MY_G_SPIN_VAL("prefs_ft_RotationStopAngle"));
00944     cfg->Write(wxT("/Finetune/RotationSteps"), MY_G_SPIN_VAL("prefs_ft_RotationSteps"));
00945 
00948     // cache
00949 #ifdef __WXMSW__
00950     // shifting only 12 bits rights: 32-20=12 and the prefs_cache_UpperBound is in GB
00951     cfg->Write(wxT("/ImageCache/UpperBoundHigh"), (long) MY_G_SPIN_VAL("prefs_cache_UpperBound") >> 12);
00952 #endif
00953     cfg->Write(wxT("/ImageCache/UpperBound"), (long) MY_G_SPIN_VAL("prefs_cache_UpperBound") << 20);
00954     // locale
00955     // language
00956     wxChoice* lang = XRCCTRL(*this, "prefs_gui_language", wxChoice);
00957     // DEBUG_TRACE("Language Selection Name: " << huginApp::Get()->GetLocale().GetLanguageName((int) lang->GetClientData(lang->GetSelection())).mb_str(wxConvLocal));
00958     //DEBUG_INFO("Language Selection locale: " << ((huginApp::Get()->GetLocale().GetLanguageInfo((int) lang->GetClientData(lang->GetSelection())))->CanonicalName).mb_str(wxConvLocal));
00959     //DEBUG_INFO("Current System Language ID: " << huginApp::Get()->GetLocale().GetSystemLanguage());
00960 
00961     void* tmplp = lang->GetClientData(lang->GetSelection());
00962     long templ =  * static_cast<long*>(tmplp);
00963     cfg->Write(wxT("language"), templ);
00964     DEBUG_INFO("Language Selection ID: " << templ);
00965     // smart undo
00966     cfg->Write(wxT("smartUndo"), MY_G_BOOL_VAL("prefs_smart_undo"));
00967     cfg->Write(wxT("CopyLogToClipboard"), MY_G_BOOL_VAL("prefs_copy_log"));
00968     // show projections hints
00969     cfg->Write(wxT("/GLPreviewFrame/ShowProjectionHints"), MY_G_BOOL_VAL("pref_show_projection_hints"));
00970     //auto-rotate
00971     cfg->Write("/CPEditorPanel/AutoRot", MY_G_BOOL_VAL("pref_autorotate"));
00972     // tempdir
00973     cfg->Write(wxT("tempDir"),MY_G_STR_VAL("prefs_misc_tempdir"));
00974     // filename templates
00975     wxString filename=XRCCTRL(*this, "prefs_project_filename", wxTextCtrl)->GetValue();
00976 #ifdef __WXMSW__
00977     filename.Replace(wxT("\\"), wxT("/"), true);
00978 #endif
00979     cfg->Write(wxT("ProjectFilename"), filename);
00980     filename=XRCCTRL(*this, "prefs_output_filename", wxTextCtrl)->GetValue();
00981 #ifdef __WXMSW__
00982     filename.Replace(wxT("\\"), wxT("/"), true);
00983 #endif
00984     cfg->Write(wxT("OutputFilename"), filename);
00987     cpdetector_config_edit.Write(cfg);
00988 
00991     cfg->Write(wxT("/output/ldr_format"), MY_G_CHOICE_VAL("pref_ldr_output_file_format"));
00993     // cfg->Write(wxT("/output/hdr_format"), MY_G_CHOICE_VAL("pref_hdr_output_file_format"));
00994     cfg->Write(wxT("/output/tiff_compression"), MY_G_CHOICE_VAL("pref_tiff_compression"));
00995     cfg->Write(wxT("/output/jpeg_quality"), MY_G_SPIN_VAL("pref_jpeg_quality"));
00996 
00997     cfg->Write(wxT("/default_blender"), static_cast<long>(GetSelectedValue(XRCCTRL(*this, "pref_default_blender", wxChoice))));
00998     if (XRCCTRL(*this, "pref_internal_blender_seam", wxChoice)->GetSelection() == 1)
00999     {
01000         cfg->Write(wxT("/VerdandiDefaultArgs"), wxT("--seam=blend"));
01001     }
01002     else
01003     {
01004         cfg->Write(wxT("/VerdandiDefaultArgs"), wxEmptyString);
01005     };
01006 
01009     cfg->Write(wxT("/Processor/gui"), MY_G_CHOICE_VAL("pref_processor_gui"));
01010     cfg->Write(wxT("/Processor/start"), MY_G_BOOL_VAL("pref_processor_start"));
01011     cfg->Write(wxT("/Processor/overwrite"), MY_G_BOOL_VAL("pref_processor_overwrite"));
01012     cfg->Write(wxT("/Processor/verbose"), MY_G_BOOL_VAL("pref_processor_verbose"));
01013 
01014     cfg->Write(wxT("/output/useExiftool"), MY_G_BOOL_VAL("pref_exiftool_metadata"));
01015     cfg->Write(wxT("/output/CopyArgfile"), MY_G_STR_VAL("pref_exiftool_argfile"));
01016     cfg->Write(wxT("/output/FinalArgfile"), MY_G_STR_VAL("pref_exiftool_argfile2"));
01017     cfg->Write(wxT("/output/writeGPano"), MY_G_BOOL_VAL("pref_exiftool_gpano"));
01018     cfg->Write(wxT("/output/NumberOfThreads"), MY_G_SPIN_VAL("prefs_output_NumberOfThreads"));
01021     cfg->Write(wxT("/Nona/Interpolator"), MY_G_CHOICE_VAL("prefs_nona_interpolator"));
01022     cfg->Write(wxT("/Nona/CroppedImages"), MY_G_BOOL_VAL("prefs_nona_createCroppedImages"));
01023     cfg->Write(wxT("/Nona/UseGPU"), MY_G_BOOL_VAL("prefs_nona_useGpu"));
01024 
01027     cfg->Write(wxT("/Enblend/Custom"), MY_G_BOOL_VAL("prefs_enblend_Custom"));
01028     cfg->Write(wxT("/Enblend/Exe"), MY_G_STR_VAL("prefs_enblend_EnblendExe"));
01029     cfg->Write(wxT("/Enblend/Args"), MY_G_STR_VAL("prefs_enblend_EnblendArgs"));
01030 
01031     cfg->Write(wxT("/Enfuse/Custom"), MY_G_BOOL_VAL("prefs_enblend_enfuseCustom"));
01032     cfg->Write(wxT("/Enfuse/Exe"), MY_G_STR_VAL("prefs_enblend_EnfuseExe"));
01033     cfg->Write(wxT("/Enfuse/Args"), MY_G_STR_VAL("prefs_enblend_EnfuseArgs"));
01034 
01035     // Celeste
01036     t = MY_G_STR_VAL("prefs_celeste_threshold");
01037     td = HUGIN_CELESTE_THRESHOLD;
01038     hugin_utils::stringToDouble(std::string(t.mb_str(wxConvLocal)), td);
01039     cfg->Write(wxT("/Celeste/Threshold"), td);
01040     cfg->Write(wxT("/Celeste/Filter"), MY_G_CHOICE_VAL("prefs_celeste_filter"));
01041     //photometric optimizer
01042     cfg->Write(wxT("/OptimizePhotometric/nRandomPointsPerImage"), MY_G_SPIN_VAL("prefs_photo_optimizer_nr_points"));
01043     cfg->Write(wxT("/ShowSaveMessage"), MY_G_BOOL_VAL("prefs_warning_save"));
01044     cfg->Write(wxT("/ShowExposureWarning"), MY_G_BOOL_VAL("prefs_warning_exposure"));
01045     cfg->Write(wxT("/EditCPAfterAction"), MY_G_CHOICE_VAL("pref_editcp_action"));
01046 
01047     cfg->Flush();
01048     UpdateDisplayData(0);
01049 }
01050 
01051 void PreferencesDialog::OnCPDetectorAdd(wxCommandEvent& e)
01052 {
01053     CPDetectorDialog cpdetector_dlg(this);
01054     if(cpdetector_dlg.ShowModal()==wxOK)
01055     {
01056         cpdetector_config_edit.settings.Add(new CPDetectorSetting);
01057         cpdetector_dlg.UpdateSettings(&cpdetector_config_edit,cpdetector_config_edit.GetCount()-1);
01058         cpdetector_config_edit.FillControl(m_CPDetectorList,false,true);
01059         m_CPDetectorList->SetSelection(cpdetector_config_edit.GetCount()-1);
01060     };
01061 };
01062 
01063 void PreferencesDialog::OnCPDetectorEdit(wxCommandEvent& e)
01064 {
01065     CPDetectorDialog autopano_dlg(this);
01066     int selection=m_CPDetectorList->GetSelection();
01067     if (selection == wxNOT_FOUND)
01068     {
01069         wxMessageBox(_("Please select an entry first"),_("Select Entry"),wxOK |
01070                      wxICON_EXCLAMATION,this);
01071     }
01072     else
01073     {
01074         autopano_dlg.UpdateFields(&cpdetector_config_edit, selection);
01075         if(autopano_dlg.ShowModal()==wxOK)
01076         {
01077             autopano_dlg.UpdateSettings(&cpdetector_config_edit, selection);
01078             cpdetector_config_edit.FillControl(m_CPDetectorList,false,true);
01079             m_CPDetectorList->SetSelection(selection);
01080         };
01081     }
01082 };
01083 
01084 void PreferencesDialog::OnCPDetectorDelete(wxCommandEvent& e)
01085 {
01086     unsigned int selection=m_CPDetectorList->GetSelection();
01087     if(m_CPDetectorList->GetCount()==1)
01088     {
01089         wxMessageBox(_("You can't delete the last setting.\nAt least one setting is required."),_("Warning"),wxOK | wxICON_EXCLAMATION,this);
01090     }
01091     else
01092     {
01093         if(wxMessageBox(wxString::Format(_("Do you really want to remove control point detector setting \"%s\"?"),cpdetector_config_edit.settings[selection].GetCPDetectorDesc().c_str())
01094                         ,_("Delete control point detector setting"),wxYES_NO | wxICON_QUESTION,this)==wxYES)
01095         {
01096             if(cpdetector_config_edit.GetDefaultGenerator()==selection)
01097             {
01098                 cpdetector_config_edit.SetDefaultGenerator(0);
01099             }
01100             cpdetector_config_edit.settings.RemoveAt(selection);
01101             cpdetector_config_edit.FillControl(m_CPDetectorList,false,true);
01102             if(selection>=m_CPDetectorList->GetCount())
01103             {
01104                 selection=m_CPDetectorList->GetCount()-1;
01105             }
01106             m_CPDetectorList->SetSelection(selection);
01107         };
01108     };
01109 };
01110 
01111 void PreferencesDialog::OnCPDetectorMoveUp(wxCommandEvent& e)
01112 {
01113     unsigned int selection=m_CPDetectorList->GetSelection();
01114     if(selection>0)
01115     {
01116         cpdetector_config_edit.Swap(selection-1);
01117         cpdetector_config_edit.FillControl(m_CPDetectorList,false,true);
01118         m_CPDetectorList->SetSelection(selection-1);
01119     };
01120 };
01121 
01122 void PreferencesDialog::OnCPDetectorMoveDown(wxCommandEvent& e)
01123 {
01124     unsigned int selection=m_CPDetectorList->GetSelection();
01125     if(selection<m_CPDetectorList->GetCount()-1)
01126     {
01127         cpdetector_config_edit.Swap(selection);
01128         cpdetector_config_edit.FillControl(m_CPDetectorList,false,true);
01129         m_CPDetectorList->SetSelection(selection+1);
01130     };
01131 };
01132 
01133 void PreferencesDialog::OnCPDetectorDefault(wxCommandEvent& e)
01134 {
01135     unsigned int selection=m_CPDetectorList->GetSelection();
01136     if(selection!=cpdetector_config_edit.GetDefaultGenerator())
01137     {
01138         cpdetector_config_edit.SetDefaultGenerator(selection);
01139         cpdetector_config_edit.FillControl(m_CPDetectorList,false,true);
01140         m_CPDetectorList->SetSelection(selection);
01141     };
01142 };
01143 
01144 void PreferencesDialog::OnCPDetectorListDblClick(wxCommandEvent& e)
01145 {
01146     OnCPDetectorEdit(e);
01147 };
01148 
01149 void PreferencesDialog::OnCPDetectorLoad(wxCommandEvent& e)
01150 {
01151     wxFileDialog dlg(this,_("Load control point detector settings"),
01152                      wxConfigBase::Get()->Read(wxT("/actualPath"),wxT("")), wxEmptyString,
01153                      _("Control point detector settings (*.setting)|*.setting"),wxFD_OPEN | wxFD_FILE_MUST_EXIST);
01154     if (dlg.ShowModal() == wxID_OK)
01155     {
01156         wxConfig::Get()->Write(wxT("/actualPath"), dlg.GetDirectory());  // remember for later
01157         wxString fn = dlg.GetPath();
01158         cpdetector_config_edit.ReadFromFile(fn);
01159         cpdetector_config_edit.Write();
01160         UpdateDisplayData(4);
01161     };
01162 };
01163 
01164 void PreferencesDialog::OnCPDetectorSave(wxCommandEvent& e)
01165 {
01166     wxFileDialog dlg(this,_("Save control point detector settings"),
01167                      wxConfigBase::Get()->Read(wxT("/actualPath"),wxT("")), wxEmptyString,
01168                      _("Control point detector settings (*.setting)|*.setting"),wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
01169     if (dlg.ShowModal() == wxID_OK)
01170     {
01171         wxConfig::Get()->Write(wxT("/actualPath"), dlg.GetDirectory());  // remember for later
01172         wxString fn = dlg.GetPath();
01173 #ifndef __WXMSW__
01174         //append extension if not given
01175         //not necessary on Windows, the wxFileDialog appends it automatic
01176         if(fn.Right(8)!=wxT(".setting"))
01177         {
01178             fn.Append(wxT(".setting"));
01179         };
01180 #endif
01181         cpdetector_config_edit.WriteToFile(fn);
01182     };
01183 };
01184 
01185 void PreferencesDialog::OnFileFormatChanged(wxCommandEvent& e)
01186 {
01187     UpdateFileFormatControls();
01188 };
01189 
01190 void PreferencesDialog::UpdateFileFormatControls()
01191 {
01192     int i=MY_G_CHOICE_VAL("pref_ldr_output_file_format");
01193     XRCCTRL(*this,"pref_tiff_compression_label",wxStaticText)->Show(i==0);
01194     XRCCTRL(*this,"pref_tiff_compression",wxChoice)->Show(i==0);
01195     XRCCTRL(*this,"pref_jpeg_quality_label",wxStaticText)->Show(i==1);
01196     XRCCTRL(*this,"pref_jpeg_quality",wxSpinCtrl)->Show(i==1);
01197     XRCCTRL(*this,"pref_tiff_compression",wxChoice)->GetParent()->Layout();
01198 };
01199 
01200 void PreferencesDialog::OnProcessorChanged(wxCommandEvent& e)
01201 {
01202     UpdateProcessorControls();
01203 };
01204 
01205 void PreferencesDialog::UpdateProcessorControls()
01206 {
01207     int i=MY_G_CHOICE_VAL("pref_processor_gui");
01208     XRCCTRL(*this,"pref_processor_start",wxCheckBox)->Enable(i==0);
01209     XRCCTRL(*this,"pref_processor_verbose",wxCheckBox)->Enable(i==0);
01210     switch(i)
01211     {
01212         case 0:
01213             //PTBatcherGUI
01214             {
01215                 wxConfigBase* config=wxConfigBase::Get();
01216                 XRCCTRL(*this,"pref_processor_start",wxCheckBox)->SetValue(config->Read(wxT("/Processor/start"), HUGIN_PROCESSOR_START) == 1);
01217                 XRCCTRL(*this,"pref_processor_verbose",wxCheckBox)->SetValue(config->Read(wxT("/Processor/verbose"), HUGIN_PROCESSOR_VERBOSE) == 1);
01218             }
01219             break;
01220         case 1:
01221             //Hugin_stitch_project
01222             XRCCTRL(*this,"pref_processor_start",wxCheckBox)->SetValue(true);
01223             XRCCTRL(*this,"pref_processor_verbose",wxCheckBox)->SetValue(true);
01224             break;
01225     };
01226 };
01227 
01228 void PreferencesDialog::OnBlenderChanged(wxCommandEvent & e)
01229 {
01230     UpdateBlenderControls();
01231 };
01232 
01233 void PreferencesDialog::UpdateBlenderControls()
01234 {
01235     const int blender = MY_G_CHOICE_VAL("pref_default_blender");
01236     XRCCTRL(*this, "pref_internal_blender_seam_label", wxStaticText)->Show(blender == 1);
01237     wxChoice* seamChoice = XRCCTRL(*this, "pref_internal_blender_seam", wxChoice);
01238     seamChoice->Show(blender == 1);
01239     seamChoice->Enable(blender == 1);
01240 };
01241 
01242 void PreferencesDialog::OnUpdateProjectFilename(wxCommandEvent& e)
01243 {
01244     XRCCTRL(*this, "prefs_project_filename_preview", wxStaticText)->SetLabel(
01245         getDefaultProjectName(MainFrame::Get()->getPanorama(), XRCCTRL(*this, "prefs_project_filename", wxTextCtrl)->GetValue())
01246     );
01247 };
01248 
01249 void PreferencesDialog::OnUpdateOutputFilename(wxCommandEvent& e)
01250 {
01251     XRCCTRL(*this, "prefs_output_filename_preview", wxStaticText)->SetLabel(
01252         getDefaultOutputName(MainFrame::Get()->getProjectName(), MainFrame::Get()->getPanorama(), XRCCTRL(*this, "prefs_output_filename", wxTextCtrl)->GetValue())
01253     );
01254 };
01255 

Generated on 10 Dec 2017 for Hugintrunk by  doxygen 1.4.7