From: <hug...@li...> - 2010-11-27 14:15:28
|
branch: details: http://hugin.hg.sourceforge.net/hgweb/hugin/hugin/hgrepo/h/hu/hugin/hugin/rev/51c2fba627f9 changeset: 4619:51c2fba627f9 user: tmodes date: Sat Nov 27 15:10:17 2010 +0100 description: Correctly populate cp detectors with default settings if no stored config found Fixes issue 682099 diffstat: src/hugin1/hugin/ImagesPanel.cpp | 2 +- src/hugin1/hugin/PreferencesDialog.cpp | 10 +--------- src/hugin1/icpfind/CPDetectorConfig.cpp | 24 ++++++++++++++++++++---- src/hugin1/icpfind/CPDetectorConfig.h | 7 +++++-- 4 files changed, 27 insertions(+), 16 deletions(-) diffs (96 lines): diff -r 57d5bcba4c0c -r 51c2fba627f9 src/hugin1/hugin/ImagesPanel.cpp --- a/src/hugin1/hugin/ImagesPanel.cpp Sat Nov 27 10:30:35 2010 +0100 +++ b/src/hugin1/hugin/ImagesPanel.cpp Sat Nov 27 15:10:17 2010 +0100 @@ -185,7 +185,7 @@ wxConfigBase* config=wxConfigBase::Get(); m_degDigits = config->Read(wxT("/General/DegreeFractionalDigitsEdit"),3); //read autopano generator settings - cpdetector_config.Read(config); + cpdetector_config.Read(config,huginApp::Get()->GetDataPath()+wxT("default.setting")); //write current autopano generator settings cpdetector_config.Write(config); config->Flush(); diff -r 57d5bcba4c0c -r 51c2fba627f9 src/hugin1/hugin/PreferencesDialog.cpp --- a/src/hugin1/hugin/PreferencesDialog.cpp Sat Nov 27 10:30:35 2010 +0100 +++ b/src/hugin1/hugin/PreferencesDialog.cpp Sat Nov 27 15:10:17 2010 +0100 @@ -663,15 +663,7 @@ if (noteb->GetSelection() == 3) { ///// /// AUTOPANO - wxString default_cpg_file=huginApp::Get()->GetDataPath()+wxT("default.setting"); - if(wxFileName::FileExists(default_cpg_file)) - { - cpdetector_config_edit.ReadFromFile(default_cpg_file); - } - else - { - cpdetector_config_edit.ResetToDefault(); - }; + cpdetector_config_edit.ReadFromFile(huginApp::Get()->GetDataPath()+wxT("default.setting")); cpdetector_config_edit.Write(cfg); } if (noteb->GetSelection() == 4) { diff -r 57d5bcba4c0c -r 51c2fba627f9 src/hugin1/icpfind/CPDetectorConfig.cpp --- a/src/hugin1/icpfind/CPDetectorConfig.cpp Sat Nov 27 10:30:35 2010 +0100 +++ b/src/hugin1/icpfind/CPDetectorConfig.cpp Sat Nov 27 15:10:17 2010 +0100 @@ -40,7 +40,7 @@ /** arguments for default cp generator, for fall back procedure */ wxString default_cpgenerator_args(wxT("-o %o %s")); -void CPDetectorConfig::Read(wxConfigBase *config) +void CPDetectorConfig::Read(wxConfigBase *config,wxString loadFromFile) { settings.Clear(); int count=config->Read(wxT("/AutoPano/AutoPanoCount"),0l); @@ -51,15 +51,31 @@ ReadIndex(config, i); }; if(settings.GetCount()==0) - ResetToDefault(); + { + if(loadFromFile.IsEmpty()) + { + ResetToDefault(); + } + else + { + ReadFromFile(loadFromFile); + }; + }; if(default_generator>=settings.GetCount()) default_generator=0; }; void CPDetectorConfig::ReadFromFile(wxString filename) { - wxFileConfig fconfig(wxT("hugin"),wxEmptyString,filename); - Read(&fconfig); + if(wxFile::Exists(filename)) + { + wxFileConfig fconfig(wxT("hugin"),wxEmptyString,filename); + Read(&fconfig); + } + else + { + ResetToDefault(); + }; }; void CPDetectorConfig::ReadIndex(wxConfigBase *config, int i) diff -r 57d5bcba4c0c -r 51c2fba627f9 src/hugin1/icpfind/CPDetectorConfig.h --- a/src/hugin1/icpfind/CPDetectorConfig.h Sat Nov 27 10:30:35 2010 +0100 +++ b/src/hugin1/icpfind/CPDetectorConfig.h Sat Nov 27 15:10:17 2010 +0100 @@ -132,8 +132,11 @@ CPDetectorConfig() {}; /** destructor */ virtual ~CPDetectorConfig() {}; - /** read the settings of different cp generators from config */ - void Read(wxConfigBase* config=wxConfigBase::Get()); + /** read the settings of different cp generators from config + * @param config wxConfigBase, from which the settings are loaded, if empty the default wxConfigBase is used + * @param loadFromFile file, from which the settings are loaded, if no settings are stored by hugin itself + */ + void Read(wxConfigBase* config=wxConfigBase::Get(),wxString loadFromFile=wxEmptyString); /** writes the settings of different cp generators to config */ void Write(wxConfigBase* config=wxConfigBase::Get()); /** import the cp detector settings from external file */ |