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 );
83 this->SetBackgroundColour(
m_execPanel->GetBackgroundColour());
94 wxFileName fname(scriptFile);
95 if ( !fname.FileExists() ) {
96 wxLogError( _(
"Could not open project file:") + scriptFile);
101 wxFileName::SplitPath(scriptFile, &pathToPTO, NULL, NULL);
102 pathToPTO.Append(wxFileName::GetPathSeparator());
106 wxLogError( wxString::Format(_(
"could not open script: %s"), scriptFile.c_str()) );
116 wxLogError(wxString::Format(_(
"Project %s does not contain any active images."), scriptFile.c_str()));
120 if (ptoVersion < 2) {
123 wxConfig* config =
new wxConfig(wxT(
"hugin"));
124 wxConfigBase::Set(config);
132 wxLogError( wxString::Format(_(
"error while parsing panotools script: %s"), scriptFile.c_str()) );
137 if (!userDefinedOutput.IsEmpty())
139 wxFileInputStream input(userDefinedOutput);
142 wxLogError(wxString::Format(_(
"Can't open user defined output sequence \"%s\"."), userDefinedOutput.c_str()));
145 wxFileConfig settings(input);
147 long supportsCroppedOutput;
148 settings.Read(wxT(
"/General/SupportsCroppedTIFF"), &supportsCroppedOutput, 1l);
149 if (supportsCroppedOutput != 1)
160 DEBUG_DEBUG(
"output file specified is " << (
const char *)outname.mb_str(wxConvLocal));
164 wxFileName outputPrefix(outname);
165 outputPrefix.MakeAbsolute();
166 outpath = outputPrefix.GetPath();
167 basename = outputPrefix.GetFullName();
169 wxString tempDir= wxConfigBase::Get()->Read(wxT(
"tempDir"),wxT(
""));
170 if(!tempDir.IsEmpty())
171 if(tempDir.Last()!=wxFileName::GetPathSeparator())
172 tempDir.Append(wxFileName::GetPathSeparator());
176 m_currentPTOfn = wxFileName::CreateTempFileName(tempDir+wxT(
"huginpto_"));
178 wxLogError(_(
"Could not create temporary file"));
187 wxFileName::SetCwd(outpath);
188 const wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
189 wxArrayString outputFiles;
193 std::stringstream errors;
194 if (userDefinedOutput.IsEmpty())
202 if (commands->empty())
204 wxMessageBox(_(
"Queue is empty. This should never happen.") +
"\n\n" + wxString(errors.str()), _(
"Error during stitching"), wxICON_ERROR | wxOK);
208 wxString overwrittenFiles;
211 for (
size_t i = 0; i < outputFiles.size(); i++)
213 wxString fn(outputFiles[i]);
214 if (wxFile::Exists(fn))
216 overwrittenFiles.Append(fn + wxT(
" "));
220 if (!overwrittenFiles.IsEmpty())
222 int overwriteret = wxMessageBox(_(
"Overwrite existing images?\n\n") + overwrittenFiles, _(
"Overwrite existing images"), wxYES_NO | wxICON_QUESTION);
224 if (overwriteret != wxYES) {
231 if (!statusText.empty())
237 wxMessageBox(wxString::Format(_(
"Error while stitching project\n%s"), scriptFile.c_str()),
238 _(
"Error during stitching"), wxICON_ERROR | wxOK );
240 }
catch (std::exception & e)
242 std::cerr <<
"caught exception: " << e.what() << std::endl;
243 wxMessageBox(wxString(e.what(), wxConvLocal),
244 _(
"Error during stitching"), wxICON_ERROR | wxOK );
252 wxFileName fname(scriptFile);
253 if ( !fname.FileExists() ) {
254 wxLogError( _(
"Could not open project file:") + scriptFile);
258 if (!userDefinedAssistant.IsEmpty())
260 wxFileInputStream input(userDefinedAssistant);
263 wxLogError(wxString::Format(_(
"Can't open user defined output sequence \"%s\"."), userDefinedAssistant.c_str()));
270 wxFileName::SplitPath(scriptFile, &pathToPTO, NULL, NULL);
271 pathToPTO.Append(wxFileName::GetPathSeparator());
277 wxLogError( wxString::Format(_(
"could not open script: %s"), scriptFile.c_str()));
285 wxLogError(wxString::Format(_(
"error while parsing panotools script: %s"), scriptFile.c_str()));
291 wxString tempDir= wxConfigBase::Get()->Read(wxT(
"tempDir"),wxT(
""));
292 if (!tempDir.IsEmpty())
294 if (tempDir.Last() != wxFileName::GetPathSeparator())
296 tempDir.Append(wxFileName::GetPathSeparator());
302 fname.Normalize(wxPATH_NORM_ABSOLUTE | wxPATH_NORM_DOTS | wxPATH_NORM_TILDE | wxPATH_NORM_SHORTCUT);
303 const wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
305 if (userDefinedAssistant.IsEmpty())
311 std::stringstream errors;
314 if (commands->empty())
316 wxMessageBox(_(
"Queue is empty. This should never happen."), _(
"Error during running assistant"), wxICON_ERROR | wxOK);
321 wxMessageBox(wxString::Format(_(
"Error while running assistant\n%s"), scriptFile.c_str()),
322 _(
"Error during running assistant"), wxICON_ERROR | wxOK );
325 catch (std::exception & e)
327 std::cerr <<
"caught exception: " << e.what() << std::endl;
328 wxMessageBox(wxString(e.what(), wxConvLocal),
329 _(
"Error during running assistant"), wxICON_ERROR | wxOK );
360 if (this->GetParent())
362 event.SetEventObject(
this );
364 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