27 #include "hugin_config.h"
32 #include <wx/sysopt.h>
61 #include <wx/cshelp.h>
62 #include <wx/stdpaths.h>
65 #if wxCHECK_VERSION(3,1,0)
66 #include <wx/taskbarbutton.h>
69 #if defined __WXGTK__ && wxCHECK_VERSION(3,1,1)
83 return doj::alphanum_comp(std::string(v1.mb_str(wxConvLocal)),std::string(v2.mb_str(wxConvLocal))) < 0;
89 for (
unsigned i=0; i < comp.size(); i++) {
91 HuginGraph::ImageGraph::Components::value_type::const_iterator it = comp[i].begin();
92 while (it != comp[i].end())
94 unsigned int imgNr = *it;
97 if (it != comp[i].end() && *it == imgNr + 1)
100 while (it != comp[i].end() && *it == imgNr + 1)
106 if (it != comp[i].end())
108 ret.Append(wxT(
", "));
113 if (it != comp[i].end())
115 ret.Append(wxT(
", "));
120 ret.Append(wxT(
"]"));
121 if (i + 1 != comp.size())
123 ret.Append(wxT(
", "));
129 #if defined _WIN32 && defined Hugin_shared
130 DEFINE_LOCAL_EVENT_TYPE( EVT_IMAGE_READY )
132 DEFINE_EVENT_TYPE( EVT_IMAGE_READY )
140 #if defined USE_GDKBACKEND_X11
144 #warning Using Hugin with hard coded GDK_BACKEND=x11
145 wxIMPLEMENT_WX_THEME_SUPPORT
148 int main(
int argc,
char **argv)
150 wxDISABLE_DEBUG_SUPPORT();
151 char backend[]=
"GDK_BACKEND=x11";
153 return wxEntry(argc, argv);
164 #if wxUSE_ON_FATAL_EXCEPTION
165 wxHandleFatalExceptions();
191 DEBUG_TRACE(
"=========================== huginApp::OnInit() begin ===================");
192 SetAppName(wxT(
"hugin"));
193 #if defined __WXGTK__ && wxCHECK_VERSION(3,1,1)
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(_(
"xrc directory not found, hugin needs to be properly installed\nTried Path:" +
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
337 wxXmlResource::Get()->AddHandler(
new wxcode::wxTreeListCtrlXmlHandler());
343 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"cp_list_frame.xrc"));
344 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"preview_frame.xrc"));
345 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"edit_script_dialog.xrc"));
346 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"main_menu.xrc"));
347 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"main_tool.xrc"));
348 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"about.xrc"));
349 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"pref_dialog.xrc"));
350 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"cpdetector_dialog.xrc"));
351 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"reset_dialog.xrc"));
352 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"optimize_photo_panel.xrc"));
353 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"cp_editor_panel.xrc"));
354 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"images_panel.xrc"));
355 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"main_frame.xrc"));
356 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"optimize_panel.xrc"));
357 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"pano_panel.xrc"));
358 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"mask_editor_panel.xrc"));
359 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"lensdb_dialogs.xrc"));
360 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"image_variable_dlg.xrc"));
361 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"dlg_warning.xrc"));
362 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"import_raw_dialog.xrc"));
369 m_macOpenFileOnStart=
false;
380 frame->SendSizeEvent();
381 #if wxCHECK_VERSION(3,1,0)
383 #if wxUSE_TASKBARBUTTON
384 wxTaskBarJumpList jumpList;
385 wxFileName exeFile(wxStandardPaths::Get().GetExecutablePath());
386 exeFile.SetName(
"PTBatcherGUI");
387 wxTaskBarJumpListItem *item1 =
new wxTaskBarJumpListItem(
388 NULL, wxTASKBAR_JUMP_LIST_TASK, _(
"Open Batch Processor"), exeFile.GetFullPath(), wxEmptyString,
389 _(
"Opens PTBatcherGUI, the batch processor for Hugin's project files"),
390 exeFile.GetFullPath(), 0);
391 jumpList.GetTasks().Append(item1);
392 exeFile.SetName(
"calibrate_lens_gui");
393 wxTaskBarJumpListItem *
item2 =
new wxTaskBarJumpListItem(
394 NULL, wxTASKBAR_JUMP_LIST_TASK, _(
"Open Lens calibrate tool"), exeFile.GetFullPath(), wxEmptyString,
395 _(
"Opens Calibrate_lens_gui, a simple GUI for lens calibration"),
396 exeFile.GetFullPath(), 0);
397 jumpList.GetTasks().Append(item2);
400 #pragma message("Warning: huginApp.cpp - wxWidgets is compiled without support for taskbar buttons. Some features have therefore disabled.")
402 #warning "Warning: huginApp.cpp - wxWidgets is compiled without support for taskbar buttons. Some features have therefore disabled."
412 #if wxUSE_WXHTML_HELP
414 #if defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
417 wxString strFile = MacGetPathToBundledResourceFile(CFSTR(
"help"));
418 if (!strFile.IsEmpty())
424 wxLogError(wxString::Format(wxT(
"Could not find help directory in the bundle"), strFile.c_str()));
437 SetExitOnFrameDelete(
true);
448 wxString cwd = wxFileName::GetCwd();
450 m_workDir = config->Read(wxT(
"tempDir"),wxT(
""));
454 #if (defined __WXMSW__)
457 wxChar buffer[MAX_PATH];
458 GetTempPath(MAX_PATH, buffer);
460 #elif (defined __WXMAC__) && (defined MAC_SELF_CONTAINED_BUNDLE)
462 m_workDir = MacGetPathToUserDomainTempDir();
468 if (!wxGetEnv(wxT(
"TMPDIR"), &
m_workDir)) {
492 TIFFSetWarningHandler(0);
505 wxFileName file(argv[1]);
507 if (file.GetExt().CmpNoCase(wxT(
"pto")) == 0 ||
508 file.GetExt().CmpNoCase(wxT(
"pts")) == 0 ||
509 file.GetExt().CmpNoCase(wxT(
"ptp")) == 0 )
511 if(file.IsRelative())
512 file.MakeAbsolute(cwd);
518 std::vector<std::string> filesv;
519 std::vector<std::string> rawFilesv;
520 bool actualPathSet =
false;
521 for (
int i=1; i< argc; i++)
523 #if defined __WXMSW__
525 wxFileName fileList(argv[i]);
526 if(fileList.IsRelative())
527 fileList.MakeAbsolute(cwd);
531 if(fileList.DirExists())
532 if(dir.Open(fileList.GetPath()))
533 if(dir.GetFirst(&foundFile,fileList.GetFullName(),wxDIR_FILES | wxDIR_HIDDEN))
537 file.MakeAbsolute(dir.GetName());
539 wxFileName file(argv[i]);
541 if (file.IsRelative())
543 file.MakeAbsolute(cwd);
554 config->Write(wxT(
"/actualPath"), file.GetPath());
555 actualPathSet =
true;
569 config->Write(wxT(
"/actualPath"), file.GetPath());
570 actualPathSet =
true;
575 #if defined __WXMSW__
576 }
while (dir.GetNext(&foundFile));
581 std::vector<PanoCommand::PanoCommand*> cmds;
587 if (!rawFilesv.empty())
589 if (rawFilesv.size() == 1)
591 wxMessageDialog message(GetTopWindow(), _(
"You selected only one raw file. This is not recommended.\nAll raw files should be converted at once."),
597 wxICON_EXCLAMATION | wxOK | wxCANCEL);
598 message.SetOKLabel(_(
"Convert anyway."));
599 if (message.ShowModal() != wxID_OK)
609 if (dlg.ShowModal() == wxID_OK)
618 m_macInitDone =
true;
620 m_macOpenFileOnStart =
false;
624 wxString secondParam = argc > 2 ? wxString(argv[2]) : wxString();
625 if(secondParam.Cmp(_T(
"-notips"))!=0)
628 int nValue = config->Read(wxT(
"/MainFrame/ShowStartTip"), 1l);
633 wxCommandEvent dummy;
638 DEBUG_TRACE(
"=========================== huginApp::OnInit() end ===================");
645 delete wxHelpProvider::Set(NULL);
671 if (event.
entry.get())
673 ImageCache::getInstance().postEvent(event.
request, event.
entry);
678 ImageCache::getInstance().removeRequest(event.
request);
680 wxCommandEvent e(EVT_LOADING_FAILED);
682 frame->GetEventHandler()->AddPendingEvent(e);
693 Get()->AddPendingEvent(event);
697 void huginApp::MacOpenFile(
const wxString &fileName)
701 m_macOpenFileOnStart=
true;
702 m_macFileNameToOpenOnStart = fileName;
710 #if wxUSE_ON_FATAL_EXCEPTION
711 void huginApp::OnFatalException()
713 GenerateReport(wxDebugReport::Context_Exception);
726 wxConfigBase * config = wxConfigBase::Get();
730 wxDisplaySize(&dx,&dy);
736 int w = config->Read(wxT(
"/") + basename + wxT(
"/width"),-1l);
737 int h = config->Read(wxT(
"/") + basename + wxT(
"/height"),-1l);
738 if (w > 0 && w <= dx) {
739 frame->SetClientSize(w,h);
744 int x = config->Read(wxT(
"/") + basename + wxT(
"/positionX"),-1l);
745 int y = config->Read(wxT(
"/") + basename + wxT(
"/positionY"),-1l);
746 if ( y >= 0 && x >= 0 && x < dx && y < dy) {
752 bool maximized = config->Read(wxT(
"/") + basename + wxT(
"/maximized"), 0l) != 0;
757 int w = config->Read(wxT(
"/") + basename + wxT(
"/width"),-1l);
758 int h = config->Read(wxT(
"/") + basename + wxT(
"/height"),-1l);
759 if (w > 0 && w <= dx) {
760 frame->SetClientSize(w,h);
765 int x = config->Read(wxT(
"/") + basename + wxT(
"/positionX"),-1l);
766 int y = config->Read(wxT(
"/") + basename + wxT(
"/positionY"),-1l);
767 if ( y >= 0 && x >= 0 && x < dx && y < dy) {
781 wxConfigBase * config = wxConfigBase::Get();
787 wxSize sz = frame->GetClientSize();
788 config->Write(wxT(
"/") + basename + wxT(
"/width"), sz.GetWidth());
789 config->Write(wxT(
"/") + basename + wxT(
"/height"), sz.GetHeight());
790 wxPoint ps = frame->GetPosition();
791 config->Write(wxT(
"/") + basename + wxT(
"/positionX"), ps.x);
792 config->Write(wxT(
"/") + basename + wxT(
"/positionY"), ps.y);
793 config->Write(wxT(
"/") + basename + wxT(
"/maximized"), 0);
795 if ( (! frame->IsMaximized()) && (! frame->IsIconized()) ) {
796 wxSize sz = frame->GetClientSize();
797 config->Write(wxT(
"/") + basename + wxT(
"/width"), sz.GetWidth());
798 config->Write(wxT(
"/") + basename + wxT(
"/height"), sz.GetHeight());
799 wxPoint ps = frame->GetPosition();
800 config->Write(wxT(
"/") + basename + wxT(
"/positionX"), ps.x);
801 config->Write(wxT(
"/") + basename + wxT(
"/positionY"), ps.y);
802 config->Write(wxT(
"/") + basename + wxT(
"/maximized"), 0);
803 }
else if (frame->IsMaximized()){
804 config->Write(wxT(
"/") + basename + wxT(
"/maximized"), 1l);
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.
#define EVT_IMAGE_READY2(id, fn)
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()
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
PanoCommand::PanoCommand * GetPanoCommand()
return PanoCommand for adding converted raw files to Panorama
void StoreFramePosition(wxTopLevelWindow *frame, const wxString &basename)
Store window size and position in configfile/registry.
static MainFrame * getMainFrame()
Definition of dialog for numeric transforms.
wxwindows specific panorama commands
distributes all images above the sphere, for the assistant
void RestoreFramePosition(wxTopLevelWindow *frame, const wxString &basename)
Restore window size and position from configfile/registry.
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
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)
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[])