Hugin trunk 0.1
Loading...
Searching...
No Matches
LensCalApp.cpp
Go to the documentation of this file.
1// -*- c-basic-offset: 4 -*-
10/*
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
15 *
16 * This software is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public
22 * License along with this software. If not, see
23 * <http://www.gnu.org/licenses/>.
24 *
25 */
26
27#include "panoinc_WX.h"
28#include "panoinc.h"
29#include <wx/stdpaths.h>
30#include "base_wx/platform.h"
31#include "base_wx/wxutils.h"
32
33#include "LensCalApp.h"
34#include "LensCalImageCtrl.h"
35#include "base_wx/huginConfig.h"
37#include "base_wx/PTWXDlg.h"
38#if defined __WXGTK__
39#include "base_wx/wxPlatform.h"
40#endif
41
42#include <tiffio.h>
43
44
45// make wxwindows use this class as the main application
47
49{
50 SetAppName("hugin");
51#if defined __WXGTK__
53#endif
55 {
56 return false;
57 }
58#if wxUSE_ON_FATAL_EXCEPTION
60#endif
61#if defined __WXMSW__ && wxCHECK_VERSION(3,3,0)
62 // automatically switch between light and dark mode
63 SetAppearance(Appearance::System);
64#endif
65 // register our custom pano tools dialog handlers
67
68#if defined __WXMSW__
69 wxFileName exeDir(wxStandardPaths::Get().GetExecutablePath());
70 exeDir.RemoveLastDir();
71 m_xrcPrefix = exeDir.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) + "share\\hugin\\xrc\\";
72 // locale setup
73 locale.AddCatalogLookupPathPrefix(exeDir.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) + "share\\locale");
74#elif defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
75 // initialize paths
77 if (thePath == wxEmptyString) {
78 hugin_utils::HuginMessageBox(_("xrc directory not found in bundle"), _("Calibrate_lens_GUI"), wxOK | wxICON_ERROR, wxGetActiveWindow());
79 return false;
80 }
81 m_xrcPrefix = thePath + "/";
82#elif defined UNIX_SELF_CONTAINED_BUNDLE
83 // initialize paths
84 {
85 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
86 exePath.RemoveLastDir();
88 // add the locale directory specified during configure
89 m_xrcPrefix = huginRoot + "share/hugin/xrc/";
90 locale.AddCatalogLookupPathPrefix(huginRoot + "share/locale");
91 }
92#else
93 // add the locale directory specified during configure
94 m_xrcPrefix = INSTALL_XRC_DIR;
95 locale.AddCatalogLookupPathPrefix(INSTALL_LOCALE_DIR);
96#endif
97
98 if ( ! wxFile::Exists(m_xrcPrefix + "/lenscal_frame.xrc") )
99 {
100 hugin_utils::HuginMessageBox(wxString::Format(_("xrc directory not found, hugin needs to be properly installed\nTried Path: %s"), m_xrcPrefix), _("Calibrate_lens_GUI"), wxOK | wxICON_ERROR, wxGetActiveWindow());
101 return false;
102 }
103
104 // here goes and comes configuration
105 wxConfigBase * config = wxConfigBase::Get();
106 // do not record default values in the preferences file
107 config->SetRecordDefaults(false);
108 config->Flush();
109
110 // need to explicitly initialize locale for C++ library/runtime
111 setlocale(LC_ALL, "");
112 // initialize i18n
113 int localeID = config->Read("language", (long) HUGIN_LANGUAGE);
114 DEBUG_TRACE("localeID: " << localeID);
115 {
116 bool bLInit;
117 bLInit = locale.Init(localeID);
118 if (bLInit) {
119 DEBUG_TRACE("locale init OK");
120 DEBUG_TRACE("System Locale: " << locale.GetSysName().mb_str(wxConvLocal))
121 DEBUG_TRACE("Canonical Locale: " << locale.GetCanonicalName().mb_str(wxConvLocal))
122 } else {
123 DEBUG_TRACE("locale init failed");
124 }
125 }
126
127 // set the name of locale recource to look for
128 locale.AddCatalog("hugin");
129
130 // initialize image handlers
132
133 // Initialize all the XRC handlers.
134 wxXmlResource::Get()->InitAllHandlers();
135 wxXmlResource::Get()->AddHandler(new LensCalImageCtrlXmlHandler());
136 // load XRC files
137 wxXmlResource::Get()->Load(m_xrcPrefix + "lenscal_frame.xrc");
138 wxXmlResource::Get()->Load(m_xrcPrefix + "lensdb_dialogs.xrc");
139 wxXmlResource::Get()->Load(m_xrcPrefix + "dlg_warning.xrc");
140
141 // create main frame
142 m_frame = new LensCalFrame(NULL);
143 SetTopWindow(m_frame);
144
145 // setup main frame size, after it has been created.
146 hugin_utils::RestoreFramePosition(m_frame, "LensCalFrame");
147
148 // show the frame.
149 m_frame->Show(TRUE);
150
151 // suppress tiff warnings
153
154 return true;
155}
156
157#if wxUSE_ON_FATAL_EXCEPTION
158void LensCalApp::OnFatalException()
159{
160 GenerateReport(wxDebugReport::Context_Exception);
161};
162#endif
declaration of application class for lens calibrate application
declaration of preview for lens calibration gui
void registerPTWXDlgFcn()
Definition PTWXDlg.cpp:178
bool OnInit() wxOVERRIDE
The application class for lens_calibrate_gui .
Definition LensCalApp.h:38
The main window frame.
xrc handler for LensCalImageCtrl
#define HUGIN_LANGUAGE
implementation of huginApp Class
functions for interaction with the hugin configuration file
#define DEBUG_TRACE(msg)
Definition utils.h:67
int HuginMessageBox(const wxString &message, const wxString &caption, int style, wxWindow *parent)
Definition wxutils.cpp:176
void RestoreFramePosition(wxTopLevelWindow *frame, const wxString &basename, const bool ignoreMaximize)
Definition wxutils.cpp:67
include file for the hugin project
include file for the hugin project
std::vector< deghosting::BImagePtr > threshold(const std::vector< deghosting::FImagePtr > &inputImages, const double threshold, const uint16_t flags)
Threshold function used for creating alpha masks for images.
Definition threshold.h:41
platform/compiler specific stuff.