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 
41 
42 #include "hugin/OptimizePanel.h"
44 
45 // Celeste header
46 #include "Celeste.h"
47 #include "GuiLevel.h"
48 
49 // forward declarations, to save the #include statements
50 class CPEditorPanel;
51 class ImgPreview;
52 class ImagesPanel;
53 class MaskEditorPanel;
55 class PanoPanel;
56 class PreviewFrame;
57 class GLPreviewFrame;
58 class CPListFrame;
59 
61 class PanoDropTarget : public wxFileDropTarget
62 {
63 public:
64  PanoDropTarget(HuginBase::Panorama & p, bool imageOnly = false)
65  : pano(p)
66  { m_imageOnly = imageOnly; }
67 
68  bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames);
69 
70 private:
73 };
74 
83 class MainFrame : public wxFrame, public HuginBase::PanoramaObserver, public AppBase::ProgressDisplay
84 {
85 public:
86 
89  MainFrame(wxWindow* parent, HuginBase::Panorama & pano);
90 
93  virtual ~MainFrame();
94 
98  virtual void panoramaChanged(HuginBase::Panorama &pano);
101  const HuginBase::Panorama & getPanorama() { return pano; };
102 
103  // called when a control point in CPListFrame is selected
104  void ShowCtrlPoint(unsigned int cpNr);
105 
107  const wxString & GetXRCPath();
109  const wxString & GetDataPath();
111  void SetOptimizeOnlyActiveImages(const bool onlyActive);
112  const bool GetOptimizeOnlyActiveImages() const;
114  void SetOptimizeIgnoreLineCp(const bool ignoreLineCP);
115  const bool GetOptimizeIgnoreLineCp() const;
116 
118  static MainFrame * Get();
119 
120  // Used to display tip of the day after main interface is initialised and visible
121  void OnTipOfDay(wxCommandEvent & e);
122 
123  // load a project
124  void LoadProjectFile(const wxString & filename);
125  void RunAssistant(wxWindow* mainWin, const wxString& userdefinedAssistant=wxEmptyString);
126 
128  void DisableOpenGLTools();
129 #ifdef __WXMAC__
130  void MacOnOpenFile(const wxString & filename);
131 #endif
133  {
137  };
138  bool CloseProject(bool cancelable, CloseReason reason);
139 
140  // TODO: create a nice generic optimisation & stitching function
141  // instead of these gateway functions to the optimizer and pano panels.
142  void OnOptimize(wxCommandEvent & e);
143  void OnOnlyActiveImages(wxCommandEvent &e);
144  void OnIgnoreLineCp(wxCommandEvent &e);
145  void OnPhotometricOptimize(wxCommandEvent & e);
146  void OnDoStitch(wxCommandEvent & e);
147  void OnUserDefinedStitch(wxCommandEvent & e);
148  void OnUserDefinedStitchSaved(wxCommandEvent & e);
149  void OnTogglePreviewFrame(wxCommandEvent & e);
150  void OnToggleGLPreviewFrame(wxCommandEvent & e);
151  void OnAddImages(wxCommandEvent & e);
152  void OnSaveProject(wxCommandEvent & e);
153  void OnSetGuiSimple(wxCommandEvent & e);
154  void OnSetGuiAdvanced(wxCommandEvent & e);
155  void OnSetGuiExpert(wxCommandEvent & e);
156 
158  void DisplayHelp(wxString section = wxEmptyString);
159 
161  void ShowCtrlPointEditor(unsigned int img1, unsigned int img2);
163  void ShowMaskEditor(size_t imgNr, bool switchToCropMode = false);
165  void ShowStitcherTab();
166 
167  void OnCPListFrameClosed();
171  void RunCPGenerator(CPDetectorSetting &setting, const HuginBase::UIntSet& img);
173  void RunCPGenerator(const HuginBase::UIntSet& img);
175  const wxString GetSelectedCPGenerator();
176 
177  wxString getProjectName();
178  bool IsShowingCorrelation() const;
179 
181 
183  wxHelpController& GetHelpController() { return m_HelpController; }
184  void SetGuiLevel(GuiLevel newLevel);
185  const GuiLevel GetGuiLevel() const { return m_guiLevel; };
186 
187  wxFileHistory* GetFileHistory() { return &m_mruFiles; };
188 
190  wxString GetCurrentOptimizerString();
191 
192 protected:
193  // called when a progress message should be displayed
199  void updateProgressDisplay();
200 
201 private:
202 
203  // event handlers
204  void OnExit(wxCloseEvent & e);
205  void OnUserQuit(wxCommandEvent & e);
206  void OnAbout(wxCommandEvent & e);
207  void OnHelp(wxCommandEvent & e);
208  void OnKeyboardHelp(wxCommandEvent & e);
209  void OnFAQ(wxCommandEvent & e);
210  void OnShowPrefs(wxCommandEvent &e);
211 #ifdef HUGIN_HSI
212  void OnPythonScript(wxCommandEvent & e);
213  void OnPlugin(wxCommandEvent& e);
214 #endif
215  void OnUndo(wxCommandEvent & e);
216  void OnRedo(wxCommandEvent & e);
217  void OnSaveProjectAs(wxCommandEvent & e);
218  void OnSavePTStitcherAs(wxCommandEvent & e);
219  void OnLoadProject(wxCommandEvent & e);
220  void OnBrowseProjects(wxCommandEvent & e);
221  void OnNewProject(wxCommandEvent & e);
222  void OnAddTimeImages(wxCommandEvent & e);
223  void OnRunAssistant(wxCommandEvent & e);
224  void OnRunAssistantUserdefined(wxCommandEvent & e);
225  void OnFineTuneAll(wxCommandEvent & e);
226  void OnRemoveCPinMasks(wxCommandEvent & e);
227  void OnMergeProject(wxCommandEvent & e);
228  void OnReadPapywizard(wxCommandEvent & e);
229  void OnApplyTemplate(wxCommandEvent & e);
230  void OnSendToBatch(wxCommandEvent & e);
231  void OnSendToAssistantQueue(wxCommandEvent & e);
232  void OnOpenPTBatcher(wxCommandEvent & e);
233 // void OnToggleOptimizeFrame(wxCommandEvent & e);
234  void OnShowCPFrame(wxCommandEvent & e);
236  void OnMRUFiles(wxCommandEvent &e);
238  void OnFullScreen(wxCommandEvent &e);
239  void OnSize(wxSizeEvent &e);
240  void enableTools(bool option);
242  void AddImages(wxArrayString& filenameArray);
243 
244  void OnShowPanel(wxCommandEvent &e);
246  void OnLoadingFailed(wxCommandEvent& e);
247 
248  wxFileHistory m_mruFiles;
249  wxNotebook * m_notebook;
250  // tab panels
260 
261  // flying windows
266 
267  // Image Preview
268  ImgPreview *canvas;
269 
270  // Preferences
271  //PreferencesDialog * pref_dlg;
272 
273  // the model
275 
276  // filename of the current project
277  wxString m_filename;
278  // true, if cp errors contains correlation instead of error
280 
281  // self
282  static MainFrame* m_this;
283  // file menu
286  wxMenuItem* m_outputUserMenu = nullptr;
287  wxMenuItem* m_assistantUserMenu = nullptr;
288  // sticky setting, to prevent reading to often
291  // help controller
292  wxHelpController m_HelpController;
293 
294 #ifdef HUGIN_HSI
295  // list associating the wxID in the menu with a python script
296  std::map<int, wxFileName> m_plugins;
297 #endif
298  // list for user-defined output sequences
299  std::map<int, wxString> m_userOutput;
300  std::map<int, wxString> m_userAssistant;
301 
302  DECLARE_EVENT_TABLE()
303 };
304 
305 // event used to signal invalid or missing image files
306 wxDECLARE_EVENT(EVT_LOADING_FAILED, wxCommandEvent);
307 
308 #endif // _MAINFRAME_H
void DisplayHelp(wxString section=wxEmptyString)
call help browser with given file
Definition: MainFrame.cpp:1499
void OnShowCPFrame(wxCommandEvent &e)
Definition: MainFrame.cpp:1609
OptimizePanel * opt_panel
Definition: MainFrame.h:254
PanoPanel * pano_panel
Definition: MainFrame.h:258
const bool GetOptimizeOnlyActiveImages() const
Definition: MainFrame.cpp:1655
int m_showCorrelation
Definition: MainFrame.h:279
void updateProgressDisplay()
receive notification about progress.
Definition: MainFrame.cpp:2076
std::map< int, wxString > m_userOutput
Definition: MainFrame.h:299
declaration of helper for work with different GuiLevels
void SetGuiLevel(GuiLevel newLevel)
Definition: MainFrame.cpp:2255
void OnRemoveCPinMasks(wxCommandEvent &e)
Definition: MainFrame.cpp:1944
void OnUserQuit(wxCommandEvent &e)
Definition: MainFrame.cpp:879
void OnRunAssistant(wxCommandEvent &e)
Definition: MainFrame.cpp:2529
void OnApplyTemplate(wxCommandEvent &e)
Definition: MainFrame.cpp:1776
The OpenGL preview frame.
void AddImages(wxArrayString &filenameArray)
adds the given files to the projects, with checking for invalid filenames
Definition: MainFrame.cpp:1314
void ShowStitcherTab()
opens the stitcher tab
Definition: MainFrame.cpp:2055
const bool GetOptimizeIgnoreLineCp() const
Definition: MainFrame.cpp:1680
void OnToggleGLPreviewFrame(wxCommandEvent &e)
Definition: MainFrame.cpp:1583
void OnRedo(wxCommandEvent &e)
Definition: MainFrame.cpp:2012
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:1999
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
const wxString GetSelectedCPGenerator()
return the currently selected cp generator description
Definition: MainFrame.cpp:2153
void RunAssistant(wxWindow *mainWin, const wxString &userdefinedAssistant=wxEmptyString)
Definition: MainFrame.cpp:2431
void OnUserDefinedStitch(wxCommandEvent &e)
Definition: MainFrame.cpp:1698
void OnSavePTStitcherAs(wxCommandEvent &e)
Definition: MainFrame.cpp:1065
void OnExit(wxCloseEvent &e)
Definition: MainFrame.cpp:945
CPEditorPanel * cpe
Definition: MainFrame.h:253
void OnTipOfDay(wxCommandEvent &e)
Definition: MainFrame.cpp:1511
void OnSendToBatch(wxCommandEvent &e)
void OnMergeProject(wxCommandEvent &e)
Definition: MainFrame.cpp:1716
void SetOptimizeOnlyActiveImages(const bool onlyActive)
sets the status of the &quot;optimize only active images&quot; menu item
Definition: MainFrame.cpp:1641
void OnPhotometricOptimize(wxCommandEvent &e)
Definition: MainFrame.cpp:1685
simple class that forward the drop to the mainframe
Definition: MainFrame.h:61
wxHelpController & GetHelpController()
Definition: MainFrame.h:183
bool m_imageOnly
Definition: MainFrame.h:72
void OnSendToAssistantQueue(wxCommandEvent &e)
Definition: MainFrame.cpp:2547
mask editor panel.
void OnLoadingFailed(wxCommandEvent &e)
event handler called when loading of image file failed
Definition: MainFrame.cpp:1403
static MainFrame * m_this
Definition: MainFrame.h:282
wxMenuItem * m_outputUserMenu
Definition: MainFrame.h:286
wxNotebook * m_notebook
Definition: MainFrame.h:249
void OnUserDefinedStitchSaved(wxCommandEvent &e)
Definition: MainFrame.cpp:1703
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:2399
bool m_show_opt_panel
Definition: MainFrame.h:255
The main window frame.
Definition: MainFrame.h:83
void ShowCtrlPoint(unsigned int cpNr)
Definition: MainFrame.cpp:2021
wxString m_filename
Definition: MainFrame.h:277
Model for a panorama.
Definition: Panorama.h:152
bool m_optIgnoreLineCp
Definition: MainFrame.h:290
wxHelpController m_HelpController
Definition: MainFrame.h:292
wxMenu * m_menu_file_simple
Definition: MainFrame.h:284
void LoadProjectFile(const wxString &filename)
Definition: MainFrame.cpp:1094
HuginBase::Panorama & pano
Definition: MainFrame.h:274
void OnFineTuneAll(wxCommandEvent &e)
Definition: MainFrame.cpp:1831
const wxString & GetDataPath()
get the path to data directory
Definition: MainFrame.cpp:2163
wxFileHistory m_mruFiles
Definition: MainFrame.h:248
class, which stores all settings of one cp detector
void OnKeyboardHelp(wxCommandEvent &e)
Definition: MainFrame.cpp:1488
static MainFrame * Get()
hack.. kind of a pseudo singleton...
Definition: MainFrame.cpp:2169
void OnIgnoreLineCp(wxCommandEvent &e)
Definition: MainFrame.cpp:1660
void OnMRUFiles(wxCommandEvent &e)
event handler for recently used files
Definition: MainFrame.cpp:2190
void OnFAQ(wxCommandEvent &e)
Definition: MainFrame.cpp:1493
void OnCPListFrameClosed()
Definition: MainFrame.cpp:1624
void DisableOpenGLTools()
disables all OpenGL related menu items and toobar buttons
Definition: MainFrame.cpp:2424
void OnAddImages(wxCommandEvent &e)
Definition: MainFrame.cpp:1300
PanoDropTarget(HuginBase::Panorama &p, bool imageOnly=false)
Definition: MainFrame.h:64
void panoramaImagesChanged(HuginBase::Panorama &pano, const HuginBase::UIntSet &imgNr)
notifies about changes to images
Definition: MainFrame.cpp:872
wxString GetCurrentOptimizerString()
returns the string which describes the current selected optimizer setting
Definition: MainFrame.cpp:2617
void OnTogglePreviewFrame(wxCommandEvent &e)
Definition: MainFrame.cpp:1568
virtual ~MainFrame()
dtor.
Definition: MainFrame.cpp:767
wxDECLARE_EVENT(wxEVT_COMMAND_THUMBNAILTHREAD_UPDATE, wxCommandEvent)
void SetOptimizeIgnoreLineCp(const bool ignoreLineCP)
sets the status of the &quot;ignore line cp&quot; menu item
Definition: MainFrame.cpp:1668
const wxString & GetXRCPath()
get the path to the xrc directory
Definition: MainFrame.cpp:2158
void ShowMaskEditor(size_t imgNr, bool switchToCropMode=false)
opens the mask/crop editor with the given image selected
Definition: MainFrame.cpp:2040
void OnBrowseProjects(wxCommandEvent &e)
Definition: MainFrame.cpp:1249
void OnLoadProject(wxCommandEvent &e)
Definition: MainFrame.cpp:1199
run the optimizer.
Definition: OptimizePanel.h:38
void OnOptimize(wxCommandEvent &e)
Definition: MainFrame.cpp:1629
CPListFrame * cp_frame
Definition: MainFrame.h:264
wxMenu * m_menu_file_advanced
Definition: MainFrame.h:285
The image preview frame.
Definition: PreviewFrame.h:40
void OnSaveProjectAs(wxCommandEvent &e)
Definition: MainFrame.cpp:1027
void OnSaveProject(wxCommandEvent &e)
Definition: MainFrame.cpp:991
ImgPreview * canvas
Definition: MainFrame.h:268
void RunCPGenerator(CPDetectorSetting &setting, const HuginBase::UIntSet &img)
run the cp generator with the given setting on selected images
Definition: MainFrame.cpp:2143
bool CloseProject(bool cancelable, CloseReason reason)
Definition: MainFrame.cpp:884
void OnShowPanel(wxCommandEvent &e)
Definition: MainFrame.cpp:1358
GuiLevel m_guiLevel
Definition: MainFrame.h:265
void OnDoStitch(wxCommandEvent &e)
Definition: MainFrame.cpp:1691
struct celeste::svm_model * GetSVMModel()
Definition: MainFrame.cpp:2226
const GuiLevel GetGuiLevel() const
Definition: MainFrame.h:185
void OnHelp(wxCommandEvent &e)
Definition: MainFrame.cpp:1483
this handler class will receive change events from the Panorama.
Definition: PanoramaData.h:401
GLPreviewFrame * getGLPreview()
Definition: MainFrame.cpp:2250
void OnRunAssistantUserdefined(wxCommandEvent &e)
Definition: MainFrame.cpp:2534
void ShowCtrlPointEditor(unsigned int img1, unsigned int img2)
opens the control points tab with the both images selected
Definition: MainFrame.cpp:2028
HuginBase::Panorama & pano
Definition: MainFrame.h:71
MainFrame(wxWindow *parent, HuginBase::Panorama &pano)
ctor.
Definition: MainFrame.cpp:312
bool m_optOnlyActiveImages
Definition: MainFrame.h:289
void OnOnlyActiveImages(wxCommandEvent &e)
Definition: MainFrame.cpp:1636
void OnNewProject(wxCommandEvent &e)
Definition: MainFrame.cpp:1270
void OnSetGuiSimple(wxCommandEvent &e)
Definition: MainFrame.cpp:2366
wxFileHistory * GetFileHistory()
Definition: MainFrame.h:187
void OnOpenPTBatcher(wxCommandEvent &e)
Definition: MainFrame.cpp:1799
void OnShowPrefs(wxCommandEvent &e)
Definition: MainFrame.cpp:1538
Define the pano edit panel.
Definition: PanoPanel.h:43
void OnFullScreen(wxCommandEvent &e)
event handler for full screen
Definition: MainFrame.cpp:2217
MaskEditorPanel * mask_panel
Definition: MainFrame.h:252
GuiLevel
Definition: GuiLevel.h:31
const HuginBase::Panorama & getPanorama()
returns panorama object
Definition: MainFrame.h:101
void OnAbout(wxCommandEvent &e)
Definition: MainFrame.cpp:1445
CPDetectorSetting & GetDefaultSetting()
returns default cp detector setting
Definition: MainFrame.cpp:2138
virtual void panoramaChanged(HuginBase::Panorama &pano)
Enable or disable undo and redo.
Definition: MainFrame.cpp:808
void OnAddTimeImages(wxCommandEvent &e)
Definition: MainFrame.cpp:1347
void OnSize(wxSizeEvent &e)
Definition: MainFrame.cpp:2123
wxString getProjectName()
Definition: MainFrame.cpp:2180
bool IsShowingCorrelation() const
Definition: MainFrame.cpp:2185
PreviewFrame * preview_frame
Definition: MainFrame.h:262
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:300
void OnSetGuiExpert(wxCommandEvent &e)
Definition: MainFrame.cpp:2419
void OnReadPapywizard(wxCommandEvent &e)
Definition: MainFrame.cpp:1762
void enableTools(bool option)
Definition: MainFrame.cpp:2095