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 #if wxCHECK_VERSION(3,1,0)
106 m_progress =
new wxGauge(
this, wxID_ANY, 100, wxDefaultPosition, wxDefaultSize, wxGA_HORIZONTAL | wxGA_PROGRESS);
108 m_progress =
new wxGauge(
this, wxID_ANY, 100, wxDefaultPosition, wxDefaultSize, wxGA_HORIZONTAL);
110 bottomsizer->Add(m_progress, 1, wxEXPAND | wxALL, 10);
111 bottomsizer->Add(
new wxButton(
this, wxID_CANCEL, _(
"Cancel")),
113 topsizer->Add(bottomsizer, 0, wxEXPAND);
117 this->SetBackgroundColour(m_stitchPanel->GetBackgroundColour());
120 SetSizer( topsizer );
122 m_deleteOnExit=
false;
127 wxMessageBox(wxString::Format(_(
"HuginStitchProject. Application to stitch hugin project files.\n Version: %s"),
hugin_utils::GetHuginVersion().c_str()),
128 wxT(
"About hugin_stitch_project"),
129 wxOK | wxICON_INFORMATION );
160 if (event.GetExitCode() != 0)
162 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?"),
163 _(
"Error during stitching"), wxICON_ERROR | wxYES_NO )==wxYES)
165 wxString defaultdir = wxConfigBase::Get()->Read(wxT(
"/actualPath"),wxT(
""));
166 wxFileDialog dlg(
this,
167 _(
"Specify log file"),
169 _(
"Log files (*.log)|*.log|All files (*)|*"),
170 wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition);
171 dlg.SetDirectory(wxConfigBase::Get()->Read(wxT(
"/actualPath"),wxT(
"")));
172 if (dlg.ShowModal() == wxID_OK)
174 wxConfig::Get()->Write(wxT(
"/actualPath"), dlg.GetDirectory());
190 if (event.GetInt() >= 0)
240 void MacOpenFile(
const wxString &fileName);
246 wxString m_macFileNameToOpenOnStart;
253 TIFFSetWarningHandler(0);
267 SetAppName(wxT(
"hugin"));
268 #if defined __WXGTK__ && wxCHECK_VERSION(3,1,1)
269 CheckConfigFilename();
273 setlocale(LC_ALL,
"");
275 #if defined __WXMSW__
276 int localeID = wxConfigBase::Get()->Read(wxT(
"language"), (
long) wxLANGUAGE_DEFAULT);
283 #if defined __WXMSW__
284 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
285 exePath.RemoveLastDir();
287 m_locale.AddCatalogLookupPathPrefix(exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) + wxT(
"share\\locale"));
289 #elif defined UNIX_SELF_CONTAINED_BUNDLE
292 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
293 exePath.RemoveLastDir();
294 const wxString huginRoot=exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
296 m_locale.AddCatalogLookupPathPrefix(huginRoot + wxT(
"share/locale"));
300 m_locale.AddCatalogLookupPathPrefix(wxT(INSTALL_LOCALE_DIR));
307 static const wxCmdLineEntryDesc cmdLineDesc[] =
311 { wxCMD_LINE_SWITCH,
"h",
"help",
"show this help message",
312 wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP },
313 { wxCMD_LINE_OPTION,
"o",
"output",
"output prefix" },
314 { wxCMD_LINE_SWITCH,
"d",
"delete",
"delete pto file after stitching" },
315 { wxCMD_LINE_SWITCH,
"w",
"overwrite",
"overwrite existing files" },
316 { wxCMD_LINE_OPTION,
"u",
"user-defined-output",
"use user defined output" },
317 { wxCMD_LINE_PARAM, NULL, NULL,
"<project>",
318 wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
322 wxCmdLineParser parser(cmdLineDesc, argc, argv);
324 switch ( parser.Parse() ) {
331 wxLogError(_(
"Syntax error in parameters detected, aborting."));
338 m_macFileNameToOpenOnStart = wxT(
"");
340 scriptFile = m_macFileNameToOpenOnStart;
344 ProcessSerialNumber selfPSN;
345 OSErr err = GetCurrentProcess(&selfPSN);
348 SetFrontProcess(&selfPSN);
353 wxString userDefinedOutput;
354 parser.Found(wxT(
"u"), &userDefinedOutput);
355 if (!userDefinedOutput.IsEmpty())
359 wxMessageBox(wxString::Format(_(
"Could not find the specified user output file \"%s\"."), userDefinedOutput.c_str()),
360 _(
"Error"), wxOK | wxICON_EXCLAMATION);
364 if( parser.GetParamCount() == 0 && wxIsEmpty(scriptFile))
366 wxString defaultdir = wxConfigBase::Get()->Read(wxT(
"/actualPath"),wxT(
""));
368 _(
"Specify project source project file"),
370 _(
"Project files (*.pto)|*.pto|All files (*)|*"),
371 wxFD_OPEN, wxDefaultPosition);
373 dlg.SetDirectory(wxConfigBase::Get()->Read(wxT(
"/actualPath"),wxT(
"")));
374 if (dlg.ShowModal() == wxID_OK) {
375 wxConfig::Get()->Write(wxT(
"/actualPath"), dlg.GetDirectory());
376 scriptFile = dlg.GetPath();
380 }
else if(wxIsEmpty(scriptFile)) {
381 scriptFile = parser.GetParam(0);
382 std::cout <<
"********************* script file: " << (
const char *)scriptFile.mb_str(wxConvLocal) << std::endl;
383 if (! wxIsAbsolutePath(scriptFile)) {
384 scriptFile = wxGetCwd() + wxFileName::GetPathSeparator() + scriptFile;
388 std::cout <<
"input file is " << (
const char *)scriptFile.mb_str(wxConvLocal) << std::endl;
392 if ( !parser.Found(wxT(
"o"), &outname) ) {
394 wxFileDialog dlg(0,_(
"Specify output prefix"),
395 wxConfigBase::Get()->Read(wxT(
"/actualPath"),wxT(
"")),
397 wxFD_SAVE, wxDefaultPosition);
398 dlg.SetDirectory(wxConfigBase::Get()->Read(wxT(
"/actualPath"),wxT(
"")));
399 if (dlg.ShowModal() == wxID_OK) {
402 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()),
403 _(
"Error"),wxOK | wxICON_EXCLAMATION);
404 if(dlg.ShowModal()!=wxID_OK)
407 wxFileName prefix(dlg.GetPath());
408 while (!prefix.IsDirWritable())
410 wxMessageBox(wxString::Format(_(
"You have no permissions to write in folder \"%s\".\nPlease select another folder for the final output."), prefix.GetPath().c_str()),
412 wxT(
"Hugin_stitch_project"),
416 wxOK | wxICON_INFORMATION);
417 if (dlg.ShowModal() != wxID_OK)
421 prefix = dlg.GetPath();
424 wxConfig::Get()->Write(wxT(
"/actualPath"), dlg.GetDirectory());
425 outname = dlg.GetPath();
433 wxFileName outfn(outname);
434 wxString ext = outfn.GetExt();
436 if (ext.CmpNoCase(wxT(
"jpg")) == 0 || ext.CmpNoCase(wxT(
"jpeg")) == 0||
437 ext.CmpNoCase(wxT(
"tif")) == 0|| ext.CmpNoCase(wxT(
"tiff")) == 0 ||
438 ext.CmpNoCase(wxT(
"png")) == 0 || ext.CmpNoCase(wxT(
"exr")) == 0 ||
439 ext.CmpNoCase(wxT(
"pnm")) == 0 || ext.CmpNoCase(wxT(
"hdr")))
442 outname = outfn.GetFullPath();
447 SetTopWindow( frame );
449 wxFileName basename(scriptFile);
450 frame->SetTitle(wxString::Format(_(
"%s - Stitching"), basename.GetName().c_str()));
452 bool n = frame->
StitchProject(scriptFile, outname, userDefinedOutput, parser.Found(wxT(
"d")));
466 void stitchApp::MacOpenFile(
const wxString &fileName)
468 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)