28 #include <wx/cshelp.h>
29 #if defined __WXMSW__ || defined UNIX_SELF_CONTAINED_BUNDLE
30 #include <wx/stdpaths.h>
35 #if defined USE_GDKBACKEND_X11
39 #warning Using Hugin with hard coded GDK_BACKEND=x11
40 wxIMPLEMENT_WX_THEME_SUPPORT
43 int main(
int argc,
char **argv)
45 wxDISABLE_DEBUG_SUPPORT();
46 char backend[]=
"GDK_BACKEND=x11";
48 return wxEntry(argc, argv);
56 #if wxUSE_ON_FATAL_EXCEPTION
57 wxHandleFatalExceptions();
60 SetAppName(wxT(
"hugin"));
62 CheckConfigFilename();
66 setlocale(LC_ALL,
"");
68 int localeID = wxConfigBase::Get()->Read(wxT(
"language"), (
long) wxLANGUAGE_DEFAULT);
74 wxHelpControllerHelpProvider* provider =
new wxHelpControllerHelpProvider;
75 wxHelpProvider::Set(provider);
79 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
80 exePath.RemoveLastDir();
81 const wxString huginRoot(exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));
82 m_xrcPrefix = huginRoot + wxT(
"share\\hugin\\xrc\\");
85 m_locale.AddCatalogLookupPathPrefix(huginRoot + wxT(
"share\\locale"));
86 #elif defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
88 wxString exec_path = MacGetPathToBundledResourceFile(CFSTR(
"xrc"));
89 if(exec_path != wxT(
""))
91 m_xrcPrefix = exec_path + wxT(
"/");
95 wxMessageBox(_(
"xrc directory not found in bundle"), _(
"Fatal Error"));
101 #elif defined UNIX_SELF_CONTAINED_BUNDLE
104 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
105 exePath.RemoveLastDir();
106 const wxString huginRoot(exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));
107 m_xrcPrefix = huginRoot + wxT(
"share/hugin/xrc/");
110 m_locale.AddCatalogLookupPathPrefix(huginRoot + wxT(
"share/locale"));
114 m_xrcPrefix = wxT(INSTALL_XRC_DIR);
115 m_locale.AddCatalogLookupPathPrefix(wxT(INSTALL_LOCALE_DIR));
121 const wxString name = wxString::Format(_T(
"PTBatcherGUI-%s"), wxGetUserId().c_str());
122 m_checker =
new wxSingleInstanceChecker(name+wxT(
".lock"),wxFileName::GetTempDir());
123 bool IsFirstInstance=(!
m_checker->IsAnotherRunning());
127 if ( ! wxFile::Exists(m_xrcPrefix + wxT(
"/batch_frame.xrc")) )
129 wxMessageBox(_(
"xrc directory not found, hugin needs to be properly installed\nTried Path:") + m_xrcPrefix , _(
"Fatal Error"));
133 wxInitAllImageHandlers();
136 wxXmlResource::Get()->InitAllHandlers();
139 wxXmlResource::Get()->Load(m_xrcPrefix + wxT(
"batch_frame.xrc"));
140 wxXmlResource::Get()->Load(m_xrcPrefix + wxT(
"batch_toolbar.xrc"));
141 wxXmlResource::Get()->Load(m_xrcPrefix + wxT(
"batch_menu.xrc"));
142 wxXmlResource::Get()->Load(m_xrcPrefix + wxT(
"lensdb_dialogs.xrc"));
143 wxXmlResource::Get()->Load(m_xrcPrefix + wxT(
"dlg_warning.xrc"));
147 static const wxCmdLineEntryDesc cmdLineDesc[] =
150 wxCMD_LINE_SWITCH,
"h",
"help",
"show this help message",
151 wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP
153 { wxCMD_LINE_SWITCH,
"b",
"batch",
"run batch immediately" },
154 { wxCMD_LINE_SWITCH,
"o",
"overwrite",
"overwrite previous files without asking" },
155 { wxCMD_LINE_SWITCH,
"s",
"shutdown",
"shutdown computer after batch is complete" },
156 { wxCMD_LINE_SWITCH,
"v",
"verbose",
"show verbose output when processing projects" },
157 { wxCMD_LINE_SWITCH,
"a",
"assistant",
"run the assistant on the given projects" },
158 { wxCMD_LINE_OPTION,
"u",
"user-defined",
"use the given user defined sequence" },
160 wxCMD_LINE_PARAM, NULL, NULL,
"stitch_project.pto [output prefix]|assistant_project.pto",
161 wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL + wxCMD_LINE_PARAM_MULTIPLE
165 wxCmdLineParser parser(cmdLineDesc, argc, argv);
167 switch ( parser.Parse() )
175 wxLogError(_(
"Syntax error in parameters detected, aborting."));
181 wxConnectionBase* conn;
186 servername=wxFileName::GetTempDir()+wxFileName::GetPathSeparator()+name+wxT(
".ipc");
197 #if wxUSE_WXHTML_HELP
199 #if defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
202 wxString strFile = MacGetPathToBundledResourceFile(CFSTR(
"help"));
203 if (!strFile.IsEmpty())
209 wxLogError(wxString::Format(wxT(
"Could not find help directory in the bundle"), strFile.c_str()));
239 conn=client.MakeConnection(wxEmptyString, servername,
IPC_START);
247 if (parser.Found(wxT(
"a")))
250 wxString userDefined;
251 parser.Found(wxT(
"u"), &userDefined);
252 while (parser.GetParamCount() > count)
254 wxString param = parser.GetParam(count);
256 wxFileName name(param);
258 if (name.FileExists())
261 if (name.GetExt().CmpNoCase(wxT(
"pto")) == 0)
269 conn->Request(wxT(
"D ") + name.GetFullPath());
270 if (!userDefined.IsEmpty())
272 conn->Request(wxT(
"U ") + userDefined);
281 bool projectSpecified =
false;
282 wxString userDefined;
283 parser.Found(wxT(
"u"), &userDefined);
285 while (parser.GetParamCount() > count)
287 wxString param = parser.GetParam(count);
289 if (!projectSpecified)
291 wxFileName name(param);
299 conn->Request(wxT(
"A ") + name.GetFullPath());
300 if (!userDefined.IsEmpty())
302 conn->Request(wxT(
"U ") + userDefined);
305 projectSpecified =
true;
309 wxFileName fn(param);
319 conn->Request(wxT(
"P ") + fn.GetFullPath());
321 projectSpecified =
false;
325 wxString ext = fn.GetExt();
327 if (ext.CmpNoCase(wxT(
"jpg")) == 0 || ext.CmpNoCase(wxT(
"jpeg")) == 0 ||
328 ext.CmpNoCase(wxT(
"tif")) == 0 || ext.CmpNoCase(wxT(
"tiff")) == 0 ||
329 ext.CmpNoCase(wxT(
"png")) == 0 || ext.CmpNoCase(wxT(
"exr")) == 0 ||
330 ext.CmpNoCase(wxT(
"pnm")) == 0 || ext.CmpNoCase(wxT(
"hdr")) == 0)
339 conn->Request(wxT(
"P ") + fn.GetFullPath());
341 projectSpecified =
false;
352 conn->Request(wxT(
"A ") + fn.GetFullPath());
353 if (!userDefined.IsEmpty())
355 conn->Request(wxT(
"U ") + userDefined);
358 projectSpecified =
true;
367 wxConfigBase* config=wxConfigBase::Get();
368 if (parser.Found(wxT(
"s")))
370 config->DeleteEntry(wxT(
"/BatchFrame/ShutdownCheck"));
371 #if !defined __WXMAC__ && !defined __WXOSX_COCOA__
373 config->Write(wxT(
"/BatchFrame/AtEnd"), static_cast<long>(
Batch::SHUTDOWN));
376 if (parser.Found(wxT(
"o")))
378 config->Write(wxT(
"/BatchFrame/OverwriteCheck"), 1l);
380 if (parser.Found(wxT(
"v")))
382 config->Write(wxT(
"/BatchFrame/VerboseCheck"), 1l);
388 if (parser.Found(wxT(
"s")))
390 #if !defined __WXMAC__ && !defined __WXOSX_COCOA__
392 conn->Request(wxT(
"SetShutdownCheck"));
395 if (parser.Found(wxT(
"o")))
397 conn->Request(wxT(
"SetOverwriteCheck"));
399 if (parser.Found(wxT(
"v")))
401 conn->Request(wxT(
"SetVerboseCheck"));
403 conn->Request(wxT(
"BringWindowToTop"));
404 if(parser.Found(wxT(
"b")))
406 conn->Request(wxT(
"RunBatch"));
420 if (parser.Found(wxT(
"b")) )
434 wxArrayString emptyFiles;
435 OSXStoreOpenFiles(emptyFiles);
446 delete wxHelpProvider::Set(NULL);
450 #if wxUSE_ON_FATAL_EXCEPTION
451 void PTBatcherGUI::OnFatalException()
453 GenerateReport(wxDebugReport::Context_Exception);
459 void PTBatcherGUI::MacOpenFiles(
const wxArrayString &fileNames)
463 for (
int i = 0; i < fileNames.GetCount(); ++i)
465 wxFileName fn(fileNames[i]);
475 BatchFrame* MyBatchFrame=wxGetApp().GetFrame();
476 if(item.Left(1)==wxT(
"A"))
479 return wxEmptyString;
481 if(item.Left(1)==wxT(
"D"))
484 return wxEmptyString;
486 if(item.Left(1)==wxT(
"P"))
489 return wxEmptyString;
491 if (item.Left(1) == wxT(
"U"))
494 return wxEmptyString;
496 wxCommandEvent event;
498 #if !defined __WXMAC__ && !defined __WXOSX_COCOA__
500 if(item==wxT(
"SetShutdownCheck"))
503 wxCommandEvent choiceEvent;
509 if(item==wxT(
"SetOverwriteCheck"))
515 if(item==wxT(
"SetVerboseCheck"))
521 if(item==wxT(
"BringWindowToTop"))
523 MyBatchFrame->RequestUserAttention();
525 if(item==wxT(
"RunBatch"))
527 wxCommandEvent myEvent(wxEVT_COMMAND_TOOL_CLICKED ,XRCID(
"tool_start"));
528 MyBatchFrame->GetEventHandler()->AddPendingEvent(myEvent);
530 return wxEmptyString;
void ChangePrefix(int index, wxString newPrefix)
bool IsStartedMinimized()
returns true, if last session was finished minimized
wxIMPLEMENT_APP(huginApp)
const wxString IPC_START(wxT("BatchStart"))
topic name for BatchIPCConnection and BatchIPCServer
Batch::EndTask GetEndTask()
return which task should be executed at end
virtual const void * OnRequest(const wxString &topic, const wxString &item, size_t *size=NULL, wxIPCFormat format=wxIPC_TEXT)
request handler for transfer
void AddToList(wxString aFile, Project::Target target=Project::STITCHING, wxString userDefined=wxEmptyString)
bool GetCheckOverwrite()
return if overwrite checkbox is checked
static void Clean()
cleanup the static LensDB instance, must be called at the end of the program
virtual bool OnInit()
pseudo constructor.
virtual wxConnectionBase * OnAcceptConnection(const wxString &topic)
accept connection handler (establish the connection)
Batch processor for Hugin with GUI.
class to access Hugins camera and lens database
server which implements the communication between different PTBatcherGUI instances (see BatchIPCConne...
The application class for hugin_stitch_project.
void ChangeUserDefined(int index, wxString newUserDefined)
void OnCheckVerbose(wxCommandEvent &event)
void SetStatusInformation(wxString status)
sets status message, also updates tooltip of taskbar icon
void OnCheckOverwrite(wxCommandEvent &event)
wxHelpController & GetHelpController()
return help controller for open help
void OnChoiceEnd(wxCommandEvent &event)
wxSingleInstanceChecker * m_checker
class for communication between different PTBatcherGUI instances
BatchIPCServer * m_server
bool GetCheckVerbose()
return if verbose checkbox is checked
void SetInternalVerbose(bool newVerbose)
sets the current verbose status, does not update the checkbox
int main(int argc, char *argv[])