25 #include <hugin_config.h>
29 #include <wx/wfstream.h>
30 #include <wx/stdpaths.h>
34 #include <vigra/error.hxx>
83 wxBoxSizer * topsizer =
new wxBoxSizer( wxVERTICAL );
88 this->SetBackgroundColour(m_execPanel->GetBackgroundColour());
90 topsizer->Add(m_execPanel, 1, wxEXPAND, 0);
98 wxFileName fname(scriptFile);
99 if ( !fname.FileExists() ) {
100 wxLogError( _(
"Could not open project file:") + scriptFile);
105 wxFileName::SplitPath(scriptFile, &pathToPTO, NULL, NULL);
106 pathToPTO.Append(wxFileName::GetPathSeparator());
110 wxLogError( wxString::Format(_(
"could not open script: %s"), scriptFile.c_str()) );
120 wxLogError(wxString::Format(_(
"Project %s does not contain any active images."), scriptFile.c_str()));
124 if (ptoVersion < 2) {
127 wxConfig* config =
new wxConfig(wxT(
"hugin"));
128 wxConfigBase::Set(config);
136 wxLogError( wxString::Format(_(
"error while parsing panotools script: %s"), scriptFile.c_str()) );
141 if (!userDefinedOutput.IsEmpty())
143 wxFileInputStream input(userDefinedOutput);
146 wxLogError(wxString::Format(_(
"Can't open user defined output sequence \"%s\"."), userDefinedOutput.c_str()));
149 wxFileConfig settings(input);
151 long supportsCroppedOutput;
152 settings.Read(wxT(
"/General/SupportsCroppedTIFF"), &supportsCroppedOutput, 1l);
153 if (supportsCroppedOutput != 1)
164 DEBUG_DEBUG(
"output file specified is " << (
const char *)outname.mb_str(wxConvLocal));
168 wxFileName outputPrefix(outname);
169 outputPrefix.MakeAbsolute();
170 outpath = outputPrefix.GetPath();
171 basename = outputPrefix.GetFullName();
173 wxString tempDir= wxConfigBase::Get()->Read(wxT(
"tempDir"),wxT(
""));
174 if(!tempDir.IsEmpty())
175 if(tempDir.Last()!=wxFileName::GetPathSeparator())
176 tempDir.Append(wxFileName::GetPathSeparator());
180 m_currentPTOfn = wxFileName::CreateTempFileName(tempDir+wxT(
"huginpto_"));
182 wxLogError(_(
"Could not create temporary file"));
191 wxFileName::SetCwd(outpath);
192 const wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
193 wxArrayString outputFiles;
197 std::stringstream errors;
198 if (userDefinedOutput.IsEmpty())
206 if (commands->empty())
208 wxMessageBox(_(
"Queue is empty. This should never happen.") +
"\n\n" + wxString(errors.str()), _(
"Error during stitching"), wxICON_ERROR | wxOK);
212 wxString overwrittenFiles;
215 for (
size_t i = 0; i < outputFiles.size(); i++)
217 wxString fn(outputFiles[i]);
218 if (wxFile::Exists(fn))
220 overwrittenFiles.Append(fn + wxT(
" "));
224 if (!overwrittenFiles.IsEmpty())
226 int overwriteret = wxMessageBox(_(
"Overwrite existing images?\n\n") + overwrittenFiles, _(
"Overwrite existing images"), wxYES_NO | wxICON_QUESTION);
228 if (overwriteret != wxYES) {
235 if (!statusText.empty())
241 wxMessageBox(wxString::Format(_(
"Error while stitching project\n%s"), scriptFile.c_str()),
242 _(
"Error during stitching"), wxICON_ERROR | wxOK );
244 }
catch (std::exception & e)
246 std::cerr <<
"caught exception: " << e.what() << std::endl;
247 wxMessageBox(wxString(e.what(), wxConvLocal),
248 _(
"Error during stitching"), wxICON_ERROR | wxOK );
256 wxFileName fname(scriptFile);
257 if ( !fname.FileExists() ) {
258 wxLogError( _(
"Could not open project file:") + scriptFile);
262 if (!userDefinedAssistant.IsEmpty())
264 wxFileInputStream input(userDefinedAssistant);
267 wxLogError(wxString::Format(_(
"Can't open user defined output sequence \"%s\"."), userDefinedAssistant.c_str()));
274 wxFileName::SplitPath(scriptFile, &pathToPTO, NULL, NULL);
275 pathToPTO.Append(wxFileName::GetPathSeparator());
281 wxLogError( wxString::Format(_(
"could not open script: %s"), scriptFile.c_str()));
289 wxLogError(wxString::Format(_(
"error while parsing panotools script: %s"), scriptFile.c_str()));
295 wxString tempDir= wxConfigBase::Get()->Read(wxT(
"tempDir"),wxT(
""));
296 if (!tempDir.IsEmpty())
298 if (tempDir.Last() != wxFileName::GetPathSeparator())
300 tempDir.Append(wxFileName::GetPathSeparator());
306 fname.Normalize(wxPATH_NORM_ABSOLUTE | wxPATH_NORM_DOTS | wxPATH_NORM_TILDE | wxPATH_NORM_SHORTCUT);
307 const wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
309 if (userDefinedAssistant.IsEmpty())
315 std::stringstream errors;
318 if (commands->empty())
320 wxMessageBox(_(
"Queue is empty. This should never happen."), _(
"Error during running assistant"), wxICON_ERROR | wxOK);
325 wxMessageBox(wxString::Format(_(
"Error while running assistant\n%s"), scriptFile.c_str()),
326 _(
"Error during running assistant"), wxICON_ERROR | wxOK );
329 catch (std::exception & e)
331 std::cerr <<
"caught exception: " << e.what() << std::endl;
332 wxMessageBox(wxString(e.what(), wxConvLocal),
333 _(
"Error during running assistant"), wxICON_ERROR | wxOK );
364 if (this->GetParent())
366 event.SetEventObject(
this );
368 this->GetParent()->GetEventHandler()->ProcessEvent( event );
void setMemento(const PanoramaMemento &memento)
set the internal state
bool StitchProject(const wxString &scriptFile, const wxString &outname, const wxString &userDefinedOutput=wxEmptyString)
void OnProcessTerminate(wxProcessEvent &event)
interface of CommandQueue creating for stitching engine
int ExecQueue(HuginQueue::CommandQueue *queue)
std::string enfuseOptions
include file for the hugin project
wxArrayString m_tempFiles
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
bool SaveLog(const wxString &filename)
save the content of the window into a given log file
bool loadPTScript(std::istream &i, int &ptoVersion, const std::string &prefix="")
load a Hugin file
void AddString(const wxString &s)
display the string in the panel
#define HUGIN_NONA_USEGPU
MyExecPanel * m_execPanel
UIntSet getActiveImages() const
get active images
include file for the hugin project
std::string enblendOptions
const PanoramaOptions & getOptions() const
returns the options for this panorama
void SetOverwrite(bool over=true)
bool DetectProject(const wxString &scriptFile, const wxString &userDefinedAssistant=wxEmptyString)
Memento class for a Panorama object.
#define HUGIN_ENFUSE_ARGS
functions for interaction with the hugin configuration file
bool WritePTOFile(const std::string &filename, const std::string &prefix="")
write data to given pto file
void setOptions(const PanoramaOptions &opt)
set new output settings This is not used directly for optimizing/stiching, but it can be feed into ru...
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
void PauseProcess(bool pause=true)
function to pause running process, argument pause defaults to true - to resume, set it to false ...
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...
#define HUGIN_ENBLEND_ARGS
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
bool SaveLog(const wxString &filename)
save the content of the window into a given log file