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())
111 if (it != comp[i].end())
119 if (i + 1 != comp.size())
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 ===================");
193 #if defined __WXMSW__ && wxCHECK_VERSION(3,3,0)
195 SetAppearance(Appearance::System);
197 #if defined __WXGTK__
198 CheckConfigFilename();
206 wxSystemOptions::SetOption(
"mac.listctrl.always_use_generic", 1);
211 wxSystemOptions::SetOption(wxOSX_FILEDIALOG_ALWAYS_SHOW_TYPES, 1);
218 wxFileSystem::AddHandler(
new wxZipFSHandler);
221 wxHelpControllerHelpProvider* provider =
new wxHelpControllerHelpProvider;
222 wxHelpProvider::Set(provider);
224 #if defined __WXMSW__
225 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
226 m_utilsBinDir = exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
227 exePath.RemoveLastDir();
228 const wxString huginRoot=exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
230 m_DataDir = huginRoot +
"share\\hugin\\data\\";
233 locale.AddCatalogLookupPathPrefix(huginRoot +
"share\\locale");
235 #elif defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
238 wxString thePath = MacGetPathToBundledResourceFile(CFSTR(
"xrc"));
239 if (thePath == wxEmptyString) {
250 wxString pythonHome = MacGetPathToBundledFrameworksDirectory() +
"/Python27.framework/Versions/Current";
251 if(! wxDir::Exists(pythonHome)){
252 hugin_utils::HuginMessageBox(wxString::Format(_(
"Directory '%s' does not exists"), pythonHome), _(
"Hugin"), wxOK | wxICON_ERROR, wxGetActiveWindow());
254 wxUnsetEnv(
"PYTHONPATH");
255 if(! wxSetEnv(
"PYTHONHOME", pythonHome)){
264 #elif defined UNIX_SELF_CONTAINED_BUNDLE
267 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
268 m_utilsBinDir = exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
269 exePath.RemoveLastDir();
270 const wxString huginRoot=exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
272 m_DataDir = huginRoot +
"share/hugin/data/";
275 locale.AddCatalogLookupPathPrefix(huginRoot +
"share/locale");
282 locale.AddCatalogLookupPathPrefix(INSTALL_LOCALE_DIR);
285 if ( ! wxFile::Exists(
m_xrcPrefix +
"/main_frame.xrc") ) {
286 hugin_utils::HuginMessageBox(wxString::Format(_(
"xrc directory not found, hugin needs to be properly installed\nTried Path: %s"),
m_xrcPrefix), _(
"Hugin"), wxOK | wxICON_ERROR, wxGetActiveWindow());
291 wxConfigBase * config = wxConfigBase::Get();
293 config->SetRecordDefaults(
false);
298 setlocale(LC_ALL,
"");
304 bLInit =
locale.Init(localeID);
308 DEBUG_TRACE(
"Canonical Locale: " <<
locale.GetCanonicalName().mb_str(wxConvLocal))
315 locale.AddCatalog(
"hugin");
318 wxInitAllImageHandlers();
321 wxXmlResource::Get()->InitAllHandlers();
324 #ifdef _INCLUDE_UI_RESOURCES
340 wxXmlResource::Get()->AddHandler(
new wxcode::wxTreeListCtrlXmlHandler());
346 wxXmlResource::Get()->Load(
m_xrcPrefix +
"cp_list_frame.xrc");
347 wxXmlResource::Get()->Load(
m_xrcPrefix +
"preview_frame.xrc");
348 wxXmlResource::Get()->Load(
m_xrcPrefix +
"edit_script_dialog.xrc");
349 wxXmlResource::Get()->Load(
m_xrcPrefix +
"main_menu.xrc");
350 wxXmlResource::Get()->Load(
m_xrcPrefix +
"main_tool.xrc");
351 wxXmlResource::Get()->Load(
m_xrcPrefix +
"about.xrc");
352 wxXmlResource::Get()->Load(
m_xrcPrefix +
"pref_dialog.xrc");
353 wxXmlResource::Get()->Load(
m_xrcPrefix +
"cpdetector_dialog.xrc");
354 wxXmlResource::Get()->Load(
m_xrcPrefix +
"reset_dialog.xrc");
355 wxXmlResource::Get()->Load(
m_xrcPrefix +
"optimize_photo_panel.xrc");
356 wxXmlResource::Get()->Load(
m_xrcPrefix +
"cp_editor_panel.xrc");
357 wxXmlResource::Get()->Load(
m_xrcPrefix +
"images_panel.xrc");
358 wxXmlResource::Get()->Load(
m_xrcPrefix +
"main_frame.xrc");
359 wxXmlResource::Get()->Load(
m_xrcPrefix +
"optimize_panel.xrc");
360 wxXmlResource::Get()->Load(
m_xrcPrefix +
"pano_panel.xrc");
361 wxXmlResource::Get()->Load(
m_xrcPrefix +
"mask_editor_panel.xrc");
362 wxXmlResource::Get()->Load(
m_xrcPrefix +
"lensdb_dialogs.xrc");
363 wxXmlResource::Get()->Load(
m_xrcPrefix +
"image_variable_dlg.xrc");
364 wxXmlResource::Get()->Load(
m_xrcPrefix +
"dlg_warning.xrc");
365 wxXmlResource::Get()->Load(
m_xrcPrefix +
"import_raw_dialog.xrc");
372 m_macOpenFileOnStart=
false;
383 frame->SendSizeEvent();
385 #if wxUSE_TASKBARBUTTON
386 wxTaskBarJumpList jumpList;
387 wxFileName exeFile(wxStandardPaths::Get().GetExecutablePath());
388 exeFile.SetName(
"PTBatcherGUI");
389 wxTaskBarJumpListItem *item1 =
new wxTaskBarJumpListItem(
390 NULL, wxTASKBAR_JUMP_LIST_TASK, _(
"Open Batch Processor"), exeFile.GetFullPath(), wxEmptyString,
391 _(
"Opens PTBatcherGUI, the batch processor for Hugin's project files"),
392 exeFile.GetFullPath(), 0);
393 jumpList.GetTasks().Append(item1);
394 exeFile.SetName(
"calibrate_lens_gui");
395 item1 =
new wxTaskBarJumpListItem(
396 NULL, wxTASKBAR_JUMP_LIST_TASK, _(
"Open Lens calibrate tool"), exeFile.GetFullPath(), wxEmptyString,
397 _(
"Opens Calibrate_lens_gui, a simple GUI for lens calibration"),
398 exeFile.GetFullPath(), 0);
399 jumpList.GetTasks().Append(item1);
400 exeFile.SetName(
"Hugin_toolbox");
401 item1 =
new wxTaskBarJumpListItem(
402 NULL, wxTASKBAR_JUMP_LIST_TASK, _(
"Open Hugin toolbox"), exeFile.GetFullPath(), wxEmptyString,
403 _(
"Opens Hugin_toolbox, a GUI for several small helper programs"),
404 exeFile.GetFullPath(), 0);
405 jumpList.GetTasks().Append(item1);
408 #pragma message("Warning: huginApp.cpp - wxWidgets is compiled without support for taskbar buttons. Some features have therefore disabled.")
410 #warning "Warning: huginApp.cpp - wxWidgets is compiled without support for taskbar buttons. Some features have therefore disabled."
419 #if wxUSE_WXHTML_HELP
421 #if defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
424 wxString strFile = MacGetPathToBundledResourceFile(CFSTR(
"help"));
425 if (!strFile.IsEmpty())
431 wxLogError(wxString::Format(
"Could not find help directory in the bundle", strFile.c_str()));
444 SetExitOnFrameDelete(
true);
455 wxString cwd = wxFileName::GetCwd();
457 m_workDir = config->Read(
"tempDir",wxEmptyString);
461 #if (defined __WXMSW__)
464 wxChar buffer[MAX_PATH];
465 GetTempPath(MAX_PATH, buffer);
467 #elif (defined __WXMAC__) && (defined MAC_SELF_CONTAINED_BUNDLE)
469 m_workDir = MacGetPathToUserDomainTempDir();
499 TIFFSetWarningHandler(0);
512 wxFileName file(argv[1]);
514 if (file.GetExt().CmpNoCase(
"pto") == 0 ||
515 file.GetExt().CmpNoCase(
"pts") == 0 ||
516 file.GetExt().CmpNoCase(
"ptp") == 0 )
518 if(file.IsRelative())
519 file.MakeAbsolute(cwd);
525 std::vector<std::string> filesv;
526 std::vector<std::string> rawFilesv;
527 bool actualPathSet =
false;
528 for (
int i=1; i< argc; i++)
530 #if defined __WXMSW__
532 wxFileName fileList(argv[i]);
533 if(fileList.IsRelative())
534 fileList.MakeAbsolute(cwd);
538 if(fileList.DirExists())
539 if(dir.Open(fileList.GetPath()))
540 if(dir.GetFirst(&foundFile,fileList.GetFullName(),wxDIR_FILES | wxDIR_HIDDEN))
544 file.MakeAbsolute(dir.GetName());
546 wxFileName file(argv[i]);
548 if (file.IsRelative())
550 file.MakeAbsolute(cwd);
561 config->Write(
"/actualPath", file.GetPath());
562 actualPathSet =
true;
576 config->Write(
"/actualPath", file.GetPath());
577 actualPathSet =
true;
582 #if defined __WXMSW__
583 }
while (dir.GetNext(&foundFile));
588 std::vector<PanoCommand::PanoCommand*> cmds;
594 if (!rawFilesv.empty())
596 if (rawFilesv.size() == 1)
599 _(
"Hugin"), wxICON_EXCLAMATION | wxOK | wxCANCEL, wxGetActiveWindow());
600 message->SetOKLabel(_(
"Convert anyway."));
601 if (message->ShowModal() != wxID_OK)
611 if (dlg.ShowModal() == wxID_OK)
620 m_macInitDone =
true;
622 m_macOpenFileOnStart =
false;
626 wxString secondParam = argc > 2 ? wxString(argv[2]) : wxString();
627 if(secondParam.Cmp(_T(
"-notips"))!=0)
630 int nValue = config->Read(
"/MainFrame/ShowStartTip", 1l);
635 wxCommandEvent dummy;
640 DEBUG_TRACE(
"=========================== huginApp::OnInit() end ===================");
647 delete wxHelpProvider::Set(NULL);
673 if (event.
entry.get())
675 ImageCache::getInstance().postEvent(event.
request, event.
entry);
680 ImageCache::getInstance().removeRequest(event.
request);
682 wxCommandEvent e(EVT_LOADING_FAILED);
684 frame->GetEventHandler()->AddPendingEvent(e);
695 Get()->AddPendingEvent(event);
699 void huginApp::MacOpenFile(
const wxString &fileName)
703 m_macOpenFileOnStart=
true;
704 m_macFileNameToOpenOnStart = fileName;
712 #if wxUSE_ON_FATAL_EXCEPTION
713 void huginApp::OnFatalException()
715 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.
void RestoreFramePosition(wxTopLevelWindow *frame, const wxString &basename, const bool ignoreMaximize)
start a new project, reset options to values in preferences
center panorama horizontically
declaration of main image tree control
wxIMPLEMENT_APP(huginApp)
std::unique_ptr< wxMessageDialogBase > MessageDialog
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
MessageDialog GetMessageDialog(const wxString &message, const wxString &caption, int style, wxWindow *parent)
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)
int HuginMessageBox(const wxString &message, const wxString &caption, int style, wxWindow *parent)
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
int main(int argc, char *argv[])