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 #if defined _WIN32 && defined Hugin_shared
51 DECLARE_LOCAL_EVENT_TYPE( EVT_IMAGE_READY, )
52 #else
53 DECLARE_EVENT_TYPE( EVT_IMAGE_READY, )
54 #endif
55 
61  : public wxEvent
62 {
63  public:
66 
67 
70  : wxEvent (0, EVT_IMAGE_READY)
71  , request(request)
72  , entry(entry)
73  {
74  };
75  virtual wxEvent * Clone() const
76  {
77  return new ImageReadyEvent(request, entry);
78  }
79 };
80 
81 typedef void (wxEvtHandler::*ImageReadyEventFunction)(ImageReadyEvent&);
82 
83 #define EVT_IMAGE_READY2(id, fn) \
84  DECLARE_EVENT_TABLE_ENTRY( EVT_IMAGE_READY, id, -1, \
85  (wxObjectEventFunction) (wxEventFunction) \
86  wxStaticCastEvent( ImageReadyEventFunction, & fn ), (wxObject *) NULL ),
87 
92 class huginApp : public wxApp
93 {
94 public:
95 
98  huginApp();
99 
102  virtual ~huginApp();
103 
106  virtual bool OnInit();
107 
109  virtual int OnExit();
110 
112  static huginApp * Get();
113  static MainFrame* getMainFrame();
114 
116  void relayImageLoaded(ImageReadyEvent & event);
117 
121 
123  wxLocale & GetLocale()
124  {
125  return locale;
126  }
127 
128  wxString GetWorkDir()
129  {
130  return m_workDir;
131  }
132 
134  const wxString & GetXRCPath()
135  {
136  return m_xrcPrefix;
137  }
138 
140  const wxString & GetDataPath()
141  {
142  return m_DataDir;
143  }
144 
145  const wxString & GetUtilsBinDir()
146  {
147  return m_utilsBinDir;
148  }
149 
151  const cmsHPROFILE GetMonitorProfile() const
152  {
153  return m_monitorProfile;
154  }
156  bool HasMonitorProfile() const
157  {
158  return !m_monitorProfileName.IsEmpty();
159  }
161  const wxString& GetMonitorProfileName() const
162  {
163  return m_monitorProfileName;
164  };
165 
166 #ifdef __WXMAC__
167  //Defined in wxApp.h; This one lets project file to be opened from Finder and other applications.
168  void MacOpenFile(const wxString &fileName);
169 #endif
170 
171 #if wxUSE_ON_FATAL_EXCEPTION
172 #if wxCHECK_VERSION(3,1,0)
173  virtual void OnFatalException() wxOVERRIDE;
174 #else
175  virtual void OnFatalException();
176 #endif
177 #endif
178 
179 private:
181  wxLocale locale;
182 
184  wxString m_workDir;
185 
187 
188  // self
189  static huginApp * m_this;
190 
191  // the model
193 
194  // folder for xrc (GUI resources)
195  wxString m_xrcPrefix;
196  // folder for data shared by CLI and GUI to enable separate packaging of CLI tools
197  wxString m_DataDir;
198  // folder for CLI tools
199  wxString m_utilsBinDir;
200  // monitor profile
202  cmsHPROFILE m_monitorProfile;
203 
204 #ifdef __WXMAC__
205  bool m_macInitDone;
206  bool m_macOpenFileOnStart;
207  wxString m_macFileNameToOpenOnStart;
208 #endif
209 
210  DECLARE_EVENT_TABLE()
211 };
212 
213 DECLARE_APP(huginApp)
214 
215 #endif // _HUGINAPP_H
static huginApp * m_this
Definition: huginApp.h:189
The application class for hugin.
Definition: huginApp.h:92
const wxString & GetDataPath()
return the current data path
Definition: huginApp.h:140
virtual bool OnInit()
pseudo constructor.
Definition: huginApp.cpp:189
HuginBase::Panorama pano
Definition: huginApp.h:192
cmsHPROFILE m_monitorProfile
Definition: huginApp.h:202
void relayImageLoaded(ImageReadyEvent &event)
Relay image loaded event when the UI thread is ready to process it.
Definition: huginApp.cpp:669
MainFrame * frame
Definition: huginApp.h:186
const cmsHPROFILE GetMonitorProfile() const
returns the monitor profile, if no monitor profile was found the sRGB profile is used instead ...
Definition: huginApp.h:151
huginApp()
ctor.
Definition: huginApp.cpp:159
wxString m_DataDir
Definition: huginApp.h:197
wxString m_monitorProfileName
Definition: huginApp.h:201
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:649
The main window frame.
Definition: MainFrame.h:87
Model for a panorama.
Definition: Panorama.h:152
wxString m_xrcPrefix
Definition: huginApp.h:195
HuginBase::ImageCache::EntryPtr entry
Definition: huginApp.h:65
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:660
std::shared_ptr< Request > RequestPtr
Reference counted request for an image to load.
Definition: ImageCache.h:151
wxString m_utilsBinDir
Definition: huginApp.h:199
bool HasMonitorProfile() const
return true if we found a suitable monitor profile and could loading it
Definition: huginApp.h:156
virtual wxEvent * Clone() const
Definition: huginApp.h:75
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:81
const wxString & GetMonitorProfileName() const
return filename of monitor profile
Definition: huginApp.h:161
const wxString & GetUtilsBinDir()
Definition: huginApp.h:145
ImageReadyEvent(HuginBase::ImageCache::RequestPtr request, HuginBase::ImageCache::EntryPtr entry)
Definition: huginApp.h:68
wxString m_workDir
temporary working directory
Definition: huginApp.h:184
virtual ~huginApp()
dtor.
Definition: huginApp.cpp:169
virtual int OnExit()
just for testing purposes
Definition: huginApp.cpp:642
wxString GetWorkDir()
Definition: huginApp.h:128
wxLocale & GetLocale()
return currently active locale
Definition: huginApp.h:123
const wxString & GetXRCPath()
return the current xrc path
Definition: huginApp.h:134
HuginBase::ImageCache::RequestPtr request
Definition: huginApp.h:64
wxString Components2Str(const HuginGraph::ImageGraph::Components &comp)
Definition: huginApp.cpp:86
Resources Definition.
Definition: huginApp.h:60
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:686
wxLocale locale
locale for internationalisation
Definition: huginApp.h:164