Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MainFrame.h
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
24 #ifndef _MAINFRAME_H
25 #define _MAINFRAME_H
26 
27 
28 #include <vector>
29 #include <set>
30 #include <map>
31 
32 #include "panodata/Panorama.h"
33 
34 #include "wx/docview.h"
35 #include "wx/help.h"
36 #if !wxUSE_HELP
37 #error wxWidgets needs to be compiled with help support (wxUSE_HELP not set)
38 #endif
39 #if defined __WXMSW__ && !(wxCHECK_VERSION(3,1,1))
40 #include "base_wx/wxPlatform.h"
41 #define wxHelpController HuginCHMHelpController
42 #endif
43 
45 
46 #include "hugin/OptimizePanel.h"
48 
49 // Celeste header
50 #include "Celeste.h"
51 #include "GuiLevel.h"
52 
53 // forward declarations, to save the #include statements
54 class CPEditorPanel;
55 class ImgPreview;
56 class ImagesPanel;
57 class MaskEditorPanel;
59 class PanoPanel;
60 class PreviewFrame;
61 class GLPreviewFrame;
62 class CPListFrame;
63 
65 class PanoDropTarget : public wxFileDropTarget
66 {
67 public:
68  PanoDropTarget(HuginBase::Panorama & p, bool imageOnly = false)
69  : pano(p)
70  { m_imageOnly = imageOnly; }
71 
72  bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames);
73 
74 private:
77 };
78 
87 class MainFrame : public wxFrame, public HuginBase::PanoramaObserver, public AppBase::ProgressDisplay
88 {
89 public:
90 
93  MainFrame(wxWindow* parent, HuginBase::Panorama & pano);
94 
97  virtual ~MainFrame();
98 
102  virtual void panoramaChanged(HuginBase::Panorama &pano);
105  const HuginBase::Panorama & getPanorama() { return pano; };
106 
107  // called when a control point in CPListFrame is selected
108  void ShowCtrlPoint(unsigned int cpNr);
109 
111  const wxString & GetXRCPath();
113  const wxString & GetDataPath();
115  void SetOptimizeOnlyActiveImages(const bool onlyActive);
116  const bool GetOptimizeOnlyActiveImages() const;
118  void SetOptimizeIgnoreLineCp(const bool ignoreLineCP);
119  const bool GetOptimizeIgnoreLineCp() const;
120 
122  static MainFrame * Get();
123 
124  // Used to display tip of the day after main interface is initialised and visible
125  void OnTipOfDay(wxCommandEvent & e);
126 
127  // load a project
128  void LoadProjectFile(const wxString & filename);
129  void RunAssistant(wxWindow* mainWin, const wxString& userdefinedAssistant=wxEmptyString);
130 
132  void DisableOpenGLTools();
133 #ifdef __WXMAC__
134  void MacOnOpenFile(const wxString & filename);
135 #endif
137  {
141  };
142  bool CloseProject(bool cancelable, CloseReason reason);
143 
144  // TODO: create a nice generic optimisation & stitching function
145  // instead of these gateway functions to the optimizer and pano panels.
146  void OnOptimize(wxCommandEvent & e);
147  void OnOnlyActiveImages(wxCommandEvent &e);
148  void OnIgnoreLineCp(wxCommandEvent &e);
149  void OnPhotometricOptimize(wxCommandEvent & e);
150  void OnDoStitch(wxCommandEvent & e);
151  void OnUserDefinedStitch(wxCommandEvent & e);
152  void OnUserDefinedStitchSaved(wxCommandEvent & e);
153  void OnTogglePreviewFrame(wxCommandEvent & e);
154  void OnToggleGLPreviewFrame(wxCommandEvent & e);
155  void OnAddImages(wxCommandEvent & e);
156  void OnSaveProject(wxCommandEvent & e);
157  void OnSetGuiSimple(wxCommandEvent & e);
158  void OnSetGuiAdvanced(wxCommandEvent & e);
159  void OnSetGuiExpert(wxCommandEvent & e);
160 
162  void DisplayHelp(wxString section = wxEmptyString);
163 
165  void ShowCtrlPointEditor(unsigned int img1, unsigned int img2);
167  void ShowMaskEditor(size_t imgNr, bool switchToCropMode = false);
169  void ShowStitcherTab();
170 
171  void OnCPListFrameClosed();
175  void RunCPGenerator(CPDetectorSetting &setting, const HuginBase::UIntSet& img);
177  void RunCPGenerator(const HuginBase::UIntSet& img);
179  const wxString GetSelectedCPGenerator();
180 
181  wxString getProjectName();
182  bool IsShowingCorrelation() const;
183 
185 
187  wxHelpController& GetHelpController() { return m_HelpController; }
188  void SetGuiLevel(GuiLevel newLevel);
189  const GuiLevel GetGuiLevel() const { return m_guiLevel; };
190 
191  wxFileHistory* GetFileHistory() { return &m_mruFiles; };
192 
194  wxString GetCurrentOptimizerString();
195 
196 protected:
197  // called when a progress message should be displayed
203  void updateProgressDisplay();
204 
205 private:
206 
207  // event handlers
208  void OnExit(wxCloseEvent & e);
209  void OnUserQuit(wxCommandEvent & e);
210  void OnAbout(wxCommandEvent & e);
211  void OnHelp(wxCommandEvent & e);
212  void OnKeyboardHelp(wxCommandEvent & e);
213  void OnFAQ(wxCommandEvent & e);
214  void OnShowPrefs(wxCommandEvent &e);
215 #ifdef HUGIN_HSI
216  void OnPythonScript(wxCommandEvent & e);
217  void OnPlugin(wxCommandEvent& e);
218 #endif
219  void OnUndo(wxCommandEvent & e);
220  void OnRedo(wxCommandEvent & e);
221  void OnSaveProjectAs(wxCommandEvent & e);
222  void OnSavePTStitcherAs(wxCommandEvent & e);
223  void OnLoadProject(wxCommandEvent & e);
224  void OnBrowseProjects(wxCommandEvent & e);
225  void OnNewProject(wxCommandEvent & e);
226  void OnAddTimeImages(wxCommandEvent & e);
227  void OnRunAssistant(wxCommandEvent & e);
228  void OnRunAssistantUserdefined(wxCommandEvent & e);
229  void OnFineTuneAll(wxCommandEvent & e);
230  void OnRemoveCPinMasks(wxCommandEvent & e);
231  void OnMergeProject(wxCommandEvent & e);
232  void OnReadPapywizard(wxCommandEvent & e);
233  void OnApplyTemplate(wxCommandEvent & e);
234  void OnSendToBatch(wxCommandEvent & e);
235  void OnSendToAssistantQueue(wxCommandEvent & e);
236  void OnOpenPTBatcher(wxCommandEvent & e);
237 // void OnToggleOptimizeFrame(wxCommandEvent & e);
238  void OnShowCPFrame(wxCommandEvent & e);
240  void OnMRUFiles(wxCommandEvent &e);
242  void OnFullScreen(wxCommandEvent &e);
243  void OnSize(wxSizeEvent &e);
244  void enableTools(bool option);
246  void AddImages(wxArrayString& filenameArray);
247 
248  void OnShowPanel(wxCommandEvent &e);
250  void OnLoadingFailed(wxCommandEvent& e);
251 
252  wxFileHistory m_mruFiles;
253  wxNotebook * m_notebook;
254  // tab panels
264 
265  // flying windows
270 
271  // Image Preview
272  ImgPreview *canvas;
273 
274  // Preferences
275  //PreferencesDialog * pref_dlg;
276 
277  // the model
279 
280  // filename of the current project
281  wxString m_filename;
282  // true, if cp errors contains correlation instead of error
284 
285  // self
286  static MainFrame* m_this;
287  // file menu
290  wxMenuItem* m_outputUserMenu = nullptr;
291  wxMenuItem* m_assistantUserMenu = nullptr;
292  // sticky setting, to prevent reading to often
295  // help controller
296  wxHelpController m_HelpController;
297 
298 #ifdef HUGIN_HSI
299  // list associating the wxID in the menu with a python script
300  std::map<int, wxFileName> m_plugins;
301 #endif
302  // list for user-defined output sequences
303  std::map<int, wxString> m_userOutput;
304  std::map<int, wxString> m_userAssistant;
305 
306  DECLARE_EVENT_TABLE()
307 };
308 
309 // event used to signal invalid or missing image files
310 #if defined _WIN32 && defined Hugin_shared
311 DECLARE_LOCAL_EVENT_TYPE(EVT_LOADING_FAILED, -1)
312 #else
313 DECLARE_EVENT_TYPE(EVT_LOADING_FAILED, -1)
314 #endif
315 
316 #endif // _MAINFRAME_H
void DisplayHelp(wxString section=wxEmptyString)
call help browser with given file
Definition: MainFrame.cpp:1504
void OnShowCPFrame(wxCommandEvent &e)
Definition: MainFrame.cpp:1621
OptimizePanel * opt_panel
Definition: MainFrame.h:258
PanoPanel * pano_panel
Definition: MainFrame.h:262
const bool GetOptimizeOnlyActiveImages() const
Definition: MainFrame.cpp:1667
int m_showCorrelation
Definition: MainFrame.h:283
void updateProgressDisplay()
receive notification about progress.
Definition: MainFrame.cpp:2088
std::map< int, wxString > m_userOutput
Definition: MainFrame.h:303
declaration of helper for work with different GuiLevels
void SetGuiLevel(GuiLevel newLevel)
Definition: MainFrame.cpp:2267
void OnRemoveCPinMasks(wxCommandEvent &e)
Definition: MainFrame.cpp:1956
void OnUserQuit(wxCommandEvent &e)
Definition: MainFrame.cpp:884
void OnRunAssistant(wxCommandEvent &e)
Definition: MainFrame.cpp:2541
void OnApplyTemplate(wxCommandEvent &e)
Definition: MainFrame.cpp:1788
The OpenGL preview frame.
void AddImages(wxArrayString &filenameArray)
adds the given files to the projects, with checking for invalid filenames
Definition: MainFrame.cpp:1319
void ShowStitcherTab()
opens the stitcher tab
Definition: MainFrame.cpp:2067
const bool GetOptimizeIgnoreLineCp() const
Definition: MainFrame.cpp:1692
void OnToggleGLPreviewFrame(wxCommandEvent &e)
Definition: MainFrame.cpp:1595
void OnRedo(wxCommandEvent &e)
Definition: MainFrame.cpp:2024
GLPreviewFrame * gl_preview_frame
Definition: MainFrame.h:267
ImagesPanel * images_panel
Definition: MainFrame.h:255
bool m_show_opt_photo_panel
Definition: MainFrame.h:261
void OnUndo(wxCommandEvent &e)
Definition: MainFrame.cpp:2011
wxMenuItem * m_assistantUserMenu
Definition: MainFrame.h:291
struct celeste::svm_model * svmModel
Definition: MainFrame.h:263
control point editor panel.
Definition: CPEditorPanel.h:64
OptimizePhotometricPanel * opt_photo_panel
Definition: MainFrame.h:260
const wxString GetSelectedCPGenerator()
return the currently selected cp generator description
Definition: MainFrame.cpp:2165
void RunAssistant(wxWindow *mainWin, const wxString &userdefinedAssistant=wxEmptyString)
Definition: MainFrame.cpp:2443
void OnUserDefinedStitch(wxCommandEvent &e)
Definition: MainFrame.cpp:1710
void OnSavePTStitcherAs(wxCommandEvent &e)
Definition: MainFrame.cpp:1070
void OnExit(wxCloseEvent &e)
Definition: MainFrame.cpp:950
CPEditorPanel * cpe
Definition: MainFrame.h:257
void OnTipOfDay(wxCommandEvent &e)
Definition: MainFrame.cpp:1523
void OnSendToBatch(wxCommandEvent &e)
void OnMergeProject(wxCommandEvent &e)
Definition: MainFrame.cpp:1728
void SetOptimizeOnlyActiveImages(const bool onlyActive)
sets the status of the &quot;optimize only active images&quot; menu item
Definition: MainFrame.cpp:1653
void OnPhotometricOptimize(wxCommandEvent &e)
Definition: MainFrame.cpp:1697
simple class that forward the drop to the mainframe
Definition: MainFrame.h:65
wxHelpController & GetHelpController()
Definition: MainFrame.h:187
bool m_imageOnly
Definition: MainFrame.h:76
void OnSendToAssistantQueue(wxCommandEvent &e)
Definition: MainFrame.cpp:2559
mask editor panel.
void OnLoadingFailed(wxCommandEvent &e)
event handler called when loading of image file failed
Definition: MainFrame.cpp:1408
static MainFrame * m_this
Definition: MainFrame.h:286
wxMenuItem * m_outputUserMenu
Definition: MainFrame.h:290
wxNotebook * m_notebook
Definition: MainFrame.h:253
void OnUserDefinedStitchSaved(wxCommandEvent &e)
Definition: MainFrame.cpp:1715
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:2411
bool m_show_opt_panel
Definition: MainFrame.h:259
The main window frame.
Definition: MainFrame.h:87
void ShowCtrlPoint(unsigned int cpNr)
Definition: MainFrame.cpp:2033
wxString m_filename
Definition: MainFrame.h:281
Model for a panorama.
Definition: Panorama.h:152
bool m_optIgnoreLineCp
Definition: MainFrame.h:294
wxHelpController m_HelpController
Definition: MainFrame.h:296
wxMenu * m_menu_file_simple
Definition: MainFrame.h:288
void LoadProjectFile(const wxString &filename)
Definition: MainFrame.cpp:1099
HuginBase::Panorama & pano
Definition: MainFrame.h:278
void OnFineTuneAll(wxCommandEvent &e)
Definition: MainFrame.cpp:1843
const wxString & GetDataPath()
get the path to data directory
Definition: MainFrame.cpp:2175
wxFileHistory m_mruFiles
Definition: MainFrame.h:252
class, which stores all settings of one cp detector
void OnKeyboardHelp(wxCommandEvent &e)
Definition: MainFrame.cpp:1493
static MainFrame * Get()
hack.. kind of a pseudo singleton...
Definition: MainFrame.cpp:2181
void OnIgnoreLineCp(wxCommandEvent &e)
Definition: MainFrame.cpp:1672
void OnMRUFiles(wxCommandEvent &e)
event handler for recently used files
Definition: MainFrame.cpp:2202
void OnFAQ(wxCommandEvent &e)
Definition: MainFrame.cpp:1498
void OnCPListFrameClosed()
Definition: MainFrame.cpp:1636
void DisableOpenGLTools()
disables all OpenGL related menu items and toobar buttons
Definition: MainFrame.cpp:2436
void OnAddImages(wxCommandEvent &e)
Definition: MainFrame.cpp:1305
PanoDropTarget(HuginBase::Panorama &p, bool imageOnly=false)
Definition: MainFrame.h:68
void panoramaImagesChanged(HuginBase::Panorama &pano, const HuginBase::UIntSet &imgNr)
notifies about changes to images
Definition: MainFrame.cpp:877
wxString GetCurrentOptimizerString()
returns the string which describes the current selected optimizer setting
Definition: MainFrame.cpp:2629
void OnTogglePreviewFrame(wxCommandEvent &e)
Definition: MainFrame.cpp:1580
virtual ~MainFrame()
dtor.
Definition: MainFrame.cpp:772
void SetOptimizeIgnoreLineCp(const bool ignoreLineCP)
sets the status of the &quot;ignore line cp&quot; menu item
Definition: MainFrame.cpp:1680
const wxString & GetXRCPath()
get the path to the xrc directory
Definition: MainFrame.cpp:2170
void ShowMaskEditor(size_t imgNr, bool switchToCropMode=false)
opens the mask/crop editor with the given image selected
Definition: MainFrame.cpp:2052
void OnBrowseProjects(wxCommandEvent &e)
Definition: MainFrame.cpp:1254
void OnLoadProject(wxCommandEvent &e)
Definition: MainFrame.cpp:1204
run the optimizer.
Definition: OptimizePanel.h:38
void OnOptimize(wxCommandEvent &e)
Definition: MainFrame.cpp:1641
CPListFrame * cp_frame
Definition: MainFrame.h:268
wxMenu * m_menu_file_advanced
Definition: MainFrame.h:289
The image preview frame.
Definition: PreviewFrame.h:40
void OnSaveProjectAs(wxCommandEvent &e)
Definition: MainFrame.cpp:1032
void OnSaveProject(wxCommandEvent &e)
Definition: MainFrame.cpp:996
ImgPreview * canvas
Definition: MainFrame.h:272
void RunCPGenerator(CPDetectorSetting &setting, const HuginBase::UIntSet &img)
run the cp generator with the given setting on selected images
Definition: MainFrame.cpp:2155
bool CloseProject(bool cancelable, CloseReason reason)
Definition: MainFrame.cpp:889
void OnShowPanel(wxCommandEvent &e)
Definition: MainFrame.cpp:1363
GuiLevel m_guiLevel
Definition: MainFrame.h:269
void OnDoStitch(wxCommandEvent &e)
Definition: MainFrame.cpp:1703
struct celeste::svm_model * GetSVMModel()
Definition: MainFrame.cpp:2238
const GuiLevel GetGuiLevel() const
Definition: MainFrame.h:189
void OnHelp(wxCommandEvent &e)
Definition: MainFrame.cpp:1488
this handler class will receive change events from the Panorama.
Definition: PanoramaData.h:401
GLPreviewFrame * getGLPreview()
Definition: MainFrame.cpp:2262
void OnRunAssistantUserdefined(wxCommandEvent &e)
Definition: MainFrame.cpp:2546
void ShowCtrlPointEditor(unsigned int img1, unsigned int img2)
opens the control points tab with the both images selected
Definition: MainFrame.cpp:2040
HuginBase::Panorama & pano
Definition: MainFrame.h:75
MainFrame(wxWindow *parent, HuginBase::Panorama &pano)
ctor.
Definition: MainFrame.cpp:317
bool m_optOnlyActiveImages
Definition: MainFrame.h:293
void OnOnlyActiveImages(wxCommandEvent &e)
Definition: MainFrame.cpp:1648
void OnNewProject(wxCommandEvent &e)
Definition: MainFrame.cpp:1275
void OnSetGuiSimple(wxCommandEvent &e)
Definition: MainFrame.cpp:2378
wxFileHistory * GetFileHistory()
Definition: MainFrame.h:191
platform/compiler specific stuff.
void OnOpenPTBatcher(wxCommandEvent &e)
Definition: MainFrame.cpp:1811
void OnShowPrefs(wxCommandEvent &e)
Definition: MainFrame.cpp:1550
Define the pano edit panel.
Definition: PanoPanel.h:43
void OnFullScreen(wxCommandEvent &e)
event handler for full screen
Definition: MainFrame.cpp:2229
MaskEditorPanel * mask_panel
Definition: MainFrame.h:256
GuiLevel
Definition: GuiLevel.h:31
const HuginBase::Panorama & getPanorama()
returns panorama object
Definition: MainFrame.h:105
void OnAbout(wxCommandEvent &e)
Definition: MainFrame.cpp:1450
CPDetectorSetting & GetDefaultSetting()
returns default cp detector setting
Definition: MainFrame.cpp:2150
virtual void panoramaChanged(HuginBase::Panorama &pano)
Enable or disable undo and redo.
Definition: MainFrame.cpp:813
void OnAddTimeImages(wxCommandEvent &e)
Definition: MainFrame.cpp:1352
void OnSize(wxSizeEvent &e)
Definition: MainFrame.cpp:2135
wxString getProjectName()
Definition: MainFrame.cpp:2192
bool IsShowingCorrelation() const
Definition: MainFrame.cpp:2197
PreviewFrame * preview_frame
Definition: MainFrame.h:266
bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString &filenames)
file drag and drop handler method
Definition: MainFrame.cpp:120
std::map< int, wxString > m_userAssistant
Definition: MainFrame.h:304
void OnSetGuiExpert(wxCommandEvent &e)
Definition: MainFrame.cpp:2431
void OnReadPapywizard(wxCommandEvent &e)
Definition: MainFrame.cpp:1774
void enableTools(bool option)
Definition: MainFrame.cpp:2107