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

Generated on Tue May 21 01:25:37 2013 for Hugintrunk by  doxygen 1.3.9.1