25 #include "hugin_config.h"
29 #include <wx/config.h>
30 #include <wx/filename.h>
32 #include <wx/translation.h>
33 #if defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
45 std::cout <<
GetCommand().mb_str(wxConvLocal) << std::endl;
50 std::cout << std::endl <<
m_comment.mb_str(wxConvLocal) << std::endl;
52 return wxExecute(
GetCommand(), wxEXEC_SYNC | wxEXEC_MAKE_GROUP_LEADER) == 0l;
90 wxSetEnv(wxT(
"OMP_NUM_THREADS"), s);
93 wxString tempDir = wxConfig::Get()->Read(wxT(
"tempDir"), wxT(
""));
94 if (!tempDir.IsEmpty())
97 wxSetEnv(wxT(
"TMPDIR"), tempDir);
99 wxSetEnv(wxT(
"TMP"), tempDir);
102 bool isSuccessful =
true;
105 wxLogStream
log(&std::cerr);
107 while (isSuccessful && i < queue->size())
109 isSuccessful = (*queue)[i]->Execute(dryRun);
120 while (!queue->empty())
122 delete queue->back();
131 #if defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
132 CFStringRef filename = MacCreateCFStringWithWxString(name);
133 wxString fn = MacGetPathToBundledExecutableFile(filename);
137 std::cerr << wxString::Format(_(
"External program %s not found in the bundle, reverting to system path"), name.c_str()) << std::endl;
142 return bindir + name;
150 #if defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
151 if (config->Read(name + wxT(
"/Custom"), 0l))
153 wxString fn = config->Read(name + wxT(
"/Exe"), wxT(
""));
160 std::cerr << wxString::Format(_(
"WARNING: External program %s not found as specified in preferences, reverting to bundled version"), fn.c_str()) << std::endl;
163 if (name == wxT(
"exiftool"))
165 wxString exiftoolDirPath = MacGetPathToBundledResourceFile(CFSTR(
"ExifTool"));
166 if (exiftoolDirPath != wxT(
""))
168 return exiftoolDirPath + wxT(
"/exiftool");
172 std::cerr << wxString::Format(_(
"WARNING: External program %s not found in the bundle, reverting to system path"), name.c_str()) << std::endl;
173 return wxT(
"exiftool");
177 CFStringRef filename = MacCreateCFStringWithWxString(name);
178 wxString fn = MacGetPathToBundledExecutableFile(filename);
182 std::cerr << wxString::Format(_(
"WARNING: External program %s not found in the bundle, reverting to system path"), name.c_str()) << std::endl;
187 if (config->Read(name + wxT(
"/Custom"), 0l))
189 wxString fn = config->Read(name + wxT(
"/Exe"), wxT(
""));
193 if (prog.IsAbsolute())
195 if (prog.FileExists())
204 pathlist.Add(bindir);
205 pathlist.AddEnvList(wxT(
"PATH"));
206 fn = pathlist.FindAbsoluteValidPath(fn);
212 std::cerr << wxString::Format(_(
"WARNING: External program %s not found as specified in preferences, reverting to bundled version"), name.c_str()) << std::endl;
218 return bindir + name;
219 #elif defined UNIX_SELF_CONTAINED_BUNDLE
224 return bindir + name;
241 const wxString sep = wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER);
242 s.Replace(sep, wxT(
"."));
249 wxString MSWGetProgname(
const wxString& bindir,
const wxString& name)
251 wxFileName prog(name);
252 if (prog.IsAbsolute())
254 if (prog.FileExists())
256 return prog.GetFullPath();
262 const bool hasExt = prog.HasExt();
268 pathlist.Add(bindir);
269 pathlist.AddEnvList(wxT(
"PATH"));
270 const wxString fullName = pathlist.FindAbsoluteValidPath(prog.GetFullName());
271 if (!fullName.IsEmpty())
281 const wxString
GetSettingString(wxConfigBase* setting,
const wxString& name,
const wxString defaultValue)
283 wxString s = setting->Read(name, defaultValue);
284 s = s.Trim(
true).Trim(
false);
293 return wxEmptyString;
297 return wxGetTranslation(text);
304 wxString tempDir = config->Read(wxT(
"tempDir"), wxT(
""));
305 if (!tempDir.IsEmpty())
307 if (tempDir.Last() != wxFileName::GetPathSeparator())
309 tempDir.Append(wxFileName::GetPathSeparator());
const wxString GetSettingString(wxConfigBase *setting, const wxString &name, const wxString defaultValue)
read a string from setting and remove all whitespaces
bool FileExists(const std::string &filename)
checks if file exists
virtual wxString GetCommand() const
const wxString GetConfigTempDir(const wxConfigBase *config)
return the temp dir from the preferences, ensure that it ends with path separator ...
wxString doubleTowxString(double d, int digits)
wxString GetInternalProgram(const wxString &bindir, const wxString &name)
return path and name of external program, which comes bundled with Hugin
basic classes and function for queuing commands in wxWidgets
bool RunCommandsQueue(CommandQueue *queue, size_t threads, bool dryRun)
execute the given, set environment variable OMP_NUM_THREADS to threads (ignored for 0) after running ...
virtual bool Execute(bool dryRun)
void CleanQueue(CommandQueue *queue)
clean the queue, delete all entries, but not the queue itself
vigra::RGBValue< T, RIDX, GIDX, BIDX > log(vigra::RGBValue< T, RIDX, GIDX, BIDX > const &v)
component-wise logarithm
wxString GetComment() const
const wxString GetSettingStringTranslated(wxConfigBase *setting, const wxString &name, const wxString defaultValue)
read a translated string from settings and remove all whitespaces
str wxEscapeFilename(const str &arg)
special escaping routine for CommandQueues
virtual bool Execute(bool dryRun)
virtual bool CheckReturnCode() const
wxString GetExternalProgram(wxConfigBase *config, const wxString &bindir, const wxString &name)
return path and name of external program, which can be overwritten by the user
virtual bool CheckReturnCode() const
std::vector< NormalCommand * > CommandQueue
wxString wxStringFromCDouble(double val, int precision)
convert double to wxString, it is always using a '.