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

Generated on 21 Sep 2017 for Hugintrunk by  doxygen 1.4.7