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());
128 #elif defined UNIX_SELF_CONTAINED_BUNDLE
131 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
132 exePath.RemoveLastDir();
133 const wxString huginRoot(exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));
134 xrcPrefix = huginRoot +
"share/hugin/xrc/";
138 xrcPrefix = INSTALL_XRC_DIR;
140 if (!xrcPrefix.IsEmpty())
142 wxIcon myIcon(xrcPrefix +
"data/hugin.png", wxBITMAP_TYPE_PNG);
147 SetSizer( topsizer );
149 m_deleteOnExit=
false;
162 _(
"Hugin_stitch_project"), wxOK | wxICON_INFORMATION,
this);
193 if (event.GetExitCode() != 0)
195 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?"),
196 _(
"Hugin_stitch_project"), wxICON_ERROR | wxYES_NO,
this) == wxYES)
198 wxString defaultdir = wxConfigBase::Get()->Read(
"/actualPath",wxEmptyString);
199 wxFileDialog dlg(
this,
200 _(
"Specify log file"),
201 defaultdir, wxEmptyString,
202 _(
"Log files (*.log)|*.log|All files (*)|*"),
203 wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition);
204 dlg.SetDirectory(wxConfigBase::Get()->Read(
"/actualPath",wxEmptyString));
205 if (dlg.ShowModal() == wxID_OK)
207 wxConfig::Get()->Write(
"/actualPath", dlg.GetDirectory());
223 if (event.GetInt() >= 0)
273 void MacOpenFile(
const wxString &fileName);
279 wxString m_macFileNameToOpenOnStart;
286 TIFFSetWarningHandler(0);
301 #if defined __WXMSW__ && wxCHECK_VERSION(3,3,0)
303 SetAppearance(Appearance::System);
305 #if defined __WXGTK__
306 CheckConfigFilename();
310 setlocale(LC_ALL,
"");
312 #if defined __WXMSW__
313 int localeID = wxConfigBase::Get()->Read(
"language", (
long) wxLANGUAGE_DEFAULT);
320 #if defined __WXMSW__
321 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
322 exePath.RemoveLastDir();
324 m_locale.AddCatalogLookupPathPrefix(exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) +
"share\\locale");
326 #elif defined UNIX_SELF_CONTAINED_BUNDLE
329 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
330 exePath.RemoveLastDir();
331 const wxString huginRoot=exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
333 m_locale.AddCatalogLookupPathPrefix(huginRoot +
"share/locale");
337 m_locale.AddCatalogLookupPathPrefix(INSTALL_LOCALE_DIR);
344 static const wxCmdLineEntryDesc cmdLineDesc[] =
348 { wxCMD_LINE_SWITCH,
"h",
"help",
"show this help message",
349 wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP },
350 { wxCMD_LINE_OPTION,
"o",
"output",
"output prefix" },
351 { wxCMD_LINE_SWITCH,
"d",
"delete",
"delete pto file after stitching" },
352 { wxCMD_LINE_SWITCH,
"w",
"overwrite",
"overwrite existing files" },
353 { wxCMD_LINE_OPTION,
"u",
"user-defined-output",
"use user defined output" },
354 { wxCMD_LINE_PARAM, NULL, NULL,
"<project>",
355 wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
359 wxCmdLineParser parser(cmdLineDesc, argc, argv);
361 switch ( parser.Parse() ) {
368 wxLogError(_(
"Syntax error in parameters detected, aborting."));
375 m_macFileNameToOpenOnStart = wxEmptyString;
377 scriptFile = m_macFileNameToOpenOnStart;
381 ProcessSerialNumber selfPSN;
382 OSErr err = GetCurrentProcess(&selfPSN);
385 SetFrontProcess(&selfPSN);
390 wxString userDefinedOutput;
391 parser.Found(
"u", &userDefinedOutput);
392 if (!userDefinedOutput.IsEmpty())
397 _(
"Hugin_stitch_project"), wxOK | wxICON_EXCLAMATION, wxGetActiveWindow());
401 if( parser.GetParamCount() == 0 && wxIsEmpty(scriptFile))
403 wxString defaultdir = wxConfigBase::Get()->Read(
"/actualPath",wxEmptyString);
405 _(
"Specify project source project file"),
406 defaultdir, wxEmptyString,
407 _(
"Project files (*.pto)|*.pto|All files (*)|*"),
408 wxFD_OPEN, wxDefaultPosition);
410 dlg.SetDirectory(wxConfigBase::Get()->Read(
"/actualPath",wxEmptyString));
411 if (dlg.ShowModal() == wxID_OK) {
412 wxConfig::Get()->Write(
"/actualPath", dlg.GetDirectory());
413 scriptFile = dlg.GetPath();
417 }
else if(wxIsEmpty(scriptFile)) {
418 scriptFile = parser.GetParam(0);
419 std::cout <<
"********************* script file: " << (
const char *)scriptFile.mb_str(wxConvLocal) << std::endl;
420 if (! wxIsAbsolutePath(scriptFile)) {
421 scriptFile = wxGetCwd() + wxFileName::GetPathSeparator() + scriptFile;
425 std::cout <<
"input file is " << (
const char *)scriptFile.mb_str(wxConvLocal) << std::endl;
429 if ( !parser.Found(
"o", &outname) ) {
431 wxFileDialog dlg(0,_(
"Specify output prefix"),
432 wxConfigBase::Get()->Read(
"/actualPath",wxEmptyString),
433 wxEmptyString, wxEmptyString,
434 wxFD_SAVE, wxDefaultPosition);
435 dlg.SetDirectory(wxConfigBase::Get()->Read(
"/actualPath",wxEmptyString));
436 if (dlg.ShowModal() == wxID_OK) {
440 _(
"Hugin_stitch_project"), wxOK | wxICON_EXCLAMATION, wxGetActiveWindow());
441 if(dlg.ShowModal()!=wxID_OK)
444 wxFileName prefix(dlg.GetPath());
445 while (!prefix.IsDirWritable())
447 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()),
448 _(
"Hugin_stitch_project"), wxOK | wxICON_INFORMATION, wxGetActiveWindow());
449 if (dlg.ShowModal() != wxID_OK)
453 prefix = dlg.GetPath();
456 wxConfig::Get()->Write(
"/actualPath", dlg.GetDirectory());
457 outname = dlg.GetPath();
465 wxFileName outfn(outname);
466 wxString ext = outfn.GetExt();
468 if (ext.CmpNoCase(
"jpg") == 0 || ext.CmpNoCase(
"jpeg") == 0||
469 ext.CmpNoCase(
"tif") == 0|| ext.CmpNoCase(
"tiff") == 0 ||
470 ext.CmpNoCase(
"png") == 0 || ext.CmpNoCase(
"exr") == 0 ||
471 ext.CmpNoCase(
"pnm") == 0 || ext.CmpNoCase(
"hdr"))
474 outname = outfn.GetFullPath();
479 SetTopWindow( frame );
481 wxFileName basename(scriptFile);
482 frame->SetTitle(wxString::Format(_(
"%s - Stitching"), basename.GetName().c_str()));
484 bool n = frame->
StitchProject(scriptFile, outname, userDefinedOutput, parser.Found(
"d"));
498 void stitchApp::MacOpenFile(
const wxString &fileName)
500 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)