Hugin trunk 0.1
Loading...
Searching...
No Matches
ToolboxApp.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 "ToolboxApp.h"
34#include "ToolboxFrame.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
45
47{
48#if wxUSE_ON_FATAL_EXCEPTION
50#endif
51 SetAppName("hugin");
52#if defined __WXMSW__ && wxCHECK_VERSION(3,3,0)
53 // automatically switch between light and dark mode
54 SetAppearance(Appearance::System);
55#endif
56#if defined __WXGTK__
58#endif
59 // register our custom pano tools dialog handlers
61
62#if defined __WXMSW__
63 wxFileName exeDir(wxStandardPaths::Get().GetExecutablePath());
64 exeDir.RemoveLastDir();
65 m_xrcPrefix = exeDir.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) + "share\\hugin\\xrc\\";
66 // locale setup
67 locale.AddCatalogLookupPathPrefix(exeDir.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) + "share\\locale");
68#elif defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
69 // initialize paths
71 if (thePath == "")
72 {
73 hugin_utils::HuginMessageBox(_("xrc directory not found in bundle"), _("Hugin toolbox"), wxOK | wxICON_ERROR, wxGetActiveWindow());
74 return false;
75 }
76 m_xrcPrefix = thePath + "/";
77#elif defined UNIX_SELF_CONTAINED_BUNDLE
78 // initialize paths
79 {
80 wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
81 exePath.RemoveLastDir();
83 // add the locale directory specified during configure
84 m_xrcPrefix = huginRoot + "share/hugin/xrc/";
85 locale.AddCatalogLookupPathPrefix(huginRoot + "share/locale");
86 }
87#else
88 // add the locale directory specified during configure
89 m_xrcPrefix = INSTALL_XRC_DIR;
90 locale.AddCatalogLookupPathPrefix(INSTALL_LOCALE_DIR);
91#endif
92
93 if ( ! wxFile::Exists(m_xrcPrefix + "/toolbox_panel.xrc") )
94 {
95 hugin_utils::HuginMessageBox(wxString::Format(_("xrc directory not found, hugin needs to be properly installed\nTried Path: %s"), m_xrcPrefix), _("Hugin toolbox"), wxOK | wxICON_ERROR, wxGetActiveWindow());
96 return false;
97 }
98
99 // here goes and comes configuration
100 wxConfigBase * config = wxConfigBase::Get();
101 // do not record default values in the preferences file
102 config->SetRecordDefaults(false);
103 config->Flush();
104
105 // need to explicitly initialize locale for C++ library/runtime
106 setlocale(LC_ALL, "");
107 // initialize i18n
108 int localeID = config->Read("language", (long) HUGIN_LANGUAGE);
109 DEBUG_TRACE("localeID: " << localeID);
110 {
111 bool bLInit = locale.Init(localeID);
112 if (bLInit)
113 {
114 DEBUG_TRACE("locale init OK");
115 DEBUG_TRACE("System Locale: " << locale.GetSysName().mb_str(wxConvLocal));
116 DEBUG_TRACE("Canonical Locale: " << locale.GetCanonicalName().mb_str(wxConvLocal))
117 }
118 else
119 {
120 DEBUG_TRACE("locale init failed");
121 }
122 }
123
124 // set the name of locale recource to look for
125 locale.AddCatalog("hugin");
126
127 // initialize image handlers
129
130 // Initialize all the XRC handlers.
131 wxXmlResource::Get()->InitAllHandlers();
132 // load XRC files
133 wxXmlResource::Get()->Load(m_xrcPrefix + "toolbox_panel.xrc");
134
135 // create main frame
136 m_frame = new ToolboxFrame(NULL);
137 SetTopWindow(m_frame);
138 // show the frame.
139 m_frame->Show(TRUE);
140
141 // suppress tiff warnings
143
144 return true;
145}
146
147#if wxUSE_ON_FATAL_EXCEPTION
148void ToolboxApp::OnFatalException()
149{
150 GenerateReport(wxDebugReport::Context_Exception);
151};
152#endif
void registerPTWXDlgFcn()
Definition PTWXDlg.cpp:178
declaration of main frame class for toolbox GUI
The application class for toolbox app.
Definition ToolboxApp.h:35
The main window frame.
#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
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.