27 #include "hugin_config.h"
32 #include <wx/sysopt.h>
60 #include <wx/cshelp.h>
61 #include <wx/stdpaths.h>
64 #include <wx/taskbarbutton.h>
80 return doj::alphanum_comp(std::string(v1.mb_str(wxConvLocal)),std::string(v2.mb_str(wxConvLocal))) < 0;
86 for (
unsigned i=0; i < comp.size(); i++) {
88 HuginGraph::ImageGraph::Components::value_type::const_iterator it = comp[i].begin();
89 while (it != comp[i].end())
91 unsigned int imgNr = *it;
94 if (it != comp[i].end() && *it == imgNr + 1)
97 while (it != comp[i].end() && *it == imgNr + 1)
103 if (it != comp[i].end())
105 ret.Append(wxT(
", "));
110 if (it != comp[i].end())
112 ret.Append(wxT(
", "));
117 ret.Append(wxT(
"]"));
118 if (i + 1 != comp.size())
120 ret.Append(wxT(
", "));
127 #if defined USE_GDKBACKEND_X11
131 #warning Using Hugin with hard coded GDK_BACKEND=x11
132 wxIMPLEMENT_WX_THEME_SUPPORT
135 int main(
int argc,
char **argv)
137 wxDISABLE_DEBUG_SUPPORT();
138 char backend[]=
"GDK_BACKEND=x11";
140 return wxEntry(argc, argv);
162 #if wxUSE_ON_FATAL_EXCEPTION
163 wxHandleFatalExceptions();
190 DEBUG_TRACE(
"=========================== huginApp::OnInit() begin ===================");
191 SetAppName(wxT(
"hugin"));
192 #if defined __WXGTK__
193 CheckConfigFilename();
201 wxSystemOptions::SetOption(wxT(
"mac.listctrl.always_use_generic"), 1);
206 wxSystemOptions::SetOption(wxOSX_FILEDIALOG_ALWAYS_SHOW_TYPES, 1);
213 wxFileSystem::AddHandler(
new wxZipFSHandler);
216 wxHelpControllerHelpProvider* provider =
new wxHelpControllerHelpProvider;
217 wxHelpProvider::Set(provider);
219 #if defined __WXMSW__
220 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
221 m_utilsBinDir = exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
222 exePath.RemoveLastDir();
223 const wxString huginRoot=exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
224 m_xrcPrefix = huginRoot + wxT(
"share\\hugin\\xrc\\");
225 m_DataDir = huginRoot + wxT(
"share\\hugin\\data\\");
228 locale.AddCatalogLookupPathPrefix(huginRoot + wxT(
"share\\locale"));
230 #elif defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
233 wxString thePath = MacGetPathToBundledResourceFile(CFSTR(
"xrc"));
234 if (thePath == wxT(
"")) {
235 wxMessageBox(_(
"xrc directory not found in bundle"), _(
"Fatal Error"));
245 wxString pythonHome = MacGetPathToBundledFrameworksDirectory() + wxT(
"/Python27.framework/Versions/Current");
246 if(! wxDir::Exists(pythonHome)){
247 wxMessageBox(wxString::Format(_(
"Directory '%s' does not exists"), pythonHome.c_str()));
249 wxUnsetEnv(wxT(
"PYTHONPATH"));
250 if(! wxSetEnv(wxT(
"PYTHONHOME"), pythonHome)){
251 wxMessageBox(_(
"Could not set environment variable PYTHONHOME"));
259 #elif defined UNIX_SELF_CONTAINED_BUNDLE
262 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
263 m_utilsBinDir = exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
264 exePath.RemoveLastDir();
265 const wxString huginRoot=exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
267 m_DataDir = huginRoot + wxT(
"share/hugin/data/");
270 locale.AddCatalogLookupPathPrefix(huginRoot + wxT(
"share/locale"));
277 locale.AddCatalogLookupPathPrefix(wxT(INSTALL_LOCALE_DIR));
280 if ( ! wxFile::Exists(
m_xrcPrefix + wxT(
"/main_frame.xrc")) ) {
281 wxMessageBox(_(
"xrc directory not found, hugin needs to be properly installed\nTried Path:" +
m_xrcPrefix ), _(
"Fatal Error"));
286 wxConfigBase * config = wxConfigBase::Get();
288 config->SetRecordDefaults(
false);
293 setlocale(LC_ALL,
"");
295 int localeID = config->Read(wxT(
"language"), (
long)
HUGIN_LANGUAGE);
299 bLInit =
locale.Init(localeID);
303 DEBUG_TRACE(
"Canonical Locale: " <<
locale.GetCanonicalName().mb_str(wxConvLocal))
310 locale.AddCatalog(wxT(
"hugin"));
313 wxInitAllImageHandlers();
316 wxXmlResource::Get()->InitAllHandlers();
319 #ifdef _INCLUDE_UI_RESOURCES
335 wxXmlResource::Get()->AddHandler(
new wxcode::wxTreeListCtrlXmlHandler());
341 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"cp_list_frame.xrc"));
342 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"preview_frame.xrc"));
343 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"edit_script_dialog.xrc"));
344 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"main_menu.xrc"));
345 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"main_tool.xrc"));
346 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"about.xrc"));
347 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"pref_dialog.xrc"));
348 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"cpdetector_dialog.xrc"));
349 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"reset_dialog.xrc"));
350 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"optimize_photo_panel.xrc"));
351 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"cp_editor_panel.xrc"));
352 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"images_panel.xrc"));
353 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"main_frame.xrc"));
354 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"optimize_panel.xrc"));
355 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"pano_panel.xrc"));
356 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"mask_editor_panel.xrc"));
357 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"lensdb_dialogs.xrc"));
358 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"image_variable_dlg.xrc"));
359 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"dlg_warning.xrc"));
360 wxXmlResource::Get()->Load(
m_xrcPrefix + wxT(
"import_raw_dialog.xrc"));
367 m_macOpenFileOnStart=
false;
378 frame->SendSizeEvent();
380 #if wxUSE_TASKBARBUTTON
381 wxTaskBarJumpList jumpList;
382 wxFileName exeFile(wxStandardPaths::Get().GetExecutablePath());
383 exeFile.SetName(
"PTBatcherGUI");
384 wxTaskBarJumpListItem *item1 =
new wxTaskBarJumpListItem(
385 NULL, wxTASKBAR_JUMP_LIST_TASK, _(
"Open Batch Processor"), exeFile.GetFullPath(), wxEmptyString,
386 _(
"Opens PTBatcherGUI, the batch processor for Hugin's project files"),
387 exeFile.GetFullPath(), 0);
388 jumpList.GetTasks().Append(item1);
389 exeFile.SetName(
"calibrate_lens_gui");
390 wxTaskBarJumpListItem *
item2 =
new wxTaskBarJumpListItem(
391 NULL, wxTASKBAR_JUMP_LIST_TASK, _(
"Open Lens calibrate tool"), exeFile.GetFullPath(), wxEmptyString,
392 _(
"Opens Calibrate_lens_gui, a simple GUI for lens calibration"),
393 exeFile.GetFullPath(), 0);
394 jumpList.GetTasks().Append(item2);
397 #pragma message("Warning: huginApp.cpp - wxWidgets is compiled without support for taskbar buttons. Some features have therefore disabled.")
399 #warning "Warning: huginApp.cpp - wxWidgets is compiled without support for taskbar buttons. Some features have therefore disabled."
408 #if wxUSE_WXHTML_HELP
410 #if defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
413 wxString strFile = MacGetPathToBundledResourceFile(CFSTR(
"help"));
414 if (!strFile.IsEmpty())
420 wxLogError(wxString::Format(wxT(
"Could not find help directory in the bundle"), strFile.c_str()));
433 SetExitOnFrameDelete(
true);
444 wxString cwd = wxFileName::GetCwd();
446 m_workDir = config->Read(wxT(
"tempDir"),wxT(
""));
450 #if (defined __WXMSW__)
453 wxChar buffer[MAX_PATH];
454 GetTempPath(MAX_PATH, buffer);
456 #elif (defined __WXMAC__) && (defined MAC_SELF_CONTAINED_BUNDLE)
458 m_workDir = MacGetPathToUserDomainTempDir();
464 if (!wxGetEnv(wxT(
"TMPDIR"), &
m_workDir)) {
488 TIFFSetWarningHandler(0);
501 wxFileName file(argv[1]);
503 if (file.GetExt().CmpNoCase(wxT(
"pto")) == 0 ||
504 file.GetExt().CmpNoCase(wxT(
"pts")) == 0 ||
505 file.GetExt().CmpNoCase(wxT(
"ptp")) == 0 )
507 if(file.IsRelative())
508 file.MakeAbsolute(cwd);
514 std::vector<std::string> filesv;
515 std::vector<std::string> rawFilesv;
516 bool actualPathSet =
false;
517 for (
int i=1; i< argc; i++)
519 #if defined __WXMSW__
521 wxFileName fileList(argv[i]);
522 if(fileList.IsRelative())
523 fileList.MakeAbsolute(cwd);
527 if(fileList.DirExists())
528 if(dir.Open(fileList.GetPath()))
529 if(dir.GetFirst(&foundFile,fileList.GetFullName(),wxDIR_FILES | wxDIR_HIDDEN))
533 file.MakeAbsolute(dir.GetName());
535 wxFileName file(argv[i]);
537 if (file.IsRelative())
539 file.MakeAbsolute(cwd);
550 config->Write(wxT(
"/actualPath"), file.GetPath());
551 actualPathSet =
true;
565 config->Write(wxT(
"/actualPath"), file.GetPath());
566 actualPathSet =
true;
571 #if defined __WXMSW__
572 }
while (dir.GetNext(&foundFile));
577 std::vector<PanoCommand::PanoCommand*> cmds;
583 if (!rawFilesv.empty())
585 if (rawFilesv.size() == 1)
587 wxMessageDialog message(GetTopWindow(), _(
"You selected only one raw file. This is not recommended.\nAll raw files should be converted at once."),
593 wxICON_EXCLAMATION | wxOK | wxCANCEL);
594 message.SetOKLabel(_(
"Convert anyway."));
595 if (message.ShowModal() != wxID_OK)
605 if (dlg.ShowModal() == wxID_OK)
614 m_macInitDone =
true;
616 m_macOpenFileOnStart =
false;
620 wxString secondParam = argc > 2 ? wxString(argv[2]) : wxString();
621 if(secondParam.Cmp(_T(
"-notips"))!=0)
624 int nValue = config->Read(wxT(
"/MainFrame/ShowStartTip"), 1l);
629 wxCommandEvent dummy;
634 DEBUG_TRACE(
"=========================== huginApp::OnInit() end ===================");
641 delete wxHelpProvider::Set(NULL);
667 if (event.
entry.get())
669 ImageCache::getInstance().postEvent(event.
request, event.
entry);
674 ImageCache::getInstance().removeRequest(event.
request);
676 wxCommandEvent e(EVT_LOADING_FAILED);
678 frame->GetEventHandler()->AddPendingEvent(e);
689 Get()->AddPendingEvent(event);
693 void huginApp::MacOpenFile(
const wxString &fileName)
697 m_macOpenFileOnStart=
true;
698 m_macFileNameToOpenOnStart = fileName;
706 #if wxUSE_ON_FATAL_EXCEPTION
707 void huginApp::OnFatalException()
709 GenerateReport(wxDebugReport::Context_Exception);
722 wxConfigBase * config = wxConfigBase::Get();
726 wxDisplaySize(&dx,&dy);
732 int w = config->Read(wxT(
"/") + basename + wxT(
"/width"),-1l);
733 int h = config->Read(wxT(
"/") + basename + wxT(
"/height"),-1l);
734 if (w > 0 && w <= dx) {
735 frame->SetClientSize(w,h);
740 int x = config->Read(wxT(
"/") + basename + wxT(
"/positionX"),-1l);
741 int y = config->Read(wxT(
"/") + basename + wxT(
"/positionY"),-1l);
742 if ( y >= 0 && x >= 0 && x < dx && y < dy) {
748 bool maximized = config->Read(wxT(
"/") + basename + wxT(
"/maximized"), 0l) != 0;
753 int w = config->Read(wxT(
"/") + basename + wxT(
"/width"),-1l);
754 int h = config->Read(wxT(
"/") + basename + wxT(
"/height"),-1l);
755 if (w > 0 && w <= dx) {
756 frame->SetClientSize(w,h);
761 int x = config->Read(wxT(
"/") + basename + wxT(
"/positionX"),-1l);
762 int y = config->Read(wxT(
"/") + basename + wxT(
"/positionY"),-1l);
763 if ( y >= 0 && x >= 0 && x < dx && y < dy) {
777 wxConfigBase * config = wxConfigBase::Get();
783 wxSize sz = frame->GetClientSize();
784 config->Write(wxT(
"/") + basename + wxT(
"/width"), sz.GetWidth());
785 config->Write(wxT(
"/") + basename + wxT(
"/height"), sz.GetHeight());
786 wxPoint ps = frame->GetPosition();
787 config->Write(wxT(
"/") + basename + wxT(
"/positionX"), ps.x);
788 config->Write(wxT(
"/") + basename + wxT(
"/positionY"), ps.y);
789 config->Write(wxT(
"/") + basename + wxT(
"/maximized"), 0);
791 if ( (! frame->IsMaximized()) && (! frame->IsIconized()) ) {
792 wxSize sz = frame->GetClientSize();
793 config->Write(wxT(
"/") + basename + wxT(
"/width"), sz.GetWidth());
794 config->Write(wxT(
"/") + basename + wxT(
"/height"), sz.GetHeight());
795 wxPoint ps = frame->GetPosition();
796 config->Write(wxT(
"/") + basename + wxT(
"/positionX"), ps.x);
797 config->Write(wxT(
"/") + basename + wxT(
"/positionY"), ps.y);
798 config->Write(wxT(
"/") + basename + wxT(
"/maximized"), 0);
799 }
else if (frame->IsMaximized()){
800 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.
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
void StoreFramePosition(wxTopLevelWindow *frame, const wxString &basename)
Store window size and position in configfile/registry.
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
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
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)
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[])