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()));
235 conn=client.MakeConnection(wxEmptyString, servername,
IPC_START);
243 if (parser.Found(wxT(
"a")))
246 wxString userDefined;
247 parser.Found(wxT(
"u"), &userDefined);
248 while (parser.GetParamCount() > count)
250 wxString param = parser.GetParam(count);
252 wxFileName name(param);
254 if (name.FileExists())
257 if (name.GetExt().CmpNoCase(wxT(
"pto")) == 0)
265 conn->Request(wxT(
"D ") + name.GetFullPath());
266 if (!userDefined.IsEmpty())
268 conn->Request(wxT(
"U ") + userDefined);
277 bool projectSpecified =
false;
278 wxString userDefined;
279 parser.Found(wxT(
"u"), &userDefined);
281 while (parser.GetParamCount() > count)
283 wxString param = parser.GetParam(count);
285 if (!projectSpecified)
287 wxFileName name(param);
295 conn->Request(wxT(
"A ") + name.GetFullPath());
296 if (!userDefined.IsEmpty())
298 conn->Request(wxT(
"U ") + userDefined);
301 projectSpecified =
true;
305 wxFileName fn(param);
315 conn->Request(wxT(
"P ") + fn.GetFullPath());
317 projectSpecified =
false;
321 wxString ext = fn.GetExt();
323 if (ext.CmpNoCase(wxT(
"jpg")) == 0 || ext.CmpNoCase(wxT(
"jpeg")) == 0 ||
324 ext.CmpNoCase(wxT(
"tif")) == 0 || ext.CmpNoCase(wxT(
"tiff")) == 0 ||
325 ext.CmpNoCase(wxT(
"png")) == 0 || ext.CmpNoCase(wxT(
"exr")) == 0 ||
326 ext.CmpNoCase(wxT(
"pnm")) == 0 || ext.CmpNoCase(wxT(
"hdr")) == 0)
335 conn->Request(wxT(
"P ") + fn.GetFullPath());
337 projectSpecified =
false;
348 conn->Request(wxT(
"A ") + fn.GetFullPath());
349 if (!userDefined.IsEmpty())
351 conn->Request(wxT(
"U ") + userDefined);
354 projectSpecified =
true;
363 wxConfigBase* config=wxConfigBase::Get();
364 if (parser.Found(wxT(
"s")))
366 config->DeleteEntry(wxT(
"/BatchFrame/ShutdownCheck"));
367 #if !defined __WXMAC__ && !defined __WXOSX_COCOA__
369 config->Write(wxT(
"/BatchFrame/AtEnd"), static_cast<long>(
Batch::SHUTDOWN));
372 if (parser.Found(wxT(
"o")))
374 config->Write(wxT(
"/BatchFrame/OverwriteCheck"), 1l);
376 if (parser.Found(wxT(
"v")))
378 config->Write(wxT(
"/BatchFrame/VerboseCheck"), 1l);
384 if (parser.Found(wxT(
"s")))
386 #if !defined __WXMAC__ && !defined __WXOSX_COCOA__
388 conn->Request(wxT(
"SetShutdownCheck"));
391 if (parser.Found(wxT(
"o")))
393 conn->Request(wxT(
"SetOverwriteCheck"));
395 if (parser.Found(wxT(
"v")))
397 conn->Request(wxT(
"SetVerboseCheck"));
399 conn->Request(wxT(
"BringWindowToTop"));
400 if(parser.Found(wxT(
"b")))
402 conn->Request(wxT(
"RunBatch"));
416 if (parser.Found(wxT(
"b")) )
430 wxArrayString emptyFiles;
431 OSXStoreOpenFiles(emptyFiles);
442 delete wxHelpProvider::Set(NULL);
446 #if wxUSE_ON_FATAL_EXCEPTION
447 void PTBatcherGUI::OnFatalException()
449 GenerateReport(wxDebugReport::Context_Exception);
455 void PTBatcherGUI::MacOpenFiles(
const wxArrayString &fileNames)
459 for (
int i = 0; i < fileNames.GetCount(); ++i)
461 wxFileName fn(fileNames[i]);
471 BatchFrame* MyBatchFrame=wxGetApp().GetFrame();
472 if(item.Left(1)==wxT(
"A"))
475 return wxEmptyString;
477 if(item.Left(1)==wxT(
"D"))
480 return wxEmptyString;
482 if(item.Left(1)==wxT(
"P"))
485 return wxEmptyString;
487 if (item.Left(1) == wxT(
"U"))
490 return wxEmptyString;
492 wxCommandEvent event;
494 #if !defined __WXMAC__ && !defined __WXOSX_COCOA__
496 if(item==wxT(
"SetShutdownCheck"))
499 wxCommandEvent choiceEvent;
505 if(item==wxT(
"SetOverwriteCheck"))
511 if(item==wxT(
"SetVerboseCheck"))
517 if(item==wxT(
"BringWindowToTop"))
519 MyBatchFrame->RequestUserAttention();
521 if(item==wxT(
"RunBatch"))
523 wxCommandEvent myEvent(wxEVT_COMMAND_TOOL_CLICKED ,XRCID(
"tool_start"));
524 MyBatchFrame->GetEventHandler()->AddPendingEvent(myEvent);
526 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 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[])