[d5c5e9]: src / hugin1 / base_wx / huginConfig.cpp  Maximize  Restore  History

Download this file

152 lines (132 with data), 5.3 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// -*- c-basic-offset: 4 -*-
/** @file huginConfig.cpp
*
* @brief functions for interaction with the hugin configuration file
*
* @author Pablo d'Angelo <pablo.dangelo@web.de>
*
* $Id$
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "huginConfig.h"
#include "hugin/config_defaults.h"
#include "platform.h"
using namespace PT;
std::string getProgram(wxConfigBase * config, wxString bindir, wxString file, wxString name)
{
std::string pname;
#if defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
if (config->Read(name + wxT("/Custom"), 0l)) {
wxString fn = config->Read(name + wxT("/Exe"),wxT(""));
if (wxFileName::FileExists(fn)) {
pname = fn.mb_str();
return pname;
} else {
wxMessageBox(wxString::Format(_("External program %s not found as specified in preferences, reverting to bundled version"), file.c_str()), _("Error"));
}
}
CFStringRef filename = CFStringCreateWithCString(NULL,
(const char*)file.mb_str(wxConvUTF8),
kCFStringEncodingUTF8);
wxString fn = MacGetPathTOBundledExecutableFile(filename);
CFRelease(filename);
if(fn == wxT(""))
{
wxMessageBox(wxString::Format(_("External program %s not found in the bundle, reverting to system path"), file.c_str()), _("Error"));
pname = file.mb_str();
} else {
pname = fn.mb_str();
}
return pname;
#elif defined __WXMSW__
if (config->Read(name + wxT("/Custom"), 0l)) {
wxString fn = config->Read(name + wxT("/Exe"),wxT(""));
if (wxFileName::FileExists(fn)) {
pname = fn.mb_str();
} else {
wxMessageBox(wxString::Format(_("External program %s not found as specified in preferences, reverting to bundled version"), file.c_str()), _("Error"));
pname = (bindir + wxT("\\") + file).mb_str();
}
} else {
pname = (bindir + wxT("\\") + file).mb_str();
}
return pname;
#else
// unix, never bundled
if (config->Read(name + wxT("/Custom"), 0l)) {
wxString fn = config->Read(name + wxT("/Exe"),wxT(""));
pname = fn.mb_str();
return pname;
// TODO: need to search path, a simple FileExists() doesn't work as expected.
/*
if (wxFileName::FileExists(fn)) {
pname = fn.mb_str();
return pname;
} else {
wxMessageBox(wxString::Format(_("External program %s not found as specified in preferences, reverting to system path"), file.c_str()), _("Error"));
}
*/
}
pname = file.mb_str();
return pname;
#endif
}
PTPrograms getPTProgramsConfig(wxString bundledBinDir, wxConfigBase * config)
{
PTPrograms progs;
wxString bindir;
#ifndef __WXGTK__
// add trailing directory separator, if needed
wxFileName bindirFN = wxFileName::DirName(bundledBinDir);
bindir = bindirFN.GetPath();
#endif
progs.PTmender = getProgram(config,bindir, wxT("PTmender"), wxT("PTmender"));
progs.PTblender= getProgram(config,bindir, wxT("PTblender"), wxT("PTblender"));
progs.PTmasker= getProgram(config,bindir, wxT("PTmasker"), wxT("PTmasker"));
progs.PTroller= getProgram(config,bindir, wxT("PTroller"), wxT("PTroller"));
progs.enblend = getProgram(config,bindir, wxT("enblend"), wxT("Enblend"));
progs.enblend_opts = config->Read(wxT("/Enblend/Args"), wxT(HUGIN_ENBLEND_ARGS)).mb_str();
progs.enfuse = getProgram(config,bindir, wxT("enfuse"), wxT("Enfuse"));
progs.enfuse_opts = config->Read(wxT("/Enfuse/Args"), wxT(HUGIN_ENFUSE_ARGS)).mb_str();
// smartblend (never bundled)
progs.smartblend = config->Read(wxT("/Smartblend/SmartblendExe"),wxT("smartblend.exe")).mb_str();
progs.smartblend_opts = config->Read(wxT("/Smartblend/SmartblendArgs"),wxT(HUGIN_SMARTBLEND_ARGS)).mb_str();
return progs;
}
wxString getExePath(wxString argv0)
{
wxString huginPath;
#ifdef __WXMSW__
// special code to find location of hugin.exe under windows
#if wxUSE_UNICODE
WCHAR tpath[MAX_PATH];
#else //ANSI
char tpath[MAX_PATH];
#endif
tpath[0] = 0;
GetModuleFileName(0,tpath,sizeof(tpath)-1);
#ifdef wxUSE_UNICODE
wxString path(tpath);
#else
wxString path(tpath, wxConvLocal);
#endif
wxFileName::SplitPath( path, &huginPath, NULL, NULL );
#else
wxFileName::SplitPath( argv0, &huginPath, NULL, NULL );
#endif
return huginPath;
}

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks