27 #include "hugin_config.h"
32 #include <wx/sysopt.h>
61 #include <wx/cshelp.h>
62 #include <wx/stdpaths.h>
65 #include <wx/taskbarbutton.h>
81 return doj::alphanum_comp(std::string(v1.mb_str(wxConvLocal)),std::string(v2.mb_str(wxConvLocal))) < 0;
87 for (
unsigned i=0; i < comp.size(); i++) {
89 HuginGraph::ImageGraph::Components::value_type::const_iterator it = comp[i].begin();
90 while (it != comp[i].end())
92 unsigned int imgNr = *it;
95 if (it != comp[i].end() && *it == imgNr + 1)
98 while (it != comp[i].end() && *it == imgNr + 1)
104 if (it != comp[i].end())
106 ret.Append(wxT(
", "));
111 if (it != comp[i].end())
113 ret.Append(wxT(
", "));
118 ret.Append(wxT(
"]"));
119 if (i + 1 != comp.size())
121 ret.Append(wxT(
", "));
128 #if defined USE_GDKBACKEND_X11
132 #warning Using Hugin with hard coded GDK_BACKEND=x11
133 wxIMPLEMENT_WX_THEME_SUPPORT
136 int main(
int argc,
char **argv)
138 wxDISABLE_DEBUG_SUPPORT();
139 char backend[]=
"GDK_BACKEND=x11";
141 return wxEntry(argc, argv);
163 #if wxUSE_ON_FATAL_EXCEPTION
164 wxHandleFatalExceptions();
191 DEBUG_TRACE(
"=========================== huginApp::OnInit() begin ===================");
192 SetAppName(wxT(
"hugin"));
193 #if defined __WXGTK__
194 CheckConfigFilename();
202 wxSystemOptions::SetOption(wxT(
"mac.listctrl.always_use_generic"), 1);
207 wxSystemOptions::SetOption(wxOSX_FILEDIALOG_ALWAYS_SHOW_TYPES, 1);
214 wxFileSystem::AddHandler(
new wxZipFSHandler);
217 wxHelpControllerHelpProvider* provider =
new wxHelpControllerHelpProvider;
218 wxHelpProvider::Set(provider);
220 #if defined __WXMSW__
221 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
222 m_utilsBinDir = exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
223 exePath.RemoveLastDir();
224 const wxString huginRoot=exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
225 m_xrcPrefix = huginRoot + wxT(
"share\\hugin\\xrc\\");
226 m_DataDir = huginRoot + wxT(
"share\\hugin\\data\\");
229 locale.AddCatalogLookupPathPrefix(huginRoot + wxT(
"share\\locale"));
231 #elif defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
234 wxString thePath = MacGetPathToBundledResourceFile(CFSTR(
"xrc"));
235 if (thePath == wxT(
"")) {
236 wxMessageBox(_(
"xrc directory not found in bundle"), _(
"Fatal Error"));
246 wxString pythonHome = MacGetPathToBundledFrameworksDirectory() + wxT(
"/Python27.framework/Versions/Current");
247 if(! wxDir::Exists(pythonHome)){
248 wxMessageBox(wxString::Format(_(
"Directory '%s' does not exists"), pythonHome.c_str()));
250 wxUnsetEnv(wxT(
"PYTHONPATH"));
251 if(! wxSetEnv(wxT(
"PYTHONHOME"), pythonHome)){
252 wxMessageBox(_(
"Could not set environment variable PYTHONHOME"));
260 #elif defined UNIX_SELF_CONTAINED_BUNDLE
263 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
264 m_utilsBinDir = exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
265 exePath.RemoveLastDir();
266 const wxString huginRoot=exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
268 m_DataDir = huginRoot + wxT(
"share/hugin/data/");
271 locale.AddCatalogLookupPathPrefix(huginRoot + wxT(
"share/locale"));
278 locale.AddCatalogLookupPathPrefix(wxT(INSTALL_LOCALE_DIR));
281 if ( ! wxFile::Exists(
m_xrcPrefix + wxT(
"/main_frame.xrc")) ) {
282 wxMessageBox(wxString::Format(_(
"xrc directory not found, hugin needs to be properly installed\nTried Path: %s"),
m_xrcPrefix), _(
"Fatal Error"));
287 wxConfigBase * config = wxConfigBase::Get();
289 config->SetRecordDefaults(
false);
294 setlocale(LC_ALL,
"");
296 int localeID = config->Read(wxT(
"language"), (
long)
HUGIN_LANGUAGE);
300 bLInit =
locale.Init(localeID);
304 DEBUG_TRACE(
"Canonical Locale: " <<
locale.GetCanonicalName().mb_str(wxConvLocal))
311 locale.AddCatalog(wxT(
"hugin"));
314 wxInitAllImageHandlers();
317 wxXmlResource::Get()->InitAllHandlers();
320 #ifdef _INCLUDE_UI_RESOURCES
336 wxXmlResource::Get()->AddHandler(
new wxcode::wxTreeListCtrlXmlHandler());
342 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"cp_list_frame.xrc"));
343 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"preview_frame.xrc"));
344 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"edit_script_dialog.xrc"));
345 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"main_menu.xrc"));
346 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"main_tool.xrc"));
347 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"about.xrc"));
348 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"pref_dialog.xrc"));
349 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"cpdetector_dialog.xrc"));
350 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"reset_dialog.xrc"));
351 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"optimize_photo_panel.xrc"));
352 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"cp_editor_panel.xrc"));
353 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"images_panel.xrc"));
354 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"main_frame.xrc"));
355 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"optimize_panel.xrc"));
356 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"pano_panel.xrc"));
357 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"mask_editor_panel.xrc"));
358 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"lensdb_dialogs.xrc"));
359 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"image_variable_dlg.xrc"));
360 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"dlg_warning.xrc"));
361 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"import_raw_dialog.xrc"));
368 m_macOpenFileOnStart=
false;
379 frame->SendSizeEvent();
381 #if wxUSE_TASKBARBUTTON
382 wxTaskBarJumpList jumpList;
383 wxFileName exeFile(wxStandardPaths::Get().GetExecutablePath());
384 exeFile.SetName(
"PTBatcherGUI");
385 wxTaskBarJumpListItem *item1 =
new wxTaskBarJumpListItem(
386 NULL, wxTASKBAR_JUMP_LIST_TASK, _(
"Open Batch Processor"), exeFile.GetFullPath(), wxEmptyString,
387 _(
"Opens PTBatcherGUI, the batch processor for Hugin's project files"),
388 exeFile.GetFullPath(), 0);
389 jumpList.GetTasks().Append(item1);
390 exeFile.SetName(
"calibrate_lens_gui");
391 item1 =
new wxTaskBarJumpListItem(
392 NULL, wxTASKBAR_JUMP_LIST_TASK, _(
"Open Lens calibrate tool"), exeFile.GetFullPath(), wxEmptyString,
393 _(
"Opens Calibrate_lens_gui, a simple GUI for lens calibration"),
394 exeFile.GetFullPath(), 0);
395 jumpList.GetTasks().Append(item1);
396 exeFile.SetName(
"Hugin_toolbox");
397 item1 =
new wxTaskBarJumpListItem(
398 NULL, wxTASKBAR_JUMP_LIST_TASK, _(
"Open Hugin toolbox"), exeFile.GetFullPath(), wxEmptyString,
399 _(
"Opens Hugin_toolbox, a GUI for several small helper programs"),
400 exeFile.GetFullPath(), 0);
401 jumpList.GetTasks().Append(item1);
404 #pragma message("Warning: huginApp.cpp - wxWidgets is compiled without support for taskbar buttons. Some features have therefore disabled.")
406 #warning "Warning: huginApp.cpp - wxWidgets is compiled without support for taskbar buttons. Some features have therefore disabled."
415 #if wxUSE_WXHTML_HELP
417 #if defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
420 wxString strFile = MacGetPathToBundledResourceFile(CFSTR(
"help"));
421 if (!strFile.IsEmpty())
427 wxLogError(wxString::Format(wxT(
"Could not find help directory in the bundle"), strFile.c_str()));
440 SetExitOnFrameDelete(
true);
451 wxString cwd = wxFileName::GetCwd();
453 m_workDir = config->Read(wxT(
"tempDir"),wxT(
""));
457 #if (defined __WXMSW__)
460 wxChar buffer[MAX_PATH];
461 GetTempPath(MAX_PATH, buffer);
463 #elif (defined __WXMAC__) && (defined MAC_SELF_CONTAINED_BUNDLE)
465 m_workDir = MacGetPathToUserDomainTempDir();
471 if (!wxGetEnv(wxT(
"TMPDIR"), &
m_workDir)) {
495 TIFFSetWarningHandler(0);
508 wxFileName file(argv[1]);
510 if (file.GetExt().CmpNoCase(wxT(
"pto")) == 0 ||
511 file.GetExt().CmpNoCase(wxT(
"pts")) == 0 ||
512 file.GetExt().CmpNoCase(wxT(
"ptp")) == 0 )
514 if(file.IsRelative())
515 file.MakeAbsolute(cwd);
521 std::vector<std::string> filesv;
522 std::vector<std::string> rawFilesv;
523 bool actualPathSet =
false;
524 for (
int i=1; i< argc; i++)
526 #if defined __WXMSW__
528 wxFileName fileList(argv[i]);
529 if(fileList.IsRelative())
530 fileList.MakeAbsolute(cwd);
534 if(fileList.DirExists())
535 if(dir.Open(fileList.GetPath()))
536 if(dir.GetFirst(&foundFile,fileList.GetFullName(),wxDIR_FILES | wxDIR_HIDDEN))
540 file.MakeAbsolute(dir.GetName());
542 wxFileName file(argv[i]);
544 if (file.IsRelative())
546 file.MakeAbsolute(cwd);
557 config->Write(wxT(
"/actualPath"), file.GetPath());
558 actualPathSet =
true;
572 config->Write(wxT(
"/actualPath"), file.GetPath());
573 actualPathSet =
true;
578 #if defined __WXMSW__
579 }
while (dir.GetNext(&foundFile));
584 std::vector<PanoCommand::PanoCommand*> cmds;
590 if (!rawFilesv.empty())
592 if (rawFilesv.size() == 1)
594 wxMessageDialog message(GetTopWindow(), _(
"You selected only one raw file. This is not recommended.\nAll raw files should be converted at once."),
600 wxICON_EXCLAMATION | wxOK | wxCANCEL);
601 message.SetOKLabel(_(
"Convert anyway."));
602 if (message.ShowModal() != wxID_OK)
612 if (dlg.ShowModal() == wxID_OK)
621 m_macInitDone =
true;
623 m_macOpenFileOnStart =
false;
627 wxString secondParam = argc > 2 ? wxString(argv[2]) : wxString();
628 if(secondParam.Cmp(_T(
"-notips"))!=0)
631 int nValue = config->Read(wxT(
"/MainFrame/ShowStartTip"), 1l);
636 wxCommandEvent dummy;
641 DEBUG_TRACE(
"=========================== huginApp::OnInit() end ===================");
648 delete wxHelpProvider::Set(NULL);
674 if (event.
entry.get())
676 ImageCache::getInstance().postEvent(event.
request, event.
entry);
681 ImageCache::getInstance().removeRequest(event.
request);
683 wxCommandEvent e(EVT_LOADING_FAILED);
685 frame->GetEventHandler()->AddPendingEvent(e);
696 Get()->AddPendingEvent(event);
700 void huginApp::MacOpenFile(
const wxString &fileName)
704 m_macOpenFileOnStart=
true;
705 m_macFileNameToOpenOnStart = fileName;
713 #if wxUSE_ON_FATAL_EXCEPTION
714 void huginApp::OnFatalException()
716 GenerateReport(wxDebugReport::Context_Exception);
wxDEFINE_EVENT(EVT_QUEUE_PROGRESS, wxCommandEvent)
bool checkVersion(wxString v1, wxString v2)
int alphanum_comp(const std::string &l, const std::string &r)
Compare l and r with the same semantics as strcmp(), but with the "Alphanum Algorithm" which produces...
The application class for hugin.
virtual bool OnInit()
pseudo constructor.
start a new project, reset options to values in preferences
center panorama horizontically
declaration of main image tree control
wxIMPLEMENT_APP(huginApp)
cmsHPROFILE m_monitorProfile
xrc handler for handling mask editor panel
void registerPTWXDlgFcn()
void relayImageLoaded(ImageReadyEvent &event)
Relay image loaded event when the UI thread is ready to process it.
void OnTipOfDay(wxCommandEvent &e)
#define DEBUG_ASSERT(cond)
include file for the hugin project
wxHelpController & GetHelpController()
virtual wxEvent * Clone() const
wxString m_monitorProfileName
std::vector< HuginBase::UIntSet > Components
stores the components of the graph
static void Clean()
cleanup the static LensDB instance, must be called at the end of the program
static huginApp * Get()
hack.. kind of a pseudo singleton...
PanoCommand to combine other PanoCommands.
class to access Hugins camera and lens database
xrc handler for mask editor
void LoadProjectFile(const wxString &filename)
Definition of dialog and functions to import RAW images to project file.
HuginBase::ImageCache::EntryPtr entry
std::shared_ptr< Entry > EntryPtr
a shared pointer to the entry
PanoCommand::PanoCommand * GetPanoCommand()
return PanoCommand for adding converted raw files to Panorama
static MainFrame * getMainFrame()
Definition of dialog for numeric transforms.
std::shared_ptr< Request > RequestPtr
Reference counted request for an image to load.
wxwindows specific panorama commands
distributes all images above the sphere, for the assistant
xrc handler for CPImagesComboBox
static GlobalCmdHist & getInstance()
void addCommand(PanoCommand *command, bool execute=true)
Adds a command to the history.
void clear()
Erases all the undo/redo history.
xrc handler for CPImagesComboBox
ImageReadyEvent(HuginBase::ImageCache::RequestPtr request, HuginBase::ImageCache::EntryPtr entry)
wxString m_workDir
temporary working directory
include file for the hugin project
const GuiLevel GetGuiLevel() const
GLPreviewFrame * getGLPreview()
virtual int OnExit()
just for testing purposes
add image(s) to a panorama
functions for interaction with the hugin configuration file
xrc handler for HTMLWindow
Definition of HTMLWindow class which supports opening external links in default web browser...
HuginBase::ImageCache::RequestPtr request
wxString Components2Str(const HuginGraph::ImageGraph::Components &comp)
Event for when a requested image finished loading.
static void imageLoadedAsync(HuginBase::ImageCache::RequestPtr request, HuginBase::ImageCache::EntryPtr entry)
Queue up an image loaded event when an image has just loaded.
wxLocale locale
locale for internationalisation
bool CheckRawFiles()
return true, if all raw files are from the same camera
void GetMonitorProfile(wxString &profileName, cmsHPROFILE &profile)
retrieve monitor profile from system
void RestoreFramePosition(wxTopLevelWindow *frame, const wxString &basename)
Restore window size and position from configfile/registry.
int main(int argc, char *argv[])