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#if wxUSE_ON_FATAL_EXCEPTION
52#endif
53 SetAppName("hugin");
54#if defined __WXMSW__ && wxCHECK_VERSION(3,3,0)
55 // automatically switch between light and dark mode
56 SetAppearance(Appearance::System);
57#endif
58#if defined __WXGTK__
60#endif
61 // register our custom pano tools dialog handlers
63
64#if defined __WXMSW__
65 wxFileName exeDir(wxStandardPaths::Get().GetExecutablePath());
66 exeDir.RemoveLastDir();
67 m_xrcPrefix = exeDir.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) + "share\\hugin\\xrc\\";
68 // locale setup
69 locale.AddCatalogLookupPathPrefix(exeDir.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) + "share\\locale");
70#elif defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
71 // initialize paths
73 if (thePath == wxEmptyString) {
74 hugin_utils::HuginMessageBox(_("xrc directory not found in bundle"), _("Calibrate_lens_GUI"), wxOK | wxICON_ERROR, wxGetActiveWindow());
75 return false;
76 }
77 m_xrcPrefix = thePath + "/";
78#elif defined UNIX_SELF_CONTAINED_BUNDLE
79 // initialize paths
80 {
81 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
82 exePath.RemoveLastDir();
84 // add the locale directory specified during configure
85 m_xrcPrefix = huginRoot + "share/hugin/xrc/";
86 locale.AddCatalogLookupPathPrefix(huginRoot + "share/locale");
87 }
88#else
89 // add the locale directory specified during configure
90 m_xrcPrefix = INSTALL_XRC_DIR;
91 locale.AddCatalogLookupPathPrefix(INSTALL_LOCALE_DIR);
92#endif
93
94 if ( ! wxFile::Exists(m_xrcPrefix + "/lenscal_frame.xrc") )
95 {
96 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());
97 return false;
98 }
99
100 // here goes and comes configuration
101 wxConfigBase * config = wxConfigBase::Get();
102 // do not record default values in the preferences file
103 config->SetRecordDefaults(false);
104 config->Flush();
105
106 // need to explicitly initialize locale for C++ library/runtime
107 setlocale(LC_ALL, "");
108 // initialize i18n
109 int localeID = config->Read("language", (long) HUGIN_LANGUAGE);
110 DEBUG_TRACE("localeID: " << localeID);
111 {
112 bool bLInit;
113 bLInit = locale.Init(localeID);
114 if (bLInit) {
115 DEBUG_TRACE("locale init OK");
116 DEBUG_TRACE("System Locale: " << locale.GetSysName().mb_str(wxConvLocal))
117 DEBUG_TRACE("Canonical Locale: " << locale.GetCanonicalName().mb_str(wxConvLocal))
118 } else {
119 DEBUG_TRACE("locale init failed");
120 }
121 }
122
123 // set the name of locale recource to look for
124 locale.AddCatalog("hugin");
125
126 // initialize image handlers
128
129 // Initialize all the XRC handlers.
130 wxXmlResource::Get()->InitAllHandlers();
131 wxXmlResource::Get()->AddHandler(new LensCalImageCtrlXmlHandler());
132 // load XRC files
133 wxXmlResource::Get()->Load(m_xrcPrefix + "lenscal_frame.xrc");
134 wxXmlResource::Get()->Load(m_xrcPrefix + "lensdb_dialogs.xrc");
135 wxXmlResource::Get()->Load(m_xrcPrefix + "dlg_warning.xrc");
136
137 // create main frame
138 m_frame = new LensCalFrame(NULL);
139 SetTopWindow(m_frame);
140
141 // setup main frame size, after it has been created.
142 hugin_utils::RestoreFramePosition(m_frame, "LensCalFrame");
143
144 // show the frame.
145 m_frame->Show(TRUE);
146
147 // suppress tiff warnings
149
150 return true;
151}
152
153#if wxUSE_ON_FATAL_EXCEPTION
154void LensCalApp::OnFatalException()
155{
156 GenerateReport(wxDebugReport::Context_Exception);
157};
158#endif
declaration of application class for lens calibrate application
declaration of preview for lens calibration gui
void registerPTWXDlgFcn()
Definition PTWXDlg.cpp:178
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.