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