25 #include <hugin_config.h>
29 #include <wx/wfstream.h>
30 #include <wx/stdpaths.h>
34 #include <vigra/error.hxx>
79 wxBoxSizer * topsizer =
new wxBoxSizer( wxVERTICAL );
91 wxFileName fname(scriptFile);
92 if ( !fname.FileExists() ) {
93 wxLogError( _(
"Could not open project file:") + scriptFile);
98 wxFileName::SplitPath(scriptFile, &pathToPTO, NULL, NULL);
99 pathToPTO.Append(wxFileName::GetPathSeparator());
103 wxLogError( wxString::Format(_(
"could not open script: %s"), scriptFile.c_str()) );
113 wxLogError(wxString::Format(_(
"Project %s does not contain any active images."), scriptFile.c_str()));
117 if (ptoVersion < 2) {
120 wxConfig* config =
new wxConfig(
"hugin");
121 wxConfigBase::Set(config);
129 wxLogError( wxString::Format(_(
"error while parsing panotools script: %s"), scriptFile.c_str()) );
134 if (!userDefinedOutput.IsEmpty())
136 wxFileInputStream input(userDefinedOutput);
139 wxLogError(wxString::Format(_(
"Can't open user defined output sequence \"%s\"."), userDefinedOutput.c_str()));
142 wxFileConfig settings(input);
144 long supportsCroppedOutput;
145 settings.Read(
"/General/SupportsCroppedTIFF", &supportsCroppedOutput, 1l);
146 if (supportsCroppedOutput != 1)
157 DEBUG_DEBUG(
"output file specified is " << (
const char *)outname.mb_str(wxConvLocal));
161 wxFileName outputPrefix(outname);
162 outputPrefix.MakeAbsolute();
163 outpath = outputPrefix.GetPath();
164 basename = outputPrefix.GetFullName();
166 wxString tempDir= wxConfigBase::Get()->Read(
"tempDir",wxEmptyString);
167 if(!tempDir.IsEmpty())
168 if(tempDir.Last()!=wxFileName::GetPathSeparator())
169 tempDir.Append(wxFileName::GetPathSeparator());
173 m_currentPTOfn = wxFileName::CreateTempFileName(tempDir+
"huginpto_");
175 wxLogError(_(
"Could not create temporary file"));
184 wxFileName::SetCwd(outpath);
185 const wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
186 wxArrayString outputFiles;
190 std::stringstream errors;
191 if (userDefinedOutput.IsEmpty())
199 if (commands->empty())
201 hugin_utils::HuginMessageBox(_(
"Queue is empty. This should never happen.") +
"\n\n" + wxString(errors.str()), _(
"Hugin"), wxICON_ERROR | wxOK,
this);
205 wxString overwrittenFiles;
208 for (
size_t i = 0; i < outputFiles.size(); i++)
210 wxString fn(outputFiles[i]);
211 if (wxFile::Exists(fn))
213 overwrittenFiles.Append(fn +
" ");
217 if (!overwrittenFiles.IsEmpty())
220 dlg->SetYesNoLabels(_(
"Overwrite files"), _(
"Cancel, don't overwrite files"));
221 if (dlg->ShowModal() != wxID_YES)
229 if (!statusText.empty())
236 _(
"Hugin"), wxICON_ERROR | wxOK,
this);
238 }
catch (std::exception & e)
240 std::cerr <<
"caught exception: " << e.what() << std::endl;
242 _(
"Hugin"), wxICON_ERROR | wxOK,
this);
250 wxFileName fname(scriptFile);
251 if ( !fname.FileExists() ) {
252 wxLogError( _(
"Could not open project file:") + scriptFile);
256 if (!userDefinedAssistant.IsEmpty())
258 wxFileInputStream input(userDefinedAssistant);
261 wxLogError(wxString::Format(_(
"Can't open user defined output sequence \"%s\"."), userDefinedAssistant.c_str()));
268 wxFileName::SplitPath(scriptFile, &pathToPTO, NULL, NULL);
269 pathToPTO.Append(wxFileName::GetPathSeparator());
275 wxLogError( wxString::Format(_(
"could not open script: %s"), scriptFile.c_str()));
283 wxLogError(wxString::Format(_(
"error while parsing panotools script: %s"), scriptFile.c_str()));
289 wxString tempDir= wxConfigBase::Get()->Read(
"tempDir",wxEmptyString);
290 if (!tempDir.IsEmpty())
292 if (tempDir.Last() != wxFileName::GetPathSeparator())
294 tempDir.Append(wxFileName::GetPathSeparator());
300 fname.Normalize(wxPATH_NORM_ABSOLUTE | wxPATH_NORM_DOTS | wxPATH_NORM_TILDE | wxPATH_NORM_SHORTCUT);
301 const wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
303 if (userDefinedAssistant.IsEmpty())
309 std::stringstream errors;
312 if (commands->empty())
320 _(
"Hugin"), wxICON_ERROR | wxOK,
this);
323 catch (std::exception & e)
325 std::cerr <<
"caught exception: " << e.what() << std::endl;
327 _(
"Hugin"), wxICON_ERROR | wxOK,
this);
358 if (this->GetParent())
360 event.SetEventObject(
this );
362 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
std::unique_ptr< wxMessageDialogBase > MessageDialog
int ExecQueue(HuginQueue::CommandQueue *queue)
std::string enfuseOptions
include file for the hugin project
wxArrayString m_tempFiles
MessageDialog GetMessageDialog(const wxString &message, const wxString &caption, int style, wxWindow *parent)
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...
int HuginMessageBox(const wxString &message, const wxString &caption, int style, wxWindow *parent)
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