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);
55 EVT_LIST_ITEM_ACTIVATED(XRCID("project_listbox"),
PTBatcherGUI::OnItemActivated)
60 #if wxUSE_ON_FATAL_EXCEPTION
61 wxHandleFatalExceptions();
64 SetAppName(wxT(
"hugin"));
65 #if defined __WXGTK__ && wxCHECK_VERSION(3,1,1)
66 CheckConfigFilename();
70 setlocale(LC_ALL,
"");
72 int localeID = wxConfigBase::Get()->Read(wxT(
"language"), (
long) wxLANGUAGE_DEFAULT);
73 m_locale.Init(localeID);
75 m_locale.Init(wxLANGUAGE_DEFAULT);
78 wxHelpControllerHelpProvider* provider =
new wxHelpControllerHelpProvider;
79 wxHelpProvider::Set(provider);
83 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
84 exePath.RemoveLastDir();
85 const wxString huginRoot(exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));
86 m_xrcPrefix = huginRoot + wxT(
"share\\hugin\\xrc\\");
89 m_locale.AddCatalogLookupPathPrefix(huginRoot + wxT(
"share\\locale"));
90 #elif defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
92 wxString exec_path = MacGetPathToBundledResourceFile(CFSTR(
"xrc"));
93 if(exec_path != wxT(
""))
95 m_xrcPrefix = exec_path + wxT(
"/");
99 wxMessageBox(_(
"xrc directory not found in bundle"), _(
"Fatal Error"));
105 #elif defined UNIX_SELF_CONTAINED_BUNDLE
108 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
109 exePath.RemoveLastDir();
110 const wxString huginRoot(exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));
111 m_xrcPrefix = huginRoot + wxT(
"share/hugin/xrc/");
114 m_locale.AddCatalogLookupPathPrefix(huginRoot + wxT(
"share/locale"));
118 m_xrcPrefix = wxT(INSTALL_XRC_DIR);
119 m_locale.AddCatalogLookupPathPrefix(wxT(INSTALL_LOCALE_DIR));
123 m_locale.AddCatalog(wxT(
"hugin"));
125 const wxString name = wxString::Format(_T(
"PTBatcherGUI-%s"), wxGetUserId().c_str());
126 m_checker =
new wxSingleInstanceChecker(name+wxT(
".lock"),wxFileName::GetTempDir());
127 bool IsFirstInstance=(!m_checker->IsAnotherRunning());
131 if ( ! wxFile::Exists(m_xrcPrefix + wxT(
"/batch_frame.xrc")) )
133 wxMessageBox(_(
"xrc directory not found, hugin needs to be properly installed\nTried Path:") + m_xrcPrefix , _(
"Fatal Error"));
137 wxInitAllImageHandlers();
140 wxXmlResource::Get()->InitAllHandlers();
143 wxXmlResource::Get()->Load(m_xrcPrefix + wxT(
"batch_frame.xrc"));
144 wxXmlResource::Get()->Load(m_xrcPrefix + wxT(
"batch_toolbar.xrc"));
145 wxXmlResource::Get()->Load(m_xrcPrefix + wxT(
"batch_menu.xrc"));
146 wxXmlResource::Get()->Load(m_xrcPrefix + wxT(
"lensdb_dialogs.xrc"));
147 wxXmlResource::Get()->Load(m_xrcPrefix + wxT(
"dlg_warning.xrc"));
151 static const wxCmdLineEntryDesc cmdLineDesc[] =
154 wxCMD_LINE_SWITCH,
"h",
"help",
"show this help message",
155 wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP
157 { wxCMD_LINE_SWITCH,
"b",
"batch",
"run batch immediately" },
158 { wxCMD_LINE_SWITCH,
"o",
"overwrite",
"overwrite previous files without asking" },
159 { wxCMD_LINE_SWITCH,
"s",
"shutdown",
"shutdown computer after batch is complete" },
160 { wxCMD_LINE_SWITCH,
"v",
"verbose",
"show verbose output when processing projects" },
161 { wxCMD_LINE_SWITCH,
"a",
"assistant",
"run the assistant on the given projects" },
162 { wxCMD_LINE_OPTION,
"u",
"user-defined",
"use the given user defined sequence" },
164 wxCMD_LINE_PARAM, NULL, NULL,
"stitch_project.pto [output prefix]|assistant_project.pto",
165 wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL + wxCMD_LINE_PARAM_MULTIPLE
169 wxCmdLineParser parser(cmdLineDesc, argc, argv);
171 switch ( parser.Parse() )
179 wxLogError(_(
"Syntax error in parameters detected, aborting."));
185 wxConnectionBase* conn;
190 servername=wxFileName::GetTempDir()+wxFileName::GetPathSeparator()+name+wxT(
".ipc");
194 m_frame =
new BatchFrame(&m_locale,m_xrcPrefix);
195 m_frame->RestoreSize();
197 provider->SetHelpController(&m_frame->GetHelpController());
199 m_frame->GetHelpController().Initialize(m_xrcPrefix + wxT(
"data/hugin_help_en_EN.chm"));
201 #if wxUSE_WXHTML_HELP
203 #if defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
206 wxString strFile = MacGetPathToBundledResourceFile(CFSTR(
"help"));
207 if (!strFile.IsEmpty())
209 m_frame->GetHelpController().AddBook(wxFileName(strFile + wxT(
"/hugin_help_en_EN.hhp")));
213 wxLogError(wxString::Format(wxT(
"Could not find help directory in the bundle"), strFile.c_str()));
217 m_frame->GetHelpController().AddBook(wxFileName(m_xrcPrefix + wxT(
"data/help_en_EN/hugin_help_en_EN.hhp")));
221 m_frame->GetHelpController().Initialize(Initialize(m_xrcPrefix + wxT(
"data/help_en_EN")));
225 SetTopWindow(m_frame);
226 if(!(m_frame->IsStartedMinimized()))
232 m_frame->SetStatusInformation(_(
"PTBatcherGUI started"));
235 if (!m_server->Create(servername))
243 conn=client.MakeConnection(wxEmptyString, servername,
IPC_START);
251 if (parser.Found(wxT(
"a")))
254 wxString userDefined;
255 parser.Found(wxT(
"u"), &userDefined);
256 while (parser.GetParamCount() > count)
258 wxString param = parser.GetParam(count);
260 wxFileName name(param);
262 if (name.FileExists())
265 if (name.GetExt().CmpNoCase(wxT(
"pto")) == 0)
273 conn->Request(wxT(
"D ") + name.GetFullPath());
274 if (!userDefined.IsEmpty())
276 conn->Request(wxT(
"U ") + userDefined);
285 bool projectSpecified =
false;
286 wxString userDefined;
287 parser.Found(wxT(
"u"), &userDefined);
289 while (parser.GetParamCount() > count)
291 wxString param = parser.GetParam(count);
293 if (!projectSpecified)
295 wxFileName name(param);
303 conn->Request(wxT(
"A ") + name.GetFullPath());
304 if (!userDefined.IsEmpty())
306 conn->Request(wxT(
"U ") + userDefined);
309 projectSpecified =
true;
313 wxFileName fn(param);
319 m_frame->ChangePrefix(-1, fn.GetFullPath());
323 conn->Request(wxT(
"P ") + fn.GetFullPath());
325 projectSpecified =
false;
329 wxString ext = fn.GetExt();
331 if (ext.CmpNoCase(wxT(
"jpg")) == 0 || ext.CmpNoCase(wxT(
"jpeg")) == 0 ||
332 ext.CmpNoCase(wxT(
"tif")) == 0 || ext.CmpNoCase(wxT(
"tiff")) == 0 ||
333 ext.CmpNoCase(wxT(
"png")) == 0 || ext.CmpNoCase(wxT(
"exr")) == 0 ||
334 ext.CmpNoCase(wxT(
"pnm")) == 0 || ext.CmpNoCase(wxT(
"hdr")) == 0)
339 m_frame->ChangePrefix(-1, fn.GetFullPath());
343 conn->Request(wxT(
"P ") + fn.GetFullPath());
345 projectSpecified =
false;
356 conn->Request(wxT(
"A ") + fn.GetFullPath());
357 if (!userDefined.IsEmpty())
359 conn->Request(wxT(
"U ") + userDefined);
362 projectSpecified =
true;
371 wxConfigBase* config=wxConfigBase::Get();
372 if (parser.Found(wxT(
"s")))
374 config->DeleteEntry(wxT(
"/BatchFrame/ShutdownCheck"));
375 #if !defined __WXMAC__ && !defined __WXOSX_COCOA__
377 config->Write(wxT(
"/BatchFrame/AtEnd"), static_cast<long>(
Batch::SHUTDOWN));
380 if (parser.Found(wxT(
"o")))
382 config->Write(wxT(
"/BatchFrame/OverwriteCheck"), 1l);
384 if (parser.Found(wxT(
"v")))
386 config->Write(wxT(
"/BatchFrame/VerboseCheck"), 1l);
392 if (parser.Found(wxT(
"s")))
394 #if !defined __WXMAC__ && !defined __WXOSX_COCOA__
396 conn->Request(wxT(
"SetShutdownCheck"));
399 if (parser.Found(wxT(
"o")))
401 conn->Request(wxT(
"SetOverwriteCheck"));
403 if (parser.Found(wxT(
"v")))
405 conn->Request(wxT(
"SetVerboseCheck"));
407 conn->Request(wxT(
"BringWindowToTop"));
408 if(parser.Found(wxT(
"b")))
410 conn->Request(wxT(
"RunBatch"));
417 m_frame->SetCheckboxes();
418 m_frame->PropagateDefaults();
420 if(m_frame->IsStartedMinimized())
422 m_frame->SetInternalVerbose(
false);
424 if (parser.Found(wxT(
"b")) )
438 wxArrayString emptyFiles;
439 OSXStoreOpenFiles(emptyFiles);
450 delete wxHelpProvider::Set(NULL);
454 #if wxUSE_ON_FATAL_EXCEPTION
455 void PTBatcherGUI::OnFatalException()
457 GenerateReport(wxDebugReport::Context_Exception);
463 wxCommandEvent dummy;
469 void PTBatcherGUI::MacOpenFiles(
const wxArrayString &fileNames)
473 for (
int i = 0; i < fileNames.GetCount(); ++i)
475 wxFileName fn(fileNames[i]);
485 BatchFrame* MyBatchFrame=wxGetApp().GetFrame();
486 if(item.Left(1)==wxT(
"A"))
489 return wxEmptyString;
491 if(item.Left(1)==wxT(
"D"))
494 return wxEmptyString;
496 if(item.Left(1)==wxT(
"P"))
499 return wxEmptyString;
501 if (item.Left(1) == wxT(
"U"))
504 return wxEmptyString;
506 wxCommandEvent event;
508 #if !defined __WXMAC__ && !defined __WXOSX_COCOA__
510 if(item==wxT(
"SetShutdownCheck"))
513 wxCommandEvent choiceEvent;
519 if(item==wxT(
"SetOverwriteCheck"))
525 if(item==wxT(
"SetVerboseCheck"))
531 if(item==wxT(
"BringWindowToTop"))
533 MyBatchFrame->RequestUserAttention();
535 if(item==wxT(
"RunBatch"))
537 wxCommandEvent myEvent(wxEVT_COMMAND_TOOL_CLICKED ,XRCID(
"tool_start"));
538 MyBatchFrame->GetEventHandler()->AddPendingEvent(myEvent);
540 return wxEmptyString;
void ChangePrefix(int index, wxString newPrefix)
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 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 OnCheckOverwrite(wxCommandEvent &event)
void OnButtonOpenWithHugin(wxCommandEvent &event)
void OnChoiceEnd(wxCommandEvent &event)
wxSingleInstanceChecker * m_checker
void OnItemActivated(wxListEvent &event)
class for communication between different PTBatcherGUI instances
BatchIPCServer * m_server
bool GetCheckVerbose()
return if verbose checkbox is checked
int main(int argc, char *argv[])