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     enum CloseReason
00134     {
00135         CLOSE_PROGRAM,
00136         LOAD_NEW_PROJECT,
00137         NEW_PROJECT
00138     };
00139     bool CloseProject(bool cancelable, CloseReason reason);
00140 
00141     // TODO: create a nice generic optimisation & stitching function
00142     // instead of these gateway functions to the optimizer and pano panels.
00143     void OnOptimize(wxCommandEvent & e);
00144     void OnOnlyActiveImages(wxCommandEvent &e);
00145     void OnPhotometricOptimize(wxCommandEvent & e);
00146     void OnDoStitch(wxCommandEvent & e);
00147     void OnUserDefinedStitch(wxCommandEvent & e);
00148     void OnUserDefinedStitchSaved(wxCommandEvent & e);
00149     void OnTogglePreviewFrame(wxCommandEvent & e);
00150     void OnToggleGLPreviewFrame(wxCommandEvent & e);
00151     void OnAddImages(wxCommandEvent & e);
00152     void OnSaveProject(wxCommandEvent & e);
00153     void OnSetGuiSimple(wxCommandEvent & e);
00154     void OnSetGuiAdvanced(wxCommandEvent & e);
00155     void OnSetGuiExpert(wxCommandEvent & e);
00156 
00158     void DisplayHelp(wxString section = wxEmptyString);
00159 
00161     void ShowCtrlPointEditor(unsigned int img1, unsigned int img2);
00163     void ShowMaskEditor(size_t imgNr);
00165     void ShowStitcherTab();
00166 
00167     void OnCPListFrameClosed();
00169     CPDetectorSetting& GetDefaultSetting();
00171     void RunCPGenerator(CPDetectorSetting &setting, const HuginBase::UIntSet& img);
00173     void RunCPGenerator(const HuginBase::UIntSet& img);
00175     const wxString GetSelectedCPGenerator();
00176 
00177     wxString getProjectName();
00178 
00179     struct celeste::svm_model* GetSVMModel();
00180     
00181     GLPreviewFrame * getGLPreview();
00182     wxHelpController& GetHelpController() { return m_HelpController; }
00183     void SetGuiLevel(GuiLevel newLevel);
00184     const GuiLevel GetGuiLevel() const { return m_guiLevel; };
00185 
00186     wxFileHistory* GetFileHistory() { return &m_mruFiles; };
00187 
00189     wxString GetCurrentOptimizerString();
00190 
00191 protected:
00192     // called when a progress message should be displayed
00198     void updateProgressDisplay();
00199 
00200 private:
00201 
00202     // event handlers
00203     void OnExit(wxCloseEvent & e);
00204     void OnUserQuit(wxCommandEvent & e);
00205     void OnAbout(wxCommandEvent & e);
00206     void OnHelp(wxCommandEvent & e);
00207     void OnKeyboardHelp(wxCommandEvent & e);
00208     void OnFAQ(wxCommandEvent & e);
00209     void OnShowPrefs(wxCommandEvent &e);
00210 #ifdef HUGIN_HSI
00211     void OnPythonScript(wxCommandEvent & e);
00212     void OnPlugin(wxCommandEvent& e);
00213 #endif
00214     void OnUndo(wxCommandEvent & e);
00215     void OnRedo(wxCommandEvent & e);
00216     void OnSaveProjectAs(wxCommandEvent & e);
00217     void OnSavePTStitcherAs(wxCommandEvent & e);
00218     void OnLoadProject(wxCommandEvent & e);
00219     void OnNewProject(wxCommandEvent & e);
00220     void OnAddTimeImages(wxCommandEvent & e);
00221     void OnRunAssistant(wxCommandEvent & e);
00222     void OnFineTuneAll(wxCommandEvent & e);
00223     void OnRemoveCPinMasks(wxCommandEvent & e);
00224     void OnMergeProject(wxCommandEvent & e);
00225     void OnReadPapywizard(wxCommandEvent & e);
00226     void OnApplyTemplate(wxCommandEvent & e);
00227     void OnSendToBatch(wxCommandEvent & e);
00228     void OnSendToAssistantQueue(wxCommandEvent & e);
00229     void OnOpenPTBatcher(wxCommandEvent & e);
00230 //    void OnToggleOptimizeFrame(wxCommandEvent & e);
00231     void OnShowCPFrame(wxCommandEvent & e);
00233     void OnMRUFiles(wxCommandEvent &e);
00235     void OnFullScreen(wxCommandEvent &e);
00236     void UpdatePanels(wxCommandEvent & e);
00237     void OnSize(wxSizeEvent &e);
00238     void enableTools(bool option);
00240     void AddImages(wxArrayString& filenameArray);
00241 
00242     void OnShowDonate(wxCommandEvent &e);
00243     void OnShowPanel(wxCommandEvent &e);
00245     void OnLoadingFailed(wxCommandEvent& e);
00246 
00247     wxFileHistory m_mruFiles;
00248     wxNotebook * m_notebook;
00249     // tab panels
00250     ImagesPanel* images_panel;
00251     MaskEditorPanel* mask_panel;
00252     CPEditorPanel * cpe;
00253     OptimizePanel * opt_panel;
00254     bool m_show_opt_panel;
00255     OptimizePhotometricPanel * opt_photo_panel;
00256     bool m_show_opt_photo_panel;
00257     PanoPanel * pano_panel;
00258     struct celeste::svm_model* svmModel;
00259 
00260     // flying windows
00261     PreviewFrame * preview_frame;
00262     GLPreviewFrame * gl_preview_frame;
00263     CPListFrame * cp_frame;
00264     GuiLevel m_guiLevel;
00265 
00266     // Image Preview
00267     ImgPreview *canvas;
00268 
00269     // Preferences
00270     //PreferencesDialog * pref_dlg;
00271 
00272     // the model
00273     HuginBase::Panorama & pano;
00274 
00275     // filename of the current project
00276     wxString m_filename;
00277 
00278     // self
00279     static MainFrame* m_this;
00280     // file menu
00281     wxMenu* m_menu_file_simple;
00282     wxMenu* m_menu_file_advanced;
00283     // sticky setting, to prevent reading to often
00284     bool m_optOnlyActiveImages;
00285     // help controller
00286     wxHelpController m_HelpController;
00287 
00288 #ifdef HUGIN_HSI
00289     // list associating the wxID in the menu with a python script
00290     std::map<int, wxFileName> m_plugins;
00291 #endif
00292     // list for user-defined output sequences
00293     std::map<int, wxString> m_userOutput;
00294 
00295     DECLARE_EVENT_TABLE()
00296 };
00297 
00298 // event used to signal invalid or missing image files
00299 #if defined _WIN32 && defined Hugin_shared
00300 DECLARE_LOCAL_EVENT_TYPE(EVT_LOADING_FAILED, -1)
00301 #else
00302 DECLARE_EVENT_TYPE(EVT_LOADING_FAILED, -1)
00303 #endif
00304 
00305 #endif // _MAINFRAME_H

Generated on 23 Apr 2017 for Hugintrunk by  doxygen 1.4.7