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(
", "));
134 #if defined USE_GDKBACKEND_X11
138 #warning Using Hugin with hard coded GDK_BACKEND=x11
139 wxIMPLEMENT_WX_THEME_SUPPORT
142 int main(
int argc,
char **argv)
144 wxDISABLE_DEBUG_SUPPORT();
145 char backend[]=
"GDK_BACKEND=x11";
147 return wxEntry(argc, argv);
158 #if wxUSE_ON_FATAL_EXCEPTION
159 wxHandleFatalExceptions();
185 DEBUG_TRACE(
"=========================== huginApp::OnInit() begin ===================");
186 SetAppName(wxT(
"hugin"));
187 #if defined __WXGTK__
188 CheckConfigFilename();
196 wxSystemOptions::SetOption(wxT(
"mac.listctrl.always_use_generic"), 1);
201 wxSystemOptions::SetOption(wxOSX_FILEDIALOG_ALWAYS_SHOW_TYPES, 1);
208 wxFileSystem::AddHandler(
new wxZipFSHandler);
211 wxHelpControllerHelpProvider* provider =
new wxHelpControllerHelpProvider;
212 wxHelpProvider::Set(provider);
214 #if defined __WXMSW__
215 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
216 m_utilsBinDir = exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
217 exePath.RemoveLastDir();
218 const wxString huginRoot=exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
219 m_xrcPrefix = huginRoot + wxT(
"share\\hugin\\xrc\\");
220 m_DataDir = huginRoot + wxT(
"share\\hugin\\data\\");
223 locale.AddCatalogLookupPathPrefix(huginRoot + wxT(
"share\\locale"));
225 #elif defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
228 wxString thePath = MacGetPathToBundledResourceFile(CFSTR(
"xrc"));
229 if (thePath == wxT(
"")) {
230 wxMessageBox(_(
"xrc directory not found in bundle"), _(
"Fatal Error"));
240 wxString pythonHome = MacGetPathToBundledFrameworksDirectory() + wxT(
"/Python27.framework/Versions/Current");
241 if(! wxDir::Exists(pythonHome)){
242 wxMessageBox(wxString::Format(_(
"Directory '%s' does not exists"), pythonHome.c_str()));
244 wxUnsetEnv(wxT(
"PYTHONPATH"));
245 if(! wxSetEnv(wxT(
"PYTHONHOME"), pythonHome)){
246 wxMessageBox(_(
"Could not set environment variable PYTHONHOME"));
254 #elif defined UNIX_SELF_CONTAINED_BUNDLE
257 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
258 m_utilsBinDir = exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
259 exePath.RemoveLastDir();
260 const wxString huginRoot=exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
262 m_DataDir = huginRoot + wxT(
"share/hugin/data/");
265 locale.AddCatalogLookupPathPrefix(huginRoot + wxT(
"share/locale"));
272 locale.AddCatalogLookupPathPrefix(wxT(INSTALL_LOCALE_DIR));
275 if ( ! wxFile::Exists(
m_xrcPrefix + wxT(
"/main_frame.xrc")) ) {
276 wxMessageBox(_(
"xrc directory not found, hugin needs to be properly installed\nTried Path:" +
m_xrcPrefix ), _(
"Fatal Error"));
281 wxConfigBase * config = wxConfigBase::Get();
283 config->SetRecordDefaults(
false);
288 setlocale(LC_ALL,
"");
290 int localeID = config->Read(wxT(
"language"), (
long)
HUGIN_LANGUAGE);
294 bLInit =
locale.Init(localeID);
298 DEBUG_TRACE(
"Canonical Locale: " <<
locale.GetCanonicalName().mb_str(wxConvLocal))
305 locale.AddCatalog(wxT(
"hugin"));
308 wxInitAllImageHandlers();
311 wxXmlResource::Get()->InitAllHandlers();
314 #ifdef _INCLUDE_UI_RESOURCES
331 wxXmlResource::Get()->AddHandler(
new wxcode::wxTreeListCtrlXmlHandler());
337 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"cp_list_frame.xrc"));
338 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"preview_frame.xrc"));
339 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"edit_script_dialog.xrc"));
340 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"main_menu.xrc"));
341 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"main_tool.xrc"));
342 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"about.xrc"));
343 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"pref_dialog.xrc"));
344 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"cpdetector_dialog.xrc"));
345 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"reset_dialog.xrc"));
346 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"optimize_photo_panel.xrc"));
347 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"cp_editor_panel.xrc"));
348 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"images_panel.xrc"));
349 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"main_frame.xrc"));
350 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"optimize_panel.xrc"));
351 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"pano_panel.xrc"));
352 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"mask_editor_panel.xrc"));
353 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"lensdb_dialogs.xrc"));
354 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"image_variable_dlg.xrc"));
355 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"dlg_warning.xrc"));
356 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"import_raw_dialog.xrc"));
363 m_macOpenFileOnStart=
false;
374 frame->SendSizeEvent();
376 #if wxUSE_TASKBARBUTTON
377 wxTaskBarJumpList jumpList;
378 wxFileName exeFile(wxStandardPaths::Get().GetExecutablePath());
379 exeFile.SetName(
"PTBatcherGUI");
380 wxTaskBarJumpListItem *item1 =
new wxTaskBarJumpListItem(
381 NULL, wxTASKBAR_JUMP_LIST_TASK, _(
"Open Batch Processor"), exeFile.GetFullPath(), wxEmptyString,
382 _(
"Opens PTBatcherGUI, the batch processor for Hugin's project files"),
383 exeFile.GetFullPath(), 0);
384 jumpList.GetTasks().Append(item1);
385 exeFile.SetName(
"calibrate_lens_gui");
386 wxTaskBarJumpListItem *
item2 =
new wxTaskBarJumpListItem(
387 NULL, wxTASKBAR_JUMP_LIST_TASK, _(
"Open Lens calibrate tool"), exeFile.GetFullPath(), wxEmptyString,
388 _(
"Opens Calibrate_lens_gui, a simple GUI for lens calibration"),
389 exeFile.GetFullPath(), 0);
390 jumpList.GetTasks().Append(item2);
393 #pragma message("Warning: huginApp.cpp - wxWidgets is compiled without support for taskbar buttons. Some features have therefore disabled.")
395 #warning "Warning: huginApp.cpp - wxWidgets is compiled without support for taskbar buttons. Some features have therefore disabled."
404 #if wxUSE_WXHTML_HELP
406 #if defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
409 wxString strFile = MacGetPathToBundledResourceFile(CFSTR(
"help"));
410 if (!strFile.IsEmpty())
416 wxLogError(wxString::Format(wxT(
"Could not find help directory in the bundle"), strFile.c_str()));
429 SetExitOnFrameDelete(
true);
440 wxString cwd = wxFileName::GetCwd();
442 m_workDir = config->Read(wxT(
"tempDir"),wxT(
""));
446 #if (defined __WXMSW__)
449 wxChar buffer[MAX_PATH];
450 GetTempPath(MAX_PATH, buffer);
452 #elif (defined __WXMAC__) && (defined MAC_SELF_CONTAINED_BUNDLE)
454 m_workDir = MacGetPathToUserDomainTempDir();
460 if (!wxGetEnv(wxT(
"TMPDIR"), &
m_workDir)) {
484 TIFFSetWarningHandler(0);
497 wxFileName file(argv[1]);
499 if (file.GetExt().CmpNoCase(wxT(
"pto")) == 0 ||
500 file.GetExt().CmpNoCase(wxT(
"pts")) == 0 ||
501 file.GetExt().CmpNoCase(wxT(
"ptp")) == 0 )
503 if(file.IsRelative())
504 file.MakeAbsolute(cwd);
510 std::vector<std::string> filesv;
511 std::vector<std::string> rawFilesv;
512 bool actualPathSet =
false;
513 for (
int i=1; i< argc; i++)
515 #if defined __WXMSW__
517 wxFileName fileList(argv[i]);
518 if(fileList.IsRelative())
519 fileList.MakeAbsolute(cwd);
523 if(fileList.DirExists())
524 if(dir.Open(fileList.GetPath()))
525 if(dir.GetFirst(&foundFile,fileList.GetFullName(),wxDIR_FILES | wxDIR_HIDDEN))
529 file.MakeAbsolute(dir.GetName());
531 wxFileName file(argv[i]);
533 if (file.IsRelative())
535 file.MakeAbsolute(cwd);
546 config->Write(wxT(
"/actualPath"), file.GetPath());
547 actualPathSet =
true;
561 config->Write(wxT(
"/actualPath"), file.GetPath());
562 actualPathSet =
true;
567 #if defined __WXMSW__
568 }
while (dir.GetNext(&foundFile));
573 std::vector<PanoCommand::PanoCommand*> cmds;
579 if (!rawFilesv.empty())
581 if (rawFilesv.size() == 1)
583 wxMessageDialog message(GetTopWindow(), _(
"You selected only one raw file. This is not recommended.\nAll raw files should be converted at once."),
589 wxICON_EXCLAMATION | wxOK | wxCANCEL);
590 message.SetOKLabel(_(
"Convert anyway."));
591 if (message.ShowModal() != wxID_OK)
601 if (dlg.ShowModal() == wxID_OK)
610 m_macInitDone =
true;
612 m_macOpenFileOnStart =
false;
616 wxString secondParam = argc > 2 ? wxString(argv[2]) : wxString();
617 if(secondParam.Cmp(_T(
"-notips"))!=0)
620 int nValue = config->Read(wxT(
"/MainFrame/ShowStartTip"), 1l);
625 wxCommandEvent dummy;
630 DEBUG_TRACE(
"=========================== huginApp::OnInit() end ===================");
637 delete wxHelpProvider::Set(NULL);
663 if (event.
entry.get())
665 ImageCache::getInstance().postEvent(event.
request, event.
entry);
670 ImageCache::getInstance().removeRequest(event.
request);
672 wxCommandEvent e(EVT_LOADING_FAILED);
674 frame->GetEventHandler()->AddPendingEvent(e);
685 Get()->AddPendingEvent(event);
689 void huginApp::MacOpenFile(
const wxString &fileName)
693 m_macOpenFileOnStart=
true;
694 m_macFileNameToOpenOnStart = fileName;
702 #if wxUSE_ON_FATAL_EXCEPTION
703 void huginApp::OnFatalException()
705 GenerateReport(wxDebugReport::Context_Exception);
718 wxConfigBase * config = wxConfigBase::Get();
722 wxDisplaySize(&dx,&dy);
728 int w = config->Read(wxT(
"/") + basename + wxT(
"/width"),-1l);
729 int h = config->Read(wxT(
"/") + basename + wxT(
"/height"),-1l);
730 if (w > 0 && w <= dx) {
731 frame->SetClientSize(w,h);
736 int x = config->Read(wxT(
"/") + basename + wxT(
"/positionX"),-1l);
737 int y = config->Read(wxT(
"/") + basename + wxT(
"/positionY"),-1l);
738 if ( y >= 0 && x >= 0 && x < dx && y < dy) {
744 bool maximized = config->Read(wxT(
"/") + basename + wxT(
"/maximized"), 0l) != 0;
749 int w = config->Read(wxT(
"/") + basename + wxT(
"/width"),-1l);
750 int h = config->Read(wxT(
"/") + basename + wxT(
"/height"),-1l);
751 if (w > 0 && w <= dx) {
752 frame->SetClientSize(w,h);
757 int x = config->Read(wxT(
"/") + basename + wxT(
"/positionX"),-1l);
758 int y = config->Read(wxT(
"/") + basename + wxT(
"/positionY"),-1l);
759 if ( y >= 0 && x >= 0 && x < dx && y < dy) {
773 wxConfigBase * config = wxConfigBase::Get();
779 wxSize sz = frame->GetClientSize();
780 config->Write(wxT(
"/") + basename + wxT(
"/width"), sz.GetWidth());
781 config->Write(wxT(
"/") + basename + wxT(
"/height"), sz.GetHeight());
782 wxPoint ps = frame->GetPosition();
783 config->Write(wxT(
"/") + basename + wxT(
"/positionX"), ps.x);
784 config->Write(wxT(
"/") + basename + wxT(
"/positionY"), ps.y);
785 config->Write(wxT(
"/") + basename + wxT(
"/maximized"), 0);
787 if ( (! frame->IsMaximized()) && (! frame->IsIconized()) ) {
788 wxSize sz = frame->GetClientSize();
789 config->Write(wxT(
"/") + basename + wxT(
"/width"), sz.GetWidth());
790 config->Write(wxT(
"/") + basename + wxT(
"/height"), sz.GetHeight());
791 wxPoint ps = frame->GetPosition();
792 config->Write(wxT(
"/") + basename + wxT(
"/positionX"), ps.x);
793 config->Write(wxT(
"/") + basename + wxT(
"/positionY"), ps.y);
794 config->Write(wxT(
"/") + basename + wxT(
"/maximized"), 0);
795 }
else if (frame->IsMaximized()){
796 config->Write(wxT(
"/") + basename + wxT(
"/maximized"), 1l);
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.
#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)
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[])