huginApp.h

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
00024 #ifndef _HUGINAPP_H
00025 #define _HUGINAPP_H
00026 
00027 #include "config.h"
00028 #include <huginapp/ImageCache.h>
00029 #include <PT/ImageGraph.h>
00030 
00031 #include "hugin/MainFrame.h"
00032 
00033 // utility functions
00034 bool str2double(wxString s, double & d);
00035 wxString Components2Str(const CPComponents & comp);
00036 
00038 void StoreFramePosition(wxTopLevelWindow * frame, const wxString & basename);
00040 void RestoreFramePosition(wxTopLevelWindow * frame, const wxString & basename);
00041 
00046 #ifdef _INCLUDE_UI_RESOURCES
00047   void InitXmlResource();
00048 #endif
00049 
00050 #if _WINDOWS && defined Hugin_shared
00051 DECLARE_LOCAL_EVENT_TYPE( EVT_IMAGE_READY, )
00052 #else
00053 DECLARE_EVENT_TYPE( EVT_IMAGE_READY, )
00054 #endif
00055 
00060 class ImageReadyEvent
00061     : public wxEvent
00062 {
00063     public:
00064         HuginBase::ImageCache::RequestPtr request;
00065         HuginBase::ImageCache::EntryPtr entry;
00066         
00067         
00068         ImageReadyEvent(HuginBase::ImageCache::RequestPtr request,
00069                         HuginBase::ImageCache::EntryPtr entry)
00070             : wxEvent (0, EVT_IMAGE_READY)
00071             , request(request)
00072             , entry(entry)
00073         {
00074         };
00075         virtual wxEvent * Clone() const
00076         {
00077             return new ImageReadyEvent(request, entry);
00078         }
00079 };
00080 
00081 typedef void (wxEvtHandler::*ImageReadyEventFunction)(ImageReadyEvent&);
00082 
00083 #define EVT_IMAGE_READY2(id, fn) \
00084     DECLARE_EVENT_TABLE_ENTRY( EVT_IMAGE_READY, id, -1, \
00085         (wxObjectEventFunction) (wxEventFunction) \
00086         wxStaticCastEvent( ImageReadyEventFunction, & fn ), (wxObject *) NULL ),
00087 
00092 class huginApp : public wxApp
00093 {
00094 public:
00095 
00098     huginApp();
00099 
00102     virtual ~huginApp();
00103 
00106     virtual bool OnInit();
00107 
00109     virtual int OnExit();
00110 
00112     static huginApp * Get();
00113     static MainFrame* getMainFrame();
00114     
00116     void relayImageLoaded(ImageReadyEvent & event);
00117     
00119     static void imageLoadedAsync(HuginBase::ImageCache::RequestPtr request,
00120                           HuginBase::ImageCache::EntryPtr entry);
00121 
00123     wxLocale & GetLocale()
00124     {
00125         return locale;
00126     }
00127 
00128     wxString GetWorkDir()
00129     {
00130         return m_workDir;
00131     }
00132     
00134     const wxString & GetXRCPath()
00135     {
00136         return m_xrcPrefix;
00137     }
00138 
00140     const wxString & GetDataPath()
00141     {
00142         return m_DataDir;
00143     }
00144 
00145     const wxString & GetUtilsBinDir()
00146     {
00147         return m_utilsBinDir;
00148     }
00149 
00150 #ifdef __WXMAC__
00151     //Defined in wxApp.h; This one lets project file to be opened from Finder and other applications.
00152     void MacOpenFile(const wxString &fileName);
00153 #endif
00154 
00155 private:
00157     wxLocale locale;
00158 
00160     wxString m_workDir;
00161 
00162     MainFrame * frame;
00163 
00164     // self
00165     static huginApp * m_this;
00166 
00167     // the model
00168     Panorama pano;
00169 
00170         // folder for xrc (GUI resources)
00171     wxString m_xrcPrefix;
00172         // folder for data shared by CLI and GUI to enable separate packaging of CLI tools
00173         wxString m_DataDir;
00174         // folder for CLI tools
00175     wxString m_utilsBinDir;
00176 
00177 #ifdef __WXMAC__
00178     bool m_macInitDone;
00179     bool m_macOpenFileOnStart;
00180     wxString m_macFileNameToOpenOnStart;
00181 #endif
00182 
00183     DECLARE_EVENT_TABLE()
00184 };
00185 
00186 DECLARE_APP(huginApp)
00187 
00188 #endif // _HUGINAPP_H

Generated on 25 Oct 2014 for Hugintrunk by  doxygen 1.4.7