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

Generated on 20 Oct 2017 for Hugintrunk by  doxygen 1.4.7