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 "panoinc.h"
00031 
00032 #include "base_wx/wxPlatform.h"
00033 
00034 #include "hugin/huginApp.h"
00035 #include "hugin/config_defaults.h"
00036 #include "hugin/PreferencesDialog.h"
00037 #include "hugin/CPDetectorDialog.h"
00038 #include "hugin/MainFrame.h"
00039 #include "base_wx/huginConfig.h"
00040 
00041 // validators are working different somehow...
00042 //#define MY_STR_VAL(id, filter) { XRCCTRL(*this, "prefs_" #id, wxTextCtrl)->SetValidator(wxTextValidator(filter, &id)); }
00043 //#define MY_SPIN_VAL(id) {     XRCCTRL(*this, "prefs_" #id, wxSpinCtrl)->SetValidator(wxGenericValidator(&id)); }
00044 
00045 #define MY_STR_VAL(id, val) { XRCCTRL(*this, id, wxTextCtrl)->SetValue(val); };
00046 #define MY_SPIN_VAL(id, val) { XRCCTRL(*this, id, wxSpinCtrl)->SetValue(val); };
00047 #define MY_BOOL_VAL(id, val) { XRCCTRL(*this, id, wxCheckBox)->SetValue(val); };
00048 #define MY_CHOICE_VAL(id, val) { XRCCTRL(*this, id, wxChoice)->SetSelection(val); };
00049 #define MY_STATIC_VAL(id, val) { XRCCTRL(*this, id, wxStaticText)->SetLabel(val); };
00050 
00051 #define MY_G_STR_VAL(id)  XRCCTRL(*this, id, wxTextCtrl)->GetValue()
00052 #define MY_G_SPIN_VAL(id)  XRCCTRL(*this, id, wxSpinCtrl)->GetValue()
00053 #define MY_G_BOOL_VAL(id)  XRCCTRL(*this, id, wxCheckBox)->GetValue()
00054 #define MY_G_CHOICE_VAL(id)  XRCCTRL(*this, id, wxChoice)->GetSelection()
00055 
00056 
00057 
00058 BEGIN_EVENT_TABLE(PreferencesDialog, wxDialog)
00059     EVT_BUTTON(wxID_OK, PreferencesDialog::OnOk)
00060     EVT_BUTTON(wxID_HELP, PreferencesDialog::OnHelp)
00061     EVT_BUTTON(wxID_CANCEL, PreferencesDialog::OnCancel)
00062     EVT_BUTTON(XRCID("prefs_defaults"), PreferencesDialog::OnRestoreDefaults)
00063     EVT_BUTTON(XRCID("prefs_enblend_select"), PreferencesDialog::OnEnblendExe)
00064     EVT_BUTTON(XRCID("prefs_enblend_enfuse_select"), PreferencesDialog::OnEnfuseExe)
00065     EVT_CHECKBOX(XRCID("prefs_ft_RotationSearch"), PreferencesDialog::OnRotationCheckBox)
00066     EVT_CHECKBOX(XRCID("prefs_enblend_Custom"), PreferencesDialog::OnCustomEnblend)
00067     EVT_CHECKBOX(XRCID("prefs_enblend_enfuseCustom"), PreferencesDialog::OnCustomEnfuse)
00068     EVT_BUTTON(XRCID("pref_cpdetector_new"), PreferencesDialog::OnCPDetectorAdd)
00069     EVT_BUTTON(XRCID("pref_cpdetector_edit"), PreferencesDialog::OnCPDetectorEdit)
00070     EVT_BUTTON(XRCID("pref_cpdetector_del"), PreferencesDialog::OnCPDetectorDelete)
00071     EVT_BUTTON(XRCID("pref_cpdetector_moveup"), PreferencesDialog::OnCPDetectorMoveUp)
00072     EVT_BUTTON(XRCID("pref_cpdetector_movedown"), PreferencesDialog::OnCPDetectorMoveDown)
00073     EVT_BUTTON(XRCID("pref_cpdetector_default"), PreferencesDialog::OnCPDetectorDefault)
00074     EVT_LISTBOX_DCLICK(XRCID("pref_cpdetector_list"), PreferencesDialog::OnCPDetectorListDblClick)
00075     EVT_BUTTON(XRCID("pref_cpdetector_load"), PreferencesDialog::OnCPDetectorLoad)
00076     EVT_BUTTON(XRCID("pref_cpdetector_save"), PreferencesDialog::OnCPDetectorSave)
00077     EVT_CHOICE(XRCID("pref_ldr_output_file_format"), PreferencesDialog::OnFileFormatChanged)
00078     EVT_CHOICE(XRCID("pref_processor_gui"), PreferencesDialog::OnProcessorChanged)
00079     EVT_TEXT(XRCID("prefs_project_filename"), PreferencesDialog::OnUpdateProjectFilename)
00080     EVT_TEXT(XRCID("prefs_output_filename"), PreferencesDialog::OnUpdateOutputFilename)
00081 END_EVENT_TABLE()
00082 
00083 
00084 PreferencesDialog::PreferencesDialog(wxWindow* parent)
00085 //: wxDialog(parent, -1, _("Preferences - hugin"))
00086 {
00087     DEBUG_TRACE("");
00088     // load our children. some children might need special
00089     // initialization. this will be done later.
00090     wxXmlResource::Get()->LoadDialog(this, parent, wxT("pref_dialog"));
00091 
00092 #ifdef __WXMSW__
00093     wxIcon myIcon(huginApp::Get()->GetXRCPath() + wxT("data/hugin.ico"),wxBITMAP_TYPE_ICO);
00094 #else
00095     wxIcon myIcon(huginApp::Get()->GetXRCPath() + wxT("data/hugin.png"),wxBITMAP_TYPE_PNG);
00096 #endif
00097     SetIcon(myIcon);
00098 
00099     // Custom setup ( stuff that can not be done in XRC )
00100     XRCCTRL(*this, "prefs_ft_RotationStartAngle", wxSpinCtrl)->SetRange(-180,0);
00101     XRCCTRL(*this, "prefs_ft_RotationStopAngle", wxSpinCtrl)->SetRange(0,180);
00102     XRCCTRL(*this, "prefs_ass_nControlPoints", wxSpinCtrl)->SetRange(3,3000);
00103 
00104     wxChoice* lang_choice = XRCCTRL(*this, "prefs_gui_language", wxChoice);
00105 
00106 #if __WXMAC__
00107     lang_choice->Disable();
00108 #endif
00109 
00110     // add languages to choice
00111     long* lp = new long;
00112     *lp = wxLANGUAGE_DEFAULT;
00113     lang_choice->Append(_("System default"), lp);
00114     lp = new long;
00115     *lp = wxLANGUAGE_BASQUE;
00116     lang_choice->Append(_("Basque"), lp);
00125     lp = new long;
00126     *lp = wxLANGUAGE_CHINESE_SIMPLIFIED;
00127     lang_choice->Append(_("Chinese (Simplified)"), lp);
00128     lp = new long;
00129     *lp = wxLANGUAGE_CHINESE_TRADITIONAL;
00130     lang_choice->Append(_("Chinese (Traditional)"), lp);
00131     lp = new long;
00132     *lp = wxLANGUAGE_CZECH;
00133     lang_choice->Append(_("Czech"), lp);
00134     lp = new long;
00135     *lp = wxLANGUAGE_DANISH;
00136     lang_choice->Append(_("Danish"), lp);
00137     lp = new long;
00138     *lp = wxLANGUAGE_DUTCH;
00139     lang_choice->Append(_("Dutch"), lp);
00140     lp = new long;
00141     *lp = wxLANGUAGE_ENGLISH;
00142     lang_choice->Append(_("English"), lp);
00143     lp = new long;
00144     *lp = wxLANGUAGE_FRENCH;
00145     lang_choice->Append(_("French"), lp);
00146     lp = new long;
00147     *lp = wxLANGUAGE_GERMAN;
00148     lang_choice->Append(_("German"), lp);
00149     lp = new long;
00150     *lp = wxLANGUAGE_HUNGARIAN;
00151     lang_choice->Append(_("Hungarian"), lp);
00152     lp = new long;
00153     *lp = wxLANGUAGE_ITALIAN;
00154     lang_choice->Append(_("Italian"), lp);
00155     lp = new long;
00156     *lp = wxLANGUAGE_JAPANESE;
00157     lang_choice->Append(_("Japanese"), lp);
00163     lp = new long;
00164     *lp = wxLANGUAGE_POLISH;
00165     lang_choice->Append(_("Polish"), lp);
00166     lp = new long;
00167     *lp = wxLANGUAGE_PORTUGUESE_BRAZILIAN;
00168     lang_choice->Append(_("Portuguese (Brazilian)"), lp);
00169     lp = new long;
00170     *lp = wxLANGUAGE_RUSSIAN;
00171     lang_choice->Append(_("Russian"), lp);
00172     lp = new long;
00173     *lp = wxLANGUAGE_SLOVAK;
00174     lang_choice->Append(_("Slovak"), lp);
00180     lp = new long;
00181     *lp = wxLANGUAGE_SPANISH;
00182     lang_choice->Append(_("Spanish"), lp);
00183     lp = new long;
00184     *lp = wxLANGUAGE_SWEDISH;
00185     lang_choice->Append(_("Swedish"), lp);
00191     lp = new long;
00192     *lp = wxLANGUAGE_FINNISH;
00193     lang_choice->Append(_("Finnish"), lp);
00194     lang_choice->SetSelection(0);
00195 
00196 #if wxCHECK_VERSION(2,9,1)
00197     wxStaticText* preview=XRCCTRL(*this, "prefs_project_filename_preview", wxStaticText);
00198     preview->SetWindowStyle(preview->GetWindowStyle() | wxST_ELLIPSIZE_START);
00199     preview=XRCCTRL(*this, "prefs_output_filename_preview", wxStaticText);
00200     preview->SetWindowStyle(preview->GetWindowStyle() | wxST_ELLIPSIZE_START);
00201 #endif
00202     // load autopano settings
00203     wxConfigBase* cfg = wxConfigBase::Get();
00204     m_CPDetectorList = XRCCTRL(*this, "pref_cpdetector_list", wxListBox);
00205     cpdetector_config_edit.Read(cfg);
00206 
00207     // Load configuration values from wxConfig
00208     UpdateDisplayData(0);
00209 
00210 #ifdef __WXMSW__
00211     // wxFrame does have a strange background color on Windows, copy color from a child widget
00212     this->SetBackgroundColour(XRCCTRL(*this, "prefs_tab", wxNotebook)->GetBackgroundColour());
00213 #endif
00214 
00215 #if wxCHECK_VERSION(2,9,1)
00216     wxCheckBox* show_hints=XRCCTRL(*this,"pref_show_projection_hints",wxCheckBox);
00217     show_hints->Enable(true);
00218     show_hints->Show(true);
00219     show_hints->Update();
00220     Update();
00221 #endif
00222 
00223     GetSizer()->SetSizeHints(this);
00224     //    GetSizer()->Layout();
00225 
00226 
00227     // only enable bundled if the build is actually bundled.
00228 #if defined __WXMSW__ || defined MAC_SELF_CONTAINED_BUNDLE
00229 
00230 #else
00231     MY_BOOL_VAL("prefs_enblend_Custom", HUGIN_ENBLEND_EXE_CUSTOM);
00232     XRCCTRL(*this, "prefs_enblend_Custom", wxCheckBox)->Hide();
00233     cfg->Write(wxT("/Enblend/Custom"), HUGIN_ENBLEND_EXE_CUSTOM);
00234 
00235     MY_BOOL_VAL("prefs_enblend_enfuseCustom", HUGIN_ENFUSE_EXE_CUSTOM);
00236     XRCCTRL(*this, "prefs_enblend_enfuseCustom", wxCheckBox)->Hide();
00237     cfg->Write(wxT("/Enfuse/Custom"), HUGIN_ENFUSE_EXE_CUSTOM);
00238 #endif
00239 
00240     RestoreFramePosition(this, wxT("PreferencesDialog"));
00241 }
00242 
00243 
00244 PreferencesDialog::~PreferencesDialog()
00245 {
00246     DEBUG_TRACE("begin dtor");
00247 
00248     StoreFramePosition(this, wxT("PreferencesDialog"));
00249 
00250     // delete custom list data
00251     wxChoice* lang_choice = XRCCTRL(*this, "prefs_gui_language", wxChoice);
00252     for (int i = 0; i < (int) lang_choice->GetCount(); i++)
00253     {
00254         delete static_cast<long*>(lang_choice->GetClientData(i));
00255     }
00256 
00257     DEBUG_TRACE("end dtor");
00258 }
00259 
00260 void PreferencesDialog::OnOk(wxCommandEvent& e)
00261 {
00262     UpdateConfigData();
00263     this->EndModal(wxOK);
00264 }
00265 
00266 void PreferencesDialog::OnCancel(wxCommandEvent& e)
00267 {
00268     this->EndModal(wxCANCEL);
00269 }
00270 
00271 void PreferencesDialog::OnHelp(wxCommandEvent& e)
00272 {
00273     MainFrame::Get()->DisplayHelp(wxT("/Hugin_Preferences.html"));
00274 };
00275 
00276 void PreferencesDialog::OnRotationCheckBox(wxCommandEvent& e)
00277 {
00278     EnableRotationCtrls(e.IsChecked());
00279 }
00280 
00281 void PreferencesDialog::OnEnblendExe(wxCommandEvent& e)
00282 {
00283     wxFileDialog dlg(this,_("Select Enblend"),
00284                      wxT(""), wxT(HUGIN_ENBLEND_EXE),
00285 #ifdef __WXMSW__
00286                      _("Executables (*.exe)|*.exe"),
00287 #else
00288                      wxT("*"),
00289 #endif
00290                      wxFD_OPEN, wxDefaultPosition);
00291     if (dlg.ShowModal() == wxID_OK)
00292     {
00293         XRCCTRL(*this, "prefs_enblend_EnblendExe", wxTextCtrl)->SetValue(
00294             dlg.GetPath());
00295     }
00296 }
00297 
00298 void PreferencesDialog::OnEnfuseExe(wxCommandEvent& e)
00299 {
00300     wxFileDialog dlg(this,_("Select Enfuse"),
00301                      wxT(""), wxT(HUGIN_ENFUSE_EXE),
00302 #ifdef __WXMSW__
00303                      _("Executables (*.exe)|*.exe"),
00304 #else
00305                      wxT("*"),
00306 #endif
00307                      wxFD_OPEN, wxDefaultPosition);
00308     if (dlg.ShowModal() == wxID_OK)
00309     {
00310         XRCCTRL(*this, "prefs_enblend_EnfuseExe", wxTextCtrl)->SetValue(
00311             dlg.GetPath());
00312     }
00313 }
00314 
00315 void PreferencesDialog::OnCustomEnblend(wxCommandEvent& e)
00316 {
00317     XRCCTRL(*this, "prefs_enblend_EnblendExe", wxTextCtrl)->Enable(e.IsChecked());
00318     XRCCTRL(*this, "prefs_enblend_select", wxButton)->Enable(e.IsChecked());
00319 }
00320 
00321 void PreferencesDialog::OnCustomEnfuse(wxCommandEvent& e)
00322 {
00323     XRCCTRL(*this, "prefs_enblend_EnfuseExe", wxTextCtrl)->Enable(e.IsChecked());
00324     XRCCTRL(*this, "prefs_enblend_enfuse_select", wxButton)->Enable(e.IsChecked());
00325 }
00326 
00327 void PreferencesDialog::EnableRotationCtrls(bool enable)
00328 {
00329     XRCCTRL(*this, "prefs_ft_rot_panel", wxPanel)->Enable(enable);
00330 }
00331 
00332 void PreferencesDialog::UpdateDisplayData(int panel)
00333 {
00334     DEBUG_DEBUG("Updating display data");
00335 
00336     double d;
00337     bool t;
00338     wxString tstr;
00339     wxConfigBase* cfg = wxConfigBase::Get();
00340 
00341     if (panel==0 || panel == 1)
00342     {
00343         // memory setting
00344         unsigned long long mem = cfg->Read(wxT("/ImageCache/UpperBound"), HUGIN_IMGCACHE_UPPERBOUND);
00345 #ifdef __WXMSW__
00346         unsigned long mem_low = cfg->Read(wxT("/ImageCache/UpperBound"), HUGIN_IMGCACHE_UPPERBOUND);
00347         unsigned long mem_high = cfg->Read(wxT("/ImageCache/UpperBoundHigh"), (long) 0);
00348         if (mem_high > 0)
00349         {
00350             mem = ((unsigned long long) mem_high << 32) + mem_low;
00351         }
00352         else
00353         {
00354             mem = mem_low;
00355         }
00356 #endif
00357         MY_SPIN_VAL("prefs_cache_UpperBound", mem >> 20);
00358 
00359         // number of threads
00360         int nThreads = wxThread::GetCPUCount();
00361         if (nThreads < 1)
00362         {
00363             nThreads = 1;
00364         }
00365         nThreads = cfg->Read(wxT("/Nona/NumberOfThreads"), nThreads);
00366         MY_SPIN_VAL("prefs_nona_NumberOfThreads", nThreads);
00367 
00368         // language
00369         // check if current language is in list and activate it then.
00370         wxChoice* lang_choice = XRCCTRL(*this, "prefs_gui_language", wxChoice);
00371         int curlang = cfg->Read(wxT("language"), HUGIN_LANGUAGE);
00372         bool found = false;
00373         int idx = 0;
00374         for (int i = 0; i < (int)lang_choice->GetCount(); i++)
00375         {
00376             long lang = * static_cast<long*>(lang_choice->GetClientData(i));
00377             if (curlang == lang)
00378             {
00379                 found = true;
00380                 idx = i;
00381             }
00382         }
00383         if (found)
00384         {
00385             DEBUG_DEBUG("wxChoice language updated:" << curlang);
00386             // update language
00387             lang_choice->SetSelection(idx);
00388         }
00389         else
00390         {
00391             // unknown language selected..
00392             DEBUG_WARN("Unknown language configured");
00393         }
00394 
00395         // smart undo
00396         t = cfg->Read(wxT("smartUndo"), HUGIN_SMART_UNDO) == 1;
00397         MY_BOOL_VAL("prefs_smart_undo", t);
00398 
00399         // copy log to clipboard
00400         t = cfg->Read(wxT("CopyLogToClipboard"), 0l) == 1;
00401         MY_BOOL_VAL("prefs_copy_log", t);
00402 
00403         // save makefile 
00404         t = cfg->Read(wxT("SaveMakefile"), 0l) == 1;
00405         MY_BOOL_VAL("prefs_makefile", t);
00406 
00407         t = cfg->Read(wxT("/GLPreviewFrame/ShowProjectionHints"), HUGIN_SHOW_PROJECTION_HINTS) == 1;
00408         MY_BOOL_VAL("pref_show_projection_hints", t)
00409     };
00410 
00411     // filename panel
00412     if(panel==0 || panel==2)
00413     {
00414         // tempdir
00415         MY_STR_VAL("prefs_misc_tempdir", cfg->Read(wxT("tempDir"),wxT("")));
00416         // default filenames
00417         wxString filename=cfg->Read(wxT("ProjectFilename"), wxT(HUGIN_DEFAULT_PROJECT_NAME));
00418 #ifdef __WXMSW__
00419         filename.Replace(wxT("/"),wxT("\\"),true);
00420 #endif
00421         MY_STR_VAL("prefs_project_filename", filename);
00422         filename=cfg->Read(wxT("OutputFilename"), wxT(HUGIN_DEFAULT_OUTPUT_NAME));
00423 #ifdef __WXMSW__
00424         filename.Replace(wxT("/"),wxT("\\"),true);
00425 #endif
00426         MY_STR_VAL("prefs_output_filename", filename);
00427     }
00428 
00429     if (panel==0 || panel == 3)
00430     {
00431         // Assistant settings
00432         t = cfg->Read(wxT("/Assistant/autoAlign"), HUGIN_ASS_AUTO_ALIGN) == 1;
00433         MY_BOOL_VAL("prefs_ass_autoAlign", t);
00434         MY_SPIN_VAL("prefs_ass_nControlPoints",
00435                     cfg->Read(wxT("/Assistant/nControlPoints"), HUGIN_ASS_NCONTROLPOINTS));
00436         double factor = HUGIN_ASS_PANO_DOWNSIZE_FACTOR;
00437         cfg->Read(wxT("/Assistant/panoDownsizeFactor"), &factor);
00438         MY_SPIN_VAL("prefs_ass_panoDownsizeFactor",(int)(factor*100.0));
00439         t = cfg->Read(wxT("/Assistant/Linefind"), HUGIN_ASS_LINEFIND) == 1;
00440         MY_BOOL_VAL("prefs_ass_linefind", t);
00441         t = cfg->Read(wxT("/Celeste/Auto"), HUGIN_CELESTE_AUTO) == 1;
00442         MY_BOOL_VAL("prefs_celeste_auto", t);
00443         t = cfg->Read(wxT("/Assistant/AutoCPClean"), HUGIN_ASS_AUTO_CPCLEAN) == 1;
00444         MY_BOOL_VAL("prefs_auto_cpclean", t);
00445     }
00446     // Fine tune settings
00447 
00448     if (panel==0 || panel == 4)
00449     {
00450         // hdr display settings
00451         MY_CHOICE_VAL("prefs_misc_hdr_mapping", cfg->Read(wxT("/ImageCache/Mapping"), HUGIN_IMGCACHE_MAPPING_FLOAT));
00452         //MY_CHOICE_VAL("prefs_misc_hdr_range", cfg->Read(wxT("/ImageCache/Range"), HUGIN_IMGCACHE_RANGE));
00453 
00454         MY_SPIN_VAL("prefs_ft_TemplateSize",
00455                     cfg->Read(wxT("/Finetune/TemplateSize"),HUGIN_FT_TEMPLATE_SIZE));
00456         MY_SPIN_VAL("prefs_ft_SearchAreaPercent",cfg->Read(wxT("/Finetune/SearchAreaPercent"),
00457                     HUGIN_FT_SEARCH_AREA_PERCENT));
00458         MY_SPIN_VAL("prefs_ft_LocalSearchWidth", cfg->Read(wxT("/Finetune/LocalSearchWidth"),
00459                     HUGIN_FT_LOCAL_SEARCH_WIDTH));
00460 
00461         d=HUGIN_FT_CORR_THRESHOLD;
00462         cfg->Read(wxT("/Finetune/CorrThreshold"), &d, HUGIN_FT_CORR_THRESHOLD);
00463         tstr = hugin_utils::doubleTowxString(d);
00464         MY_STR_VAL("prefs_ft_CorrThreshold", tstr);
00465 
00466         cfg->Read(wxT("/Finetune/CurvThreshold"), &d, HUGIN_FT_CURV_THRESHOLD);
00467         tstr = hugin_utils::doubleTowxString(d);
00468         MY_STR_VAL("prefs_ft_CurvThreshold", tstr);
00469 
00470         t = cfg->Read(wxT("/Finetune/RotationSearch"), HUGIN_FT_ROTATION_SEARCH) == 1;
00471         MY_BOOL_VAL("prefs_ft_RotationSearch", t);
00472         EnableRotationCtrls(t);
00473 
00474         d = HUGIN_FT_ROTATION_START_ANGLE;
00475         cfg->Read(wxT("/Finetune/RotationStartAngle"),&d,HUGIN_FT_ROTATION_START_ANGLE);
00476         MY_SPIN_VAL("prefs_ft_RotationStartAngle", hugin_utils::roundi(d))
00477 
00478         d = HUGIN_FT_ROTATION_STOP_ANGLE;
00479         cfg->Read(wxT("/Finetune/RotationStopAngle"), &d, HUGIN_FT_ROTATION_STOP_ANGLE);
00480         MY_SPIN_VAL("prefs_ft_RotationStopAngle", hugin_utils::roundi(d));
00481 
00482         MY_SPIN_VAL("prefs_ft_RotationSteps", cfg->Read(wxT("/Finetune/RotationSteps"),
00483                     HUGIN_FT_ROTATION_STEPS));
00484     }
00485 
00488 
00491 
00492     if (panel==0 || panel == 5)
00493     {
00494         cpdetector_config_edit.FillControl(m_CPDetectorList,true,true);
00495     }
00496 
00497     if (panel==0 || panel == 6)
00498     {
00501         MY_CHOICE_VAL("pref_ldr_output_file_format", cfg->Read(wxT("/output/ldr_format"), HUGIN_LDR_OUTPUT_FORMAT));
00503         // MY_CHOICE_VAL("pref_hdr_output_file_format", cfg->Read(wxT("/output/hdr_format"), HUGIN_HDR_OUTPUT_FORMAT));
00504         MY_CHOICE_VAL("pref_tiff_compression", cfg->Read(wxT("/output/tiff_compression"), HUGIN_TIFF_COMPRESSION));
00505         MY_SPIN_VAL("pref_jpeg_quality", cfg->Read(wxT("/output/jpeg_quality"), HUGIN_JPEG_QUALITY));
00506         UpdateFileFormatControls();
00507 
00510         MY_CHOICE_VAL("pref_processor_gui", cfg->Read(wxT("/Processor/gui"), HUGIN_PROCESSOR_GUI));
00511         t = cfg->Read(wxT("/Processor/start"), HUGIN_PROCESSOR_START) == 1;
00512         MY_BOOL_VAL("pref_processor_start", t);
00513         t = cfg->Read(wxT("/Processor/parallel"), HUGIN_PROCESSOR_PARALLEL) == 1;
00514         MY_BOOL_VAL("pref_processor_parallel", t);
00515         t = cfg->Read(wxT("/Processor/overwrite"), HUGIN_PROCESSOR_OVERWRITE) == 1;
00516         MY_BOOL_VAL("pref_processor_overwrite", t);
00517         t = cfg->Read(wxT("/Processor/verbose"), HUGIN_PROCESSOR_VERBOSE) == 1;
00518         MY_BOOL_VAL("pref_processor_verbose", t);
00519         UpdateProcessorControls();
00520 
00521         t = cfg->Read(wxT("/output/useExiftool"), 1l) == 1;
00522         MY_BOOL_VAL("pref_exiftool_metadata", t);
00523 
00524         int nThreads = cfg->Read(wxT("/output/NumberOfThreads"), 0l);
00525         MY_SPIN_VAL("prefs_output_NumberOfThreads", nThreads);
00526 
00527     }
00528 
00529     if (panel==0 || panel == 7)
00530     {
00531 
00534         MY_CHOICE_VAL("prefs_nona_interpolator", cfg->Read(wxT("/Nona/Interpolator"), HUGIN_NONA_INTERPOLATOR));
00535         t = cfg->Read(wxT("/Nona/CroppedImages"), HUGIN_NONA_CROPPEDIMAGES) == 1;
00536         MY_BOOL_VAL("prefs_nona_createCroppedImages", t);
00537         t = cfg->Read(wxT("/Nona/UseGPU"), HUGIN_NONA_USEGPU) == 1;
00538         MY_BOOL_VAL("prefs_nona_useGpu", t);
00539 
00542         MY_STR_VAL("prefs_enblend_EnblendExe", cfg->Read(wxT("/Enblend/Exe"),
00543                    wxT(HUGIN_ENBLEND_EXE)));
00544         bool customEnblendExe = HUGIN_ENBLEND_EXE_CUSTOM;
00545         cfg->Read(wxT("/Enblend/Custom"), &customEnblendExe);
00546         MY_BOOL_VAL("prefs_enblend_Custom", customEnblendExe);
00547         XRCCTRL(*this, "prefs_enblend_EnblendExe", wxTextCtrl)->Enable(customEnblendExe);
00548         XRCCTRL(*this, "prefs_enblend_select", wxButton)->Enable(customEnblendExe);
00549         MY_STR_VAL("prefs_enblend_EnblendArgs", cfg->Read(wxT("/Enblend/Args"),
00550                    wxT(HUGIN_ENBLEND_ARGS)));
00553         MY_STR_VAL("prefs_enblend_EnfuseExe", cfg->Read(wxT("/Enfuse/Exe"),
00554                    wxT(HUGIN_ENFUSE_EXE)));
00555         bool customEnfuseExe = HUGIN_ENFUSE_EXE_CUSTOM;
00556         cfg->Read(wxT("/Enfuse/Custom"), &customEnfuseExe);
00557         MY_BOOL_VAL("prefs_enblend_enfuseCustom", customEnfuseExe);
00558         XRCCTRL(*this, "prefs_enblend_EnfuseExe", wxTextCtrl)->Enable(customEnfuseExe);
00559         XRCCTRL(*this, "prefs_enblend_enfuse_select", wxButton)->Enable(customEnfuseExe);
00560         MY_STR_VAL("prefs_enblend_EnfuseArgs", cfg->Read(wxT("/Enfuse/Args"),
00561                    wxT(HUGIN_ENFUSE_ARGS)));
00562     }
00563 
00564     if (panel==0 || panel == 8)
00565     {
00566         // Celeste settings
00567         d=HUGIN_CELESTE_THRESHOLD;
00568         cfg->Read(wxT("/Celeste/Threshold"), &d, HUGIN_CELESTE_THRESHOLD);
00569         tstr = hugin_utils::doubleTowxString(d);
00570         MY_STR_VAL("prefs_celeste_threshold", tstr);
00571         MY_CHOICE_VAL("prefs_celeste_filter", cfg->Read(wxT("/Celeste/Filter"), HUGIN_CELESTE_FILTER));
00572         // photometric optimizer settings
00573         MY_SPIN_VAL("prefs_photo_optimizer_nr_points", cfg->Read(wxT("/OptimizePhotometric/nRandomPointsPerImage"), HUGIN_PHOTOMETRIC_OPTIMIZER_NRPOINTS));
00574 
00575     }
00576 }
00577 
00578 void PreferencesDialog::OnRestoreDefaults(wxCommandEvent& e)
00579 {
00580     DEBUG_TRACE("");
00581     wxConfigBase* cfg = wxConfigBase::Get();
00582     // check which tab is enabled
00583     wxNotebook* noteb = XRCCTRL(*this, "prefs_tab", wxNotebook);
00584     int really = wxMessageBox(_("Really reset displayed preferences to default values?"), _("Load Defaults"),
00585                               wxYES_NO, this);
00586     if ( really == wxYES)
00587     {
00588         if (noteb->GetSelection() == 0)
00589         {
00590             // MISC
00591             // cache
00592             /*
00593              * special treatment for windows not necessary here since we know the value of
00594              * HUGIN_IMGCACHE_UPPERBOUND must fit into 32bit to be compatible with 32bit systems.
00595              * However, just as a reminder:
00596             #ifdef __WXMSW__
00597                 cfg->Write(wxT("/ImageCache/UpperBoundHigh"), HUGIN_IMGCACHE_UPPERBOUND >> 32);
00598             #endif
00599             */
00600             cfg->Write(wxT("/ImageCache/UpperBound"), HUGIN_IMGCACHE_UPPERBOUND);
00601             // number of threads
00602             int cpucount = wxThread::GetCPUCount();
00603             if (cpucount < 1)
00604             {
00605                 cpucount = 1;
00606             }
00607             cfg->Write(wxT("/Nona/NumberOfThreads"), cpucount);
00608             // locale
00609             cfg->Write(wxT("language"), int(HUGIN_LANGUAGE));
00610             // smart undo
00611             cfg->Write(wxT("smartUndo"), HUGIN_SMART_UNDO);
00612             cfg->Write(wxT("CopyLogToClipboard"), 0l);
00613             cfg->Write(wxT("SaveMakefile"), 0l);
00614             // projection hints
00615             cfg->Write(wxT("/GLPreviewFrame/ShowProjectionHints"), HUGIN_SHOW_PROJECTION_HINTS);
00616         }
00617         if(noteb->GetSelection() == 1)
00618         {
00619             cfg->Write(wxT("tempDir"), wxT(""));
00620             cfg->Write(wxT("ProjectFilename"), wxT(HUGIN_DEFAULT_PROJECT_NAME));
00621             cfg->Write(wxT("OutputFilename"), wxT(HUGIN_DEFAULT_OUTPUT_NAME));
00622         };
00623         if (noteb->GetSelection() == 2)
00624         {
00625             cfg->Write(wxT("/Assistant/autoAlign"), HUGIN_ASS_AUTO_ALIGN);
00626             cfg->Write(wxT("/Assistant/nControlPoints"), HUGIN_ASS_NCONTROLPOINTS);
00627             cfg->Write(wxT("/Assistant/panoDownsizeFactor"),HUGIN_ASS_PANO_DOWNSIZE_FACTOR);
00628             cfg->Write(wxT("/Assistant/Linefind"), HUGIN_ASS_LINEFIND);
00629             cfg->Write(wxT("/Celeste/Auto"), HUGIN_CELESTE_AUTO);
00630             cfg->Write(wxT("/Assistant/AutoCPClean"), HUGIN_ASS_AUTO_CPCLEAN);
00631         }
00632         if (noteb->GetSelection() == 3)
00633         {
00634             // hdr
00635             cfg->Write(wxT("/ImageCache/Mapping"), HUGIN_IMGCACHE_MAPPING_FLOAT);
00636             //cfg->Write(wxT("/ImageCache/Range"), HUGIN_IMGCACHE_RANGE);
00637             // Fine tune settings
00638             cfg->Write(wxT("/Finetune/SearchAreaPercent"), HUGIN_FT_SEARCH_AREA_PERCENT);
00639             cfg->Write(wxT("/Finetune/TemplateSize"), HUGIN_FT_TEMPLATE_SIZE);
00640             cfg->Write(wxT("/Finetune/LocalSearchWidth"), HUGIN_FT_LOCAL_SEARCH_WIDTH);
00641 
00642             cfg->Write(wxT("/Finetune/CorrThreshold"), HUGIN_FT_CORR_THRESHOLD);
00643             cfg->Write(wxT("/Finetune/CurvThreshold"), HUGIN_FT_CURV_THRESHOLD);
00644 
00645             cfg->Write(wxT("/Finetune/RotationSearch"), HUGIN_FT_ROTATION_SEARCH);
00646             cfg->Write(wxT("/Finetune/RotationStartAngle"), HUGIN_FT_ROTATION_START_ANGLE);
00647             cfg->Write(wxT("/Finetune/RotationStopAngle"), HUGIN_FT_ROTATION_STOP_ANGLE);
00648             cfg->Write(wxT("/Finetune/RotationSteps"), HUGIN_FT_ROTATION_STEPS);
00649         }
00650         if (noteb->GetSelection() == 4)
00651         {
00654             cpdetector_config_edit.ReadFromFile(huginApp::Get()->GetDataPath()+wxT("default.setting"));
00655             cpdetector_config_edit.Write(cfg);
00656         }
00657         if (noteb->GetSelection() == 5)
00658         {
00660             cfg->Write(wxT("/output/ldr_format"), HUGIN_LDR_OUTPUT_FORMAT);
00662             // cfg->Write(wxT("/output/hdr_format"), HUGIN_HDR_OUTPUT_FORMAT);
00663             cfg->Write(wxT("/output/tiff_compression"), HUGIN_TIFF_COMPRESSION);
00664             cfg->Write(wxT("/output/jpeg_quality"), HUGIN_JPEG_QUALITY);
00665             // stitching engine
00666             cfg->Write(wxT("/Processor/gui"), HUGIN_PROCESSOR_GUI);
00667             cfg->Write(wxT("/Processor/start"), HUGIN_PROCESSOR_START);
00668             cfg->Write(wxT("/Processor/parallel"), HUGIN_PROCESSOR_PARALLEL);
00669             cfg->Write(wxT("/Processor/overwrite"), HUGIN_PROCESSOR_OVERWRITE);
00670             cfg->Write(wxT("/Processor/verbose"), HUGIN_PROCESSOR_VERBOSE);
00671             cfg->Write(wxT("/output/useExiftool"), 1l);
00672             cfg->Write(wxT("/output/NumberOfThreads"), 0l);
00673 
00674         }
00675         if (noteb->GetSelection() == 6)
00676         {
00678             cfg->Write(wxT("/Enblend/Exe"), wxT(HUGIN_ENBLEND_EXE));
00679             cfg->Write(wxT("/Enblend/Custom"), HUGIN_ENBLEND_EXE_CUSTOM);
00680             cfg->Write(wxT("/Enblend/Args"), wxT(HUGIN_ENBLEND_ARGS));
00681 
00682             cfg->Write(wxT("/Enfuse/Exe"), wxT(HUGIN_ENFUSE_EXE));
00683             cfg->Write(wxT("/Enfuse/Custom"), HUGIN_ENFUSE_EXE_CUSTOM);
00684             cfg->Write(wxT("/Enfuse/Args"), wxT(HUGIN_ENFUSE_ARGS));
00685         }
00686 
00687         if (noteb->GetSelection() == 7)
00688         {
00690             cfg->Write(wxT("/Celeste/Threshold"), HUGIN_CELESTE_THRESHOLD);
00691             cfg->Write(wxT("/Celeste/Filter"), HUGIN_CELESTE_FILTER);
00692             cfg->Write(wxT("/OptimizePhotometric/nRandomPointsPerImage"), HUGIN_PHOTOMETRIC_OPTIMIZER_NRPOINTS);
00693         }
00694 
00695         /*
00696                 if (noteb->GetSelection() == 5) {
00697                     cfg->Write(wxT("/PTmender/Exe"), wxT(HUGIN_PT_MENDER_EXE) );
00698                     cfg->Write(wxT("/PTmender/Custom"),HUGIN_PT_MENDER_EXE_CUSTOM);
00699                     cfg->Write(wxT("/PanoTools/ScriptFile"), wxT("PT_script.txt"));
00700                 }
00701         */
00702         UpdateDisplayData(noteb->GetSelection() + 1);
00703     }
00704 }
00705 
00706 void PreferencesDialog::UpdateConfigData()
00707 {
00708     DEBUG_TRACE("");
00709     wxConfigBase* cfg = wxConfigBase::Get();
00710     // Assistant
00711     cfg->Write(wxT("/Assistant/autoAlign"),MY_G_BOOL_VAL("prefs_ass_autoAlign"));
00712     cfg->Write(wxT("/Assistant/nControlPoints"), MY_G_SPIN_VAL("prefs_ass_nControlPoints"));
00713     cfg->Write(wxT("/Assistant/panoDownsizeFactor"), MY_G_SPIN_VAL("prefs_ass_panoDownsizeFactor") / 100.0);
00714     cfg->Write(wxT("/Assistant/Linefind"), MY_G_BOOL_VAL("prefs_ass_linefind"));
00715     cfg->Write(wxT("/Celeste/Auto"), MY_G_BOOL_VAL("prefs_celeste_auto"));
00716     cfg->Write(wxT("/Assistant/AutoCPClean"), MY_G_BOOL_VAL("prefs_auto_cpclean"));
00717 
00718     // hdr display
00719     cfg->Write(wxT("/ImageCache/Mapping"),MY_G_CHOICE_VAL("prefs_misc_hdr_mapping"));
00720     //cfg->Write(wxT("/ImageCache/Range"),MY_G_CHOICE_VAL("prefs_misc_hdr_range"));
00721 
00722     // Fine tune settings
00723     cfg->Write(wxT("/Finetune/SearchAreaPercent"), MY_G_SPIN_VAL("prefs_ft_SearchAreaPercent"));
00724     cfg->Write(wxT("/Finetune/TemplateSize"), MY_G_SPIN_VAL("prefs_ft_TemplateSize"));
00725     cfg->Write(wxT("/Finetune/LocalSearchWidth"), MY_G_SPIN_VAL("prefs_ft_LocalSearchWidth"));
00726     wxString t = MY_G_STR_VAL("prefs_ft_CorrThreshold");
00727     double td= HUGIN_FT_CORR_THRESHOLD;
00728     hugin_utils::stringToDouble(std::string(t.mb_str(wxConvLocal)), td);
00729     cfg->Write(wxT("/Finetune/CorrThreshold"), td);
00730 
00731     t = MY_G_STR_VAL("prefs_ft_CurvThreshold");
00732     td = HUGIN_FT_CURV_THRESHOLD;
00733     hugin_utils::stringToDouble(std::string(t.mb_str(wxConvLocal)), td);
00734     cfg->Write(wxT("/Finetune/CurvThreshold"), td);
00735 
00736     cfg->Write(wxT("/Finetune/RotationSearch"), MY_G_BOOL_VAL("prefs_ft_RotationSearch"));
00737     cfg->Write(wxT("/Finetune/RotationStartAngle"), (double) MY_G_SPIN_VAL("prefs_ft_RotationStartAngle"));
00738     cfg->Write(wxT("/Finetune/RotationStopAngle"), (double) MY_G_SPIN_VAL("prefs_ft_RotationStopAngle"));
00739     cfg->Write(wxT("/Finetune/RotationSteps"), MY_G_SPIN_VAL("prefs_ft_RotationSteps"));
00740 
00743     // cache
00744 #ifdef __WXMSW__
00745     // shifting only 12 bits rights: 32-20=12 and the prefs_cache_UpperBound is in GB
00746     cfg->Write(wxT("/ImageCache/UpperBoundHigh"), (long) MY_G_SPIN_VAL("prefs_cache_UpperBound") >> 12);
00747 #endif
00748     cfg->Write(wxT("/ImageCache/UpperBound"), (long) MY_G_SPIN_VAL("prefs_cache_UpperBound") << 20);
00749     // number of threads
00750     cfg->Write(wxT("/Nona/NumberOfThreads"), MY_G_SPIN_VAL("prefs_nona_NumberOfThreads"));
00751 
00752     // locale
00753     // language
00754     wxChoice* lang = XRCCTRL(*this, "prefs_gui_language", wxChoice);
00755     // DEBUG_TRACE("Language Selection Name: " << huginApp::Get()->GetLocale().GetLanguageName((int) lang->GetClientData(lang->GetSelection())).mb_str(wxConvLocal));
00756     //DEBUG_INFO("Language Selection locale: " << ((huginApp::Get()->GetLocale().GetLanguageInfo((int) lang->GetClientData(lang->GetSelection())))->CanonicalName).mb_str(wxConvLocal));
00757     //DEBUG_INFO("Current System Language ID: " << huginApp::Get()->GetLocale().GetSystemLanguage());
00758 
00759     void* tmplp = lang->GetClientData(lang->GetSelection());
00760     long templ =  * static_cast<long*>(tmplp);
00761     cfg->Write(wxT("language"), templ);
00762     DEBUG_INFO("Language Selection ID: " << templ);
00763     // smart undo
00764     cfg->Write(wxT("smartUndo"), MY_G_BOOL_VAL("prefs_smart_undo"));
00765     cfg->Write(wxT("CopyLogToClipboard"), MY_G_BOOL_VAL("prefs_copy_log"));
00766     cfg->Write(wxT("SaveMakefile"), MY_G_BOOL_VAL("prefs_makefile"));
00767     // show projections hints
00768     cfg->Write(wxT("/GLPreviewFrame/ShowProjectionHints"), MY_G_BOOL_VAL("pref_show_projection_hints"));
00769     // tempdir
00770     cfg->Write(wxT("tempDir"),MY_G_STR_VAL("prefs_misc_tempdir"));
00771     // filename templates
00772     wxString filename=XRCCTRL(*this, "prefs_project_filename", wxTextCtrl)->GetValue();
00773 #ifdef __WXMSW__
00774     filename.Replace(wxT("\\"), wxT("/"), true);
00775 #endif
00776     cfg->Write(wxT("ProjectFilename"), filename);
00777     filename=XRCCTRL(*this, "prefs_output_filename", wxTextCtrl)->GetValue();
00778 #ifdef __WXMSW__
00779     filename.Replace(wxT("\\"), wxT("/"), true);
00780 #endif
00781     cfg->Write(wxT("OutputFilename"), filename);
00784     cpdetector_config_edit.Write(cfg);
00785 
00788     cfg->Write(wxT("/output/ldr_format"), MY_G_CHOICE_VAL("pref_ldr_output_file_format"));
00790     // cfg->Write(wxT("/output/hdr_format"), MY_G_CHOICE_VAL("pref_hdr_output_file_format"));
00791     cfg->Write(wxT("/output/tiff_compression"), MY_G_CHOICE_VAL("pref_tiff_compression"));
00792     cfg->Write(wxT("/output/jpeg_quality"), MY_G_SPIN_VAL("pref_jpeg_quality"));
00793 
00796     cfg->Write(wxT("/Processor/gui"), MY_G_CHOICE_VAL("pref_processor_gui"));
00797     cfg->Write(wxT("/Processor/start"), MY_G_BOOL_VAL("pref_processor_start"));
00798     cfg->Write(wxT("/Processor/parallel"), MY_G_BOOL_VAL("pref_processor_parallel"));
00799     cfg->Write(wxT("/Processor/overwrite"), MY_G_BOOL_VAL("pref_processor_overwrite"));
00800     cfg->Write(wxT("/Processor/verbose"), MY_G_BOOL_VAL("pref_processor_verbose"));
00801 
00802     cfg->Write(wxT("/output/useExiftool"), MY_G_BOOL_VAL("pref_exiftool_metadata"));
00803     cfg->Write(wxT("/output/NumberOfThreads"), MY_G_SPIN_VAL("prefs_output_NumberOfThreads"));
00806     cfg->Write(wxT("/Nona/Interpolator"), MY_G_CHOICE_VAL("prefs_nona_interpolator"));
00807     cfg->Write(wxT("/Nona/CroppedImages"), MY_G_BOOL_VAL("prefs_nona_createCroppedImages"));
00808     cfg->Write(wxT("/Nona/UseGPU"), MY_G_BOOL_VAL("prefs_nona_useGpu"));
00809 
00812     cfg->Write(wxT("/Enblend/Custom"), MY_G_BOOL_VAL("prefs_enblend_Custom"));
00813     cfg->Write(wxT("/Enblend/Exe"), MY_G_STR_VAL("prefs_enblend_EnblendExe"));
00814     cfg->Write(wxT("/Enblend/Args"), MY_G_STR_VAL("prefs_enblend_EnblendArgs"));
00815 
00816     cfg->Write(wxT("/Enfuse/Custom"), MY_G_BOOL_VAL("prefs_enblend_enfuseCustom"));
00817     cfg->Write(wxT("/Enfuse/Exe"), MY_G_STR_VAL("prefs_enblend_EnfuseExe"));
00818     cfg->Write(wxT("/Enfuse/Args"), MY_G_STR_VAL("prefs_enblend_EnfuseArgs"));
00819 
00820     // Celeste
00821     t = MY_G_STR_VAL("prefs_celeste_threshold");
00822     td = HUGIN_CELESTE_THRESHOLD;
00823     hugin_utils::stringToDouble(std::string(t.mb_str(wxConvLocal)), td);
00824     cfg->Write(wxT("/Celeste/Threshold"), td);
00825     cfg->Write(wxT("/Celeste/Filter"), MY_G_CHOICE_VAL("prefs_celeste_filter"));
00826     //photometric optimizer
00827     cfg->Write(wxT("/OptimizePhotometric/nRandomPointsPerImage"), MY_G_SPIN_VAL("prefs_photo_optimizer_nr_points"));
00828 
00829     cfg->Flush();
00830     UpdateDisplayData(0);
00831 }
00832 
00833 void PreferencesDialog::OnCPDetectorAdd(wxCommandEvent& e)
00834 {
00835     CPDetectorDialog cpdetector_dlg(this);
00836     if(cpdetector_dlg.ShowModal()==wxOK)
00837     {
00838         cpdetector_config_edit.settings.Add(new CPDetectorSetting);
00839         cpdetector_dlg.UpdateSettings(&cpdetector_config_edit,cpdetector_config_edit.GetCount()-1);
00840         cpdetector_config_edit.FillControl(m_CPDetectorList,false,true);
00841         m_CPDetectorList->SetSelection(cpdetector_config_edit.GetCount()-1);
00842     };
00843 };
00844 
00845 void PreferencesDialog::OnCPDetectorEdit(wxCommandEvent& e)
00846 {
00847     CPDetectorDialog autopano_dlg(this);
00848     int selection=m_CPDetectorList->GetSelection();
00849     if (selection == wxNOT_FOUND)
00850     {
00851         wxMessageBox(_("Please select an entry first"),_("Select Entry"),wxOK |
00852                      wxICON_EXCLAMATION,this);
00853     }
00854     else
00855     {
00856         autopano_dlg.UpdateFields(&cpdetector_config_edit, selection);
00857         if(autopano_dlg.ShowModal()==wxOK)
00858         {
00859             autopano_dlg.UpdateSettings(&cpdetector_config_edit, selection);
00860             cpdetector_config_edit.FillControl(m_CPDetectorList,false,true);
00861             m_CPDetectorList->SetSelection(selection);
00862         };
00863     }
00864 };
00865 
00866 void PreferencesDialog::OnCPDetectorDelete(wxCommandEvent& e)
00867 {
00868     unsigned int selection=m_CPDetectorList->GetSelection();
00869     if(m_CPDetectorList->GetCount()==1)
00870     {
00871         wxMessageBox(_("You can't delete the last setting.\nAt least one setting is required."),_("Warning"),wxOK | wxICON_EXCLAMATION,this);
00872     }
00873     else
00874     {
00875         if(wxMessageBox(wxString::Format(_("Do you really want to remove control point detector setting \"%s\"?"),cpdetector_config_edit.settings[selection].GetCPDetectorDesc().c_str())
00876                         ,_("Delete control point detector setting"),wxYES_NO | wxICON_QUESTION,this)==wxYES)
00877         {
00878             if(cpdetector_config_edit.GetDefaultGenerator()==selection)
00879             {
00880                 cpdetector_config_edit.SetDefaultGenerator(0);
00881             }
00882             cpdetector_config_edit.settings.RemoveAt(selection);
00883             cpdetector_config_edit.FillControl(m_CPDetectorList,false,true);
00884             if(selection>=m_CPDetectorList->GetCount())
00885             {
00886                 selection=m_CPDetectorList->GetCount()-1;
00887             }
00888             m_CPDetectorList->SetSelection(selection);
00889         };
00890     };
00891 };
00892 
00893 void PreferencesDialog::OnCPDetectorMoveUp(wxCommandEvent& e)
00894 {
00895     unsigned int selection=m_CPDetectorList->GetSelection();
00896     if(selection>0)
00897     {
00898         cpdetector_config_edit.Swap(selection-1);
00899         cpdetector_config_edit.FillControl(m_CPDetectorList,false,true);
00900         m_CPDetectorList->SetSelection(selection-1);
00901     };
00902 };
00903 
00904 void PreferencesDialog::OnCPDetectorMoveDown(wxCommandEvent& e)
00905 {
00906     unsigned int selection=m_CPDetectorList->GetSelection();
00907     if(selection<m_CPDetectorList->GetCount()-1)
00908     {
00909         cpdetector_config_edit.Swap(selection);
00910         cpdetector_config_edit.FillControl(m_CPDetectorList,false,true);
00911         m_CPDetectorList->SetSelection(selection+1);
00912     };
00913 };
00914 
00915 void PreferencesDialog::OnCPDetectorDefault(wxCommandEvent& e)
00916 {
00917     unsigned int selection=m_CPDetectorList->GetSelection();
00918     if(selection!=cpdetector_config_edit.GetDefaultGenerator())
00919     {
00920         cpdetector_config_edit.SetDefaultGenerator(selection);
00921         cpdetector_config_edit.FillControl(m_CPDetectorList,false,true);
00922         m_CPDetectorList->SetSelection(selection);
00923     };
00924 };
00925 
00926 void PreferencesDialog::OnCPDetectorListDblClick(wxCommandEvent& e)
00927 {
00928     OnCPDetectorEdit(e);
00929 };
00930 
00931 void PreferencesDialog::OnCPDetectorLoad(wxCommandEvent& e)
00932 {
00933     wxFileDialog dlg(this,_("Load control point detector settings"),
00934                      wxConfigBase::Get()->Read(wxT("/actualPath"),wxT("")), wxEmptyString,
00935                      _("Control point detector settings (*.setting)|*.setting"),wxFD_OPEN | wxFD_FILE_MUST_EXIST);
00936     if (dlg.ShowModal() == wxID_OK)
00937     {
00938         wxConfig::Get()->Write(wxT("/actualPath"), dlg.GetDirectory());  // remember for later
00939         wxString fn = dlg.GetPath();
00940         cpdetector_config_edit.ReadFromFile(fn);
00941         cpdetector_config_edit.Write();
00942         UpdateDisplayData(4);
00943     };
00944 };
00945 
00946 void PreferencesDialog::OnCPDetectorSave(wxCommandEvent& e)
00947 {
00948     wxFileDialog dlg(this,_("Save control point detector settings"),
00949                      wxConfigBase::Get()->Read(wxT("/actualPath"),wxT("")), wxEmptyString,
00950                      _("Control point detector settings (*.setting)|*.setting"),wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
00951     if (dlg.ShowModal() == wxID_OK)
00952     {
00953         wxConfig::Get()->Write(wxT("/actualPath"), dlg.GetDirectory());  // remember for later
00954         wxString fn = dlg.GetPath();
00955 #ifndef __WXMSW__
00956         //append extension if not given
00957         //not necessary on Windows, the wxFileDialog appends it automatic
00958         if(fn.Right(8)!=wxT(".setting"))
00959         {
00960             fn.Append(wxT(".setting"));
00961         };
00962 #endif
00963         cpdetector_config_edit.WriteToFile(fn);
00964     };
00965 };
00966 
00967 void PreferencesDialog::OnFileFormatChanged(wxCommandEvent& e)
00968 {
00969     UpdateFileFormatControls();
00970 };
00971 
00972 void PreferencesDialog::UpdateFileFormatControls()
00973 {
00974     int i=MY_G_CHOICE_VAL("pref_ldr_output_file_format");
00975     XRCCTRL(*this,"pref_tiff_compression_label",wxStaticText)->Show(i==0);
00976     XRCCTRL(*this,"pref_tiff_compression",wxChoice)->Show(i==0);
00977     XRCCTRL(*this,"pref_jpeg_quality_label",wxStaticText)->Show(i==1);
00978     XRCCTRL(*this,"pref_jpeg_quality",wxSpinCtrl)->Show(i==1);
00979     XRCCTRL(*this,"pref_tiff_compression",wxChoice)->GetParent()->Layout();
00980 };
00981 
00982 void PreferencesDialog::OnProcessorChanged(wxCommandEvent& e)
00983 {
00984     UpdateProcessorControls();
00985 };
00986 
00987 void PreferencesDialog::UpdateProcessorControls()
00988 {
00989     int i=MY_G_CHOICE_VAL("pref_processor_gui");
00990     XRCCTRL(*this,"pref_processor_start",wxCheckBox)->Enable(i==0);
00991     XRCCTRL(*this,"pref_processor_parallel",wxCheckBox)->Enable(i==0);
00992     XRCCTRL(*this,"pref_processor_verbose",wxCheckBox)->Enable(i==0);
00993     switch(i)
00994     {
00995         case 0:
00996             //PTBatcherGUI
00997             {
00998                 wxConfigBase* config=wxConfigBase::Get();
00999                 XRCCTRL(*this,"pref_processor_start",wxCheckBox)->SetValue(config->Read(wxT("/Processor/start"), HUGIN_PROCESSOR_START) == 1);
01000                 XRCCTRL(*this,"pref_processor_parallel",wxCheckBox)->SetValue(config->Read(wxT("/Processor/parallel"), HUGIN_PROCESSOR_PARALLEL) == 1);
01001                 XRCCTRL(*this,"pref_processor_verbose",wxCheckBox)->SetValue(config->Read(wxT("/Processor/verbose"), HUGIN_PROCESSOR_VERBOSE) == 1);
01002             }
01003             break;
01004         case 1:
01005             //Hugin_stitch_project
01006             XRCCTRL(*this,"pref_processor_start",wxCheckBox)->SetValue(true);
01007             XRCCTRL(*this,"pref_processor_parallel",wxCheckBox)->SetValue(false);
01008             XRCCTRL(*this,"pref_processor_verbose",wxCheckBox)->SetValue(true);
01009             break;
01010     };
01011 };
01012 
01013 void PreferencesDialog::OnUpdateProjectFilename(wxCommandEvent& e)
01014 {
01015     XRCCTRL(*this, "prefs_project_filename_preview", wxStaticText)->SetLabel(
01016         getDefaultProjectName(MainFrame::Get()->getPanorama(), XRCCTRL(*this, "prefs_project_filename", wxTextCtrl)->GetValue())
01017     );
01018 };
01019 
01020 void PreferencesDialog::OnUpdateOutputFilename(wxCommandEvent& e)
01021 {
01022     XRCCTRL(*this, "prefs_output_filename_preview", wxStaticText)->SetLabel(
01023         getDefaultOutputName(MainFrame::Get()->getProjectName(), MainFrame::Get()->getPanorama(), XRCCTRL(*this, "prefs_output_filename", wxTextCtrl)->GetValue())
01024     );
01025 };
01026 

Generated on 23 Oct 2014 for Hugintrunk by  doxygen 1.4.7