Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MainFrame.cpp
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
2 
27 #include "hugin_config.h"
28 
29 #include <wx/dir.h>
30 #include <wx/stdpaths.h>
31 #include <wx/wfstream.h>
32 #include "panoinc_WX.h"
33 #include "panoinc.h"
34 
35 #include "base_wx/platform.h"
36 #include "base_wx/wxPlatform.h"
37 
38 #include "vigra/imageinfo.hxx"
39 #include "vigra_ext/Correlation.h"
40 
41 #include "hugin/config_defaults.h"
43 #include "hugin/MainFrame.h"
44 #include "base_wx/wxPanoCommand.h"
45 #include "base_wx/CommandHistory.h"
46 #include "hugin/PanoPanel.h"
47 #include "hugin/ImagesPanel.h"
48 #include "hugin/MaskEditorPanel.h"
49 #include "hugin/OptimizePanel.h"
51 #include "hugin/PreviewFrame.h"
52 #include "hugin/GLPreviewFrame.h"
53 #include "hugin/huginApp.h"
54 #include "hugin/CPEditorPanel.h"
55 #include "hugin/CPListFrame.h"
58 #include "hugin/PanoOperation.h"
59 #include "hugin/PapywizardImport.h"
60 
62 #include "base_wx/RunStitchPanel.h"
63 #include "base_wx/wxImageCache.h"
64 #include "base_wx/PTWXDlg.h"
68 
69 #include "base_wx/huginConfig.h"
70 #include "hugin/AboutDialog.h"
71 #include "hugin/RawImport.h"
72 #include "hugin/BrowseDialog.h"
73 
74 #if HUGIN_HSI
75 #include "PluginItems.h"
76 #endif
77 
78 #ifdef __MINGW32__
79 // fixes for mingw compilation...
80 #undef FindWindow
81 #endif
82 
87 class HuginSplashScreen : public wxFrame
88 {
89 public:
91  HuginSplashScreen(wxWindow* parent, wxBitmap bitmap) :
92  wxFrame(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW | wxFRAME_NO_TASKBAR | wxSTAY_ON_TOP)
93  {
94  SetExtraStyle(GetExtraStyle() | wxWS_EX_TRANSIENT);
95  wxSizer* topSizer=new wxBoxSizer(wxVERTICAL);
96  wxStaticBitmap* staticBitmap=new wxStaticBitmap(this,wxID_ANY,bitmap);
97  topSizer->Add(staticBitmap,1,wxEXPAND);
98  SetSizerAndFit(topSizer);
99  SetClientSize(bitmap.GetWidth(), bitmap.GetHeight());
100  CenterOnScreen();
101  Show(true);
102  SetFocus();
103 #if defined(__WXMSW__) || defined(__WXMAC__)
104  Update();
105 #elif defined(__WXGTK20__)
106  //do nothing
107 #else
108  wxYieldIfNeeded();
109 #endif
110  };
111  DECLARE_DYNAMIC_CLASS(HuginSplashScreen)
112 };
113 
115 
116 
117 bool PanoDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames)
118 {
119  DEBUG_TRACE("OnDropFiles");
120  MainFrame * mf = MainFrame::Get();
121  if (!mf) return false;
122 
123  if (!m_imageOnly && filenames.GetCount() == 1) {
124  wxFileName file(filenames[0]);
125  if (file.GetExt().CmpNoCase(wxT("pto")) == 0 ||
126  file.GetExt().CmpNoCase(wxT("ptp")) == 0 ||
127  file.GetExt().CmpNoCase(wxT("pts")) == 0 )
128  {
129  // load project
131  {
132  mf->LoadProjectFile(file.GetFullPath());
133  // remove old images from cache
134  ImageCache::getInstance().flush();
135  }
136  return true;
137  }
138  }
139 
140  // try to add as images
141  std::vector<std::string> filesv;
142  std::vector<std::string> rawFilesv;
143  wxArrayString invalidFiles;
144  for (unsigned int i=0; i< filenames.GetCount(); i++) {
145  wxFileName file(filenames[i]);
146  // first check if raw file
147  // vigra::isImage reports also some raw files as image because
148  // technical some of them are tiff files
149  if (IsRawExtension(file.GetExt()))
150  {
151  if (containsInvalidCharacters(filenames[i]))
152  {
153  invalidFiles.Add(file.GetFullPath());
154  }
155  else
156  {
157  rawFilesv.push_back((const char *)file.GetFullPath().mb_str(HUGIN_CONV_FILENAME));
158  };
159  }
160  else
161  {
162  // now check if drop file is a image
163  if (vigra::isImage(file.GetFullPath().mb_str(HUGIN_CONV_FILENAME)))
164  {
165  if (containsInvalidCharacters(filenames[i]))
166  {
167  invalidFiles.Add(file.GetFullPath());
168  }
169  else
170  {
171  filesv.push_back((const char *)filenames[i].mb_str(HUGIN_CONV_FILENAME));
172  };
173  };
174  };
175  }
176  // show warning about invalid file names
177  if (!invalidFiles.empty())
178  {
179  ShowFilenameWarning(mf, invalidFiles);
180  }
181  // we got some images to add.
182  if (!filesv.empty())
183  {
184  // use a Command to ensure proper undo and updating of GUI parts
185  wxBusyCursor();
186  if(pano.getNrOfCtrlPoints()>0)
187  {
189  }
190  else
191  {
192  std::vector<PanoCommand::PanoCommand*> cmds;
193  cmds.push_back(new PanoCommand::wxAddImagesCmd(pano, filesv));
194  cmds.push_back(new PanoCommand::DistributeImagesCmd(pano));
195  cmds.push_back(new PanoCommand::CenterPanoCmd(pano));
197  };
198  };
199  if (!rawFilesv.empty())
200  {
201  if (rawFilesv.size() == 1)
202  {
203  wxMessageDialog message(mf, _("You selected only one raw file. This is not recommended.\nAll raw files should be converted at once."),
204 #ifdef _WIN32
205  _("Hugin"),
206 #else
207  wxT(""),
208 #endif
209  wxICON_EXCLAMATION | wxOK | wxCANCEL);
210  message.SetOKLabel(_("Convert anyway."));
211  if (message.ShowModal() != wxID_OK)
212  {
213  return true;
214  };
215  };
216  RawImportDialog dlg(mf, &pano, rawFilesv);
217  // check that raw files are from same camera and that all can be read
218  if (dlg.CheckRawFiles())
219  {
220  // now show dialog
221  if (dlg.ShowModal() == wxID_OK)
222  {
224  };
225  };
226  };
227  return true;
228 }
229 
230 wxDEFINE_EVENT(EVT_LOADING_FAILED, wxCommandEvent);
231 
232 enum
233 {
234  wxIDPYTHONSCRIPTS = wxID_HIGHEST + 2000,
235  wxIDUSEROUTPUTSEQUENCE = wxID_HIGHEST + 2500,
236  wxIDUSERASSISTANT = wxID_HIGHEST + 3000
237 };
238 
239 MainFrame::MainFrame(wxWindow* parent, HuginBase::Panorama & pano)
240  : cp_frame(0), pano(pano)
241 {
242  preview_frame = 0;
243  svmModel=NULL;
244 
245  bool disableOpenGL=false;
246  if(wxGetKeyState(WXK_COMMAND))
247  {
248  wxDialog dlg;
249  wxXmlResource::Get()->LoadDialog(&dlg, NULL, wxT("disable_opengl_dlg"));
250  long noOpenGL=wxConfigBase::Get()->Read(wxT("DisableOpenGL"), 0l);
251  if(noOpenGL==1)
252  {
253  XRCCTRL(dlg, "disable_dont_ask_checkbox", wxCheckBox)->SetValue(true);
254  };
255  if(dlg.ShowModal()==wxID_OK)
256  {
257  if(XRCCTRL(dlg, "disable_dont_ask_checkbox", wxCheckBox)->IsChecked())
258  {
259  wxConfigBase::Get()->Write(wxT("DisableOpenGL"), 1l);
260  }
261  else
262  {
263  wxConfigBase::Get()->Write(wxT("DisableOpenGL"), 0l);
264  };
265  disableOpenGL=true;
266  }
267  else
268  {
269  wxConfigBase::Get()->Write(wxT("DisableOpenGL"), 0l);
270  };
271  }
272  else
273  {
274  long noOpenGL=wxConfigBase::Get()->Read(wxT("DisableOpenGL"), 0l);
275  disableOpenGL=(noOpenGL==1);
276  };
277 
278  wxBitmap bitmap;
279  HuginSplashScreen* splash = 0;
280  wxYield();
281 
282  if (bitmap.LoadFile(huginApp::Get()->GetXRCPath() + wxT("data/splash.png"), wxBITMAP_TYPE_PNG))
283  {
284  // embed package version into string.
285  {
286  wxMemoryDC dc;
287  dc.SelectObject(bitmap);
288 #ifdef __WXMAC__
289  wxFont font(9, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
290 #else
291  wxFont font(8, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
292 #endif
293  dc.SetFont(font);
294  dc.SetTextForeground(*wxBLACK);
295  dc.SetTextBackground(*wxWHITE);
296  int tw, th;
297  wxString version;
298  version.Printf(_("Version %s"), wxString(hugin_utils::GetHuginVersion().c_str(), wxConvLocal).c_str());
299  dc.GetTextExtent(version, &tw, &th);
300  // place text on bitmap.
301  dc.DrawText(version, bitmap.GetWidth() - tw - 3, bitmap.GetHeight() - th - 3);
302  dc.SelectObject(wxNullBitmap);
303  }
304  bitmap.SetScaleFactor(GetDPIScaleFactor());
305  splash = new HuginSplashScreen(NULL, bitmap);
306  } else {
307  wxLogFatalError(_("Fatal installation error\nThe file data/splash.png was not found at:") + huginApp::Get()->GetXRCPath());
308  abort();
309  }
310  //splash->Refresh();
311  wxYield();
312 
313  // save our pointer
314  m_this = this;
315 
316  DEBUG_TRACE("");
317  // load our children. some children might need special
318  // initialization. this will be done later.
319  wxXmlResource::Get()->LoadFrame(this, parent, wxT("main_frame"));
320  DEBUG_TRACE("");
321 
322  // load our menu bar
323 #ifdef __WXMAC__
324  wxApp::s_macAboutMenuItemId = XRCID("action_show_about");
325  wxApp::s_macPreferencesMenuItemId = XRCID("action_show_prefs");
326  wxApp::s_macExitMenuItemId = XRCID("action_exit_hugin");
327  wxApp::s_macHelpMenuTitleName = _("&Help");
328 #endif
329  wxMenuBar* mainMenu=wxXmlResource::Get()->LoadMenuBar(this, wxT("main_menubar"));
330  m_menu_file_simple=wxXmlResource::Get()->LoadMenu(wxT("file_menu_simple"));
331  m_menu_file_advanced=wxXmlResource::Get()->LoadMenu(wxT("file_menu_advanced"));
332  mainMenu->Insert(0, m_menu_file_simple, _("&File"));
333  SetMenuBar(mainMenu);
334  m_optOnlyActiveImages = (wxConfigBase::Get()->Read(wxT("/OptimizePanel/OnlyActiveImages"), 1l) != 0);
335  m_optIgnoreLineCp = false;
336  // observe the panorama, this should be the first observer
337  pano.addObserver(this);
338 
339 #ifdef HUGIN_HSI
340  wxMenuBar* menubar=GetMenuBar();
341  // the plugin menu will be generated dynamically
342  wxMenu *pluginMenu=new wxMenu();
343  // search for all .py files in plugins directory
344  wxDir dir(GetDataPath()+wxT("plugins"));
345  if (dir.IsOpened())
346  {
347  wxString filename;
348  bool cont = dir.GetFirst(&filename, wxT("*.py"), wxDIR_FILES | wxDIR_HIDDEN);
349  PluginItems items;
350  while (cont)
351  {
352  wxFileName file(dir.GetName(), filename);
353  file.MakeAbsolute();
354  PluginItem item(file);
355  if (item.IsAPIValid())
356  {
357  items.push_back(item);
358  };
359  cont = dir.GetNext(&filename);
360  };
361  items.sort(comparePluginItem);
362 
363  int pluginID = wxIDPYTHONSCRIPTS;
364  for (PluginItems::const_iterator it = items.begin(); it != items.end(); ++it)
365  {
366  PluginItem item = *it;
367  int categoryID = pluginMenu->FindItem(item.GetCategory());
368  wxMenu* categoryMenu;
369  if (categoryID == wxNOT_FOUND)
370  {
371  categoryMenu = new wxMenu();
372  pluginMenu->AppendSubMenu(categoryMenu, item.GetCategory());
373  }
374  else
375  {
376  categoryMenu = pluginMenu->FindItem(categoryID)->GetSubMenu();
377  };
378  categoryMenu->Append(pluginID, item.GetName(), item.GetDescription());
379  m_plugins[pluginID] = item.GetFilename();
380  Bind(wxEVT_MENU, &MainFrame::OnPlugin, this, pluginID);
381  pluginID++;
382  };
383  // show the new menu
384  if (pluginMenu->GetMenuItemCount() > 0)
385  {
386  menubar->Insert(menubar->GetMenuCount() - 2, pluginMenu, _("&Actions"));
387  };
388  };
389 #else
390  GetMenuBar()->Enable(XRCID("action_python_script"), false);
391 #endif
392 
393  // create tool bar
394  SetToolBar(wxXmlResource::Get()->LoadToolBar(this, wxT("main_toolbar")));
395 
396  // Disable tools by default
397  enableTools(false);
398 
399  // put an "unknown" object in an xrc file and
400  // take as wxObject (second argument) the return value of wxXmlResource::Get
401  // finish the images_panel
402  DEBUG_TRACE("");
403 
404  // image_panel
405  images_panel = XRCCTRL(*this, "images_panel_unknown", ImagesPanel);
406  assert(images_panel);
407  images_panel->Init(&pano);
408  DEBUG_TRACE("");
409 
410  m_notebook = XRCCTRL((*this), "controls_notebook", wxNotebook);
411 // m_notebook = ((wxNotebook*) ((*this).FindWindow(XRCID("controls_notebook"))));
412 // m_notebook = ((wxNotebook*) (FindWindow(XRCID("controls_notebook"))));
414 
415  // the mask panel
416  mask_panel = XRCCTRL(*this, "mask_panel_unknown", MaskEditorPanel);
417  assert(mask_panel);
418  mask_panel->Init(&pano);
419 
420  // the pano_panel
421  DEBUG_TRACE("");
422  pano_panel = XRCCTRL(*this, "panorama_panel_unknown", PanoPanel);
423  assert(pano_panel);
424  pano_panel->Init(&pano);
425  pano_panel->panoramaChanged (pano); // initialize from pano
426 
427  cpe = XRCCTRL(*this, "cp_editor_panel_unknown", CPEditorPanel);
428  assert(cpe);
429  cpe->Init(&pano);
430 
431  opt_panel = XRCCTRL(*this, "optimizer_panel_unknown", OptimizePanel);
432  assert(opt_panel);
433  opt_panel->Init(&pano);
434  m_show_opt_panel=true;
435 
436  opt_photo_panel = XRCCTRL(*this, "optimizer_photometric_panel_unknown", OptimizePhotometricPanel);
437  assert(opt_photo_panel);
438  opt_photo_panel->Init(&pano);
440 
441  // generate list of most recently uses files and add it to menu
442  // needs to be initialized before the fast preview, there we call AddFilesToMenu()
443  wxConfigBase * config=wxConfigBase::Get();
444  m_mruFiles.Load(*config);
445  m_mruFiles.UseMenu(m_menu_file_advanced->FindItem(XRCID("menu_mru"))->GetSubMenu());
446 
447  preview_frame = new PreviewFrame(this, pano);
448  if(disableOpenGL)
449  {
450  gl_preview_frame=NULL;
452  m_mruFiles.AddFilesToMenu();
453  }
454  else
455  {
456  gl_preview_frame = new GLPreviewFrame(this, pano);
457  };
458 
459  // add saved user defined output sequences
460  {
461  wxArrayString files;
462  // search all .executor files, do not follow links
463  wxDir::GetAllFiles(GetDataPath()+"output", &files, wxT("*.executor"), wxDIR_FILES | wxDIR_HIDDEN | wxDIR_NO_FOLLOW);
464  const size_t nrAllUserSequences = files.size();
465  wxDir::GetAllFiles(hugin_utils::GetUserAppDataDir(), &files, wxT("*.executor"), wxDIR_FILES | wxDIR_HIDDEN | wxDIR_NO_FOLLOW);
466  if (!files.IsEmpty())
467  {
468  // we found some files
469  long outputId = wxIDUSEROUTPUTSEQUENCE;
470  int outputMenuId=mainMenu->FindMenu(_("&Output"));
471  if (outputMenuId != wxNOT_FOUND)
472  {
473  wxMenu* outputSequencesMenu = new wxMenu;
474  size_t i = 0;
475  for (auto file : files)
476  {
477  if (i > 0 && i == nrAllUserSequences && outputSequencesMenu->GetMenuItemCount() > 0)
478  {
479  outputSequencesMenu->AppendSeparator();
480  if (gl_preview_frame)
481  {
482  // add assistant to context menu on align button
483  gl_preview_frame->AddUserDefinedSequence(-1, wxEmptyString, wxEmptyString);
484  };
485 
486  };
487  wxFileInputStream inputStream(file);
488  if (inputStream.IsOk())
489  {
490  // read descriptions from file
491  wxFileConfig executorFile(inputStream);
492  wxString desc = HuginQueue::GetSettingStringTranslated(&executorFile, wxT("/General/Description"), wxEmptyString);
493  wxString help = HuginQueue::GetSettingStringTranslated(&executorFile, wxT("/General/Help"), wxEmptyString);
494  if (help.IsEmpty())
495  {
496  help = wxString::Format(_("User defined sequence: %s"), file);
497  };
498  // add menu
499  if (!desc.IsEmpty())
500  {
501  outputSequencesMenu->Append(outputId, desc, help);
502  Bind(wxEVT_MENU, &MainFrame::OnUserDefinedStitchSaved, this, outputId);
503  m_userOutput[outputId] = file;
504  if (gl_preview_frame)
505  {
506  // add output sequence to context menu on create button
507  gl_preview_frame->AddUserDefinedSequence(outputId, desc, help);
508  };
509  ++outputId;
510  };
511  };
512  i++;
513  };
514  if ((outputSequencesMenu->GetMenuItemCount() == 1 && !(outputSequencesMenu->FindItemByPosition(0)->IsSeparator())) ||
515  outputSequencesMenu->GetMenuItemCount() > 1)
516  {
517  m_outputUserMenu = mainMenu->GetMenu(outputMenuId)->AppendSubMenu(outputSequencesMenu, _("User defined output sequences"));
518  }
519  else
520  {
521  delete outputSequencesMenu;
522  };
523  };
524  };
525  };
526  // add saved user defined assistants
527  {
528  wxArrayString files;
529  // search all .assistant files, do not follow links
530  wxDir::GetAllFiles(GetDataPath() + "assistant", &files, wxT("*.assistant"), wxDIR_FILES | wxDIR_HIDDEN | wxDIR_NO_FOLLOW);
531  const size_t nrAllUserSequences = files.size();
532  wxDir::GetAllFiles(hugin_utils::GetUserAppDataDir(), &files, wxT("*.assistant"), wxDIR_FILES | wxDIR_HIDDEN | wxDIR_NO_FOLLOW);
533  if (!files.IsEmpty())
534  {
535  // we found some files
536  long assistantId = wxIDUSERASSISTANT;
537  const int editMenuId = mainMenu->FindMenu(_("&Edit"));
538  if (editMenuId != wxNOT_FOUND)
539  {
540  wxMenu* userAssistantMenu = new wxMenu;
541  size_t i = 0;
542  for (auto file : files)
543  {
544  if (i > 0 && i == nrAllUserSequences && userAssistantMenu->GetMenuItemCount() > 0)
545  {
546  userAssistantMenu->AppendSeparator();
547  if (gl_preview_frame)
548  {
549  // add assistant to context menu on align button
550  gl_preview_frame->AddUserDefinedAssistant(-1, wxEmptyString, wxEmptyString);
551  };
552  };
553  wxFileInputStream inputStream(file);
554  if (inputStream.IsOk())
555  {
556  // read descriptions from file
557  wxFileConfig assistantFile(inputStream);
558  wxString desc = HuginQueue::GetSettingStringTranslated(&assistantFile, wxT("/General/Description"), wxEmptyString);
559  wxString help = HuginQueue::GetSettingStringTranslated(&assistantFile, wxT("/General/Help"), wxEmptyString);
560  help = help.Trim(true).Trim(false);
561  if (help.IsEmpty())
562  {
563  help = wxString::Format(_("User defined assistant: %s"), file);
564  };
565  // add menu
566  if (!desc.IsEmpty())
567  {
568  userAssistantMenu->Append(assistantId, desc, help);
569  Bind(wxEVT_MENU, &MainFrame::OnRunAssistantUserdefined, this, assistantId);
570  m_userAssistant[assistantId] = file;
571  if (gl_preview_frame)
572  {
573  // add assistant to context menu on align button
574  gl_preview_frame->AddUserDefinedAssistant(assistantId, desc, help);
575  };
576  ++assistantId;
577  };
578  };
579  i++;
580  };
581  if (userAssistantMenu->GetMenuItemCount() > 0)
582  {
583  m_assistantUserMenu = mainMenu->GetMenu(editMenuId)->Insert(5, wxID_ANY, _("User defined assistant"), userAssistantMenu);
584  }
585  else
586  {
587  delete userAssistantMenu;
588  };
589  };
590  };
591  };
592 
593 
594  // set the minimize icon
595 #ifdef __WXMSW__
596  wxIconBundle myIcons(GetXRCPath() + wxT("data/hugin.ico"), wxBITMAP_TYPE_ICO);
597  SetIcons(myIcons);
598 #else
599  wxIcon myIcon(GetXRCPath() + wxT("data/hugin.png"),wxBITMAP_TYPE_PNG);
600  SetIcon(myIcon);
601 #endif
602 
603  // create a new drop handler. wxwindows deletes the automaticall
604  SetDropTarget(new PanoDropTarget(pano));
605  DEBUG_TRACE("");
606 
608 
609  // create a status bar
610  const int fields (2);
611  CreateStatusBar(fields);
612  int widths[fields] = {-1, 85};
613  SetStatusWidths( fields, &widths[0]);
614  SetStatusText(_("Started"), 0);
615  wxYield();
616  DEBUG_TRACE("");
617 
618  // Set sizing characteristics
619  //set minumum size
620 #if defined __WXMAC__ || defined __WXMSW__
621  // a minimum nice looking size; smaller than this would clutter the layout.
622  SetSizeHints(900, 675);
623 #else
624  // For ASUS eeePc
625  SetSizeHints(780, 455); //set minumum size
626 #endif
627 
628  // set progress display for image cache.
629  ImageCache::getInstance().setProgressDisplay(this);
630 #if defined __WXMSW__
631  unsigned long long mem = HUGIN_IMGCACHE_UPPERBOUND;
632  unsigned long mem_low = wxConfigBase::Get()->Read(wxT("/ImageCache/UpperBound"), HUGIN_IMGCACHE_UPPERBOUND);
633  unsigned long mem_high = wxConfigBase::Get()->Read(wxT("/ImageCache/UpperBoundHigh"), (long) 0);
634  if (mem_high > 0) {
635  mem = ((unsigned long long) mem_high << 32) + mem_low;
636  }
637  else {
638  mem = mem_low;
639  }
640  ImageCache::getInstance().SetUpperLimit(mem);
641 #else
642  ImageCache::getInstance().SetUpperLimit(wxConfigBase::Get()->Read(wxT("/ImageCache/UpperBound"), HUGIN_IMGCACHE_UPPERBOUND));
643 #endif
644 
645  if(splash) {
646  splash->Close();
647  delete splash;
648  }
649  wxYield();
650 
651  // disable automatic Layout() calls, to it by hand
652  SetAutoLayout(false);
654 
655 // By using /SUBSYSTEM:CONSOLE /ENTRY:"WinMainCRTStartup" in the linker
656 // options for the debug build, a console window will be used for stdout
657 // and stderr. No need to redirect to a file. Better security since we can't
658 // guarantee that c: exists and writing a file to the root directory is
659 // never a good idea. release build still uses /SUBSYSTEM:WINDOWS
660 
661 #if 0
662 #ifdef DEBUG
663 #ifdef __WXMSW__
664 
665  freopen("c:\\hugin_stdout.txt", "w", stdout); // redirect stdout to file
666  freopen("c:\\hugin_stderr.txt", "w", stderr); // redirect stderr to file
667 #endif
668 #endif
669 #endif
670  //reload gui level
672  long guiLevel=config->Read(wxT("/GuiLevel"),(long)0);
673  guiLevel = std::max<long>(0, std::min<long>(2, guiLevel));
674  if(guiLevel==GUI_SIMPLE && disableOpenGL)
675  {
676  guiLevel=GUI_ADVANCED;
677  };
678  SetGuiLevel(static_cast<GuiLevel>(guiLevel));
679 
680 #ifndef __WXMSW__
681  // check settings of help window and fix when needed
682  FixHelpSettings();
683 #endif
684  // bind handler for menu items
685  Bind(wxEVT_MENU, &MainFrame::OnNewProject, this, XRCID("action_new_project"));
686  Bind(wxEVT_MENU, &MainFrame::OnLoadProject, this, XRCID("action_load_project"));
687  Bind(wxEVT_MENU, &MainFrame::OnBrowseProjects, this, XRCID("action_browse_projects"));
688  Bind(wxEVT_MENU, &MainFrame::OnSaveProject, this, XRCID("action_save_project"));
689  Bind(wxEVT_MENU, &MainFrame::OnSaveProjectAs, this, XRCID("action_save_as_project"));
690  Bind(wxEVT_MENU, &MainFrame::OnSavePTStitcherAs, this, XRCID("action_save_as_ptstitcher"));
691  Bind(wxEVT_MENU, &MainFrame::OnOpenPTBatcher, this, XRCID("action_open_batch_processor"));
692  Bind(wxEVT_MENU, &MainFrame::OnMergeProject, this, XRCID("action_import_project"));
693  Bind(wxEVT_MENU, &MainFrame::OnReadPapywizard, this, XRCID("action_import_papywizard"));
694  Bind(wxEVT_MENU, &MainFrame::OnApplyTemplate, this, XRCID("action_apply_template"));
695  Bind(wxEVT_MENU, &MainFrame::OnUserQuit, this, XRCID("action_exit_hugin"));
696  for (int i = 0; i < 9; ++i)
697  {
698  Bind(wxEVT_MENU, &MainFrame::OnMRUFiles, this, wxID_FILE1 + i);
699  }
700  Bind(wxEVT_MENU, &MainFrame::OnAbout, this, XRCID("action_show_about"));
701  Bind(wxEVT_MENU, &MainFrame::OnHelp, this, XRCID("action_show_help"));
702  Bind(wxEVT_MENU, &MainFrame::OnTipOfDay, this, XRCID("action_show_tip"));
703  Bind(wxEVT_MENU, &MainFrame::OnKeyboardHelp, this, XRCID("action_show_shortcuts"));
704  Bind(wxEVT_MENU, &MainFrame::OnFAQ, this, XRCID("action_show_faq"));
705  Bind(wxEVT_MENU, &MainFrame::OnShowPrefs, this, XRCID("action_show_prefs"));
706  Bind(wxEVT_MENU, &MainFrame::OnRunAssistant, this, XRCID("action_assistant"));
707  Bind(wxEVT_MENU, &MainFrame::OnSendToAssistantQueue, this, XRCID("action_batch_assistant"));
708  Bind(wxEVT_MENU, &MainFrame::OnSetGuiSimple, this, XRCID("action_gui_simple"));
709  Bind(wxEVT_MENU, &MainFrame::OnSetGuiAdvanced, this, XRCID("action_gui_advanced"));
710  Bind(wxEVT_MENU, &MainFrame::OnSetGuiExpert, this, XRCID("action_gui_expert"));
711 #ifdef HUGIN_HSI
712  Bind(wxEVT_MENU, &MainFrame::OnPythonScript, this, XRCID("action_python_script"));
713 #endif
714  Bind(wxEVT_MENU, &MainFrame::OnUndo, this, XRCID("ID_EDITUNDO"));
715  Bind(wxEVT_MENU, &MainFrame::OnRedo, this, XRCID("ID_EDITREDO"));
716  Bind(wxEVT_MENU, &MainFrame::OnFullScreen, this, XRCID("ID_SHOW_FULL_SCREEN"));
717  Bind(wxEVT_MENU, &MainFrame::OnTogglePreviewFrame, this, XRCID("ID_SHOW_PREVIEW_FRAME"));
718  Bind(wxEVT_MENU, &MainFrame::OnToggleGLPreviewFrame, this, XRCID("ID_SHOW_GL_PREVIEW_FRAME"));
719  Bind(wxEVT_BUTTON, &MainFrame::OnTogglePreviewFrame, this, XRCID("ID_SHOW_PREVIEW_FRAME"));
720  Bind(wxEVT_BUTTON, &MainFrame::OnToggleGLPreviewFrame, this, XRCID("ID_SHOW_GL_PREVIEW_FRAME"));
721 
722  Bind(wxEVT_MENU, &MainFrame::OnOptimize, this, XRCID("action_optimize"));
723  Bind(wxEVT_MENU, &MainFrame::OnOnlyActiveImages, this, XRCID("action_optimize_only_active"));
724  Bind(wxEVT_MENU, &MainFrame::OnIgnoreLineCp, this, XRCID("action_optimize_ignore_line_cp"));
725  Bind(wxEVT_BUTTON, &MainFrame::OnOptimize, this, XRCID("action_optimize"));
726  Bind(wxEVT_MENU, &MainFrame::OnFineTuneAll, this, XRCID("action_finetune_all_cp"));
727  Bind(wxEVT_MENU, &MainFrame::OnRemoveCPinMasks, this, XRCID("action_remove_cp_in_masks"));
728 
729  Bind(wxEVT_MENU, &MainFrame::OnShowCPFrame, this, XRCID("ID_CP_TABLE"));
730  Bind(wxEVT_BUTTON, &MainFrame::OnShowCPFrame, this, XRCID("ID_CP_TABLE"));
731 
732  Bind(wxEVT_MENU, &MainFrame::OnShowPanel, this, XRCID("ID_SHOW_PANEL_IMAGES"));
733  Bind(wxEVT_MENU, &MainFrame::OnShowPanel, this, XRCID("ID_SHOW_PANEL_MASK"));
734  Bind(wxEVT_MENU, &MainFrame::OnShowPanel, this, XRCID("ID_SHOW_PANEL_CP_EDITOR"));
735  Bind(wxEVT_MENU, &MainFrame::OnShowPanel, this, XRCID("ID_SHOW_PANEL_OPTIMIZER"));
736  Bind(wxEVT_MENU, &MainFrame::OnShowPanel, this, XRCID("ID_SHOW_PANEL_OPTIMIZER_PHOTOMETRIC"));
737  Bind(wxEVT_MENU, &MainFrame::OnShowPanel, this, XRCID("ID_SHOW_PANEL_PANORAMA"));
738  Bind(wxEVT_MENU, &MainFrame::OnDoStitch, this, XRCID("action_stitch"));
739  Bind(wxEVT_MENU, &MainFrame::OnUserDefinedStitch, this, XRCID("action_stitch_userdefined"));
740  Bind(wxEVT_MENU, &MainFrame::OnAddImages, this, XRCID("action_add_images"));
741  Bind(wxEVT_BUTTON, &MainFrame::OnAddImages, this, XRCID("action_add_images"));
742  Bind(wxEVT_MENU, &MainFrame::OnAddTimeImages, this, XRCID("action_add_time_images"));
743  Bind(wxEVT_BUTTON, &MainFrame::OnAddTimeImages, this, XRCID("action_add_time_images"));
744  Bind(wxEVT_CLOSE_WINDOW, &MainFrame::OnExit, this);
745  Bind(wxEVT_SIZE, &MainFrame::OnSize, this);
746  Bind(EVT_LOADING_FAILED, &MainFrame::OnLoadingFailed, this);
747 
748  DEBUG_TRACE("");
749 }
750 
752 {
753  DEBUG_TRACE("dtor");
755  {
756  delete m_menu_file_advanced;
757  }
758  else
759  {
760  delete m_menu_file_simple;
761  };
762  ImageCache::getInstance().setProgressDisplay(NULL);
763  delete & ImageCache::getInstance();
765 // delete cpe;
766 // delete images_panel;
767  DEBUG_DEBUG("removing observer");
768  pano.removeObserver(this);
769 
770  // get the global config object
771  wxConfigBase* config = wxConfigBase::Get();
772 
773  StoreFramePosition(this, wxT("MainFrame"));
774 
775  //store most recently used files
776  m_mruFiles.Save(*config);
777  //store gui level
778  config->Write(wxT("/GuiLevel"),(long)m_guiLevel);
779  // store optimize only active images
780  config->Write("/OptimizePanel/OnlyActiveImages", m_optOnlyActiveImages ? 1l : 0l);
781 
782  config->Flush();
783  if(svmModel!=NULL)
784  {
786  };
788 
789  DEBUG_TRACE("dtor end");
790 }
791 
793 {
794  // set flag to indicate list should show correlation instead of error
795  if (m_showCorrelation == 2)
796  {
797  const std::string lastCommand = PanoCommand::GlobalCmdHist::getInstance().getLastCommandName();
798  if (!(lastCommand == "remove control point" || lastCommand == "remove control points"))
799  {
800  m_showCorrelation = 0;
801  };
802  };
803  if (m_showCorrelation == 1)
804  {
806  };
807  wxToolBar* theToolBar = GetToolBar();
808  wxMenuBar* theMenuBar = GetMenuBar();
810  theMenuBar->Enable (XRCID("ID_EDITUNDO"), can_undo);
811  theToolBar->EnableTool(XRCID("ID_EDITUNDO"), can_undo);
813  theMenuBar->Enable (XRCID("ID_EDITREDO"), can_redo);
814  theToolBar->EnableTool(XRCID("ID_EDITREDO"), can_redo);
815 
816  //show or hide optimizer and exposure optimizer tab depending on optimizer master switches
817  if(pano.getOptimizerSwitch()==0 && !m_show_opt_panel)
818  {
819  m_notebook->InsertPage(3, opt_panel, _("Optimizer"));
820  m_show_opt_panel=true;
821  };
822  if(pano.getOptimizerSwitch()!=0 && m_show_opt_panel)
823  {
824  m_notebook->RemovePage(3);
825  m_show_opt_panel=false;
826  };
828  {
829  if(m_show_opt_panel)
830  {
831  m_notebook->InsertPage(4, opt_photo_panel, _("Exposure"));
832  }
833  else
834  {
835  m_notebook->InsertPage(3, opt_photo_panel, _("Exposure"));
836  }
838  };
840  {
841  if(m_show_opt_panel)
842  {
843  m_notebook->RemovePage(4);
844  }
845  else
846  {
847  m_notebook->RemovePage(3);
848  };
850  };
851  theMenuBar->Enable(XRCID("ID_SHOW_PANEL_OPTIMIZER"), m_show_opt_panel);
852  theMenuBar->Enable(XRCID("ID_SHOW_PANEL_OPTIMIZER_PHOTOMETRIC"), m_show_opt_photo_panel);
853 }
854 
855 //void MainFrame::panoramaChanged(HuginBase::Panorama &panorama)
857 {
858  DEBUG_TRACE("");
859  assert(&pano == &panorama);
861 }
862 
863 void MainFrame::OnUserQuit(wxCommandEvent & e)
864 {
865  Close();
866 }
867 
868 bool MainFrame::CloseProject(bool cancelable, CloseReason reason)
869 {
870  if (pano.isDirty()) {
871  wxString messageString;
872  switch (reason)
873  {
874  case LOAD_NEW_PROJECT:
875  messageString = _("Save changes to the project file before opening another project?");
876  break;
877  case NEW_PROJECT:
878  messageString = _("Save changes to the project file before starting a new project?");
879  break;
880  case CLOSE_PROGRAM:
881  default:
882  messageString = _("Save changes to the project file before closing?");
883  break;
884  };
885  wxMessageDialog message(wxGetActiveWindow(), messageString,
886 #ifdef _WIN32
887  _("Hugin"),
888 #else
889  wxT(""),
890 #endif
891  wxICON_EXCLAMATION | wxYES_NO | (cancelable? (wxCANCEL):0));
892  switch(reason)
893  {
894  case LOAD_NEW_PROJECT:
895  message.SetExtendedMessage(_("If you load another project without saving, your changes since last save will be discarded."));
896  break;
897  case NEW_PROJECT:
898  message.SetExtendedMessage(_("If you start a new project without saving, your changes since last save will be discarded."));
899  break;
900  case CLOSE_PROGRAM:
901  default:
902  message.SetExtendedMessage(_("If you close without saving, your changes since your last save will be discarded."));
903  break;
904  };
905  #if defined __WXMAC__ || defined __WXMSW__
906  // Apple human interface guidelines and Windows user experience interaction guidelines
907  message.SetYesNoLabels(wxID_SAVE, _("Don't Save"));
908  #else
909  // Gnome human interface guidelines:
910  message.SetYesNoLabels(wxID_SAVE, _("Close without saving"));
911  #endif
912  int answer = message.ShowModal();
913  switch (answer){
914  case wxID_YES:
915  {
916  wxCommandEvent dummy;
917  OnSaveProject(dummy);
918  return !pano.isDirty();
919  }
920  case wxID_CANCEL:
921  return false;
922  default: //no save
923  return true;
924  }
925  }
926  else return true;
927 }
928 
929 void MainFrame::OnExit(wxCloseEvent & e)
930 {
931  DEBUG_TRACE("");
933  {
934  if(!CloseProject(e.CanVeto(), CLOSE_PROGRAM))
935  {
936  if (e.CanVeto())
937  {
938  e.Veto();
939  return;
940  }
941  wxLogError(_("forced close"));
942  }
943  }
944  else
945  {
946  if(e.CanVeto())
947  {
948  Hide();
949  e.Veto();
950  return;
951  };
952  };
953 
954  if(preview_frame)
955  {
956  preview_frame->Close(true);
957  }
958  if(gl_preview_frame)
959  {
961  {
963  }
964  else
965  {
966  gl_preview_frame->Close(true);
967  };
968  }
969 
970  ImageCache::getInstance().flush();
971  Destroy();
972  DEBUG_TRACE("");
973 }
974 
975 void MainFrame::OnSaveProject(wxCommandEvent & e)
976 {
977  DEBUG_TRACE("");
978  try {
979  wxFileName scriptName = m_filename;
980  if (m_filename == wxT("")) {
981  OnSaveProjectAs(e);
982  scriptName = m_filename;
983  } else {
984  // the project file is just a PTOptimizer script...
985  DEBUG_DEBUG("stripping " << path << " from image filenames");
986  const std::string script(scriptName.GetFullPath().mb_str(HUGIN_CONV_FILENAME));
988 
989  SetStatusText(wxString::Format(_("saved project %s"), m_filename.c_str()),0);
991  {
992  if(gl_preview_frame)
993  {
994  gl_preview_frame->SetTitle(scriptName.GetName() + wxT(".") + scriptName.GetExt() + wxT(" - ") + _("Hugin - Panorama Creator"));
995  };
996  SetTitle(scriptName.GetName() + wxT(".") + scriptName.GetExt() + wxT(" - ") + _("Panorama editor"));
997  }
998  else
999  {
1000  SetTitle(scriptName.GetName() + wxT(".") + scriptName.GetExt() + wxT(" - ") + _("Hugin - Panorama Creator"));
1001  };
1002 
1003  pano.clearDirty();
1004  }
1005  } catch (std::exception & e) {
1006  wxString err(e.what(), wxConvLocal);
1007  wxMessageBox(wxString::Format(_("Could not save project file \"%s\".\nMaybe the file or the folder is read-only.\n\n(Error code: %s)"),m_filename.c_str(),err.c_str()),_("Error"),wxOK|wxICON_ERROR);
1008  }
1009 }
1010 
1011 void MainFrame::OnSaveProjectAs(wxCommandEvent & e)
1012 {
1013  DEBUG_TRACE("");
1014  wxFileName scriptName;
1015  if (m_filename.IsEmpty())
1016  {
1017  scriptName.Assign(getDefaultProjectName(pano) + wxT(".pto"));
1018  }
1019  else
1020  {
1021  scriptName=m_filename;
1022  };
1023  scriptName.Normalize(wxPATH_NORM_ABSOLUTE | wxPATH_NORM_DOTS | wxPATH_NORM_TILDE | wxPATH_NORM_SHORTCUT);
1024  wxFileDialog dlg(wxGetActiveWindow(),
1025  _("Save project file"),
1026  scriptName.GetPath(), scriptName.GetFullName(),
1027  _("Project files (*.pto)|*.pto|All files (*)|*"),
1028  wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition);
1029  if (dlg.ShowModal() == wxID_OK) {
1030  wxConfig::Get()->Write(wxT("/actualPath"), dlg.GetDirectory()); // remember for later
1031  wxString fn = dlg.GetPath();
1032  if (fn.Right(4).CmpNoCase(wxT(".pto"))!=0)
1033  {
1034  fn.Append(wxT(".pto"));
1035  if (wxFile::Exists(fn)) {
1036  int d = wxMessageBox(wxString::Format(_("File %s exists. Overwrite?"), fn.c_str()),
1037  _("Save project"), wxYES_NO | wxICON_QUESTION);
1038  if (d != wxYES) {
1039  return;
1040  }
1041  }
1042  }
1043  m_filename = fn;
1044  m_mruFiles.AddFileToHistory(m_filename);
1045  OnSaveProject(e);
1046  }
1047 }
1048 
1049 void MainFrame::OnSavePTStitcherAs(wxCommandEvent & e)
1050 {
1051  DEBUG_TRACE("");
1052  wxString scriptName = m_filename;
1053  if (m_filename == wxT("")) {
1054  scriptName = getDefaultProjectName(pano);
1055  }
1056  wxFileName scriptNameFN(scriptName);
1057  wxString fn = scriptNameFN.GetName() + wxT(".txt");
1058  wxFileDialog dlg(wxGetActiveWindow(),
1059  _("Save PTmender script file"),
1060  wxConfigBase::Get()->Read(wxT("/actualPath"),wxT("")), fn,
1061  _("PTmender files (*.txt)|*.txt"),
1062  wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition);
1063  if (dlg.ShowModal() == wxID_OK) {
1064  wxString fname = dlg.GetPath();
1065  // the project file is just a PTStitcher script...
1066  wxFileName scriptName = fname;
1067  HuginBase::UIntSet all;
1068  if (pano.getNrOfImages() > 0) {
1069  fill_set(all, 0, pano.getNrOfImages()-1);
1070  }
1071  std::ofstream script(scriptName.GetFullPath().mb_str(HUGIN_CONV_FILENAME));
1072  pano.printStitcherScript(script, pano.getOptions(), all);
1073  script.close();
1074  }
1075 
1076 }
1077 
1078 void MainFrame::LoadProjectFile(const wxString & filename)
1079 {
1080  DEBUG_TRACE("");
1081 
1082  // remove old images from cache
1083  // hmm probably not a good idea, if the project is reloaded..
1084  // ImageCache::getInstance().flush();
1085 
1086  SetStatusText( _("Open project: ") + filename);
1087 
1088  wxFileName fname(filename);
1089  wxString path = fname.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
1090  if (fname.IsOk() && fname.FileExists())
1091  {
1092  m_filename = filename;
1093  wxBusyCursor wait;
1096  new PanoCommand::wxLoadPTProjectCmd(pano, (const char *)filename.mb_str(HUGIN_CONV_FILENAME), (const char *)path.mb_str(HUGIN_CONV_FILENAME), true)
1097  );
1099  {
1100  wxMessageBox(wxString::Format(_("Could not load project file \"%s\".\nIt is not a valid pto file."), filename), _("Error"), wxOK | wxICON_ERROR);
1104  return;
1105  };
1108  DEBUG_DEBUG("project contains " << pano.getNrOfImages() << " after load");
1109  GuiLevel reqGuiLevel=GetMinimumGuiLevel(pano);
1110  if(reqGuiLevel>m_guiLevel)
1111  {
1112  SetGuiLevel(reqGuiLevel);
1113  };
1114  if (pano.getNrOfImages() > 0)
1115  {
1116  SetStatusText(_("Project opened"));
1117  m_mruFiles.AddFileToHistory(fname.GetFullPath());
1118  if (m_guiLevel == GUI_SIMPLE)
1119  {
1120  if (gl_preview_frame)
1121  {
1122  gl_preview_frame->SetTitle(fname.GetName() + wxT(".") + fname.GetExt() + wxT(" - ") + _("Hugin - Panorama Stitcher"));
1123  };
1124  SetTitle(fname.GetName() + wxT(".") + fname.GetExt() + wxT(" - ") + _("Panorama editor"));
1125  }
1126  else
1127  {
1128  SetTitle(fname.GetName() + wxT(".") + fname.GetExt() + wxT(" - ") + _("Hugin - Panorama Stitcher"));
1129  };
1130  }
1131  else
1132  {
1133  SetStatusText(_("Loading canceled"));
1134  m_filename = "";
1135  if (m_guiLevel == GUI_SIMPLE)
1136  {
1137  if (gl_preview_frame)
1138  {
1139  gl_preview_frame->SetTitle(_("Hugin - Panorama Stitcher"));
1140  };
1141  SetTitle(_("Panorama editor"));
1142  }
1143  else
1144  {
1145  SetTitle(_("Hugin - Panorama Stitcher"));
1146  };
1147  };
1148  if (! (fname.GetExt() == wxT("pto"))) {
1149  // do not remember filename if its not a hugin project
1150  // to avoid overwriting the original project with an
1151  // incompatible one
1152  m_filename = wxT("");
1153  }
1154  // get the global config object
1155  wxConfigBase* config = wxConfigBase::Get();
1156  config->Write(wxT("/actualPath"), path); // remember for later
1157  } else {
1158  SetStatusText( _("Error opening project: ") + filename);
1159  DEBUG_ERROR("Could not open file " << filename);
1160  }
1161 
1162  // force update of preview window
1163  if ( !(preview_frame->IsIconized() ||(! preview_frame->IsShown()) ) ) {
1164  wxCommandEvent dummy;
1165  preview_frame->OnUpdate(dummy);
1166  };
1167  if (gl_preview_frame)
1168  {
1170  };
1171 }
1172 
1173 #ifdef __WXMAC__
1174 void MainFrame::MacOnOpenFile(const wxString & filename)
1175 {
1176  if(!CloseProject(true, LOAD_NEW_PROJECT)) return; //if closing old project is canceled do nothing.
1177 
1178  ImageCache::getInstance().flush();
1179  LoadProjectFile(filename);
1180 }
1181 #endif
1182 
1183 void MainFrame::OnLoadProject(wxCommandEvent & e)
1184 {
1185  DEBUG_TRACE("");
1186 
1187  if(CloseProject(true, LOAD_NEW_PROJECT)) //if closing old project is canceled do nothing.
1188  {
1189  // get the global config object
1190  wxConfigBase* config = wxConfigBase::Get();
1191 
1192  wxString defaultdir = config->Read(wxT("/actualPath"),wxT(""));
1193  wxFileDialog dlg(wxGetActiveWindow(),
1194  _("Open project file"),
1195  defaultdir, wxT(""),
1196  _("Project files (*.pto)|*.pto|All files (*)|*"),
1197  wxFD_OPEN, wxDefaultPosition);
1198  dlg.SetDirectory(defaultdir);
1199  if (dlg.ShowModal() == wxID_OK)
1200  {
1201  wxString filename = dlg.GetPath();
1202  if(vigra::isImage(filename.mb_str(HUGIN_CONV_FILENAME)))
1203  {
1204  if(wxMessageBox(wxString::Format(_("File %s is an image file and not a project file.\nThis file can't be open with File, Open.\nDo you want to add this image file to the current project?"),filename.c_str()),
1205 #ifdef __WXMSW__
1206  _("Hugin"),
1207 #else
1208  wxT(""),
1209 #endif
1210  wxYES_NO | wxICON_QUESTION)==wxYES)
1211  {
1212  wxArrayString filenameArray;
1213  filenameArray.Add(filename);
1214  AddImages(filenameArray);
1215  };
1216  return;
1217  }
1218  else
1219  {
1220  // remove old images from cache
1221  ImageCache::getInstance().flush();
1222 
1223  LoadProjectFile(filename);
1224  return;
1225  };
1226  }
1227  }
1228  // do not close old project
1229  // nothing to open
1230  SetStatusText( _("Open project: cancel"));
1231 }
1232 
1233 void MainFrame::OnBrowseProjects(wxCommandEvent& e)
1234 {
1235  // first check if there are unsaved changes
1236  if (CloseProject(true, LOAD_NEW_PROJECT))
1237  {
1238  // remove old images from cache
1239  ImageCache::getInstance().flush();
1240  // get the global config object
1241  wxConfigBase* config = wxConfigBase::Get();
1242  // show dialog
1243  BrowsePTOFilesDialog dialog(this, config->Read("/actualPath", ""));
1244  if (dialog.ShowModal() == wxID_OK)
1245  {
1246  // open newly selected file
1247  LoadProjectFile(dialog.GetSelectedProject());
1248  // remember path for later
1249  config->Write("/actualPath", dialog.GetSelectedPath());
1250  };
1251  };
1252 }
1253 
1254 void MainFrame::OnNewProject(wxCommandEvent & e)
1255 {
1256  if(!CloseProject(true, NEW_PROJECT)) return; //if closing current project is canceled
1257 
1258  m_filename = wxT("");
1261  // remove old images from cache
1262  ImageCache::getInstance().flush();
1263  if(m_guiLevel==GUI_SIMPLE)
1264  {
1265  if(gl_preview_frame)
1266  {
1267  gl_preview_frame->SetTitle(_("Hugin - Panorama Stitcher"));
1268  };
1269  SetTitle(_("Panorama editor"));
1270  }
1271  else
1272  {
1273  SetTitle(_("Hugin - Panorama Stitcher"));
1274  };
1275 
1276  wxCommandEvent dummy;
1277  preview_frame->OnUpdate(dummy);
1278  if (gl_preview_frame)
1279  {
1281  };
1282 }
1283 
1284 void MainFrame::OnAddImages( wxCommandEvent& event )
1285 {
1286  DEBUG_TRACE("");
1288  HuginBase::UIntSet images;
1289  PanoCommand::PanoCommand* cmd = addImage.GetCommand(wxGetActiveWindow(), pano, images, m_guiLevel);
1290  if(cmd!=NULL)
1291  {
1293  };
1294 
1295  DEBUG_TRACE("");
1296 }
1297 
1298 void MainFrame::AddImages(wxArrayString& filenameArray)
1299 {
1300  wxArrayString invalidFiles;
1301  for(unsigned int i=0;i<filenameArray.GetCount(); i++)
1302  {
1303  if(containsInvalidCharacters(filenameArray[i]))
1304  {
1305  invalidFiles.Add(filenameArray[i]);
1306  };
1307  };
1308  if(!invalidFiles.empty())
1309  {
1310  ShowFilenameWarning(this, invalidFiles);
1311  }
1312  else
1313  {
1314  std::vector<std::string> filesv;
1315  for (unsigned int i=0; i< filenameArray.GetCount(); i++) {
1316  filesv.push_back((const char *)filenameArray[i].mb_str(HUGIN_CONV_FILENAME));
1317  }
1318 
1319  // we got some images to add.
1320  if (!filesv.empty()) {
1321  // use a Command to ensure proper undo and updating of GUI
1322  // parts
1323  wxBusyCursor();
1325  new PanoCommand::wxAddImagesCmd(pano, filesv)
1326  );
1327  };
1328  };
1329 };
1330 
1331 void MainFrame::OnAddTimeImages( wxCommandEvent& event )
1332 {
1334  HuginBase::UIntSet images;
1335  PanoCommand::PanoCommand* cmd = imageSeriesOp.GetCommand(wxGetActiveWindow(), pano, images, m_guiLevel);
1336  if(cmd!=NULL)
1337  {
1339  };
1340 };
1341 
1342 void MainFrame::OnShowPanel(wxCommandEvent & e)
1343 {
1344  if(e.GetId()==XRCID("ID_SHOW_PANEL_MASK"))
1345  m_notebook->SetSelection(1);
1346  else
1347  if(e.GetId()==XRCID("ID_SHOW_PANEL_CP_EDITOR"))
1348  m_notebook->SetSelection(2);
1349  else
1350  if(e.GetId()==XRCID("ID_SHOW_PANEL_OPTIMIZER"))
1351  m_notebook->SetSelection(3);
1352  else
1353  if(e.GetId()==XRCID("ID_SHOW_PANEL_OPTIMIZER_PHOTOMETRIC"))
1354  {
1355  if(m_show_opt_panel)
1356  {
1357  m_notebook->SetSelection(4);
1358  }
1359  else
1360  {
1361  m_notebook->SetSelection(3);
1362  };
1363  }
1364  else
1365  if(e.GetId()==XRCID("ID_SHOW_PANEL_PANORAMA"))
1366  {
1368  {
1369  m_notebook->SetSelection(5);
1370  }
1371  else
1372  {
1374  {
1375  m_notebook->SetSelection(4);
1376  }
1377  else
1378  {
1379  m_notebook->SetSelection(3);
1380  };
1381  };
1382  }
1383  else
1384  m_notebook->SetSelection(0);
1385 }
1386 
1387 void MainFrame::OnLoadingFailed(wxCommandEvent & e)
1388 {
1389  // check if file exists
1390  if (wxFileExists(e.GetString()))
1391  {
1392  // file exists, but could not loaded
1393  wxMessageBox(wxString::Format(_("Could not load image \"%s\".\nThis file is not a valid image.\nThis file will be removed from the project."), e.GetString()),
1394 #ifdef _WIN32
1395  _("Hugin"),
1396 #else
1397  wxT(""),
1398 #endif
1399  wxOK | wxICON_ERROR);
1400  }
1401  else
1402  {
1403  // file does not exists
1404  wxMessageBox(wxString::Format(_("Could not load image \"%s\".\nThis file was renamed, deleted or is on a non-accessible drive.\nThis file will be removed from the project."), e.GetString()),
1405 #ifdef _WIN32
1406  _("Hugin"),
1407 #else
1408  wxT(""),
1409 #endif
1410  wxOK | wxICON_ERROR);
1411  };
1412  // now remove the file from the pano
1413  const std::string filename(e.GetString().mb_str(HUGIN_CONV_FILENAME));
1414  HuginBase::UIntSet imagesToRemove;
1415  for (size_t i = 0; i < pano.getNrOfImages(); ++i)
1416  {
1417  if (pano.getImage(i).getFilename() == filename)
1418  {
1419  imagesToRemove.insert(i);
1420  };
1421  };
1422  if (!imagesToRemove.empty())
1423  {
1425  };
1426 }
1427 
1428 
1429 void MainFrame::OnAbout(wxCommandEvent & e)
1430 {
1431  AboutDialog dlg(wxGetActiveWindow());
1432  dlg.ShowModal();
1433 }
1434 
1435 /*
1436 void MainFrame::OnAbout(wxCommandEvent & e)
1437 {
1438  DEBUG_TRACE("");
1439  wxDialog dlg;
1440  wxString strFile;
1441  wxString langCode;
1442 
1443  wxXmlResource::Get()->LoadDialog(&dlg, this, wxT("about_dlg"));
1444 
1445 #if __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
1446  //rely on the system's locale choice
1447  strFile = MacGetPathToBundledResourceFile(CFSTR("about.htm"));
1448  if(strFile!=wxT("")) XRCCTRL(dlg,"about_html",wxHtmlWindow)->LoadPage(strFile);
1449 #else
1450  //if the language is not default, load custom About file (if exists)
1451  langCode = huginApp::Get()->GetLocale().GetName().Left(2).Lower();
1452  DEBUG_INFO("Lang Code: " << langCode.mb_str(wxConvLocal));
1453  if(langCode != wxString(wxT("en")))
1454  {
1455  strFile = GetXRCPath() + wxT("data/about_") + langCode + wxT(".htm");
1456  if(wxFile::Exists(strFile))
1457  {
1458  DEBUG_TRACE("Using About: " << strFile.mb_str(wxConvLocal));
1459  XRCCTRL(dlg,"about_html",wxHtmlWindow)->LoadPage(strFile);
1460  }
1461  }
1462 #endif
1463  dlg.ShowModal();
1464 }
1465 */
1466 
1467 void MainFrame::OnHelp(wxCommandEvent & e)
1468 {
1469  DisplayHelp();
1470 }
1471 
1472 void MainFrame::OnKeyboardHelp(wxCommandEvent & e)
1473 {
1474  DisplayHelp(wxT("Hugin_Keyboard_shortcuts.html"));
1475 }
1476 
1477 void MainFrame::OnFAQ(wxCommandEvent & e)
1478 {
1479  DisplayHelp(wxT("Hugin_FAQ.html"));
1480 }
1481 
1482 
1483 void MainFrame::DisplayHelp(wxString section)
1484 {
1485  if (section.IsEmpty())
1486  {
1487  GetHelpController().DisplayContents();
1488  }
1489  else
1490  {
1491  GetHelpController().DisplaySection(section);
1492  };
1493 }
1494 
1495 void MainFrame::OnTipOfDay(wxCommandEvent& WXUNUSED(e))
1496 {
1497  wxString strFile;
1498  bool bShowAtStartup;
1499 // DGSW FIXME - Unreferenced
1500 // bool bTipsExist = false;
1501  int nValue;
1502 
1503  wxConfigBase * config = wxConfigBase::Get();
1504  nValue = config->Read(wxT("/MainFrame/ShowStartTip"),1l);
1505 
1506  //TODO: tips not localisable
1507  DEBUG_INFO("Tip index: " << nValue);
1508  strFile = GetXRCPath() + wxT("data/tips.txt"); //load default file
1509 
1510  DEBUG_INFO("Reading tips from " << strFile.mb_str(wxConvLocal));
1511  wxTipProvider *tipProvider = new LocalizedFileTipProvider(strFile, nValue);
1512  bShowAtStartup = wxShowTip(wxGetActiveWindow(), tipProvider, (nValue ? true : false));
1513 
1514  //store startup preferences
1515  nValue = (bShowAtStartup ? tipProvider->GetCurrentTip() : 0);
1516  DEBUG_INFO("Writing tip index: " << nValue);
1517  config->Write(wxT("/MainFrame/ShowStartTip"), nValue);
1518  delete tipProvider;
1519 }
1520 
1521 
1522 void MainFrame::OnShowPrefs(wxCommandEvent & e)
1523 {
1524  DEBUG_TRACE("");
1525  PreferencesDialog pref_dlg(wxGetActiveWindow());
1526  pref_dlg.ShowModal();
1527  //update image cache size
1528  wxConfigBase* cfg=wxConfigBase::Get();
1529 #if defined __WXMSW__
1530  unsigned long long mem = HUGIN_IMGCACHE_UPPERBOUND;
1531  unsigned long mem_low = cfg->Read(wxT("/ImageCache/UpperBound"), HUGIN_IMGCACHE_UPPERBOUND);
1532  unsigned long mem_high = cfg->Read(wxT("/ImageCache/UpperBoundHigh"), (long) 0);
1533  if (mem_high > 0)
1534  {
1535  mem = ((unsigned long long) mem_high << 32) + mem_low;
1536  }
1537  else
1538  {
1539  mem = mem_low;
1540  }
1541  ImageCache::getInstance().SetUpperLimit(mem);
1542 #else
1543  ImageCache::getInstance().SetUpperLimit(cfg->Read(wxT("/ImageCache/UpperBound"), HUGIN_IMGCACHE_UPPERBOUND));
1544 #endif
1546  if(gl_preview_frame)
1547  {
1548  gl_preview_frame->SetShowProjectionHints(cfg->Read(wxT("/GLPreviewFrame/ShowProjectionHints"),HUGIN_SHOW_PROJECTION_HINTS)!=0);
1549  };
1550 }
1551 
1552 void MainFrame::OnTogglePreviewFrame(wxCommandEvent & e)
1553 {
1554  DEBUG_TRACE("");
1555  if (preview_frame->IsIconized()) {
1556  preview_frame->Iconize(false);
1557  }
1558  preview_frame->Show();
1559  preview_frame->Raise();
1560 
1561  // we need to force an update since autoupdate fires
1562  // before the preview frame is shown
1563  wxCommandEvent dummy;
1564  preview_frame->OnUpdate(dummy);
1565 }
1566 
1567 void MainFrame::OnToggleGLPreviewFrame(wxCommandEvent & e)
1568 {
1569  if(gl_preview_frame==NULL)
1570  {
1571  return;
1572  };
1573 #if defined __WXMSW__ || defined __WXMAC__
1575 #endif
1576  if (gl_preview_frame->IsIconized()) {
1577  gl_preview_frame->Iconize(false);
1578  }
1579  gl_preview_frame->Show();
1580 #if defined __WXMSW__
1581  // on wxMSW Show() does not send OnShowEvent needed to update the
1582  // visibility state of the fast preview windows
1583  // so explicit calling this event handler
1584  wxShowEvent se;
1585  se.SetShow(true);
1587 #elif defined __WXGTK__
1589 #endif
1590  gl_preview_frame->Raise();
1591 }
1592 
1593 void MainFrame::OnShowCPFrame(wxCommandEvent & e)
1594 {
1595  DEBUG_TRACE("");
1596  if (cp_frame) {
1597  if (cp_frame->IsIconized()) {
1598  cp_frame->Iconize(false);
1599  }
1600  cp_frame->Show();
1601  cp_frame->Raise();
1602  } else {
1603  cp_frame = new CPListFrame(this, pano);
1604  cp_frame->Show();
1605  }
1606 }
1607 
1609 {
1610  cp_frame = 0;
1611 }
1612 
1613 void MainFrame::OnOptimize(wxCommandEvent & e)
1614 {
1615  DEBUG_TRACE("");
1616  wxCommandEvent dummy;
1617  opt_panel->OnOptimizeButton(dummy);
1618 }
1619 
1620 void MainFrame::OnOnlyActiveImages(wxCommandEvent &e)
1621 {
1622  SetOptimizeOnlyActiveImages(GetMenuBar()->IsChecked(XRCID("action_optimize_only_active")));
1623 };
1624 
1625 void MainFrame::SetOptimizeOnlyActiveImages(const bool onlyActive)
1626 {
1627  m_optOnlyActiveImages = onlyActive;
1628  wxMenuBar* menubar = GetMenuBar();
1629  if (menubar)
1630  {
1631  menubar->Check(XRCID("action_optimize_only_active"), onlyActive);
1632  };
1635  // notify all observer so they can update their display
1636  pano.changeFinished();
1637 };
1638 
1640 {
1641  return m_optOnlyActiveImages;
1642 };
1643 
1644 void MainFrame::OnIgnoreLineCp(wxCommandEvent &e)
1645 {
1646  m_optIgnoreLineCp = GetMenuBar()->IsChecked(XRCID("action_optimize_ignore_line_cp"));
1648  // notify all observer so they can update their display
1649  pano.changeFinished();
1650 };
1651 
1652 void MainFrame::SetOptimizeIgnoreLineCp(const bool ignoreLineCP)
1653 {
1654  m_optIgnoreLineCp = ignoreLineCP;
1655  wxMenuBar* menubar = GetMenuBar();
1656  if (menubar)
1657  {
1658  menubar->Check(XRCID("action_optimize_ignore_line_cp"), ignoreLineCP);
1659  // notify all observer so they can update their display
1660  pano.changeFinished();
1661  };
1662 };
1663 
1665 {
1666  return m_optIgnoreLineCp;
1667 };
1668 
1669 void MainFrame::OnPhotometricOptimize(wxCommandEvent & e)
1670 {
1671  wxCommandEvent dummy;
1673 };
1674 
1675 void MainFrame::OnDoStitch(wxCommandEvent & e)
1676 {
1677  DEBUG_TRACE("");
1678  wxCommandEvent cmdEvt(wxEVT_COMMAND_BUTTON_CLICKED,XRCID("pano_button_stitch"));
1679  pano_panel->GetEventHandler()->AddPendingEvent(cmdEvt);
1680 }
1681 
1682 void MainFrame::OnUserDefinedStitch(wxCommandEvent & e)
1683 {
1685 }
1686 
1687 void MainFrame::OnUserDefinedStitchSaved(wxCommandEvent & e)
1688 {
1689  auto filename = m_userOutput.find(e.GetId());
1690  if (filename != m_userOutput.end())
1691  {
1692  pano_panel->DoUserDefinedStitch(filename->second);
1693  }
1694  else
1695  {
1696  wxBell();
1697  };
1698 }
1699 
1700 void MainFrame::OnMergeProject(wxCommandEvent & e)
1701 {
1702  // get the global config object
1703  wxConfigBase* config = wxConfigBase::Get();
1704 
1705  wxString defaultdir = config->Read(wxT("/actualPath"),wxT(""));
1706  wxFileDialog dlg(wxGetActiveWindow(),
1707  _("Open project file"),
1708  defaultdir, wxT(""),
1709  _("Project files (*.pto)|*.pto|All files (*)|*"),
1710  wxFD_OPEN, wxDefaultPosition);
1711  dlg.SetDirectory(defaultdir);
1712  if (dlg.ShowModal() == wxID_OK)
1713  {
1714  wxString filename = dlg.GetPath();
1715  wxFileName fname(filename);
1716  wxString path = fname.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
1717  if (fname.IsOk() && fname.FileExists())
1718  {
1719  wxBusyCursor wait;
1721  std::ifstream in((const char *)fname.GetFullPath().mb_str(HUGIN_CONV_FILENAME));
1722  int ptoversion=0;
1723  if (newPano.loadPTScript(in, ptoversion, (const char *)path.mb_str(HUGIN_CONV_FILENAME)))
1724  {
1725  HuginBase::Panorama new_pano;
1726  new_pano.setMemento(newPano);
1728  new PanoCommand::MergePanoCmd(pano, new_pano)
1729  );
1730  m_mruFiles.AddFileToHistory(fname.GetFullPath());
1731  // force update of preview window
1732  if ( !(preview_frame->IsIconized() ||(! preview_frame->IsShown()) ) )
1733  {
1734  wxCommandEvent dummy;
1735  preview_frame->OnUpdate(dummy);
1736  };
1737  }
1738  else
1739  {
1740  wxMessageBox(wxString::Format(_("Could not read project file %s."),fname.GetFullPath().c_str()),_("Error"),wxOK|wxICON_ERROR);
1741  };
1742  };
1743  }
1744 }
1745 
1746 void MainFrame::OnReadPapywizard(wxCommandEvent & e)
1747 {
1748  wxString currentDir = wxConfigBase::Get()->Read(wxT("/actualPath"), wxT(""));
1749  wxFileDialog dlg(wxGetActiveWindow(), _("Open Papywizard xml file"),
1750  currentDir, wxT(""), _("Papywizard xml files (*.xml)|*.xml|All files (*)|*"),
1751  wxFD_OPEN, wxDefaultPosition);
1752  dlg.SetDirectory(currentDir);
1753  if (dlg.ShowModal() == wxID_OK)
1754  {
1755  wxConfigBase::Get()->Write(wxT("/actualPath"), dlg.GetDirectory());
1756  Papywizard::ImportPapywizardFile(dlg.GetPath(), pano);
1757  };
1758 };
1759 
1760 void MainFrame::OnApplyTemplate(wxCommandEvent & e)
1761 {
1762  // get the global config object
1763  wxConfigBase* config = wxConfigBase::Get();
1764 
1765  wxFileDialog dlg(wxGetActiveWindow(),
1766  _("Choose template project"),
1767  config->Read(wxT("/templatePath"),wxT("")), wxT(""),
1768  _("Project files (*.pto)|*.pto|All files (*)|*"),
1769  wxFD_OPEN, wxDefaultPosition);
1770  dlg.SetDirectory(wxConfigBase::Get()->Read(wxT("/templatePath"),wxT("")));
1771  if (dlg.ShowModal() == wxID_OK) {
1772  wxString filename = dlg.GetPath();
1773  wxConfig::Get()->Write(wxT("/templatePath"), dlg.GetDirectory()); // remember for later
1774 
1775  std::ifstream file((const char *)filename.mb_str(HUGIN_CONV_FILENAME));
1776 
1779 
1780  }
1781 }
1782 
1783 void MainFrame::OnOpenPTBatcher(wxCommandEvent & e)
1784 {
1785 #if defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
1786  // Original patch for OSX by Charlie Reiman dd. 18 June 2011
1787  // Slightly modified by HvdW. Errors in here are mine, not Charlie's.
1788  FSRef appRef;
1789  FSRef actuallyLaunched;
1790  OSStatus err;
1791  FSRef documentArray[1]; // Don't really need an array if we only have 1 item
1792  LSLaunchFSRefSpec launchSpec;
1793  Boolean isDir;
1794 
1795  err = LSFindApplicationForInfo(kLSUnknownCreator,
1796  CFSTR("net.sourceforge.hugin.PTBatcherGUI"),
1797  NULL,
1798  &appRef,
1799  NULL);
1800  if (err != noErr) {
1801  // error, can't find PTBatcherGUI
1802  wxMessageBox(wxString::Format(_("External program %s not found in the bundle, reverting to system path"), wxT("open")), _("Error"));
1803  // Possibly a silly attempt otherwise the previous would have worked as well, but just try it.
1804  wxExecute(_T("open -b net.sourceforge.hugin.PTBatcherGUI"));
1805  }
1806  else {
1807  wxExecute(_T("open -b net.sourceforge.hugin.PTBatcherGUI"));
1808  }
1809 #else
1810  const wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
1811  wxExecute(exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) + _T("PTBatcherGUI"));
1812 #endif
1813 }
1814 
1815 void MainFrame::OnFineTuneAll(wxCommandEvent & e)
1816 {
1817  DEBUG_TRACE("");
1818  // fine-tune all points
1819 
1821 
1822  // create a map of all control points.
1823  std::set<unsigned int> unoptimized;
1824  for (unsigned int i=0; i < cps.size(); i++) {
1825  // create all control points.
1826  unoptimized.insert(i);
1827  }
1828 
1829  unsigned int nGood=0;
1830  unsigned int nBad=0;
1831 
1832  wxConfigBase *cfg = wxConfigBase::Get();
1833  double corrThresh=HUGIN_FT_CORR_THRESHOLD;
1834  cfg->Read(wxT("/Finetune/CorrThreshold"), &corrThresh, HUGIN_FT_CORR_THRESHOLD);
1835  double curvThresh = HUGIN_FT_CURV_THRESHOLD;
1836  cfg->Read(wxT("/Finetune/CurvThreshold"),&curvThresh, HUGIN_FT_CURV_THRESHOLD);
1837  // load parameters
1838  const long templWidth = cfg->Read(wxT("/Finetune/TemplateSize"), HUGIN_FT_TEMPLATE_SIZE);
1839  const long sWidth = templWidth + cfg->Read(wxT("/Finetune/LocalSearchWidth"), HUGIN_FT_LOCAL_SEARCH_WIDTH);
1840 
1841  {
1842  ProgressReporterDialog progress(unoptimized.size(), _("Fine-tuning all points"), _("Fine-tuning"), wxGetActiveWindow());
1843 
1844  ImageCache & imgCache = ImageCache::getInstance();
1845 
1846  // do not process the control points in random order,
1847  // but walk from image to image, to reduce image reloading
1848  // in low mem situations.
1849  for (unsigned int imgNr = 0 ; imgNr < pano.getNrOfImages(); imgNr++) {
1850  std::set<unsigned int>::iterator it=unoptimized.begin();
1851 
1852  imgCache.softFlush();
1853 
1854  while (it != unoptimized.end()) {
1855  if (cps[*it].image1Nr == imgNr || cps[*it].image2Nr == imgNr) {
1856  if (!progress.updateDisplayValue())
1857  {
1858  return;
1859  };
1860  if (cps[*it].mode == HuginBase::ControlPoint::X_Y) {
1861  // finetune only normal points
1862  DEBUG_DEBUG("fine tuning point: " << *it);
1863  wxImage wxSearchImg;
1864  ImageCache::ImageCacheRGB8Ptr searchImg = imgCache.getImage(
1865  pano.getImage(cps[*it].image2Nr).getFilename())->get8BitImage();
1866 
1867  ImageCache::ImageCacheRGB8Ptr templImg = imgCache.getImage(
1868  pano.getImage(cps[*it].image1Nr).getFilename())->get8BitImage();
1869 
1871  vigra::Diff2D roundP1(hugin_utils::roundi(cps[*it].x1), hugin_utils::roundi(cps[*it].y1));
1872  vigra::Diff2D roundP2(hugin_utils::roundi(cps[*it].x2), hugin_utils::roundi(cps[*it].y2));
1873 
1874  res = PointFineTuneProjectionAware(pano.getImage(cps[*it].image1Nr), *templImg, roundP1, templWidth,
1875  pano.getImage(cps[*it].image2Nr), *searchImg, roundP2, sWidth);
1876 
1877  // invert curvature. we always assume its a maxima, the curvature there is negative
1878  // however, we allow the user to specify a positive threshold, so we need to
1879  // invert it
1880  res.curv.x = - res.curv.x;
1881  res.curv.y = - res.curv.y;
1882 
1883  if (res.maxi < corrThresh || res.curv.x < curvThresh || res.curv.y < curvThresh ||
1884  res.maxpos.x < 0 || res.maxpos.y < 0 || res.corrPos.x < 0 || res.corrPos.y < 0)
1885  {
1886  // Bad correlation result.
1887  nBad++;
1888  if (res.maxi >= corrThresh) {
1889  cps[*it].error = 0;
1890  }
1891  cps[*it].error = res.maxi;
1892  DEBUG_DEBUG("low correlation: " << res.maxi << " curv: " << res.curv);
1893  } else {
1894  nGood++;
1895  // only update if a good correlation was found
1896  cps[*it].x1 = res.corrPos.x;
1897  cps[*it].y1 = res.corrPos.y;
1898  cps[*it].x2 = res.maxpos.x;
1899  cps[*it].y2 = res.maxpos.y;
1900  cps[*it].error = res.maxi;
1901  }
1902  }
1903  else
1904  {
1905  // for line control points set error = correlation to 1
1906  cps[*it].error = 1.0;
1907  };
1908  unsigned int rm = *it;
1909  ++it;
1910  unoptimized.erase(rm);
1911  } else {
1912  ++it;
1913  }
1914  }
1915  }
1916  }
1917  m_showCorrelation = 1;
1918  wxString result;
1919  result.Printf(_("%d points fine-tuned, %d points not updated due to low correlation\n\nHint: The errors of the fine-tuned points have been set to the correlation coefficient\nProblematic points can be spotted (just after fine-tune, before optimizing)\nby an error <= %.3f.\nThe error of points without a well defined peak (typically in regions with uniform color)\nwill be set to 0\n\nUse the Control Point list (F3) to see all points of the current project\n"),
1920  nGood, nBad, corrThresh);
1921  wxMessageBox(result, _("Fine-tune result"), wxOK);
1922  // set newly optimized points
1924  new PanoCommand::UpdateCPsCmd(pano, cps, false)
1925  );
1926 }
1927 
1928 void MainFrame::OnRemoveCPinMasks(wxCommandEvent & e)
1929 {
1930  if(pano.getCtrlPoints().size()<2)
1931  return;
1933  if(!cps.empty())
1934  {
1937  );
1938  wxMessageBox(wxString::Format(_("Removed %lu control points"), static_cast<unsigned long>(cps.size())),
1939  _("Removing control points in masks"),wxOK|wxICON_INFORMATION);
1940  };
1941 }
1942 
1943 #ifdef HUGIN_HSI
1944 void MainFrame::OnPythonScript(wxCommandEvent & e)
1945 {
1946  wxString fname;
1947  wxFileDialog dlg(wxGetActiveWindow(),
1948  _("Select python script"),
1949  wxConfigBase::Get()->Read(wxT("/lensPath"),wxT("")), wxT(""),
1950  _("Python script (*.py)|*.py|All files (*.*)|*.*"),
1951  wxFD_OPEN, wxDefaultPosition);
1952  dlg.SetDirectory(wxConfigBase::Get()->Read(wxT("/pythonScriptPath"),wxT("")));
1953 
1954  if (dlg.ShowModal() == wxID_OK)
1955  {
1956  wxString filename = dlg.GetPath();
1957  wxConfig::Get()->Write(wxT("/pythonScriptPath"), dlg.GetDirectory());
1958  std::string scriptfile((const char *)filename.mb_str(HUGIN_CONV_FILENAME));
1960  new PanoCommand::PythonScriptPanoCmd(pano,scriptfile)
1961  );
1962  }
1963 }
1964 
1965 void MainFrame::OnPlugin(wxCommandEvent & e)
1966 {
1967  wxFileName file=m_plugins[e.GetId()];
1968  if(file.FileExists())
1969  {
1970  std::string scriptfile((const char *)file.GetFullPath().mb_str(HUGIN_CONV_FILENAME));
1972  new PanoCommand::PythonScriptPanoCmd(pano,scriptfile)
1973  );
1974  }
1975  else
1976  {
1977  wxMessageBox(wxString::Format(wxT("Python-Script %s not found.\nStopping processing."),file.GetFullPath().c_str()),_("Warning"),wxOK|wxICON_INFORMATION);
1978  };
1979 }
1980 
1981 #endif
1982 
1983 void MainFrame::OnUndo(wxCommandEvent & e)
1984 {
1985  DEBUG_TRACE("OnUndo");
1987  {
1989  }
1990  else
1991  {
1992  wxBell();
1993  };
1994 }
1995 
1996 void MainFrame::OnRedo(wxCommandEvent & e)
1997 {
1998  DEBUG_TRACE("OnRedo");
2000  {
2002  };
2003 }
2004 
2005 void MainFrame::ShowCtrlPoint(unsigned int cpNr)
2006 {
2007  DEBUG_DEBUG("Showing control point " << cpNr);
2008  m_notebook->SetSelection(2);
2009  cpe->ShowControlPoint(cpNr);
2010 }
2011 
2012 void MainFrame::ShowCtrlPointEditor(unsigned int img1, unsigned int img2)
2013 {
2014  if(!IsShown())
2015  {
2016  Show();
2017  Raise();
2018  };
2019  m_notebook->SetSelection(2);
2020  cpe->setLeftImage(img1);
2021  cpe->setRightImage(img2);
2022 }
2023 
2024 void MainFrame::ShowMaskEditor(size_t imgNr, bool switchToCropMode)
2025 {
2026  if(!IsShown())
2027  {
2028  Show();
2029  Raise();
2030  };
2031  m_notebook->SetSelection(1);
2032  mask_panel->setImage(imgNr, true);
2033  if (switchToCropMode)
2034  {
2036  };
2037 };
2038 
2040 {
2043  {
2044  m_notebook->SetSelection(5);
2045  }
2046  else
2047  {
2049  {
2050  m_notebook->SetSelection(4);
2051  }
2052  else
2053  {
2054  m_notebook->SetSelection(3);
2055  };
2056  };
2057 }
2058 
2061 {
2062  wxString msg;
2063  if (!m_message.empty())
2064  {
2065  msg = wxGetTranslation(wxString(m_message.c_str(), wxConvLocal));
2066  if (!m_filename.empty())
2067  {
2068  msg.Append(wxT(" "));
2069  msg.Append(wxString(ProgressDisplay::m_filename.c_str(), HUGIN_CONV_FILENAME));
2070  };
2071  };
2072  GetStatusBar()->SetStatusText(msg, 0);
2073 
2074 #ifdef __WXMSW__
2075  UpdateWindow(NULL);
2076 #endif
2077 }
2078 
2079 void MainFrame::enableTools(bool option)
2080 {
2081  wxToolBar* theToolBar = GetToolBar();
2082  theToolBar->EnableTool(XRCID("action_optimize"), option);
2083  theToolBar->EnableTool(XRCID("ID_SHOW_PREVIEW_FRAME"), option);
2084  //theToolBar->EnableTool(XRCID("ID_SHOW_GL_PREVIEW_FRAME"), option);
2085  wxMenuBar* theMenuBar = GetMenuBar();
2086  theMenuBar->Enable(XRCID("action_optimize"), option);
2087  theMenuBar->Enable(XRCID("action_finetune_all_cp"), option);
2088  theMenuBar->Enable(XRCID("action_remove_cp_in_masks"), option);
2089  theMenuBar->Enable(XRCID("ID_SHOW_PREVIEW_FRAME"), option);
2090  theMenuBar->Enable(XRCID("action_stitch"), option);
2091  theMenuBar->Enable(XRCID("action_stitch_userdefined"), option);
2092  if (m_outputUserMenu != nullptr)
2093  {
2094  m_outputUserMenu->Enable(option);
2095  };
2096  if (m_assistantUserMenu != nullptr)
2097  {
2098  m_assistantUserMenu->Enable(option);
2099  };
2100  theMenuBar->Enable(XRCID("action_assistant"), option);
2101  theMenuBar->Enable(XRCID("action_batch_assistant"), option);
2102  m_menu_file_advanced->Enable(XRCID("action_import_papywizard"), option);
2103  //theMenuBar->Enable(XRCID("ID_SHOW_GL_PREVIEW_FRAME"), option);
2104 }
2105 
2106 
2107 void MainFrame::OnSize(wxSizeEvent &e)
2108 {
2109 #ifdef DEBUG
2110  wxSize sz = this->GetSize();
2111  wxSize csz = this->GetClientSize();
2112  wxSize vsz = this->GetVirtualSize();
2113  DEBUG_TRACE(" size:" << sz.x << "," << sz.y <<
2114  " client: "<< csz.x << "," << csz.y <<
2115  " virtual: "<< vsz.x << "," << vsz.y);
2116 #endif
2117 
2118  Layout();
2119  e.Skip();
2120 }
2121 
2123 {
2124  return images_panel->GetDefaultSetting();
2125 };
2126 
2128 {
2129  images_panel->RunCPGenerator(setting, img);
2130 };
2131 
2133 {
2135 };
2136 
2138 {
2140 };
2141 
2142 const wxString & MainFrame::GetXRCPath()
2143 {
2144  return huginApp::Get()->GetXRCPath();
2145 };
2146 
2147 const wxString & MainFrame::GetDataPath()
2148 {
2149  return wxGetApp().GetDataPath();
2150 };
2151 
2154 {
2155  if (m_this) {
2156  return m_this;
2157  } else {
2158  DEBUG_FATAL("MainFrame not yet created");
2160  return 0;
2161  }
2162 }
2163 
2165 {
2166  return m_filename;
2167 }
2168 
2170 {
2171  return m_showCorrelation > 0;
2172 }
2173 
2174 void MainFrame::OnMRUFiles(wxCommandEvent &e)
2175 {
2176  size_t index = e.GetId() - wxID_FILE1;
2177  wxString f(m_mruFiles.GetHistoryFile(index));
2178  if (!f.empty())
2179  {
2180  wxFileName fn(f);
2181  if (fn.FileExists())
2182  {
2183  // if closing old project was canceled do nothing
2184  if (CloseProject(true, LOAD_NEW_PROJECT))
2185  {
2186  // remove old images from cache
2187  ImageCache::getInstance().flush();
2188  // finally load project
2189  LoadProjectFile(f);
2190  };
2191  }
2192  else
2193  {
2194  m_mruFiles.RemoveFileFromHistory(index);
2195  wxMessageBox(wxString::Format(_("File \"%s\" not found.\nMaybe file was renamed, moved or deleted."),f.c_str()),
2196  _("Error!"),wxOK | wxICON_INFORMATION );
2197  };
2198  };
2199 }
2200 
2201 void MainFrame::OnFullScreen(wxCommandEvent & e)
2202 {
2203  ShowFullScreen(!IsFullScreen(), wxFULLSCREEN_NOBORDER | wxFULLSCREEN_NOCAPTION);
2204 #ifdef __WXGTK__
2205  //workaround a wxGTK bug that also the toolbar is hidden, but not requested to hide
2206  GetToolBar()->Show(true);
2207 #endif
2208 };
2209 
2211 {
2212  if(svmModel==NULL)
2213  {
2214  // determine file name of SVM model file
2215  // get XRC path from application
2216  wxString wxstrModelFileName = huginApp::Get()->GetDataPath() + wxT(HUGIN_CELESTE_MODEL);
2217  // convert wxString to string
2218  std::string strModelFileName(wxstrModelFileName.mb_str(HUGIN_CONV_FILENAME));
2219 
2220  // SVM model file
2221  if (! wxFile::Exists(wxstrModelFileName) ) {
2222  wxMessageBox(wxString::Format(_("Celeste model expected in %s not found, Hugin needs to be properly installed."),wxstrModelFileName.c_str()), _("Fatal Error"));
2223  return NULL;
2224  }
2225  if(!celeste::loadSVMmodel(svmModel,strModelFileName))
2226  {
2227  wxMessageBox(wxString::Format(_("Could not load Celeste model file %s"),wxstrModelFileName.c_str()),_("Error"));
2228  svmModel=NULL;
2229  };
2230  }
2231  return svmModel;
2232 };
2233 
2235 {
2236  return gl_preview_frame;
2237 }
2238 
2240 {
2241  if(gl_preview_frame==NULL && newLevel==GUI_SIMPLE)
2242  {
2244  return;
2245  };
2246  if(m_guiLevel==GUI_EXPERT && newLevel!=GUI_EXPERT && pano.getOptimizerSwitch()==0)
2247  {
2248  bool needsUpdateOptimizerVar=false;
2250  for(size_t i=0; i<optVec.size(); i++)
2251  {
2252  bool hasTrX=optVec[i].erase("TrX")>0;
2253  bool hasTrY=optVec[i].erase("TrY")>0;
2254  bool hasTrZ=optVec[i].erase("TrZ")>0;
2255  bool hasTpy=optVec[i].erase("Tpy")>0;
2256  bool hasTpp=optVec[i].erase("Tpp")>0;
2257  bool hasg=optVec[i].erase("g")>0;
2258  bool hast=optVec[i].erase("t")>0;
2259  needsUpdateOptimizerVar=needsUpdateOptimizerVar || hasTrX || hasTrY || hasTrZ || hasTpy || hasTpp || hasg || hast;
2260  };
2261  if(needsUpdateOptimizerVar)
2262  {
2265  );
2266  };
2267  };
2268  if(newLevel==GUI_SIMPLE && pano.getPhotometricOptimizerSwitch()==0)
2269  {
2270  bool needsUpdateOptimizerVar=false;
2272  for(size_t i=0; i<optVec.size(); i++)
2273  {
2274  bool hasVx=optVec[i].erase("Vx")>0;
2275  bool hasVy=optVec[i].erase("Vy")>0;
2276  needsUpdateOptimizerVar=needsUpdateOptimizerVar || hasVx || hasVy;
2277  };
2278  if(needsUpdateOptimizerVar)
2279  {
2282  );
2283  };
2284  };
2285  m_guiLevel=newLevel;
2290  if(gl_preview_frame)
2291  {
2293  };
2294  switch(m_guiLevel)
2295  {
2296  case GUI_SIMPLE:
2297  GetMenuBar()->FindItem(XRCID("action_gui_simple"))->Check();
2298  break;
2299  case GUI_ADVANCED:
2300  GetMenuBar()->FindItem(XRCID("action_gui_advanced"))->Check();
2301  break;
2302  case GUI_EXPERT:
2303  GetMenuBar()->FindItem(XRCID("action_gui_expert"))->Check();
2304  break;
2305  };
2306  if(m_guiLevel==GUI_SIMPLE)
2307  {
2308  if(!gl_preview_frame->IsShown())
2309  {
2310  wxCommandEvent dummy;
2311  OnToggleGLPreviewFrame(dummy);
2312  };
2313  wxGetApp().SetTopWindow(gl_preview_frame);
2314  GetMenuBar()->Remove(0);
2315  GetMenuBar()->Insert(0, m_menu_file_simple, _("&File"));
2316  if(m_filename.IsEmpty())
2317  {
2318  gl_preview_frame->SetTitle(_("Hugin - Panorama Stitcher"));
2319  SetTitle(_("Panorama editor"));
2320  }
2321  else
2322  {
2323  wxFileName scriptName = m_filename;
2324  gl_preview_frame->SetTitle(scriptName.GetName() + wxT(".") + scriptName.GetExt() + wxT(" - ") + _("Hugin - Panorama Stitcher"));
2325  SetTitle(scriptName.GetName() + wxT(".") + scriptName.GetExt() + wxT(" - ") + _("Panorama editor"));
2326  };
2327  Hide();
2328  }
2329  else
2330  {
2331  wxGetApp().SetTopWindow(this);
2332  GetMenuBar()->Remove(0);
2333  GetMenuBar()->Insert(0, m_menu_file_advanced, _("&File"));
2334  if(m_filename.IsEmpty())
2335  {
2336  SetTitle(_("Hugin - Panorama Stitcher"));
2337  }
2338  else
2339  {
2340  wxFileName scriptName = m_filename;
2341  SetTitle(scriptName.GetName() + wxT(".") + scriptName.GetExt() + wxT(" - ") + _("Hugin - Panorama Stitcher"));
2342  };
2343  if(!IsShown())
2344  {
2345  Show();
2346  };
2347  };
2348 };
2349 
2350 void MainFrame::OnSetGuiSimple(wxCommandEvent & e)
2351 {
2352  GuiLevel reqGuiLevel=GetMinimumGuiLevel(pano);
2353  if(reqGuiLevel<=GUI_SIMPLE)
2354  {
2356  }
2357  else
2358  {
2359  if(reqGuiLevel==GUI_ADVANCED)
2360  {
2361  wxMessageBox(_("Can't switch to simple interface. The project is using stacks and/or vignetting center shift.\nThese features are not supported in simple interface."),
2362 #ifdef __WXMSW__
2363  wxT("Hugin"),
2364 #else
2365  wxT(""),
2366 #endif
2367  wxOK | wxICON_INFORMATION);
2368  }
2369  else
2370  {
2371  wxMessageBox(_("Can't switch to simple interface. The project is using translation or shear parameters.\nThese parameters are not supported in simple interface."),
2372 #ifdef __WXMSW__
2373  wxT("Hugin"),
2374 #else
2375  wxT(""),
2376 #endif
2377  wxOK | wxICON_INFORMATION);
2378  }
2380  };
2381 };
2382 
2383 void MainFrame::OnSetGuiAdvanced(wxCommandEvent & e)
2384 {
2385  GuiLevel reqGuiLevel=GetMinimumGuiLevel(pano);
2386  if(reqGuiLevel<=GUI_ADVANCED)
2387  {
2389  }
2390  else
2391  {
2392  wxMessageBox(_("Can't switch to advanced interface. The project is using translation or shear parameters.\nThese parameters are not supported in advanced interface."),
2393 #ifdef __WXMSW__
2394  wxT("Hugin"),
2395 #else
2396  wxT(""),
2397 #endif
2398  wxOK | wxICON_INFORMATION);
2400  };
2401 };
2402 
2403 void MainFrame::OnSetGuiExpert(wxCommandEvent & e)
2404 {
2406 };
2407 
2409 {
2410  GetMenuBar()->Enable(XRCID("ID_SHOW_GL_PREVIEW_FRAME"), false);
2411  GetMenuBar()->Enable(XRCID("action_gui_simple"), false);
2412  GetToolBar()->EnableTool(XRCID("ID_SHOW_GL_PREVIEW_FRAME"), false);
2413 };
2414 
2415 void MainFrame::RunAssistant(wxWindow* mainWin, const wxString& userdefinedAssistant)
2416 {
2417  //save project into temp directory
2418  wxString tempDir= wxConfig::Get()->Read(wxT("tempDir"),wxT(""));
2419  if(!tempDir.IsEmpty())
2420  {
2421  if(tempDir.Last()!=wxFileName::GetPathSeparator())
2422  {
2423  tempDir.Append(wxFileName::GetPathSeparator());
2424  }
2425  };
2426  wxFileName scriptFileName(wxFileName::CreateTempFileName(tempDir+wxT("ha")));
2427  const std::string script(scriptFileName.GetFullPath().mb_str(HUGIN_CONV_FILENAME));
2428  pano.WritePTOFile(script, hugin_utils::getPathPrefix(script));
2429 
2430  // get assistant queue
2431  const wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
2432  wxArrayString tempfiles;
2433  HuginQueue::CommandQueue* commands;
2434  if (userdefinedAssistant.IsEmpty())
2435  {
2436  commands = HuginQueue::GetAssistantCommandQueue(pano, exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR), scriptFileName.GetFullPath());
2437  }
2438  else
2439  {
2440  std::stringstream errors;
2441  commands = HuginQueue::GetAssistantCommandQueueUserDefined(pano, exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR), scriptFileName.GetFullPath(), userdefinedAssistant, tempfiles, errors);
2442  if (commands->empty())
2443  {
2444  wxMessageBox(_("The assistant queue is empty. This indicates an error in the user defined assistant file.") + "\n\n" + wxString(errors.str()),
2445  _("Error"), wxOK | wxICON_ERROR, mainWin);
2446  //delete temporary files
2447  wxRemoveFile(scriptFileName.GetFullPath());
2448  return;
2449  };
2450  };
2451  //execute queue
2452  int ret = MyExecuteCommandQueue(commands, mainWin, _("Running assistant"));
2453 
2454  //read back panofile
2456  (const char *)scriptFileName.GetFullPath().mb_str(HUGIN_CONV_FILENAME), "",
2457  ret==0, false));
2458 
2459  //delete temporary files
2460  wxRemoveFile(scriptFileName.GetFullPath());
2461  if (!tempfiles.IsEmpty())
2462  {
2463  for (auto& f : tempfiles)
2464  {
2465  wxRemoveFile(f);
2466  };
2467  };
2468  // check that GUI level is still approbiate
2469  const GuiLevel reqGuiLevel = GetMinimumGuiLevel(pano);
2470  if (reqGuiLevel > m_guiLevel)
2471  {
2472  // output of assistant requires higher GUI level
2473  SetGuiLevel(reqGuiLevel);
2474  };
2475  //if return value is non-zero, an error occurred in the assistant
2476  if(ret!=0)
2477  {
2478  if (userdefinedAssistant.IsEmpty())
2479  {
2480  if (pano.getNrOfImages() == 1)
2481  {
2482  wxMessageBox(_("The assistant could not find vertical lines. Please add vertical lines in the panorama editor and optimize project manually."),
2483  _("Warning"), wxOK | wxICON_INFORMATION, mainWin);
2484  }
2485  else
2486  {
2487  //check for unconnected images
2489  const HuginGraph::ImageGraph::Components comps = graph.GetComponents();
2490  if (comps.size() > 1)
2491  {
2492  // switch to images panel.
2493  unsigned i1 = *(comps[0].rbegin());
2494  unsigned i2 = *(comps[1].begin());
2495  ShowCtrlPointEditor(i1, i2);
2496  // display message box with
2497  wxMessageBox(wxString::Format(_("Warning %d unconnected image groups found:"), static_cast<int>(comps.size())) + Components2Str(comps) + wxT("\n")
2498  + _("Please create control points between unconnected images using the Control Points tab in the panorama editor.\n\nAfter adding the points, press the \"Align\" button again"), _("Error"), wxOK, mainWin);
2499  return;
2500  };
2501  wxMessageBox(_("The assistant did not complete successfully. Please check the resulting project file."),
2502  _("Warning"), wxOK | wxICON_INFORMATION, mainWin);
2503  };
2504  }
2505  else
2506  {
2507  wxMessageBox(_("The assistant did not complete successfully. Please check the resulting project file."),
2508  _("Warning"), wxOK | wxICON_INFORMATION, mainWin);
2509  };
2510  };
2511 };
2512 
2513 void MainFrame::OnRunAssistant(wxCommandEvent & e)
2514 {
2515  RunAssistant(this);
2516 };
2517 
2519 {
2520  const auto filename = m_userAssistant.find(e.GetId());
2521  if (filename != m_userAssistant.end())
2522  {
2523  RunAssistant(this, filename->second);
2524  }
2525  else
2526  {
2527  wxBell();
2528  };
2529 };
2530 
2531 void MainFrame::OnSendToAssistantQueue(wxCommandEvent &e)
2532 {
2533  wxCommandEvent dummy;
2534  OnSaveProject(dummy);
2535  wxString projectFile = getProjectName();
2536  if(wxFileName::FileExists(projectFile))
2537  {
2538 #if defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
2539  // Original patch for OSX by Charlie Reiman dd. 18 June 2011
2540  // Slightly modified by HvdW. Errors in here are mine, not Charlie's.
2541  FSRef appRef;
2542  FSRef actuallyLaunched;
2543  OSStatus err;
2544  FSRef documentArray[1]; // Don't really need an array if we only have 1 item
2545  LSLaunchFSRefSpec launchSpec;
2546  Boolean isDir;
2547 
2548  err = LSFindApplicationForInfo(kLSUnknownCreator,
2549  CFSTR("net.sourceforge.hugin.PTBatcherGUI"),
2550  NULL,
2551  &appRef,
2552  NULL);
2553  if (err != noErr)
2554  {
2555  // error, can't find PTBatcherGUI
2556  wxMessageBox(wxString::Format(_("External program %s not found in the bundle, reverting to system path"), wxT("open")), _("Error"));
2557  // Possibly a silly attempt otherwise the previous would have worked as well, but just try it.
2558  wxExecute(_T("open -b net.sourceforge.hugin.PTBatcherGUI ")+hugin_utils::wxQuoteFilename(projectFile));
2559  return;
2560  }
2561 
2562  wxCharBuffer projectFilebuffer=projectFile.ToUTF8();
2563  // Point to document
2564  err = FSPathMakeRef((unsigned char*) projectFilebuffer.data(), &documentArray[0], &isDir);
2565  if (err != noErr || isDir)
2566  {
2567  // Something went wrong.
2568  wxMessageBox(wxString::Format(_("Project file not found"), wxT("open")), _("Error"));
2569  return;
2570  }
2571  launchSpec.appRef = &appRef;
2572  launchSpec.numDocs = sizeof(documentArray)/sizeof(documentArray[0]);
2573  launchSpec.itemRefs = documentArray;
2574  launchSpec.passThruParams = NULL;
2575  launchSpec.launchFlags = kLSLaunchDontAddToRecents + kLSLaunchDontSwitch;
2576  launchSpec.asyncRefCon = NULL;
2577 
2578  err = LSOpenFromRefSpec(&launchSpec, &actuallyLaunched);
2579  if (err != noErr && err != kLSLaunchInProgressErr)
2580  {
2581  // Should be ok if it's in progress... I think.
2582  // Launch failed.
2583  wxMessageBox(wxString::Format(_("Can't launch PTBatcherGui"), wxT("open")), _("Error"));
2584  return;
2585  }
2586 
2587  // Should verify that actuallyLaunched and appRef are the same.
2588  if (FSCompareFSRefs(&appRef, &actuallyLaunched) != noErr)
2589  {
2590  // error, lauched the wrong thing.
2591  wxMessageBox(wxString::Format(_("Launched incorrect programme"), wxT("open")), _("Error"));
2592  return;
2593  }
2594 #else
2595  const wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
2596  wxExecute(exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) + wxT("PTBatcherGUI -a ")+hugin_utils::wxQuoteFilename(projectFile));
2597 #endif
2598  }
2599 };
2600 
2602 {
2604 };
2605 
void DisplayHelp(wxString section=wxEmptyString)
call help browser with given file
Definition: MainFrame.cpp:1483
wxDEFINE_EVENT(EVT_QUEUE_PROGRESS, wxCommandEvent)
#define DEBUG_INFO(msg)
Definition: utils.h:69
void OnShowCPFrame(wxCommandEvent &e)
Definition: MainFrame.cpp:1593
OptimizePanel * opt_panel
Definition: MainFrame.h:254
int MyExecuteCommandQueue(HuginQueue::CommandQueue *queue, wxWindow *parent, const wxString &title, const wxString &comment)
execute all commands in queue with redirection of output to frame and allow canceling the queue will ...
Base class for all panorama commands.
Definition: Command.h:38
bool ImportPapywizardFile(const wxString &filename, HuginBase::Panorama &pano)
import the settings from given filename into pano
PanoPanel * pano_panel
Definition: MainFrame.h:258
void destroySVMmodel(struct svm_model *&model)
frees the resource of model
Definition: Celeste.cpp:60
const bool GetOptimizeOnlyActiveImages() const
Definition: MainFrame.cpp:1639
int m_showCorrelation
Definition: MainFrame.h:279
#define HUGIN_SHOW_PROJECTION_HINTS
void OnUpdate(wxCommandEvent &event)
std::list< PluginItem > PluginItems
Definition: PluginItems.h:61
implementation of huginApp Class
void updateProgressDisplay()
receive notification about progress.
Definition: MainFrame.cpp:2060
std::map< int, wxString > m_userOutput
Definition: MainFrame.h:299
bool FileExists(const std::string &filename)
checks if file exists
Definition: utils.cpp:362
void SetGuiLevel(GuiLevel newLevel)
Definition: MainFrame.cpp:2239
void OnRemoveCPinMasks(wxCommandEvent &e)
Definition: MainFrame.cpp:1928
const wxString & GetDataPath()
return the current data path
Definition: huginApp.h:118
void OnUserQuit(wxCommandEvent &e)
Definition: MainFrame.cpp:863
void OnRunAssistant(wxCommandEvent &e)
Definition: MainFrame.cpp:2513
hugin preferences dialog
void OnApplyTemplate(wxCommandEvent &e)
Definition: MainFrame.cpp:1760
The OpenGL preview frame.
void setMemento(const PanoramaMemento &memento)
set the internal state
Definition: Panorama.cpp:1507
virtual PanoCommand::PanoCommand * GetCommand(wxWindow *parent, HuginBase::Panorama &pano, HuginBase::UIntSet images, GuiLevel guiLevel)
returns the appropriate PanoCommand::PanoCommand to be inserted into GlobalCmdHistory, checks if operation is enabled
void AddImages(wxArrayString &filenameArray)
adds the given files to the projects, with checking for invalid filenames
Definition: MainFrame.cpp:1298
void SetGuiLevel(GuiLevel newGuiLevel)
void ShowStitcherTab()
opens the stitcher tab
Definition: MainFrame.cpp:2039
const bool GetOptimizeIgnoreLineCp() const
Definition: MainFrame.cpp:1664
int roundi(T x)
Definition: hugin_math.h:73
void StorePositionAndSize()
store position and size of window in wxConfig
start a new project, reset options to values in preferences
Definition: wxPanoCommand.h:85
read settings from papywizard xml file
#define HUGIN_FT_LOCAL_SEARCH_WIDTH
vigra_ext::CorrelationResult PointFineTuneProjectionAware(const HuginBase::SrcPanoImage &templ, const vigra::UInt8RGBImage &templImg, vigra::Diff2D templPos, int templSize, const HuginBase::SrcPanoImage &search, const vigra::UInt8RGBImage &searchImg, vigra::Diff2D searchPos, int sWidth)
function for fine-tune with remapping to stereographic projection
void OnToggleGLPreviewFrame(wxCommandEvent &e)
Definition: MainFrame.cpp:1567
void AddUserDefinedAssistant(int id, const wxString &desc, const wxString &help)
adds the given user defined assistant to SplitButton menu
void OnRedo(wxCommandEvent &e)
Definition: MainFrame.cpp:1996
GLPreviewFrame * gl_preview_frame
Definition: MainFrame.h:263
ImagesPanel * images_panel
Definition: MainFrame.h:251
bool m_show_opt_photo_panel
Definition: MainFrame.h:257
void OnUndo(wxCommandEvent &e)
Definition: MainFrame.cpp:1983
center panorama horizontically
Definition: PanoCommand.h:250
wxMenuItem * m_assistantUserMenu
Definition: MainFrame.h:287
struct celeste::svm_model * svmModel
Definition: MainFrame.h:259
control point editor panel.
Definition: CPEditorPanel.h:64
OptimizePhotometricPanel * opt_photo_panel
Definition: MainFrame.h:256
bool removeObserver(PanoramaObserver *observer)
remove a panorama observer.
Definition: Panorama.cpp:1551
#define HUGIN_CONV_FILENAME
Definition: platform.h:40
GuiLevel GetMinimumGuiLevel(HuginBase::PanoramaData &pano)
returns the requiered GuiLevel for the given panorama to work correctly
Definition: GuiLevel.cpp:29
hugin_utils::FDiff2D corrPos
Definition: Correlation.h:66
#define DEBUG_TRACE(msg)
Definition: utils.h:67
const wxString GetSelectedCPGenerator()
return the currently selected cp generator description
Definition: MainFrame.cpp:2137
void RunAssistant(wxWindow *mainWin, const wxString &userdefinedAssistant=wxEmptyString)
Definition: MainFrame.cpp:2415
#define HUGIN_FT_CURV_THRESHOLD
void registerPTWXDlgFcn()
Definition: PTWXDlg.cpp:173
void OnUserDefinedStitch(wxCommandEvent &e)
Definition: MainFrame.cpp:1682
void OnSavePTStitcherAs(wxCommandEvent &e)
Definition: MainFrame.cpp:1049
void OnExit(wxCloseEvent &e)
Definition: MainFrame.cpp:929
void RunCPGenerator(CPDetectorSetting &setting, const HuginBase::UIntSet &img)
run the cp generator with the given setting on selected images
const wxString GetDescription() const
return description
Reading python plugins metadata.
CPEditorPanel * cpe
Definition: MainFrame.h:253
void OnTipOfDay(wxCommandEvent &e)
Definition: MainFrame.cpp:1495
void deregisterPTWXDlgFcn()
Definition: PTWXDlg.cpp:180
void OnMergeProject(wxCommandEvent &e)
Definition: MainFrame.cpp:1700
This is a cache for all the images we use.
Definition: ImageCache.h:52
void SetOptimizeOnlyActiveImages(const bool onlyActive)
sets the status of the &quot;optimize only active images&quot; menu item
Definition: MainFrame.cpp:1625
#define DEBUG_ASSERT(cond)
Definition: utils.h:80
void OnPhotometricOptimize(wxCommandEvent &e)
Definition: MainFrame.cpp:1669
HuginBase::ImageCache::ImageCacheRGB8Ptr ImageCacheRGB8Ptr
Definition: wxImageCache.h:33
simple class that forward the drop to the mainframe
Definition: MainFrame.h:61
include file for the hugin project
A tip file provider that uses gettext to translate the tips.
wxHelpController & GetHelpController()
Definition: MainFrame.h:183
virtual void clearDirty()
clear dirty flag.
Definition: Panorama.h:645
void OnSendToAssistantQueue(wxCommandEvent &e)
Definition: MainFrame.cpp:2531
mask editor panel.
void setImage(unsigned int imgNr, bool updateListSelection=false)
sets the image, which is currently edited
void setLeftImage(unsigned int imgNr)
set left image
void InitPreviews()
init previews
const CPVector & getCtrlPoints() const
get all control point of this Panorama
Definition: Panorama.h:319
void GeneratePanoOperationVector()
generates the PanoOperationVector for context menu
void OnLoadingFailed(wxCommandEvent &e)
event handler called when loading of image file failed
Definition: MainFrame.cpp:1387
static MainFrame * m_this
Definition: MainFrame.h:282
wxMenuItem * m_outputUserMenu
Definition: MainFrame.h:286
remove several control points
Definition: PanoCommand.h:307
void DoUserDefinedStitch(const wxString &settings=wxString())
stitching with user defined file
Definition: PanoPanel.cpp:1332
void ShowControlPoint(unsigned int cpNr)
show a control point
Definition of PanoOperation class.
std::vector< HuginBase::UIntSet > Components
stores the components of the graph
Definition: ImageGraph.h:50
void SetGuiLevel(GuiLevel newGuiLevel)
Definition: PanoPanel.cpp:1678
void ShowFilenameWarning(wxWindow *parent, const wxArrayString filelist)
shows a dialog about filename with invalid characters, all names in filelist will be show in list ...
Definition: platform.cpp:515
static huginApp * Get()
hack.. kind of a pseudo singleton...
Definition: huginApp.cpp:645
wxNotebook * m_notebook
Definition: MainFrame.h:249
void OnUserDefinedStitchSaved(wxCommandEvent &e)
Definition: MainFrame.cpp:1687
Dialog for raw import.
Definition: RawImport.h:34
PanoCommand to combine other PanoCommands.
Definition: PanoCommand.h:39
#define DEBUG_FATAL(msg)
Definition: utils.h:78
void Init(HuginBase::Panorama *pano)
WXIMPEX void FixHelpSettings()
helper function to check window position settings of help window
Definition: wxPlatform.cpp:53
apply a template to a panorama object
Definition: wxPanoCommand.h:96
Hugin&#39;s first panel.
Definition: ImagesPanel.h:40
std::set< unsigned int > UIntSet
Definition: PanoramaData.h:51
void OnSetGuiAdvanced(wxCommandEvent &e)
Definition: MainFrame.cpp:2383
void Init(HuginBase::Panorama *pano)
Definition: PanoPanel.cpp:249
bool m_show_opt_panel
Definition: MainFrame.h:255
The main window frame.
Definition: MainFrame.h:83
CommandQueue * GetAssistantCommandQueue(const HuginBase::Panorama &pano, const wxString &ExePath, const wxString &project)
generates the command queue for running the assistant
algorithms for remove control points by statistic method
void ShowCtrlPoint(unsigned int cpNr)
Definition: MainFrame.cpp:2005
void LoadOpenGLLayout()
loads the layout of the OpenGL windows and restores it
wxString m_filename
Definition: MainFrame.h:277
updates the optimize vector, aka all variables which should be optimized
Definition: PanoCommand.h:201
Model for a panorama.
Definition: Panorama.h:152
bool m_optIgnoreLineCp
Definition: MainFrame.h:290
bool loadSVMmodel(struct svm_model *&model, std::string &model_file)
loads the SVM model from file
Definition: Celeste.cpp:45
wxMenu * m_menu_file_simple
Definition: MainFrame.h:284
void LoadProjectFile(const wxString &filename)
Definition: MainFrame.cpp:1078
#define HUGIN_IMGCACHE_UPPERBOUND
const wxFileName GetFilename() const
returns filename
std::string getPathPrefix(const std::string &filename)
Get the path to a filename.
Definition: utils.cpp:184
HuginBase::Panorama & pano
Definition: MainFrame.h:274
void OnFineTuneAll(wxCommandEvent &e)
Definition: MainFrame.cpp:1815
Definition of dialog and functions to import RAW images to project file.
const wxString & GetDataPath()
get the path to data directory
Definition: MainFrame.cpp:2147
const OptimizeVector & getOptimizeVector() const
return the optimize settings stored inside panorama
Definition: Panorama.h:454
bool loadPTScript(std::istream &i, int &ptoVersion, const std::string &prefix="")
load a Hugin file
#define HUGIN_FT_TEMPLATE_SIZE
wxFileHistory m_mruFiles
Definition: MainFrame.h:248
class, which stores all settings of one cp detector
void OnKeyboardHelp(wxCommandEvent &e)
Definition: MainFrame.cpp:1472
PanoCommand::PanoCommand * GetPanoCommand()
return PanoCommand for adding converted raw files to Panorama
Definition: RawImport.cpp:644
bool comparePluginItem(PluginItem item1, PluginItem item2)
compares 2 plugin with category and name
Definition: PluginItems.cpp:39
std::size_t getNrOfImages() const
number of images.
Definition: Panorama.h:205
static MainFrame * Get()
hack.. kind of a pseudo singleton...
Definition: MainFrame.cpp:2153
void SetIgnoreLineCP(const bool noLineCp)
for external setting of &quot;ignore line cp&quot; checkbox
void OnIgnoreLineCp(wxCommandEvent &e)
Definition: MainFrame.cpp:1644
const PanoCommand * getLastCommand() const
return the last PanoCommand
void SetOnlyActiveImages(const bool onlyActive)
for external setting of &quot;only active image&quot; checkbox
void OnFAQ(wxCommandEvent &e)
Definition: MainFrame.cpp:1477
void OnMRUFiles(wxCommandEvent &e)
event handler for recently used files
Definition: MainFrame.cpp:2174
void SwitchToCropMode()
switches the controls to crop mode
void AddUserDefinedSequence(int id, const wxString &desc, const wxString &help)
adds the given user defined output sequence to SplitButton menu
Dialog for browsing pto files.
Definition: BrowseDialog.h:72
void SetGuiLevel(GuiLevel newLevel)
sets the gui level
void StoreFramePosition(wxTopLevelWindow *frame, const wxString &basename)
Store window size and position in configfile/registry.
Definition: LensCalApp.cpp:210
void OnCPListFrameClosed()
Definition: MainFrame.cpp:1608
virtual void panoramaChanged(HuginBase::Panorama &pano)
this is called whenever the panorama has changed.
Definition: PanoPanel.cpp:277
void DisableOpenGLTools()
disables all OpenGL related menu items and toobar buttons
Definition: MainFrame.cpp:2408
void OnAddImages(wxCommandEvent &e)
Definition: MainFrame.cpp:1284
merge two project files
Definition: PanoCommand.h:375
class for generating plugin menu items
Definition: PluginItems.h:35
virtual bool wasSuccessful() const
Definition: Command.cpp:93
void SetOnlyActiveImages(const bool onlyActive)
for external setting of &quot;only active image&quot; checkbox
void panoramaImagesChanged(HuginBase::Panorama &pano, const HuginBase::UIntSet &imgNr)
notifies about changes to images
Definition: MainFrame.cpp:856
wxString GetCurrentOptimizerString()
returns the string which describes the current selected optimizer setting
Definition: MainFrame.cpp:2601
PanoOperation to add several user selected images to the panorama.
Definition: PanoOperation.h:73
IMPLEMENT_DYNAMIC_CLASS(wxTreeListHeaderWindow, wxWindow)
class for showing splash screen the class wxSplashScreen from wxWidgets does not work correctly for o...
Definition: MainFrame.cpp:87
Maximum of correlation, position and value.
Definition: Correlation.h:56
std::string getLastCommandName() const
returns the name of the last command
Dialog for about window.
Definition: AboutDialog.h:40
Definition of dialog for numeric transforms.
hugin_utils::FDiff2D curv
Definition: Correlation.h:68
void OnTogglePreviewFrame(wxCommandEvent &e)
Definition: MainFrame.cpp:1552
wxwindows specific panorama commands
bool canRedo() const
Return true iff there is a command to redo.
const wxString GetName() const
return name from metadata
void OnOptimizeButton(wxCommandEvent &e)
run the optimizer
update all control points
Definition: PanoCommand.h:117
void clearRedoQueue()
clear all commands in the redo queue
virtual ~MainFrame()
dtor.
Definition: MainFrame.cpp:751
distributes all images above the sphere, for the assistant
Definition: PanoCommand.h:649
void SetShowProjectionHints(bool new_value)
set status if projection hints should be shown or not
void SetOptimizeIgnoreLineCp(const bool ignoreLineCP)
sets the status of the &quot;ignore line cp&quot; menu item
Definition: MainFrame.cpp:1652
static GlobalCmdHist & getInstance()
const wxString & GetXRCPath()
get the path to the xrc directory
Definition: MainFrame.cpp:2142
void OnOptimizeButton(wxCommandEvent &e)
run the optimizer
void ShowMaskEditor(size_t imgNr, bool switchToCropMode=false)
opens the mask/crop editor with the given image selected
Definition: MainFrame.cpp:2024
void OnBrowseProjects(wxCommandEvent &e)
Definition: MainFrame.cpp:1233
void Init(HuginBase::Panorama *pano)
void addCommand(PanoCommand *command, bool execute=true)
Adds a command to the history.
void OnLoadProject(wxCommandEvent &e)
Definition: MainFrame.cpp:1183
const bool IsAPIValid() const
returns true, if plugin can run on given system and version
run the optimizer.
Definition: OptimizePanel.h:38
void OnOptimize(wxCommandEvent &e)
Definition: MainFrame.cpp:1613
CPListFrame * cp_frame
Definition: MainFrame.h:264
void clear()
Erases all the undo/redo history.
void ReloadCPDetectorSettings()
Reloads the cp detector settings from config, necessary after edit preferences.
#define DEBUG_ERROR(msg)
Definition: utils.h:76
wxMenu * m_menu_file_advanced
Definition: MainFrame.h:285
void Init(HuginBase::Panorama *pano)
The image preview frame.
Definition: PreviewFrame.h:40
void OnSaveProjectAs(wxCommandEvent &e)
Definition: MainFrame.cpp:1011
void OnSaveProject(wxCommandEvent &e)
Definition: MainFrame.cpp:975
void RunCPGenerator(CPDetectorSetting &setting, const HuginBase::UIntSet &img)
run the cp generator with the given setting on selected images
Definition: MainFrame.cpp:2127
bool CloseProject(bool cancelable, CloseReason reason)
Definition: MainFrame.cpp:868
void SetGuiLevel(GuiLevel newGuiLevel)
void Init(HuginBase::Panorama *pano)
void OnShowPanel(wxCommandEvent &e)
Definition: MainFrame.cpp:1342
GuiLevel m_guiLevel
Definition: MainFrame.h:265
void addObserver(PanoramaObserver *o)
add a panorama observer.
Definition: Panorama.cpp:1546
void OnDoStitch(wxCommandEvent &e)
Definition: MainFrame.cpp:1675
struct celeste::svm_model * GetSVMModel()
Definition: MainFrame.cpp:2210
void changeFinished(bool keepDirty)
notify observers about changes in this class
Definition: Panorama.cpp:831
PanoOperation to add all image in a defined timeinterval to the panorama.
Definition: PanoOperation.h:85
include file for the hugin project
#define HUGIN_CELESTE_MODEL
const PanoramaOptions & getOptions() const
returns the options for this panorama
Definition: Panorama.h:481
void OnHelp(wxCommandEvent &e)
Definition: MainFrame.cpp:1467
bool canUndo() const
Return true iff there is a command to undo.
const wxString GetSettingStringTranslated(wxConfigBase *setting, const wxString &name, const wxString defaultValue)
read a translated string from settings and remove all whitespaces
Definition: Executor.cpp:288
void setRightImage(unsigned int imgNr)
set right image
const int getPhotometricOptimizerSwitch() const
return the photometric optimizer master switch
Definition: Panorama.h:467
#define HUGIN_FT_CORR_THRESHOLD
GLPreviewFrame * getGLPreview()
Definition: MainFrame.cpp:2234
Components GetComponents()
find all connected components
Definition: ImageGraph.cpp:101
void OnRunAssistantUserdefined(wxCommandEvent &e)
Definition: MainFrame.cpp:2518
Memento class for a Panorama object.
Definition: Panorama.h:49
bool isDirty() const
true if there are unsaved changes
Definition: Panorama.h:636
void ShowCtrlPointEditor(unsigned int img1, unsigned int img2)
opens the control points tab with the both images selected
Definition: MainFrame.cpp:2012
const int getOptimizerSwitch() const
returns optimizer master switch
Definition: Panorama.h:461
MainFrame(wxWindow *parent, HuginBase::Panorama &pano)
ctor.
Definition: MainFrame.cpp:239
#define DEBUG_DEBUG(msg)
Definition: utils.h:68
std::string GetUserAppDataDir()
returns the directory for user specific Hugin settings, e.g.
Definition: utils.cpp:497
void Init(HuginBase::Panorama *pano)
bool containsInvalidCharacters(const wxString stringToTest)
returns true, if the given strings contains invalid characters
Definition: platform.cpp:502
HuginSplashScreen(wxWindow *parent, wxBitmap bitmap)
Definition: MainFrame.cpp:91
bool m_optOnlyActiveImages
Definition: MainFrame.h:289
add image(s) to a panorama
Definition: wxPanoCommand.h:50
Definition of dialog to browse directory with pto files.
virtual void redo()
Redoes the last undone action.
std::string GetHuginVersion()
return a string with version numbers
Definition: utils.cpp:907
void OnOnlyActiveImages(wxCommandEvent &e)
Definition: MainFrame.cpp:1620
void OnNewProject(wxCommandEvent &e)
Definition: MainFrame.cpp:1254
hugin_utils::FDiff2D maxpos
Definition: Correlation.h:64
void OnSetGuiSimple(wxCommandEvent &e)
Definition: MainFrame.cpp:2350
CPDetectorSetting & GetDefaultSetting()
returns the default cp detector settings
Definition: ImagesPanel.h:74
std::vector< ControlPoint > CPVector
Definition: ControlPoint.h:99
functions for interaction with the hugin configuration file
platform/compiler specific stuff.
wxString GetCurrentOptimizerString()
return the currently selected optimizer setting as string from the drop down list box ...
bool WritePTOFile(const std::string &filename, const std::string &prefix="")
write data to given pto file
Definition: Panorama.cpp:2059
void OnOpenPTBatcher(wxCommandEvent &e)
Definition: MainFrame.cpp:1783
std::vector< std::set< std::string > > OptimizeVector
void OnShowPrefs(wxCommandEvent &e)
Definition: MainFrame.cpp:1522
Define the pano edit panel.
Definition: PanoPanel.h:43
void OnFullScreen(wxCommandEvent &e)
event handler for full screen
Definition: MainFrame.cpp:2201
MaskEditorPanel * mask_panel
Definition: MainFrame.h:252
const SrcPanoImage & getImage(std::size_t nr) const
get a panorama image, counting starts with 0
Definition: Panorama.h:211
void OnShowEvent(wxShowEvent &e)
remove multiple images from a panorama
Definition: PanoCommand.h:94
GuiLevel
Definition: GuiLevel.h:31
void CleanPanoOperationVector()
clears the PanoOperationVector
void fill_set(_Container &c, typename _Container::key_type begin, typename _Container::key_type end)
Definition: stl_utils.h:81
virtual void undo()
Undoes the last action.
bool IsRawExtension(const wxString &testExt)
return true, if given extension is in list of known raw extension (comparision is case insensitive ...
Definition: platform.cpp:103
CommandQueue * GetAssistantCommandQueueUserDefined(const HuginBase::Panorama &pano, const wxString &ExePath, const wxString &project, const wxString &assistantSetting, wxArrayString &tempFilesDelete, std::ostream &errStream)
generates the command queue for running the assistant
void OnAbout(wxCommandEvent &e)
Definition: MainFrame.cpp:1429
CPDetectorSetting & GetDefaultSetting()
returns default cp detector setting
Definition: MainFrame.cpp:2122
virtual void panoramaChanged(HuginBase::Panorama &pano)
Enable or disable undo and redo.
Definition: MainFrame.cpp:792
const wxString GetCategory() const
return category name
void OnAddTimeImages(wxCommandEvent &e)
Definition: MainFrame.cpp:1331
str wxQuoteFilename(const str &arg)
Quote a filename, so that it is surrounded by &quot;&quot;.
Definition: wxPlatform.h:82
dump the current project and load a new one.
Definition: wxPanoCommand.h:66
void OnSize(wxSizeEvent &e)
Definition: MainFrame.cpp:2107
wxString getProjectName()
Definition: MainFrame.cpp:2164
const wxString & GetXRCPath()
return the current xrc path
Definition: huginApp.h:112
void SetGuiLevel(GuiLevel newGuiLevel)
sets the GuiLevel for all controls on this panel
UIntSet getCPinMasks(HuginBase::Panorama pano)
returns these control points, which are in masks
Definition: CleanCP.cpp:186
bool IsShowingCorrelation() const
Definition: MainFrame.cpp:2169
PreviewFrame * preview_frame
Definition: MainFrame.h:262
const wxString GetSelectedCPGenerator()
return the currently selected cp generator description
void ResetPreviewZoom()
reset zoom level for preview window
wxString Components2Str(const HuginGraph::ImageGraph::Components &comp)
Definition: huginApp.cpp:83
std::map< int, wxString > m_userAssistant
Definition: MainFrame.h:300
wxString getDefaultProjectName(const HuginBase::Panorama &pano, const wxString filenameTemplate)
gets the default project name, as defined in the preferences
std::vector< NormalCommand * > CommandQueue
Definition: Executor.h:61
void printStitcherScript(std::ostream &o, const PanoramaOptions &target, const UIntSet &imgs) const
create the stitcher script
Definition: Panorama.cpp:778
void OnSetGuiExpert(wxCommandEvent &e)
Definition: MainFrame.cpp:2403
bool CheckRawFiles()
return true, if all raw files are from the same camera
Definition: RawImport.cpp:649
create a CommandQueue for running the assistant using CLI tools
void OnReadPapywizard(wxCommandEvent &e)
Definition: MainFrame.cpp:1746
void enableTools(bool option)
Definition: MainFrame.cpp:2079
class to work with images graphs created from a HuginBase::Panorama class it creates a graph based on...
Definition: ImageGraph.h:44