25 #include <hugin_config.h>
29 #include <wx/wfstream.h>
30 #include <wx/stdpaths.h>
34 #include <vigra/error.hxx>
78 wxBoxSizer * topsizer =
new wxBoxSizer( wxVERTICAL );
90 wxFileName fname(scriptFile);
91 if ( !fname.FileExists() ) {
92 wxLogError( _(
"Could not open project file:") + scriptFile);
97 wxFileName::SplitPath(scriptFile, &pathToPTO, NULL, NULL);
98 pathToPTO.Append(wxFileName::GetPathSeparator());
102 wxLogError( wxString::Format(_(
"could not open script: %s"), scriptFile.c_str()) );
112 wxLogError(wxString::Format(_(
"Project %s does not contain any active images."), scriptFile.c_str()));
116 if (ptoVersion < 2) {
119 wxConfig* config =
new wxConfig(wxT(
"hugin"));
120 wxConfigBase::Set(config);
128 wxLogError( wxString::Format(_(
"error while parsing panotools script: %s"), scriptFile.c_str()) );
133 if (!userDefinedOutput.IsEmpty())
135 wxFileInputStream input(userDefinedOutput);
138 wxLogError(wxString::Format(_(
"Can't open user defined output sequence \"%s\"."), userDefinedOutput.c_str()));
141 wxFileConfig settings(input);
143 long supportsCroppedOutput;
144 settings.Read(wxT(
"/General/SupportsCroppedTIFF"), &supportsCroppedOutput, 1l);
145 if (supportsCroppedOutput != 1)
156 DEBUG_DEBUG(
"output file specified is " << (
const char *)outname.mb_str(wxConvLocal));
160 wxFileName outputPrefix(outname);
161 outputPrefix.MakeAbsolute();
162 outpath = outputPrefix.GetPath();
163 basename = outputPrefix.GetFullName();
165 wxString tempDir= wxConfigBase::Get()->Read(wxT(
"tempDir"),wxT(
""));
166 if(!tempDir.IsEmpty())
167 if(tempDir.Last()!=wxFileName::GetPathSeparator())
168 tempDir.Append(wxFileName::GetPathSeparator());
172 m_currentPTOfn = wxFileName::CreateTempFileName(tempDir+wxT(
"huginpto_"));
174 wxLogError(_(
"Could not create temporary file"));
183 wxFileName::SetCwd(outpath);
184 const wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
185 wxArrayString outputFiles;
189 std::stringstream errors;
190 if (userDefinedOutput.IsEmpty())
198 if (commands->empty())
200 wxMessageBox(_(
"Queue is empty. This should never happen.") +
"\n\n" + wxString(errors.str()), _(
"Error during stitching"), wxICON_ERROR | wxOK);
204 wxString overwrittenFiles;
207 for (
size_t i = 0; i < outputFiles.size(); i++)
209 wxString fn(outputFiles[i]);
210 if (wxFile::Exists(fn))
212 overwrittenFiles.Append(fn + wxT(
" "));
216 if (!overwrittenFiles.IsEmpty())
218 int overwriteret = wxMessageBox(_(
"Overwrite existing images?\n\n") + overwrittenFiles, _(
"Overwrite existing images"), wxYES_NO | wxICON_QUESTION);
220 if (overwriteret != wxYES) {
227 if (!statusText.empty())
233 wxMessageBox(wxString::Format(_(
"Error while stitching project\n%s"), scriptFile.c_str()),
234 _(
"Error during stitching"), wxICON_ERROR | wxOK );
236 }
catch (std::exception & e)
238 std::cerr <<
"caught exception: " << e.what() << std::endl;
239 wxMessageBox(wxString(e.what(), wxConvLocal),
240 _(
"Error during stitching"), wxICON_ERROR | wxOK );
248 wxFileName fname(scriptFile);
249 if ( !fname.FileExists() ) {
250 wxLogError( _(
"Could not open project file:") + scriptFile);
254 if (!userDefinedAssistant.IsEmpty())
256 wxFileInputStream input(userDefinedAssistant);
259 wxLogError(wxString::Format(_(
"Can't open user defined output sequence \"%s\"."), userDefinedAssistant.c_str()));
266 wxFileName::SplitPath(scriptFile, &pathToPTO, NULL, NULL);
267 pathToPTO.Append(wxFileName::GetPathSeparator());
273 wxLogError( wxString::Format(_(
"could not open script: %s"), scriptFile.c_str()));
281 wxLogError(wxString::Format(_(
"error while parsing panotools script: %s"), scriptFile.c_str()));
287 wxString tempDir= wxConfigBase::Get()->Read(wxT(
"tempDir"),wxT(
""));
288 if (!tempDir.IsEmpty())
290 if (tempDir.Last() != wxFileName::GetPathSeparator())
292 tempDir.Append(wxFileName::GetPathSeparator());
298 fname.Normalize(wxPATH_NORM_ABSOLUTE | wxPATH_NORM_DOTS | wxPATH_NORM_TILDE | wxPATH_NORM_SHORTCUT);
299 const wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
301 if (userDefinedAssistant.IsEmpty())
307 std::stringstream errors;
310 if (commands->empty())
312 wxMessageBox(_(
"Queue is empty. This should never happen."), _(
"Error during running assistant"), wxICON_ERROR | wxOK);
317 wxMessageBox(wxString::Format(_(
"Error while running assistant\n%s"), scriptFile.c_str()),
318 _(
"Error during running assistant"), wxICON_ERROR | wxOK );
321 catch (std::exception & e)
323 std::cerr <<
"caught exception: " << e.what() << std::endl;
324 wxMessageBox(wxString(e.what(), wxConvLocal),
325 _(
"Error during running assistant"), wxICON_ERROR | wxOK );
356 if (this->GetParent())
358 event.SetEventObject(
this );
360 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
RunStitchPanel(wxWindow *parent)
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