28 #include <hugin_config.h>
34 #include <wx/cmdline.h>
35 #include <wx/arrstr.h>
36 #include <wx/stdpaths.h>
58 #define APP wxAppConsole
66 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
67 m_utilsBinDir=exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
70 exePath.RemoveLastDir();
71 m_locale.AddCatalogLookupPathPrefix(exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) + wxT(
"share\\locale"));
72 #elif defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
74 #elif defined UNIX_SELF_CONTAINED_BUNDLE
77 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
78 exePath.RemoveLastDir();
79 const wxString huginRoot=exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
81 m_locale.AddCatalogLookupPathPrefix(huginRoot + wxT(
"share/locale"));
85 m_locale.AddCatalogLookupPathPrefix(wxT(INSTALL_LOCALE_DIR));
89 CheckConfigFilename();
91 wxConfig* config =
new wxConfig(wxT(
"hugin"));
92 wxConfigBase::Set(config);
95 setlocale(LC_ALL,
"");
97 int localeID = config->Read(wxT(
"language"), (
long)
HUGIN_LANGUAGE);
102 return APP::OnInit();
109 inputFile.Normalize(wxPATH_NORM_ABSOLUTE | wxPATH_NORM_DOTS | wxPATH_NORM_TILDE | wxPATH_NORM_SHORTCUT);
117 wxArrayString tempfiles;
132 wxFileName outputPrefix;
136 outputPrefix.Normalize(wxPATH_NORM_ABSOLUTE | wxPATH_NORM_DOTS | wxPATH_NORM_TILDE | wxPATH_NORM_SHORTCUT);
141 outputPrefix.MakeAbsolute();
143 oldCwd = wxFileName::GetCwd();
144 wxFileName::SetCwd(outputPrefix.GetPath());
146 wxArrayString outputFiles;
157 std::cout << statusText.mb_str(wxConvLocal) << std::endl;
161 if (commands->empty())
163 std::cout <<
"ERROR: Queue is empty." << std::endl;
169 m_threads = wxConfigBase::Get()->Read(wxT(
"/output/NumberOfThreads"), 0l);
173 if (!tempfiles.IsEmpty())
188 std::cout << _(
"Removing temporary files") << std::endl;
189 for (
size_t i = 0; i < tempfiles.size(); ++i)
191 wxRemoveFile(tempfiles[i]);
196 if (!oldCwd.IsEmpty())
198 wxFileName::SetCwd(oldCwd);
200 return success ? 0 : 1;
206 parser.AddSwitch(wxT(
"h"), wxT(
"help"), _(
"shows this help message"), wxCMD_LINE_OPTION_HELP);
207 parser.AddSwitch(wxT(
"a"), wxT(
"assistant"), _(
"execute assistant"));
208 parser.AddSwitch(wxT(
"s"), wxT(
"stitching"), _(
"execute stitching with given project"));
209 parser.AddOption(wxT(
"t"), wxT(
"threads"), _(
"number of used threads"), wxCMD_LINE_VAL_NUMBER);
210 parser.AddOption(wxT(
"p"), wxT(
"prefix"), _(
"prefix used for stitching"), wxCMD_LINE_VAL_STRING);
211 parser.AddOption(wxT(
"u"), wxT(
"user-defined-output"), _(
"use user defined commands in given file"), wxCMD_LINE_VAL_STRING);
212 parser.AddLongOption(wxT(
"user-defined-assistant"), _(
"use user defined assistant commands in given file"), wxCMD_LINE_VAL_STRING);
213 parser.AddSwitch(wxT(
"d"), wxT(
"dry-run"), _(
"only print commands"));
214 parser.AddParam(wxT(
"input.pto"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_OPTION_MANDATORY);
229 if (parser.Found(wxT(
"t"), &threads))
238 if (!userOutputFile.FileExists())
240 if (userOutputFile.GetDirCount() == 0)
244 if (!userOutputFile.FileExists())
246 const wxString testedFile1 = userOutputFile.GetFullPath();
248 if (!userOutputFile.FileExists())
250 std::cerr <<
"ERROR: File \"" <<
m_userOutput.mb_str(wxConvLocal) <<
"\" does not exists." << std::endl
251 <<
" Also tried files \"" << testedFile1.mb_str(wxConvLocal) <<
"\" and \"" << userOutputFile.GetFullPath().mb_str(wxConvLocal) <<
"\", which don't exist." << std::endl;
259 std::cerr <<
"ERROR: File \"" <<
m_userOutput.mb_str(wxConvLocal) <<
"\" does not exists." << std::endl;
268 if (!userAssistantFile.FileExists())
270 if (userAssistantFile.GetDirCount() == 0)
274 if (!userAssistantFile.FileExists())
276 const wxString testedFile1 = userAssistantFile.GetFullPath();
278 if (!userAssistantFile.FileExists())
280 std::cerr <<
"ERROR: File \"" <<
m_userAssistant.mb_str(wxConvLocal) <<
"\" does not exists." << std::endl
281 <<
" Also tried files \"" << testedFile1.mb_str(wxConvLocal) <<
"\" and \"" << userAssistantFile.GetFullPath().mb_str(wxConvLocal) <<
"\", which don't exist." << std::endl;
289 std::cerr <<
"ERROR: File \"" <<
m_userAssistant.mb_str(wxConvLocal) <<
"\" does not exists." << std::endl;
297 std::cerr <<
"ERROR: Switch --assistant or --stitching is required." << std::endl;
302 std::cerr <<
"ERROR: Switches --assistant and --stitching are mutually excluse." << std::endl;
interface of CommandQueue creating for stitching engine
long m_threads
number of threads used for assistant or stitching
virtual bool OnInit()
init translation settings
virtual int OnRun()
the main procedure of Executor app
bool m_dryRun
flag, if commands should only be printed
wxLocale m_locale
locale for internationalisation
basic classes and function for queuing commands in wxWidgets
CommandQueue * GetAssistantCommandQueue(const HuginBase::Panorama &pano, const wxString &ExePath, const wxString &project)
generates the command queue for running the assistant
std::string GetDataDir()
returns the full path to the data directory
std::string getPathPrefix(const std::string &filename)
Get the path to a filename.
virtual bool OnCmdLineParsed(wxCmdLineParser &parser)
processes the command line parameters
bool ReadPTOFile(const std::string &filename, const std::string &prefix="")
read pto file from the given filename into Panorama object it does some checks on the file and issues...
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 ...
wxString GetQuotedFilenamesString(const wxArrayString &files)
return a wxString with all files in files quoted
wxString m_input
input project file
bool m_runStitching
flag, if stitching should started
wxString m_userOutput
input file for userdefined output
bool m_runAssistant
flag, if assistant should started
std::string GetUserAppDataDir()
returns the directory for user specific Hugin settings, e.g.
functions for interaction with the hugin configuration file
wxString m_userAssistant
input file for user defined assistant
CommandQueue * GetAssistantCommandQueueUserDefined(const HuginBase::Panorama &pano, const wxString &ExePath, const wxString &project, const wxString &assistantSetting, wxArrayString &tempFilesDelete, std::ostream &errStream)
generates the command queue for running the assistant
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 ...
CommandQueue * GetStitchingCommandQueueUserOutput(const HuginBase::Panorama &pano, const wxString &ExePath, const wxString &project, const wxString &prefix, const wxString &outputSettings, wxString &statusText, wxArrayString &outputFiles, wxArrayString &tempFilesDelete, std::ostream &errStream)
generates the command queue for stitching a pano, the commands are parsed from the given executor out...
wxString m_prefix
stitching prefix
wxString m_utilsBinDir
path to utils
virtual void OnInitCmdLine(wxCmdLineParser &parser)
set the parameters for the command line parser
CommandQueue * GetStitchingCommandQueue(const HuginBase::Panorama &pano, const wxString &ExePath, const wxString &project, const wxString &prefix, wxString &statusText, wxArrayString &outputFiles, wxArrayString &tempFilesDelete, std::ostream &errStream)
generates the command queue for stitching a pano it will also generate the necessary exiftool argfile...
std::vector< NormalCommand * > CommandQueue
create a CommandQueue for running the assistant using CLI tools