Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
huginApp.h
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
24 #ifndef _HUGINAPP_H
25 #define _HUGINAPP_H
26 
27 #include "hugin_config.h"
28 #include <huginapp/ImageCache.h>
29 #include <lcms2.h>
31 
32 #include "hugin/MainFrame.h"
33 
34 // utility functions
36 
38 void StoreFramePosition(wxTopLevelWindow * frame, const wxString & basename);
40 void RestoreFramePosition(wxTopLevelWindow * frame, const wxString & basename);
41 
46 #ifdef _INCLUDE_UI_RESOURCES
47  void InitXmlResource();
48 #endif
49 
50 wxDECLARE_EVENT(EVT_IMAGE_READY, wxCommandEvent);
51 
57  : public wxEvent
58 {
59  public:
62 
63 
66  : wxEvent (0, EVT_IMAGE_READY)
67  , request(request)
68  , entry(entry)
69  {
70  };
71  virtual wxEvent * Clone() const
72  {
73  return new ImageReadyEvent(request, entry);
74  }
75 };
76 
77 typedef void (wxEvtHandler::*ImageReadyEventFunction)(ImageReadyEvent&);
78 
79 #define EVT_IMAGE_READY2(id, fn) \
80  DECLARE_EVENT_TABLE_ENTRY( EVT_IMAGE_READY, id, -1, \
81  (wxObjectEventFunction) (wxEventFunction) \
82  wxStaticCastEvent( ImageReadyEventFunction, & fn ), (wxObject *) NULL ),
83 
88 class huginApp : public wxApp
89 {
90 public:
91 
94  huginApp();
95 
98  virtual ~huginApp();
99 
102  virtual bool OnInit();
103 
105  virtual int OnExit();
106 
108  static huginApp * Get();
109  static MainFrame* getMainFrame();
110 
112  void relayImageLoaded(ImageReadyEvent & event);
113 
117 
119  wxLocale & GetLocale()
120  {
121  return locale;
122  }
123 
124  wxString GetWorkDir()
125  {
126  return m_workDir;
127  }
128 
130  const wxString & GetXRCPath()
131  {
132  return m_xrcPrefix;
133  }
134 
136  const wxString & GetDataPath()
137  {
138  return m_DataDir;
139  }
140 
141  const wxString & GetUtilsBinDir()
142  {
143  return m_utilsBinDir;
144  }
145 
147  const cmsHPROFILE GetMonitorProfile() const
148  {
149  return m_monitorProfile;
150  }
152  bool HasMonitorProfile() const
153  {
154  return !m_monitorProfileName.IsEmpty();
155  }
157  const wxString& GetMonitorProfileName() const
158  {
159  return m_monitorProfileName;
160  };
161 
162 #ifdef __WXMAC__
163  //Defined in wxApp.h; This one lets project file to be opened from Finder and other applications.
164  void MacOpenFile(const wxString &fileName);
165 #endif
166 
167 #if wxUSE_ON_FATAL_EXCEPTION
168  virtual void OnFatalException() wxOVERRIDE;
169 #endif
170 
171 private:
173  wxLocale locale;
174 
176  wxString m_workDir;
177 
179 
180  // self
181  static huginApp * m_this;
182 
183  // the model
185 
186  // folder for xrc (GUI resources)
187  wxString m_xrcPrefix;
188  // folder for data shared by CLI and GUI to enable separate packaging of CLI tools
189  wxString m_DataDir;
190  // folder for CLI tools
191  wxString m_utilsBinDir;
192  // monitor profile
194  cmsHPROFILE m_monitorProfile;
195 
196 #ifdef __WXMAC__
197  bool m_macInitDone;
198  bool m_macOpenFileOnStart;
199  wxString m_macFileNameToOpenOnStart;
200 #endif
201 
202  DECLARE_EVENT_TABLE()
203 };
204 
205 DECLARE_APP(huginApp)
206 
207 #endif // _HUGINAPP_H
static huginApp * m_this
Definition: huginApp.h:181
The application class for hugin.
Definition: huginApp.h:88
const wxString & GetDataPath()
return the current data path
Definition: huginApp.h:136
virtual bool OnInit()
pseudo constructor.
Definition: huginApp.cpp:183
HuginBase::Panorama pano
Definition: huginApp.h:184
cmsHPROFILE m_monitorProfile
Definition: huginApp.h:194
void relayImageLoaded(ImageReadyEvent &event)
Relay image loaded event when the UI thread is ready to process it.
Definition: huginApp.cpp:661
MainFrame * frame
Definition: huginApp.h:178
const cmsHPROFILE GetMonitorProfile() const
returns the monitor profile, if no monitor profile was found the sRGB profile is used instead ...
Definition: huginApp.h:147
huginApp()
ctor.
Definition: huginApp.cpp:153
wxString m_DataDir
Definition: huginApp.h:189
wxString m_monitorProfileName
Definition: huginApp.h:193
std::vector< HuginBase::UIntSet > Components
stores the components of the graph
Definition: ImageGraph.h:50
static huginApp * Get()
hack.. kind of a pseudo singleton...
Definition: huginApp.cpp:641
The main window frame.
Definition: MainFrame.h:83
Model for a panorama.
Definition: Panorama.h:152
wxString m_xrcPrefix
Definition: huginApp.h:187
HuginBase::ImageCache::EntryPtr entry
Definition: huginApp.h:61
std::shared_ptr< Entry > EntryPtr
a shared pointer to the entry
Definition: ImageCache.h:112
void StoreFramePosition(wxTopLevelWindow *frame, const wxString &basename)
Store window size and position in configfile/registry.
Definition: LensCalApp.cpp:212
static MainFrame * getMainFrame()
Definition: huginApp.cpp:652
std::shared_ptr< Request > RequestPtr
Reference counted request for an image to load.
Definition: ImageCache.h:151
wxString m_utilsBinDir
Definition: huginApp.h:191
bool HasMonitorProfile() const
return true if we found a suitable monitor profile and could loading it
Definition: huginApp.h:152
wxDECLARE_EVENT(wxEVT_COMMAND_THUMBNAILTHREAD_UPDATE, wxCommandEvent)
virtual wxEvent * Clone() const
Definition: huginApp.h:71
void RestoreFramePosition(wxTopLevelWindow *frame, const wxString &basename)
Restore window size and position from configfile/registry.
Definition: LensCalApp.cpp:158
void(wxEvtHandler::* ImageReadyEventFunction)(ImageReadyEvent &)
Definition: huginApp.h:77
const wxString & GetMonitorProfileName() const
return filename of monitor profile
Definition: huginApp.h:157
const wxString & GetUtilsBinDir()
Definition: huginApp.h:141
ImageReadyEvent(HuginBase::ImageCache::RequestPtr request, HuginBase::ImageCache::EntryPtr entry)
Definition: huginApp.h:64
wxString m_workDir
temporary working directory
Definition: huginApp.h:176
virtual ~huginApp()
dtor.
Definition: huginApp.cpp:163
virtual int OnExit()
just for testing purposes
Definition: huginApp.cpp:634
wxString GetWorkDir()
Definition: huginApp.h:124
wxLocale & GetLocale()
return currently active locale
Definition: huginApp.h:119
const wxString & GetXRCPath()
return the current xrc path
Definition: huginApp.h:130
HuginBase::ImageCache::RequestPtr request
Definition: huginApp.h:60
wxString Components2Str(const HuginGraph::ImageGraph::Components &comp)
Definition: huginApp.cpp:84
Event for when a requested image finished loading.
Definition: huginApp.h:56
static void imageLoadedAsync(HuginBase::ImageCache::RequestPtr request, HuginBase::ImageCache::EntryPtr entry)
Queue up an image loaded event when an image has just loaded.
Definition: huginApp.cpp:678
wxLocale locale
locale for internationalisation
Definition: huginApp.h:160