Hugin trunk 0.1
Loading...
Searching...
No Matches
huginConfig.cpp
Go to the documentation of this file.
1// -*- c-basic-offset: 4 -*-
2
27#include "platform.h"
28#include "huginConfig.h"
30
31// functions to handle with default project/output filenames
32typedef std::map<wxString, wxString> Placeholdersmap;
33
35{
36 // replace invalid characters in format string
37 // which are not allowed in filenames
38 wxString result(input);
39 result.Replace("/", "_");
40 result.Replace("\\", "_");
41 result.Replace(":", "-");
42 result.Replace("*", ".");
43 result.Replace("?", ".");
44 result.Replace("<", ".");
45 result.Replace(">", ".");
46 result.Replace("|", ".");
47 return result;
48}
50{
51 placeholder["%firstimage"]=_("first image");
52 placeholder["%lastimage"]=_("last image");
53 placeholder["%#images"]="0";
54 placeholder["%directory"]=_("directory");
55 placeholder["%projection"]=_("Equirectangular");
56 placeholder["%focallength"]="28";
57 wxDateTime datetime=wxDateTime(13,wxDateTime::May,2012,11,35);
58 placeholder["%date"] = CleanDateTime(datetime.FormatDate());
59 placeholder["%time"] = CleanDateTime(datetime.FormatTime());
60 placeholder["%maker"]=_("Camera maker");
61 placeholder["%model"]=_("Camera model");
62 placeholder["%lens"]=_("Lens");
63};
64
66{
68 wxFileName firstImg(wxString(img0.getFilename().c_str(),HUGIN_CONV_FILENAME));
69 placeholder["%firstimage"]=firstImg.GetName();
70 if (firstImg.GetDirCount() > 0)
71 {
72 placeholder["%directory"] = firstImg.GetDirs().Last();
73 }
74 else
75 {
76 placeholder["%directory"] = wxEmptyString;
77 };
78 placeholder["%focallength"]=wxString::Format("%.0f", img0.getExifFocalLength());
79 struct tm exifdatetime;
80 if (img0.getExifDateTime(&exifdatetime) == 0)
81 {
83 placeholder["%date"] = CleanDateTime(datetime.FormatDate());
84 placeholder["%time"] = CleanDateTime(datetime.FormatTime());
85 }
86 else
87 {
88 // no date found, use file create date
89 const wxFileName firstFile(img0.getFilename());
91 firstFile.GetTimes(NULL, NULL, &createTime);
92 placeholder["%date"] = CleanDateTime(createTime.FormatDate());
93 placeholder["%time"] = CleanDateTime(createTime.FormatTime());
94 };
95 placeholder["%maker"]=wxString(img0.getExifMake().c_str(), wxConvLocal);
96 placeholder["%model"]=wxString(img0.getExifModel().c_str(), wxConvLocal);
97 placeholder["%lens"]=wxString(img0.getExifLens().c_str(), wxConvLocal);
98
99 wxFileName lastImg(wxString(pano.getImage(pano.getNrOfImages()-1).getFilename().c_str(),HUGIN_CONV_FILENAME));
100 placeholder["%lastimage"]=lastImg.GetName();
101 placeholder["%#images"]=wxString::Format("%lu", (unsigned long)pano.getNrOfImages());
105 {
106 wxString str2(proj.name, wxConvLocal);
107 placeholder["%projection"]=wxGetTranslation(str2);
108 }
109 else
110 {
111 placeholder["%projection"]=_("unknown projection");
112 };
113};
114
116{
117 wxString filename;
118 if(filenameTemplate.IsEmpty())
119 {
120 filename=wxConfigBase::Get()->Read("ProjectFilename", HUGIN_DEFAULT_PROJECT_NAME);
121#ifdef __WXMSW__
122 filename.Replace("/", "\\", true);
123#endif
124 }
125 else
126 {
127 filename=filenameTemplate;
128 };
131 if(pano.getNrOfImages()>0)
132 {
134 wxFileName firstImg(wxString(pano.getImage(0).getFilename().c_str(),HUGIN_CONV_FILENAME));
135 pathPrefix=firstImg.GetPathWithSep();
136 }
137 else
138 {
140 };
141 // now replace all placeholder
142 for(Placeholdersmap::const_iterator it=placeholder.begin(); it!=placeholder.end(); ++it)
143 {
144 filename.Replace(it->first, it->second, true);
145 };
146 if(filename.empty())
147 {
148 filename="pano";
149 };
150 // check if template is an absolute path, if so ignore path from first image
151 wxFileName fileName(filename);
152 if (fileName.IsAbsolute())
153 {
154 return filename;
155 };
156 return pathPrefix+filename;
157};
158
162{
163 wxFileName project;
164 if (projectname.IsEmpty())
165 {
166 project=getDefaultProjectName(pano);
167 }
168 else
169 {
170 project=projectname;
171 }
172 if(project.HasExt())
173 {
174 project.ClearExt();
175 };
176
177 wxString filename;
178 if(filenameTemplate.IsEmpty())
179 {
180 filename=wxConfigBase::Get()->Read("OutputFilename", HUGIN_DEFAULT_PROJECT_NAME);
181#ifdef __WXMSW__
182 filename.Replace("/", "\\", true);
183#endif
184 }
185 else
186 {
187 filename=filenameTemplate;
188 };
189 wxString pathPrefix=project.GetPathWithSep();
191 if(pano.getNrOfImages()>0)
192 {
194 wxFileName firstImg(wxString(pano.getImage(0).getFilename().c_str(),HUGIN_CONV_FILENAME));
195 }
196 else
197 {
199 };
200 placeholder.insert(std::make_pair("%projectname", project.GetName()));
201 // now replace all placeholder
202 for(Placeholdersmap::const_iterator it=placeholder.begin(); it!=placeholder.end(); ++it)
203 {
204 filename.Replace(it->first, it->second, true);
205 };
206 if(filename.empty())
207 {
208 filename="pano";
209 };
210 // check if template is an absolute path, if so ignore path from first image
211 wxFileName fileName(filename);
212 if (fileName.IsAbsolute())
213 {
214 return filename;
215 };
216 return pathPrefix+filename;
217};
Panorama image options.
PanoramaOptions::ProjectionFormat getProjection() const
Model for a panorama.
Definition Panorama.h:153
const SrcPanoImage & getImage(std::size_t nr) const
get a panorama image, counting starts with 0
Definition Panorama.h:211
const PanoramaOptions & getOptions() const
returns the options for this panorama
Definition Panorama.h:481
std::size_t getNrOfImages() const
number of images.
Definition Panorama.h:205
All variables of a source image.
#define HUGIN_DEFAULT_PROJECT_NAME
#define HUGIN_CONV_FILENAME
Definition platform.h:40
void FillDefaultPlaceholders(Placeholdersmap &placeholder)
wxString getDefaultOutputName(const wxString projectname, const HuginBase::Panorama &pano, const wxString filenameTemplate)
gets the default output prefix, based on filename and images in project the setting is read from the ...
std::map< wxString, wxString > Placeholdersmap
wxString getDefaultProjectName(const HuginBase::Panorama &pano, const wxString filenameTemplate)
gets the default project name, as defined in the preferences
void FillPlaceholders(Placeholdersmap &placeholder, const HuginBase::Panorama &pano)
wxString CleanDateTime(const wxString &input)
functions for interaction with the hugin configuration file
platform/compiler specific stuff.
std::vector< deghosting::BImagePtr > threshold(const std::vector< deghosting::FImagePtr > &inputImages, const double threshold, const uint16_t flags)
Threshold function used for creating alpha masks for images.
Definition threshold.h:41