MainFrame.h

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
00024 #ifndef _MAINFRAME_H
00025 #define _MAINFRAME_H
00026 
00027 
00028 #include <vector>
00029 #include <set>
00030 #include <map>
00031 
00032 #include "panodata/Panorama.h"
00033 
00034 #include "wx/docview.h"
00035 #include "wx/help.h"
00036 #if !wxUSE_HELP
00037 #error wxWidgets needs to be compiled with help support (wxUSE_HELP not set)
00038 #endif
00039 #if defined __WXMSW__ && !(wxCHECK_VERSION(3,1,1))
00040 #include "base_wx/wxPlatform.h"
00041 #define wxHelpController HuginCHMHelpController
00042 #endif
00043 
00044 #include <appbase/ProgressDisplay.h>
00045 
00046 #include "hugin/OptimizePanel.h"
00047 #include "hugin/PreferencesDialog.h"
00048 
00049 // Celeste header
00050 #include "Celeste.h"
00051 #include "GuiLevel.h"
00052 
00053 // forward declarations, to save the #include statements
00054 class CPEditorPanel;
00055 class ImgPreview;
00056 class ImagesPanel;
00057 class MaskEditorPanel;
00058 class OptimizePhotometricPanel;
00059 class PanoPanel;
00060 class PreviewFrame;
00061 class GLPreviewFrame;
00062 class CPListFrame;
00063 
00065 class PanoDropTarget : public wxFileDropTarget
00066 {
00067 public:
00068     PanoDropTarget(HuginBase::Panorama & p, bool imageOnly = false)
00069         : pano(p)
00070     { m_imageOnly = imageOnly; }
00071 
00072     bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames);
00073 
00074 private:
00075     HuginBase::Panorama & pano;
00076     bool m_imageOnly;
00077 };
00078 
00087 class MainFrame : public wxFrame, public HuginBase::PanoramaObserver, public AppBase::ProgressDisplay
00088 {
00089 public:
00090 
00093     MainFrame(wxWindow* parent, HuginBase::Panorama & pano);
00094 
00097     virtual ~MainFrame();
00098 
00102     virtual void panoramaChanged(HuginBase::Panorama &pano);
00103     void panoramaImagesChanged(HuginBase::Panorama &pano, const HuginBase::UIntSet & imgNr);
00105     const HuginBase::Panorama & getPanorama() { return pano; };
00106 
00107     // called when a control point in CPListFrame is selected
00108     void ShowCtrlPoint(unsigned int cpNr);
00109 
00111     const wxString & GetXRCPath();
00113     const wxString & GetDataPath();
00115     void SetOptimizeOnlyActiveImages(const bool onlyActive);
00116     const bool GetOptimizeOnlyActiveImages() const;
00117 
00119     static MainFrame * Get();
00120 
00121     // Used to display tip of the day after main interface is initialised and visible
00122         void OnTipOfDay(wxCommandEvent & e);
00123 
00124     // load a project
00125     void LoadProjectFile(const wxString & filename);
00126     void RunAssistant(wxWindow* mainWin);
00127 
00129     void DisableOpenGLTools();
00130 #ifdef __WXMAC__
00131     void MacOnOpenFile(const wxString & filename);
00132 #endif
00133     bool CloseProject(bool cancelable);
00134 
00135     // TODO: create a nice generic optimisation & stitching function
00136     // instead of these gateway functions to the optimizer and pano panels.
00137     void OnOptimize(wxCommandEvent & e);
00138     void OnOnlyActiveImages(wxCommandEvent &e);
00139     void OnPhotometricOptimize(wxCommandEvent & e);
00140     void OnDoStitch(wxCommandEvent & e);
00141     void OnUserDefinedStitch(wxCommandEvent & e);
00142     void OnUserDefinedStitchSaved(wxCommandEvent & e);
00143     void OnTogglePreviewFrame(wxCommandEvent & e);
00144     void OnToggleGLPreviewFrame(wxCommandEvent & e);
00145     void OnAddImages(wxCommandEvent & e);
00146     void OnSaveProject(wxCommandEvent & e);
00147     void OnSetGuiSimple(wxCommandEvent & e);
00148     void OnSetGuiAdvanced(wxCommandEvent & e);
00149     void OnSetGuiExpert(wxCommandEvent & e);
00150 
00152     void DisplayHelp(wxString section = wxEmptyString);
00153 
00155     void ShowCtrlPointEditor(unsigned int img1, unsigned int img2);
00157     void ShowMaskEditor(size_t imgNr);
00159     void ShowStitcherTab();
00160 
00161     void OnCPListFrameClosed();
00163     CPDetectorSetting& GetDefaultSetting();
00165     void RunCPGenerator(CPDetectorSetting &setting, const HuginBase::UIntSet& img);
00167     void RunCPGenerator(const HuginBase::UIntSet& img);
00169     const wxString GetSelectedCPGenerator();
00170 
00171     wxString getProjectName();
00172 
00173     struct celeste::svm_model* GetSVMModel();
00174     
00175     GLPreviewFrame * getGLPreview();
00176     wxHelpController& GetHelpController() { return m_HelpController; }
00177     void SetGuiLevel(GuiLevel newLevel);
00178     const GuiLevel GetGuiLevel() const { return m_guiLevel; };
00179 
00180     wxFileHistory* GetFileHistory() { return &m_mruFiles; };
00181 
00183     wxString GetCurrentOptimizerString();
00184 
00185 protected:
00186     // called when a progress message should be displayed
00192     void updateProgressDisplay();
00193 
00194 private:
00195 
00196     // event handlers
00197     void OnExit(wxCloseEvent & e);
00198     void OnUserQuit(wxCommandEvent & e);
00199     void OnAbout(wxCommandEvent & e);
00200     void OnHelp(wxCommandEvent & e);
00201     void OnKeyboardHelp(wxCommandEvent & e);
00202     void OnFAQ(wxCommandEvent & e);
00203     void OnShowPrefs(wxCommandEvent &e);
00204 #ifdef HUGIN_HSI
00205     void OnPythonScript(wxCommandEvent & e);
00206     void OnPlugin(wxCommandEvent& e);
00207 #endif
00208     void OnUndo(wxCommandEvent & e);
00209     void OnRedo(wxCommandEvent & e);
00210     void OnSaveProjectAs(wxCommandEvent & e);
00211     void OnSavePTStitcherAs(wxCommandEvent & e);
00212     void OnLoadProject(wxCommandEvent & e);
00213     void OnNewProject(wxCommandEvent & e);
00214     void OnAddTimeImages(wxCommandEvent & e);
00215     void OnRunAssistant(wxCommandEvent & e);
00216     void OnFineTuneAll(wxCommandEvent & e);
00217     void OnRemoveCPinMasks(wxCommandEvent & e);
00218     void OnMergeProject(wxCommandEvent & e);
00219     void OnReadPapywizard(wxCommandEvent & e);
00220     void OnApplyTemplate(wxCommandEvent & e);
00221     void OnSendToBatch(wxCommandEvent & e);
00222     void OnSendToAssistantQueue(wxCommandEvent & e);
00223     void OnOpenPTBatcher(wxCommandEvent & e);
00224 //    void OnToggleOptimizeFrame(wxCommandEvent & e);
00225     void OnShowCPFrame(wxCommandEvent & e);
00227     void OnMRUFiles(wxCommandEvent &e);
00229     void OnFullScreen(wxCommandEvent &e);
00230     void UpdatePanels(wxCommandEvent & e);
00231     void OnSize(wxSizeEvent &e);
00232     void enableTools(bool option);
00234     void AddImages(wxArrayString& filenameArray);
00235 
00236     void OnShowDonate(wxCommandEvent &e);
00237     void OnShowPanel(wxCommandEvent &e);
00239     void OnLoadingFailed(wxCommandEvent& e);
00240 
00241     wxFileHistory m_mruFiles;
00242     wxNotebook * m_notebook;
00243     // tab panels
00244     ImagesPanel* images_panel;
00245     MaskEditorPanel* mask_panel;
00246     CPEditorPanel * cpe;
00247     OptimizePanel * opt_panel;
00248     bool m_show_opt_panel;
00249     OptimizePhotometricPanel * opt_photo_panel;
00250     bool m_show_opt_photo_panel;
00251     PanoPanel * pano_panel;
00252     struct celeste::svm_model* svmModel;
00253 
00254     // flying windows
00255     PreviewFrame * preview_frame;
00256     GLPreviewFrame * gl_preview_frame;
00257     CPListFrame * cp_frame;
00258     GuiLevel m_guiLevel;
00259 
00260     // Image Preview
00261     ImgPreview *canvas;
00262 
00263     // Preferences
00264     //PreferencesDialog * pref_dlg;
00265 
00266     // the model
00267     HuginBase::Panorama & pano;
00268 
00269     // filename of the current project
00270     wxString m_filename;
00271 
00272     // self
00273     static MainFrame* m_this;
00274     // file menu
00275     wxMenu* m_menu_file_simple;
00276     wxMenu* m_menu_file_advanced;
00277     // sticky setting, to prevent reading to often
00278     bool m_optOnlyActiveImages;
00279     // help controller
00280     wxHelpController m_HelpController;
00281 
00282 #ifdef HUGIN_HSI
00283     // list associating the wxID in the menu with a python script
00284     std::map<int, wxFileName> m_plugins;
00285 #endif
00286     // list for user-defined output sequences
00287     std::map<int, wxString> m_userOutput;
00288 
00289     DECLARE_EVENT_TABLE()
00290 };
00291 
00292 // event used to signal invalid or missing image files
00293 #if defined _WIN32 && defined Hugin_shared
00294 DECLARE_LOCAL_EVENT_TYPE(EVT_LOADING_FAILED, -1)
00295 #else
00296 DECLARE_EVENT_TYPE(EVT_LOADING_FAILED, -1)
00297 #endif
00298 
00299 #endif // _MAINFRAME_H

Generated on 16 Jan 2017 for Hugintrunk by  doxygen 1.4.7