branch:
details: http://hugin.hg.sourceforge.net/hgweb/hugin/hugin/hgroot/hugin/hugin/rev/3a77135d5e00
changeset: 5997:3a77135d5e00
user: tmodes
date: Wed Oct 03 09:01:32 2012 +0200
description:
Added more flexible format of project name and output prefix [680000]
diffstat:
src/hugin1/base_wx/huginConfig.cpp | 206 +++++++++++++++++++++++++++++++++
src/hugin1/base_wx/huginConfig.h | 6 +
src/hugin1/hugin/MainFrame.cpp | 8 +-
src/hugin1/hugin/MainFrame.h | 2 +
src/hugin1/hugin/PanoPanel.cpp | 42 +------
src/hugin1/hugin/PreferencesDialog.cpp | 96 +++++++++++----
src/hugin1/hugin/PreferencesDialog.h | 5 +
src/hugin1/hugin/config_defaults.h | 3 +-
src/hugin1/hugin/huginApp.cpp | 25 ----
src/hugin1/hugin/huginApp.h | 3 -
src/hugin1/hugin/xrc/pref_dialog.xrc | 99 ++++++++++++---
src/hugin1/ptbatcher/Batch.cpp | 2 +-
src/hugin1/ptbatcher/BatchFrame.cpp | 2 +-
src/hugin1/ptbatcher/ProjectArray.cpp | 11 +-
14 files changed, 387 insertions(+), 123 deletions(-)
diffs (truncated from 808 to 500 lines):
diff -r 59bbbd19005a -r 3a77135d5e00 src/hugin1/base_wx/huginConfig.cpp
--- a/src/hugin1/base_wx/huginConfig.cpp Sun Sep 30 10:23:14 2012 +0200
+++ b/src/hugin1/base_wx/huginConfig.cpp Wed Oct 03 09:01:32 2012 +0200
@@ -280,3 +280,209 @@
return huginPath;
}
+// functions to handle with default project/output filenames
+typedef std::map<wxString, wxString> Placeholdersmap;
+
+void GeneratePlaceholdermap(Placeholdersmap & placeholder)
+{
+ placeholder.insert(std::make_pair(wxT("%firstimage"), wxT("")));
+ placeholder.insert(std::make_pair(wxT("%lastimage"), wxT("")));
+ placeholder.insert(std::make_pair(wxT("%#images"), wxT("")));
+ placeholder.insert(std::make_pair(wxT("%directory"), wxT("")));
+ placeholder.insert(std::make_pair(wxT("%projection"), wxT("")));
+ placeholder.insert(std::make_pair(wxT("%focallength"), wxT("")));
+ placeholder.insert(std::make_pair(wxT("%date"), wxT("")));
+ placeholder.insert(std::make_pair(wxT("%time"), wxT("")));
+};
+
+void FillDefaultPlaceholders(Placeholdersmap & placeholder)
+{
+ placeholder[wxT("%firstimage")]=_("first image");
+ placeholder[wxT("%lastimage")]=_("last image");
+ placeholder[wxT("%#images")]=wxT("0");
+ placeholder[wxT("%directory")]=_("directory");
+ placeholder[wxT("%projection")]=_("projection");
+ placeholder[wxT("%focallength")]=wxT("0");
+ wxDateTime datetime=wxDateTime(13,wxDateTime::May,2012,11,35);
+ placeholder[wxT("%date")]=datetime.FormatDate();
+ placeholder[wxT("%time")]=datetime.FormatTime();
+
+};
+
+void FillPlaceholders(Placeholdersmap & placeholder, const HuginBase::Panorama & pano)
+{
+ const HuginBase::SrcPanoImage & img0=pano.getImage(0);
+ wxFileName firstImg(wxString(img0.getFilename().c_str(),HUGIN_CONV_FILENAME));
+ placeholder[wxT("%firstimage")]=firstImg.GetName();
+ if(firstImg.GetDirCount()>0)
+ {
+ placeholder[wxT("%directory")]=firstImg.GetDirs().Last();
+ };
+ placeholder[wxT("%focallength")]=wxString::Format(wxT("%.0f"), img0.getExifFocalLength());
+ struct tm exifdatetime;
+ if(img0.getExifDateTime(&exifdatetime)==0)
+ {
+ wxDateTime datetime=wxDateTime(exifdatetime);
+ placeholder[wxT("%date")]=datetime.FormatDate();
+ placeholder[wxT("%time")]=datetime.FormatTime();
+ };
+
+ wxFileName lastImg(wxString(pano.getImage(pano.getNrOfImages()-1).getFilename().c_str(),HUGIN_CONV_FILENAME));
+ placeholder[wxT("%lastimage")]=lastImg.GetName();
+ placeholder[wxT("%#images")]=wxString::Format(wxT("%d"), pano.getNrOfImages());
+ PanoramaOptions opts=pano.getOptions();
+ switch(opts.getProjection())
+ {
+ case PanoramaOptions::RECTILINEAR:
+ placeholder[wxT("%projection")]=_("Rectilinear");
+ break;
+ case PanoramaOptions::CYLINDRICAL:
+ placeholder[wxT("%projection")]=_("Cylindrical");
+ break;
+ case PanoramaOptions::EQUIRECTANGULAR:
+ placeholder[wxT("%projection")]=_("Equirectangular");
+ break;
+ case PanoramaOptions::FULL_FRAME_FISHEYE:
+ placeholder[wxT("%projection")]=_("Fisheye");
+ break;
+ case PanoramaOptions::STEREOGRAPHIC:
+ placeholder[wxT("%projection")]=_("Stereographic");
+ break;
+ case PanoramaOptions::MERCATOR:
+ placeholder[wxT("%projection")]=_("Mercator");
+ break;
+ case PanoramaOptions::TRANSVERSE_MERCATOR:
+ placeholder[wxT("%projection")]=_("Trans Mercator");
+ break;
+ case PanoramaOptions::SINUSOIDAL:
+ placeholder[wxT("%projection")]=_("Sinusoidal");
+ break;
+ case PanoramaOptions::LAMBERT:
+ placeholder[wxT("%projection")]=_("Lambert Cylindrical Equal Area");
+ break;
+ case PanoramaOptions::LAMBERT_AZIMUTHAL:
+ placeholder[wxT("%projection")]=_("Lambert Equal Area Azimuthal");
+ break;
+ case PanoramaOptions::ALBERS_EQUAL_AREA_CONIC:
+ placeholder[wxT("%projection")]=_("Albers Equal Area Conic");
+ break;
+ case PanoramaOptions::MILLER_CYLINDRICAL:
+ placeholder[wxT("%projection")]=_("Miller Cylindrical");
+ break;
+ case PanoramaOptions::PANINI:
+ placeholder[wxT("%projection")]=_("Panini");
+ break;
+ case PanoramaOptions::ARCHITECTURAL:
+ placeholder[wxT("%projection")]=_("Architectural");
+ break;
+ case PanoramaOptions::ORTHOGRAPHIC:
+ placeholder[wxT("%projection")]=_("Orthographic");
+ break;
+ case PanoramaOptions::EQUISOLID:
+ placeholder[wxT("%projection")]=_("Equisolid");
+ break;
+ case PanoramaOptions::EQUI_PANINI:
+ placeholder[wxT("%projection")]=_("Equirectangular Panini");
+ break;
+ case PanoramaOptions::BIPLANE:
+ placeholder[wxT("%projection")]=_("Biplane");
+ break;
+ case PanoramaOptions::TRIPLANE:
+ placeholder[wxT("%projection")]=_("Triplane");
+ break;
+ case PanoramaOptions::GENERAL_PANINI:
+ placeholder[wxT("%projection")]=_("Panini General");
+ break;
+ case PanoramaOptions::THOBY_PROJECTION:
+ placeholder[wxT("%projection")]=_("Thoby Projection");
+ break;
+ };
+};
+
+wxString getDefaultProjectName(const HuginBase::Panorama & pano,const wxString filenameTemplate)
+{
+ wxString filename;
+ if(filenameTemplate.IsEmpty())
+ {
+ filename=wxConfigBase::Get()->Read(wxT("ProjectFilename"), wxT(HUGIN_DEFAULT_PROJECT_NAME));
+ }
+ else
+ {
+ filename=filenameTemplate;
+ };
+ wxString pathPrefix;
+ Placeholdersmap placeholder;
+ GeneratePlaceholdermap(placeholder);
+ if(pano.getNrOfImages()>0)
+ {
+ FillPlaceholders(placeholder, pano);
+ wxFileName firstImg(wxString(pano.getImage(0).getFilename().c_str(),HUGIN_CONV_FILENAME));
+ pathPrefix=firstImg.GetPathWithSep();
+ }
+ else
+ {
+ FillDefaultPlaceholders(placeholder);
+ };
+ // now replace all placeholder
+ for(Placeholdersmap::const_iterator it=placeholder.begin(); it!=placeholder.end(); it++)
+ {
+ filename.Replace(it->first, it->second, true);
+ };
+ if(filename.empty())
+ {
+ filename=wxT("pano");
+ };
+ return pathPrefix+filename;
+};
+
+/** gets the default output prefix, based on filename and images in project
+ * the setting is read from the preferences */
+wxString getDefaultOutputName(const wxString projectname, const HuginBase::Panorama & pano, const wxString filenameTemplate)
+{
+ wxFileName project;
+ if (projectname.IsEmpty())
+ {
+ project=getDefaultProjectName(pano);
+ }
+ else
+ {
+ project=projectname;
+ }
+ if(project.HasExt())
+ {
+ project.ClearExt();
+ };
+
+ wxString filename;
+ if(filenameTemplate.IsEmpty())
+ {
+ filename=wxConfigBase::Get()->Read(wxT("OutputFilename"), wxT(HUGIN_DEFAULT_PROJECT_NAME));
+ }
+ else
+ {
+ filename=filenameTemplate;
+ };
+ wxString pathPrefix=project.GetPathWithSep();
+ Placeholdersmap placeholder;
+ GeneratePlaceholdermap(placeholder);
+ if(pano.getNrOfImages()>0)
+ {
+ FillPlaceholders(placeholder, pano);
+ wxFileName firstImg(wxString(pano.getImage(0).getFilename().c_str(),HUGIN_CONV_FILENAME));
+ }
+ else
+ {
+ FillDefaultPlaceholders(placeholder);
+ };
+ placeholder.insert(std::make_pair(wxT("%projectname"), project.GetName()));
+ // now replace all placeholder
+ for(Placeholdersmap::const_iterator it=placeholder.begin(); it!=placeholder.end(); it++)
+ {
+ filename.Replace(it->first, it->second, true);
+ };
+ if(filename.empty())
+ {
+ filename=wxT("pano");
+ };
+ return pathPrefix+filename;
+};
diff -r 59bbbd19005a -r 3a77135d5e00 src/hugin1/base_wx/huginConfig.h
--- a/src/hugin1/base_wx/huginConfig.h Sun Sep 30 10:23:14 2012 +0200
+++ b/src/hugin1/base_wx/huginConfig.h Wed Oct 03 09:01:32 2012 +0200
@@ -51,4 +51,10 @@
*/
WXIMPEX wxString getExePath(wxString argv0);
+/** gets the default project name, as defined in the preferences */
+WXIMPEX wxString getDefaultProjectName(const HuginBase::Panorama & pano, const wxString filenameTemplate=wxT(""));
+/** gets the default output prefix, based on filename and images in project
+ * the setting is read from the preferences */
+WXIMPEX wxString getDefaultOutputName(const wxString projectname, const HuginBase::Panorama & pano, const wxString filenameTemplate=wxT(""));
+
#endif
diff -r 59bbbd19005a -r 3a77135d5e00 src/hugin1/hugin/MainFrame.cpp
--- a/src/hugin1/hugin/MainFrame.cpp Sun Sep 30 10:23:14 2012 +0200
+++ b/src/hugin1/hugin/MainFrame.cpp Wed Oct 03 09:01:32 2012 +0200
@@ -814,9 +814,15 @@
{
DEBUG_TRACE("");
wxFileName scriptName;
- if (m_filename == wxT("")) {
+ if (m_filename.IsEmpty())
+ {
scriptName.Assign(getDefaultProjectName(pano) + wxT(".pto"));
}
+ else
+ {
+ scriptName=m_filename;
+ };
+ scriptName.Normalize();
wxFileDialog dlg(wxTheApp->GetTopWindow(),
_("Save project file"),
scriptName.GetPath(), scriptName.GetFullName(),
diff -r 59bbbd19005a -r 3a77135d5e00 src/hugin1/hugin/MainFrame.h
--- a/src/hugin1/hugin/MainFrame.h Sun Sep 30 10:23:14 2012 +0200
+++ b/src/hugin1/hugin/MainFrame.h Wed Oct 03 09:01:32 2012 +0200
@@ -100,6 +100,8 @@
*/
virtual void panoramaChanged(PT::Panorama &pano);
void panoramaImagesChanged(PT::Panorama &pano, const PT::UIntSet & imgNr);
+ /** returns panorama object */
+ const PT::Panorama & getPanorama() { return pano; };
// called when a control point in CPListFrame is selected
void ShowCtrlPoint(unsigned int cpNr);
diff -r 59bbbd19005a -r 3a77135d5e00 src/hugin1/hugin/PanoPanel.cpp
--- a/src/hugin1/hugin/PanoPanel.cpp Sun Sep 30 10:23:14 2012 +0200
+++ b/src/hugin1/hugin/PanoPanel.cpp Wed Oct 03 09:01:32 2012 +0200
@@ -137,28 +137,6 @@
m_keepViewOnResize = true;
m_hasStacks=false;
-#ifdef ThisNeverHappens
-// provide some translatable strings for the drop down menu
- wxLogMessage(_("Fisheye"));
- wxLogMessage(_("Stereographic"));
- wxLogMessage(_("Mercator"));
- wxLogMessage(_("Trans Mercator"));
- wxLogMessage(_("Sinusoidal"));
- wxLogMessage(_("Lambert Cylindrical Equal Area"));
- wxLogMessage(_("Lambert Equal Area Azimuthal"));
- wxLogMessage(_("Albers Equal Area Conic"));
- wxLogMessage(_("Miller Cylindrical"));
- wxLogMessage(_("Panini"));
- wxLogMessage(_("Architectural"));
- wxLogMessage(_("Orthographic"));
- wxLogMessage(_("Equisolid"));
- wxLogMessage(_("Equirectangular Panini"));
- wxLogMessage(_("Biplane"));
- wxLogMessage(_("Triplane"));
- wxLogMessage(_("Panini General"));
- wxLogMessage(_("Thoby Projection"));
-#endif
-
/* populate with all available projection types */
int nP = panoProjectionFormatCount();
for(int n=0; n < nP; n++) {
@@ -1050,16 +1028,8 @@
#endif
// Derive a default output prefix from the project filename if set, otherwise default project filename
- wxString ptofile = MainFrame::Get()->getProjectName();
- wxFileName outputPrefix;
- if (ptofile == wxT("")) {
- outputPrefix.Assign(getDefaultProjectName(*pano));
- } else {
- outputPrefix.Assign(ptofile);
- if (outputPrefix.GetExt() == wxT("pto")) {
- outputPrefix.ClearExt();
- };
- }
+ wxFileName outputPrefix(getDefaultOutputName(MainFrame::Get()->getProjectName(), *pano));
+ outputPrefix.Normalize();
// Show a file save dialog so user can confirm/change the prefix.
// (We don't have to worry about overwriting existing files, since hugin_switch_project checks this.)
@@ -1184,12 +1154,8 @@
wxString projectFile = MainFrame::Get()->getProjectName();
if(wxFileName::FileExists(projectFile))
{
- wxFileName outputPrefix;
- outputPrefix.Assign(projectFile);
- if (outputPrefix.GetExt() == wxT("pto"))
- {
- outputPrefix.ClearExt();
- };
+ wxFileName outputPrefix(getDefaultOutputName(projectFile, *pano));
+ outputPrefix.Normalize();
// Show a file save dialog so user can confirm/change the prefix.
// (We don't have to worry about overwriting existing files, since PTBatcherGUI checks this, or the overwrite flag was set.)
diff -r 59bbbd19005a -r 3a77135d5e00 src/hugin1/hugin/PreferencesDialog.cpp
--- a/src/hugin1/hugin/PreferencesDialog.cpp Sun Sep 30 10:23:14 2012 +0200
+++ b/src/hugin1/hugin/PreferencesDialog.cpp Wed Oct 03 09:01:32 2012 +0200
@@ -35,6 +35,8 @@
#include "hugin/config_defaults.h"
#include "hugin/PreferencesDialog.h"
#include "hugin/CPDetectorDialog.h"
+#include "hugin/MainFrame.h"
+#include "base_wx/huginConfig.h"
// validators are working different somehow...
//#define MY_STR_VAL(id, filter) { XRCCTRL(*this, "prefs_" #id, wxTextCtrl)->SetValidator(wxTextValidator(filter, &id)); }
@@ -81,6 +83,8 @@
EVT_BUTTON(XRCID("pref_cpdetector_help"), PreferencesDialog::OnCPDetectorHelp)
EVT_CHOICE(XRCID("pref_ldr_output_file_format"), PreferencesDialog::OnFileFormatChanged)
EVT_CHOICE(XRCID("pref_processor_gui"), PreferencesDialog::OnProcessorChanged)
+ EVT_TEXT(XRCID("prefs_project_filename"), PreferencesDialog::OnUpdateProjectFilename)
+ EVT_TEXT(XRCID("prefs_output_filename"), PreferencesDialog::OnUpdateOutputFilename)
// EVT_CLOSE(RunOptimizerFrame::OnClose)
END_EVENT_TABLE()
@@ -452,27 +456,33 @@
DEBUG_WARN("Unknown language configured");
}
- // project naming convention
- t = cfg->Read(wxT("ProjectNamingConvention"), HUGIN_PROJECT_NAMING_CONVENTION) == 1;
- MY_BOOL_VAL("prefs_project_naming_convention", t);
-
// smart undo
t = cfg->Read(wxT("smartUndo"), HUGIN_SMART_UNDO) == 1;
MY_BOOL_VAL("prefs_smart_undo", t);
t = cfg->Read(wxT("/GLPreviewFrame/ShowProjectionHints"), HUGIN_SHOW_PROJECTION_HINTS) == 1;
MY_BOOL_VAL("pref_show_projection_hints", t)
+ };
- // cursor setting
-// mem = cfg->Read(wxT("/CPImageCtrl/CursorType"), HUGIN_CP_CURSOR);
-// MY_SPIN_VAL("prefs_cp_CursorType", mem);
-
+ // filename panel
+ if(panel==0 || panel==2)
+ {
// tempdir
MY_STR_VAL("prefs_misc_tempdir", cfg->Read(wxT("tempDir"),wxT("")));
-
+ // default filenames
+ wxString filename=cfg->Read(wxT("ProjectFilename"), wxT(HUGIN_DEFAULT_PROJECT_NAME));
+#ifdef __WXMSW__
+ filename.Replace(wxT("/"),wxT("\\"),true);
+#endif
+ MY_STR_VAL("prefs_project_filename", filename);
+ filename=cfg->Read(wxT("OutputFilename"), wxT(HUGIN_DEFAULT_OUTPUT_NAME));
+#ifdef __WXMSW__
+ filename.Replace(wxT("/"),wxT("\\"),true);
+#endif
+ MY_STR_VAL("prefs_output_filename", filename);
}
- if (panel==0 || panel == 2) {
+ if (panel==0 || panel == 3) {
// Assistant settings
t = cfg->Read(wxT("/Assistant/autoAlign"), HUGIN_ASS_AUTO_ALIGN) == 1;
MY_BOOL_VAL("prefs_ass_autoAlign", t);
@@ -497,7 +507,7 @@
}
// Fine tune settings
- if (panel==0 || panel == 3) {
+ if (panel==0 || panel == 4) {
// hdr display settings
MY_CHOICE_VAL("prefs_misc_hdr_mapping", cfg->Read(wxT("/ImageCache/Mapping"), HUGIN_IMGCACHE_MAPPING_FLOAT));
//MY_CHOICE_VAL("prefs_misc_hdr_range", cfg->Read(wxT("/ImageCache/Range"), HUGIN_IMGCACHE_RANGE));
@@ -540,11 +550,11 @@
/////
/// CP Detector programs
- if (panel==0 || panel == 4){
+ if (panel==0 || panel == 5){
cpdetector_config_edit.FillControl(m_CPDetectorList,true,true);
}
- if (panel==0 || panel == 5){
+ if (panel==0 || panel == 6){
/////
/// DEFAULT OUTPUT FORMAT
MY_CHOICE_VAL("pref_ldr_output_file_format", cfg->Read(wxT("/output/ldr_format"), HUGIN_LDR_OUTPUT_FORMAT));
@@ -575,7 +585,7 @@
}
- if (panel==0 || panel == 6){
+ if (panel==0 || panel == 7){
/////
/// NONA
@@ -609,7 +619,7 @@
wxT(HUGIN_ENFUSE_ARGS)));
}
- if (panel==0 || panel == 7) {
+ if (panel==0 || panel == 8) {
// Celeste settings
d=HUGIN_CELESTE_THRESHOLD;
cfg->Read(wxT("/Celeste/Threshold"), &d, HUGIN_CELESTE_THRESHOLD);
@@ -676,14 +686,19 @@
cfg->Write(wxT("/Nona/NumberOfThreads"), cpucount);
// locale
cfg->Write(wxT("language"), int(HUGIN_LANGUAGE));
- // project naming convention
- cfg->Write(wxT("ProjectNamingConvention"), HUGIN_PROJECT_NAMING_CONVENTION);
// smart undo
cfg->Write(wxT("smartUndo"), HUGIN_SMART_UNDO);
// projection hints
cfg->Write(wxT("/GLPreviewFrame/ShowProjectionHints"), HUGIN_SHOW_PROJECTION_HINTS);
}
- if (noteb->GetSelection() == 1) {
+ if(noteb->GetSelection() == 1)
+ {
+ cfg->Write(wxT("tempDir"), wxT(""));
+ cfg->Write(wxT("ProjectFilename"), wxT(HUGIN_DEFAULT_PROJECT_NAME));
+ cfg->Write(wxT("OutputFilename"), wxT(HUGIN_DEFAULT_OUTPUT_NAME));
+ };
+ if (noteb->GetSelection() == 2)
+ {
cfg->Write(wxT("/Assistant/autoAlign"), HUGIN_ASS_AUTO_ALIGN);
cfg->Write(wxT("/Assistant/nControlPoints"), HUGIN_ASS_NCONTROLPOINTS);
cfg->Write(wxT("/Assistant/panoDownsizeFactor"),HUGIN_ASS_PANO_DOWNSIZE_FACTOR);
@@ -694,7 +709,8 @@
cfg->Write(wxT("/Celeste/Auto"), HUGIN_CELESTE_AUTO);
cfg->Write(wxT("/Assistant/AutoCPClean"), HUGIN_ASS_AUTO_CPCLEAN);
}
- if (noteb->GetSelection() == 2) {
+ if (noteb->GetSelection() == 3)
+ {
// hdr
cfg->Write(wxT("/ImageCache/Mapping"), HUGIN_IMGCACHE_MAPPING_FLOAT);
//cfg->Write(wxT("/ImageCache/Range"), HUGIN_IMGCACHE_RANGE);
@@ -711,14 +727,15 @@
cfg->Write(wxT("/Finetune/RotationStopAngle"), HUGIN_FT_ROTATION_STOP_ANGLE);
cfg->Write(wxT("/Finetune/RotationSteps"), HUGIN_FT_ROTATION_STEPS);
}
- if (noteb->GetSelection() == 3) {
+ if (noteb->GetSelection() == 4)
+ {
/////
/// AUTOPANO
cpdetector_config_edit.ReadFromFile(huginApp::Get()->GetDataPath()+wxT("default.setting"));
cpdetector_config_edit.Write(cfg);
}
- if (noteb->GetSelection() == 4) {
-
+ if (noteb->GetSelection() == 5)
+ {
/// OUTPUT
cfg->Write(wxT("/output/ldr_format"), HUGIN_LDR_OUTPUT_FORMAT);
/** HDR currently deactivated since HDR TIFF broken and only choice is EXR */
@@ -735,8 +752,8 @@
cfg->Write(wxT("/output/NumberOfThreads"), 0l);
}
- if (noteb->GetSelection() == 5) {
-
+ if (noteb->GetSelection() == 6)
+ {
/// ENBLEND
cfg->Write(wxT("/Enblend/Exe"), wxT(HUGIN_ENBLEND_EXE));
cfg->Write(wxT("/Enblend/Custom"), HUGIN_ENBLEND_EXE_CUSTOM);
@@ -747,7 +764,8 @@
cfg->Write(wxT("/Enfuse/Args"), wxT(HUGIN_ENFUSE_ARGS));
}
- if (noteb->GetSelection() == 6) {
+ if (noteb->GetSelection() == 7)
|