28 #include <wx/cshelp.h>
29 #if defined __WXMSW__ || defined UNIX_SELF_CONTAINED_BUNDLE
30 #include <wx/stdpaths.h>
36 #if defined USE_GDKBACKEND_X11
40 #warning Using Hugin with hard coded GDK_BACKEND=x11
41 wxIMPLEMENT_WX_THEME_SUPPORT
44 int main(
int argc,
char **argv)
46 wxDISABLE_DEBUG_SUPPORT();
47 char backend[]=
"GDK_BACKEND=x11";
49 return wxEntry(argc, argv);
57 #if wxUSE_ON_FATAL_EXCEPTION
58 wxHandleFatalExceptions();
62 #if defined __WXMSW__ && wxCHECK_VERSION(3,3,0)
64 SetAppearance(Appearance::System);
67 CheckConfigFilename();
71 setlocale(LC_ALL,
"");
73 int localeID = wxConfigBase::Get()->Read(
"language", (
long) wxLANGUAGE_DEFAULT);
79 wxHelpControllerHelpProvider* provider =
new wxHelpControllerHelpProvider;
80 wxHelpProvider::Set(provider);
84 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
85 exePath.RemoveLastDir();
86 const wxString huginRoot(exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));
90 m_locale.AddCatalogLookupPathPrefix(huginRoot +
"share\\locale");
91 #elif defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
93 wxString exec_path = MacGetPathToBundledResourceFile(CFSTR(
"xrc"));
94 if(exec_path != wxEmptyString)
96 m_xrcPrefix = exec_path +
"/";
106 #elif defined UNIX_SELF_CONTAINED_BUNDLE
109 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
110 exePath.RemoveLastDir();
111 const wxString huginRoot(exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));
112 m_xrcPrefix = huginRoot +
"share/hugin/xrc/";
115 m_locale.AddCatalogLookupPathPrefix(huginRoot +
"share/locale");
119 m_xrcPrefix = INSTALL_XRC_DIR;
120 m_locale.AddCatalogLookupPathPrefix(INSTALL_LOCALE_DIR);
126 const wxString name = wxString::Format(_T(
"PTBatcherGUI-%s"), wxGetUserId().c_str());
127 m_checker =
new wxSingleInstanceChecker(name+
".lock",wxFileName::GetTempDir());
128 bool IsFirstInstance=(!
m_checker->IsAnotherRunning());
132 if ( ! wxFile::Exists(m_xrcPrefix +
"/batch_frame.xrc") )
134 hugin_utils::HuginMessageBox(wxString::Format(_(
"xrc directory not found, hugin needs to be properly installed\nTried Path: %s"), m_xrcPrefix), _(
"PTBatcherGUI"), wxOK | wxICON_ERROR, wxGetActiveWindow());
138 wxInitAllImageHandlers();
141 wxXmlResource::Get()->InitAllHandlers();
144 wxXmlResource::Get()->Load(m_xrcPrefix +
"batch_frame.xrc");
145 wxXmlResource::Get()->Load(m_xrcPrefix +
"batch_toolbar.xrc");
146 wxXmlResource::Get()->Load(m_xrcPrefix +
"batch_menu.xrc");
147 wxXmlResource::Get()->Load(m_xrcPrefix +
"lensdb_dialogs.xrc");
148 wxXmlResource::Get()->Load(m_xrcPrefix +
"dlg_warning.xrc");
152 static const wxCmdLineEntryDesc cmdLineDesc[] =
155 wxCMD_LINE_SWITCH,
"h",
"help",
"show this help message",
156 wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP
158 { wxCMD_LINE_SWITCH,
"b",
"batch",
"run batch immediately" },
159 { wxCMD_LINE_SWITCH,
"o",
"overwrite",
"overwrite previous files without asking" },
160 { wxCMD_LINE_SWITCH,
"s",
"shutdown",
"shutdown computer after batch is complete" },
161 { wxCMD_LINE_SWITCH,
"v",
"verbose",
"show verbose output when processing projects" },
162 { wxCMD_LINE_SWITCH,
"a",
"assistant",
"run the assistant on the given projects" },
163 { wxCMD_LINE_OPTION,
"u",
"user-defined",
"use the given user defined sequence" },
165 wxCMD_LINE_PARAM, NULL, NULL,
"stitch_project.pto [output prefix]|assistant_project.pto",
166 wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL + wxCMD_LINE_PARAM_MULTIPLE
170 wxCmdLineParser parser(cmdLineDesc, argc, argv);
172 switch ( parser.Parse() )
180 wxLogError(_(
"Syntax error in parameters detected, aborting."));
186 wxConnectionBase* conn;
191 servername=wxFileName::GetTempDir()+wxFileName::GetPathSeparator()+name+
".ipc";
202 #if wxUSE_WXHTML_HELP
204 #if defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
207 wxString strFile = MacGetPathToBundledResourceFile(CFSTR(
"help"));
208 if (!strFile.IsEmpty())
214 wxLogError(wxString::Format(
"Could not find help directory in the bundle", strFile.c_str()));
240 conn=client.MakeConnection(wxEmptyString, servername,
IPC_START);
248 if (parser.Found(
"a"))
251 wxString userDefined;
252 parser.Found(
"u", &userDefined);
253 while (parser.GetParamCount() > count)
255 wxString param = parser.GetParam(count);
257 wxFileName name(param);
259 if (name.FileExists())
262 if (name.GetExt().CmpNoCase(
"pto") == 0)
270 conn->Request(
"D " + name.GetFullPath());
271 if (!userDefined.IsEmpty())
273 conn->Request(
"U " + userDefined);
282 bool projectSpecified =
false;
283 wxString userDefined;
284 parser.Found(
"u", &userDefined);
286 while (parser.GetParamCount() > count)
288 wxString param = parser.GetParam(count);
290 if (!projectSpecified)
292 wxFileName name(param);
300 conn->Request(
"A " + name.GetFullPath());
301 if (!userDefined.IsEmpty())
303 conn->Request(
"U " + userDefined);
306 projectSpecified =
true;
310 wxFileName fn(param);
320 conn->Request(
"P " + fn.GetFullPath());
322 projectSpecified =
false;
326 wxString ext = fn.GetExt();
328 if (ext.CmpNoCase(
"jpg") == 0 || ext.CmpNoCase(
"jpeg") == 0 ||
329 ext.CmpNoCase(
"tif") == 0 || ext.CmpNoCase(
"tiff") == 0 ||
330 ext.CmpNoCase(
"png") == 0 || ext.CmpNoCase(
"exr") == 0 ||
331 ext.CmpNoCase(
"pnm") == 0 || ext.CmpNoCase(
"hdr") == 0)
340 conn->Request(
"P " + fn.GetFullPath());
342 projectSpecified =
false;
353 conn->Request(
"A " + fn.GetFullPath());
354 if (!userDefined.IsEmpty())
356 conn->Request(
"U " + userDefined);
359 projectSpecified =
true;
368 wxConfigBase* config=wxConfigBase::Get();
369 if (parser.Found(
"s"))
371 config->DeleteEntry(
"/BatchFrame/ShutdownCheck");
372 #if !defined __WXMAC__ && !defined __WXOSX_COCOA__
374 config->Write(
"/BatchFrame/AtEnd", static_cast<long>(
Batch::SHUTDOWN));
377 if (parser.Found(
"o"))
379 config->Write(
"/BatchFrame/OverwriteCheck", 1l);
381 if (parser.Found(
"v"))
383 config->Write(
"/BatchFrame/VerboseCheck", 1l);
389 if (parser.Found(
"s"))
391 #if !defined __WXMAC__ && !defined __WXOSX_COCOA__
393 conn->Request(
"SetShutdownCheck");
396 if (parser.Found(
"o"))
398 conn->Request(
"SetOverwriteCheck");
400 if (parser.Found(
"v"))
402 conn->Request(
"SetVerboseCheck");
404 conn->Request(
"BringWindowToTop");
405 if(parser.Found(
"b"))
407 conn->Request(
"RunBatch");
421 if (parser.Found(
"b") )
435 wxArrayString emptyFiles;
436 OSXStoreOpenFiles(emptyFiles);
447 delete wxHelpProvider::Set(NULL);
451 #if wxUSE_ON_FATAL_EXCEPTION
452 void PTBatcherGUI::OnFatalException()
454 GenerateReport(wxDebugReport::Context_Exception);
460 void PTBatcherGUI::MacOpenFiles(
const wxArrayString &fileNames)
464 for (
int i = 0; i < fileNames.GetCount(); ++i)
466 wxFileName fn(fileNames[i]);
476 BatchFrame* MyBatchFrame=wxGetApp().GetFrame();
477 if(item.Left(1)==
"A")
480 return wxEmptyString;
482 if(item.Left(1)==
"D")
485 return wxEmptyString;
487 if(item.Left(1)==
"P")
490 return wxEmptyString;
492 if (item.Left(1) ==
"U")
495 return wxEmptyString;
497 wxCommandEvent event;
499 #if !defined __WXMAC__ && !defined __WXOSX_COCOA__
501 if(item==
"SetShutdownCheck")
504 wxCommandEvent choiceEvent;
510 if(item==
"SetOverwriteCheck")
516 if(item==
"SetVerboseCheck")
522 if(item==
"BringWindowToTop")
524 MyBatchFrame->RequestUserAttention();
528 wxCommandEvent myEvent(wxEVT_COMMAND_TOOL_CLICKED ,XRCID(
"tool_start"));
529 MyBatchFrame->GetEventHandler()->AddPendingEvent(myEvent);
531 return wxEmptyString;
void ChangePrefix(int index, wxString newPrefix)
bool IsStartedMinimized()
returns true, if last session was finished minimized
wxIMPLEMENT_APP(huginApp)
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
const wxString IPC_START("BatchStart")
topic name for BatchIPCConnection and BatchIPCServer
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 HuginMessageBox(const wxString &message, const wxString &caption, int style, wxWindow *parent)
int main(int argc, char *argv[])