27 #include <hugin_config.h>
31 #include <wx/wfstream.h>
32 #if defined __WXMSW__ || defined UNIX_SELF_CONTAINED_BUNDLE
33 #include <wx/stdpaths.h>
51 #include <wx/cmdline.h>
56 RunStitchFrame(wxWindow * parent,
const wxString& title,
const wxPoint& pos,
const wxSize& size);
58 bool StitchProject(
const wxString& scriptFile,
const wxString& outname,
const wxString& userDefinedOutput,
bool doDeleteOnExit);
60 void OnQuit(wxCommandEvent& event);
61 void OnAbout(wxCommandEvent& event);
74 void OnCancel(wxCommandEvent & event);
93 EVT_COMMAND(wxID_ANY, EVT_QUEUE_PROGRESS,
RunStitchFrame::OnProgress)
97 : wxFrame(parent, -1, title, pos, size), m_isStitching(false)
99 wxBoxSizer * topsizer =
new wxBoxSizer( wxVERTICAL );
102 topsizer->Add(m_stitchPanel, 1, wxEXPAND | wxALL, 2);
104 wxBoxSizer* bottomsizer =
new wxBoxSizer(wxHORIZONTAL);
105 m_progress =
new wxGauge(
this, wxID_ANY, 100, wxDefaultPosition, wxDefaultSize, wxGA_HORIZONTAL | wxGA_PROGRESS);
106 bottomsizer->Add(m_progress, 1, wxEXPAND | wxALL, 10);
107 bottomsizer->Add(
new wxButton(
this, wxID_CANCEL, _(
"Cancel")),
109 topsizer->Add(bottomsizer, 0, wxEXPAND);
113 this->SetBackgroundColour(m_stitchPanel->GetBackgroundColour());
116 SetSizer( topsizer );
118 m_deleteOnExit=
false;
123 wxMessageBox(wxString::Format(_(
"HuginStitchProject. Application to stitch hugin project files.\n Version: %s"),
hugin_utils::GetHuginVersion().c_str()),
124 wxT(
"About hugin_stitch_project"),
125 wxOK | wxICON_INFORMATION );
156 if (event.GetExitCode() != 0)
158 if(wxMessageBox(_(
"Error during stitching\nPlease report the complete text to the bug tracker on https://bugs.launchpad.net/hugin.\n\nDo you want to save the log file?"),
159 _(
"Error during stitching"), wxICON_ERROR | wxYES_NO )==wxYES)
161 wxString defaultdir = wxConfigBase::Get()->Read(wxT(
"/actualPath"),wxT(
""));
162 wxFileDialog dlg(
this,
163 _(
"Specify log file"),
165 _(
"Log files (*.log)|*.log|All files (*)|*"),
166 wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition);
167 dlg.SetDirectory(wxConfigBase::Get()->Read(wxT(
"/actualPath"),wxT(
"")));
168 if (dlg.ShowModal() == wxID_OK)
170 wxConfig::Get()->Write(wxT(
"/actualPath"), dlg.GetDirectory());
186 if (event.GetInt() >= 0)
236 void MacOpenFile(
const wxString &fileName);
242 wxString m_macFileNameToOpenOnStart;
249 TIFFSetWarningHandler(0);
263 SetAppName(wxT(
"hugin"));
264 #if defined __WXGTK__
265 CheckConfigFilename();
269 setlocale(LC_ALL,
"");
271 #if defined __WXMSW__
272 int localeID = wxConfigBase::Get()->Read(wxT(
"language"), (
long) wxLANGUAGE_DEFAULT);
279 #if defined __WXMSW__
280 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
281 exePath.RemoveLastDir();
283 m_locale.AddCatalogLookupPathPrefix(exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) + wxT(
"share\\locale"));
285 #elif defined UNIX_SELF_CONTAINED_BUNDLE
288 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
289 exePath.RemoveLastDir();
290 const wxString huginRoot=exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
292 m_locale.AddCatalogLookupPathPrefix(huginRoot + wxT(
"share/locale"));
296 m_locale.AddCatalogLookupPathPrefix(wxT(INSTALL_LOCALE_DIR));
303 static const wxCmdLineEntryDesc cmdLineDesc[] =
307 { wxCMD_LINE_SWITCH,
"h",
"help",
"show this help message",
308 wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP },
309 { wxCMD_LINE_OPTION,
"o",
"output",
"output prefix" },
310 { wxCMD_LINE_SWITCH,
"d",
"delete",
"delete pto file after stitching" },
311 { wxCMD_LINE_SWITCH,
"w",
"overwrite",
"overwrite existing files" },
312 { wxCMD_LINE_OPTION,
"u",
"user-defined-output",
"use user defined output" },
313 { wxCMD_LINE_PARAM, NULL, NULL,
"<project>",
314 wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
318 wxCmdLineParser parser(cmdLineDesc, argc, argv);
320 switch ( parser.Parse() ) {
327 wxLogError(_(
"Syntax error in parameters detected, aborting."));
334 m_macFileNameToOpenOnStart = wxT(
"");
336 scriptFile = m_macFileNameToOpenOnStart;
340 ProcessSerialNumber selfPSN;
341 OSErr err = GetCurrentProcess(&selfPSN);
344 SetFrontProcess(&selfPSN);
349 wxString userDefinedOutput;
350 parser.Found(wxT(
"u"), &userDefinedOutput);
351 if (!userDefinedOutput.IsEmpty())
355 wxMessageBox(wxString::Format(_(
"Could not find the specified user output file \"%s\"."), userDefinedOutput.c_str()),
356 _(
"Error"), wxOK | wxICON_EXCLAMATION);
360 if( parser.GetParamCount() == 0 && wxIsEmpty(scriptFile))
362 wxString defaultdir = wxConfigBase::Get()->Read(wxT(
"/actualPath"),wxT(
""));
364 _(
"Specify project source project file"),
366 _(
"Project files (*.pto)|*.pto|All files (*)|*"),
367 wxFD_OPEN, wxDefaultPosition);
369 dlg.SetDirectory(wxConfigBase::Get()->Read(wxT(
"/actualPath"),wxT(
"")));
370 if (dlg.ShowModal() == wxID_OK) {
371 wxConfig::Get()->Write(wxT(
"/actualPath"), dlg.GetDirectory());
372 scriptFile = dlg.GetPath();
376 }
else if(wxIsEmpty(scriptFile)) {
377 scriptFile = parser.GetParam(0);
378 std::cout <<
"********************* script file: " << (
const char *)scriptFile.mb_str(wxConvLocal) << std::endl;
379 if (! wxIsAbsolutePath(scriptFile)) {
380 scriptFile = wxGetCwd() + wxFileName::GetPathSeparator() + scriptFile;
384 std::cout <<
"input file is " << (
const char *)scriptFile.mb_str(wxConvLocal) << std::endl;
388 if ( !parser.Found(wxT(
"o"), &outname) ) {
390 wxFileDialog dlg(0,_(
"Specify output prefix"),
391 wxConfigBase::Get()->Read(wxT(
"/actualPath"),wxT(
"")),
393 wxFD_SAVE, wxDefaultPosition);
394 dlg.SetDirectory(wxConfigBase::Get()->Read(wxT(
"/actualPath"),wxT(
"")));
395 if (dlg.ShowModal() == wxID_OK) {
398 wxMessageBox(wxString::Format(_(
"The given filename contains one of the following invalid characters: %s\nHugin can not work with this filename. Please enter a valid filename."),
getInvalidCharacters().c_str()),
399 _(
"Error"),wxOK | wxICON_EXCLAMATION);
400 if(dlg.ShowModal()!=wxID_OK)
403 wxFileName prefix(dlg.GetPath());
404 while (!prefix.IsDirWritable())
406 wxMessageBox(wxString::Format(_(
"You have no permissions to write in folder \"%s\".\nPlease select another folder for the final output."), prefix.GetPath().c_str()),
408 wxT(
"Hugin_stitch_project"),
412 wxOK | wxICON_INFORMATION);
413 if (dlg.ShowModal() != wxID_OK)
417 prefix = dlg.GetPath();
420 wxConfig::Get()->Write(wxT(
"/actualPath"), dlg.GetDirectory());
421 outname = dlg.GetPath();
429 wxFileName outfn(outname);
430 wxString ext = outfn.GetExt();
432 if (ext.CmpNoCase(wxT(
"jpg")) == 0 || ext.CmpNoCase(wxT(
"jpeg")) == 0||
433 ext.CmpNoCase(wxT(
"tif")) == 0|| ext.CmpNoCase(wxT(
"tiff")) == 0 ||
434 ext.CmpNoCase(wxT(
"png")) == 0 || ext.CmpNoCase(wxT(
"exr")) == 0 ||
435 ext.CmpNoCase(wxT(
"pnm")) == 0 || ext.CmpNoCase(wxT(
"hdr")))
438 outname = outfn.GetFullPath();
443 SetTopWindow( frame );
445 wxFileName basename(scriptFile);
446 frame->SetTitle(wxString::Format(_(
"%s - Stitching"), basename.GetName().c_str()));
448 bool n = frame->
StitchProject(scriptFile, outname, userDefinedOutput, parser.Found(wxT(
"d")));
462 void stitchApp::MacOpenFile(
const wxString &fileName)
464 m_macFileNameToOpenOnStart = fileName;
RunStitchFrame(wxWindow *parent, const wxString &title, const wxPoint &pos, const wxSize &size)
bool FileExists(const std::string &filename)
checks if file exists
void OnCancel(wxCommandEvent &event)
Cancels project execution - kills process.
void OnProcessTerminate(wxProcessEvent &event)
RunStitchPanel * m_stitchPanel
bool StitchProject(const wxString &scriptFile, const wxString &outname, const wxString &userDefinedOutput=wxEmptyString)
include file for the hugin project
virtual ~stitchApp()
dtor.
bool StitchProject(wxString scriptFile, wxString outname, wxString userDefinedOutput=wxEmptyString)
Starts stitching of project file.
bool SaveLog(const wxString &filename)
save the content of the window into a given log file
void OnAbout(wxCommandEvent &event)
void OnQuit(wxCommandEvent &event)
The application class for hugin_stitch_project.
include file for the hugin project
void SetOverwrite(bool over=true)
std::string GetHuginVersion()
return a string with version numbers
functions for interaction with the hugin configuration file
virtual bool OnInit()
pseudo constructor.
virtual int OnExit()
just for testing purposes
void SetOverwrite(bool doOverwrite)
sets, if existing output file should be automatic overwritten
void OnProgress(wxCommandEvent &event)