PreferencesDialog.cpp

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

Generated on 2 Sep 2015 for Hugintrunk by  doxygen 1.4.7