27 #include <hugin_config.h>
31 #include <wx/wfstream.h>
32 #if defined __WXMSW__ || defined UNIX_SELF_CONTAINED_BUNDLE
33 #include <wx/stdpaths.h>
52 #include <wx/cmdline.h>
57 RunStitchFrame(wxWindow * parent,
const wxString& title,
const wxPoint& pos,
const wxSize& size);
59 bool StitchProject(
const wxString& scriptFile,
const wxString& outname,
const wxString& userDefinedOutput,
bool doDeleteOnExit);
61 void OnQuit(wxCommandEvent& event);
62 void OnAbout(wxCommandEvent& event);
75 void OnCancel(wxCommandEvent & event);
88 : wxFrame(parent, -1, title, pos, size), m_isStitching(false)
90 wxBoxSizer * topsizer =
new wxBoxSizer( wxVERTICAL );
93 topsizer->Add(m_stitchPanel, 1, wxEXPAND | wxALL, 2);
95 wxBoxSizer* bottomsizer =
new wxBoxSizer(wxHORIZONTAL);
96 m_progress =
new wxGauge(
this, wxID_ANY, 100, wxDefaultPosition, wxDefaultSize, wxGA_HORIZONTAL | wxGA_PROGRESS);
97 bottomsizer->Add(m_progress, 1, wxEXPAND | wxALL, 10);
98 bottomsizer->Add(
new wxButton(
this, wxID_CANCEL, _(
"Cancel")),
100 topsizer->Add(bottomsizer, 0, wxEXPAND);
104 this->SetBackgroundColour(m_stitchPanel->GetBackgroundColour());
108 wxInitAllImageHandlers();
109 #if defined __WXMSW__
110 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
111 exePath.RemoveLastDir();
112 wxIconBundle myIcons(exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) +
"share\\hugin\\xrc\\data\\hugin.ico", wxBITMAP_TYPE_ICO);
116 #if defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
118 wxString exec_path = MacGetPathToBundledResourceFile(CFSTR(
"xrc"));
119 if (!exec_path.IsEmpty())
121 xrcPrefix = exec_path +
"/";
125 hugin_utils::HuginMessageBox(_(
"xrc directory not found in bundle"), _(
"Hugin_stitch_project"), wxOK | wxICON_ERROR, wxGetActiveWindow());
129 #elif defined UNIX_SELF_CONTAINED_BUNDLE
132 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
133 exePath.RemoveLastDir();
134 const wxString huginRoot(exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));
135 xrcPrefix = huginRoot +
"share/hugin/xrc/";
139 xrcPrefix = INSTALL_XRC_DIR;
141 wxIcon myIcon(xrcPrefix +
"data/hugin.png", wxBITMAP_TYPE_PNG);
145 SetSizer( topsizer );
147 m_deleteOnExit=
false;
160 _(
"Hugin_stitch_project"), wxOK | wxICON_INFORMATION,
this);
191 if (event.GetExitCode() != 0)
193 if (
hugin_utils::HuginMessageBox(_(
"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?"),
194 _(
"Hugin_stitch_project"), wxICON_ERROR | wxYES_NO,
this) == wxYES)
196 wxString defaultdir = wxConfigBase::Get()->Read(
"/actualPath",wxEmptyString);
197 wxFileDialog dlg(
this,
198 _(
"Specify log file"),
199 defaultdir, wxEmptyString,
200 _(
"Log files (*.log)|*.log|All files (*)|*"),
201 wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition);
202 dlg.SetDirectory(wxConfigBase::Get()->Read(
"/actualPath",wxEmptyString));
203 if (dlg.ShowModal() == wxID_OK)
205 wxConfig::Get()->Write(
"/actualPath", dlg.GetDirectory());
221 if (event.GetInt() >= 0)
271 void MacOpenFile(
const wxString &fileName);
277 wxString m_macFileNameToOpenOnStart;
284 TIFFSetWarningHandler(0);
299 #if defined __WXMSW__ && wxCHECK_VERSION(3,3,0)
301 SetAppearance(Appearance::System);
303 #if defined __WXGTK__
304 CheckConfigFilename();
308 setlocale(LC_ALL,
"");
310 #if defined __WXMSW__
311 int localeID = wxConfigBase::Get()->Read(
"language", (
long) wxLANGUAGE_DEFAULT);
318 #if defined __WXMSW__
319 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
320 exePath.RemoveLastDir();
322 m_locale.AddCatalogLookupPathPrefix(exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) +
"share\\locale");
324 #elif defined UNIX_SELF_CONTAINED_BUNDLE
327 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
328 exePath.RemoveLastDir();
329 const wxString huginRoot=exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
331 m_locale.AddCatalogLookupPathPrefix(huginRoot +
"share/locale");
335 m_locale.AddCatalogLookupPathPrefix(INSTALL_LOCALE_DIR);
342 static const wxCmdLineEntryDesc cmdLineDesc[] =
346 { wxCMD_LINE_SWITCH,
"h",
"help",
"show this help message",
347 wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP },
348 { wxCMD_LINE_OPTION,
"o",
"output",
"output prefix" },
349 { wxCMD_LINE_SWITCH,
"d",
"delete",
"delete pto file after stitching" },
350 { wxCMD_LINE_SWITCH,
"w",
"overwrite",
"overwrite existing files" },
351 { wxCMD_LINE_OPTION,
"u",
"user-defined-output",
"use user defined output" },
352 { wxCMD_LINE_PARAM, NULL, NULL,
"<project>",
353 wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
357 wxCmdLineParser parser(cmdLineDesc, argc, argv);
359 switch ( parser.Parse() ) {
366 wxLogError(_(
"Syntax error in parameters detected, aborting."));
373 m_macFileNameToOpenOnStart = wxEmptyString;
375 scriptFile = m_macFileNameToOpenOnStart;
379 ProcessSerialNumber selfPSN;
380 OSErr err = GetCurrentProcess(&selfPSN);
383 SetFrontProcess(&selfPSN);
388 wxString userDefinedOutput;
389 parser.Found(
"u", &userDefinedOutput);
390 if (!userDefinedOutput.IsEmpty())
395 _(
"Hugin_stitch_project"), wxOK | wxICON_EXCLAMATION, wxGetActiveWindow());
399 if( parser.GetParamCount() == 0 && wxIsEmpty(scriptFile))
401 wxString defaultdir = wxConfigBase::Get()->Read(
"/actualPath",wxEmptyString);
403 _(
"Specify project source project file"),
404 defaultdir, wxEmptyString,
405 _(
"Project files (*.pto)|*.pto|All files (*)|*"),
406 wxFD_OPEN, wxDefaultPosition);
408 dlg.SetDirectory(wxConfigBase::Get()->Read(
"/actualPath",wxEmptyString));
409 if (dlg.ShowModal() == wxID_OK) {
410 wxConfig::Get()->Write(
"/actualPath", dlg.GetDirectory());
411 scriptFile = dlg.GetPath();
415 }
else if(wxIsEmpty(scriptFile)) {
416 scriptFile = parser.GetParam(0);
417 std::cout <<
"********************* script file: " << (
const char *)scriptFile.mb_str(wxConvLocal) << std::endl;
418 if (! wxIsAbsolutePath(scriptFile)) {
419 scriptFile = wxGetCwd() + wxFileName::GetPathSeparator() + scriptFile;
423 std::cout <<
"input file is " << (
const char *)scriptFile.mb_str(wxConvLocal) << std::endl;
427 if ( !parser.Found(
"o", &outname) ) {
429 wxFileDialog dlg(0,_(
"Specify output prefix"),
430 wxConfigBase::Get()->Read(
"/actualPath",wxEmptyString),
431 wxEmptyString, wxEmptyString,
432 wxFD_SAVE, wxDefaultPosition);
433 dlg.SetDirectory(wxConfigBase::Get()->Read(
"/actualPath",wxEmptyString));
434 if (dlg.ShowModal() == wxID_OK) {
438 _(
"Hugin_stitch_project"), wxOK | wxICON_EXCLAMATION, wxGetActiveWindow());
439 if(dlg.ShowModal()!=wxID_OK)
442 wxFileName prefix(dlg.GetPath());
443 while (!prefix.IsDirWritable())
445 hugin_utils::HuginMessageBox(wxString::Format(_(
"You have no permissions to write in folder \"%s\".\nPlease select another folder for the final output."), prefix.GetPath().c_str()),
446 _(
"Hugin_stitch_project"), wxOK | wxICON_INFORMATION, wxGetActiveWindow());
447 if (dlg.ShowModal() != wxID_OK)
451 prefix = dlg.GetPath();
454 wxConfig::Get()->Write(
"/actualPath", dlg.GetDirectory());
455 outname = dlg.GetPath();
463 wxFileName outfn(outname);
464 wxString ext = outfn.GetExt();
466 if (ext.CmpNoCase(
"jpg") == 0 || ext.CmpNoCase(
"jpeg") == 0||
467 ext.CmpNoCase(
"tif") == 0|| ext.CmpNoCase(
"tiff") == 0 ||
468 ext.CmpNoCase(
"png") == 0 || ext.CmpNoCase(
"exr") == 0 ||
469 ext.CmpNoCase(
"pnm") == 0 || ext.CmpNoCase(
"hdr"))
472 outname = outfn.GetFullPath();
477 SetTopWindow( frame );
479 wxFileName basename(scriptFile);
480 frame->SetTitle(wxString::Format(_(
"%s - Stitching"), basename.GetName().c_str()));
482 bool n = frame->
StitchProject(scriptFile, outname, userDefinedOutput, parser.Found(
"d"));
496 void stitchApp::MacOpenFile(
const wxString &fileName)
498 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
int HuginMessageBox(const wxString &message, const wxString &caption, int style, wxWindow *parent)
void OnProgress(wxCommandEvent &event)