30 #include <vigra/imageinfo.hxx>
35 wxString extensionString(
"*.");
36 extensionString.Append(ext);
37 if (wxFileName::IsCaseSensitive())
39 extensionString.Append(
";*.").Append(ext.Upper());
41 return extensionString;
46 wxString filterString;
47 const std::string extensions = vigra::impexListExtensions();
52 exts.push_back(
"tif");
53 exts.push_back(
"tiff");
54 exts.push_back(
"jpg");
55 exts.push_back(
"jpeg");
56 exts.push_back(
"png");
58 filterString.Append(_(
"All Image files")).Append(
"|");
59 for (
auto& ext : exts)
64 filterString.RemoveLast();
65 filterString.Append(
"|");
74 filterString.Append(
"|").Append(_(
"PNG files (*.png)")).Append(
"|").Append(
GetFilterExtensions(
"png"));
75 filterString.Append(
"|").Append(_(
"HDR files (*.hdr)")).Append(
"|").Append(
GetFilterExtensions(
"hdr"));
76 filterString.Append(
"|").Append(_(
"EXR files (*.exr)")).Append(
"|").Append(
GetFilterExtensions(
"exr"));
77 filterString.Append(
"|").Append(_(
"All files (*)")).Append(
"|*");
86 filterString.Append(_(
"Raw files")).Append(
"|");
87 for (
auto& ext : exts)
92 filterString.RemoveLast();
93 filterString.Append(
"|");
97 filterString.Append(
"|").Append(_(
"PNG files (*.png)")).Append(
"|").Append(
GetFilterExtensions(
"png"));
98 filterString.Append(
"|").Append(_(
"HDR files (*.hdr)")).Append(
"|").Append(
GetFilterExtensions(
"hdr"));
99 filterString.Append(
"|").Append(_(
"EXR files (*.exr)")).Append(
"|").Append(
GetFilterExtensions(
"exr"));
106 for (
auto& ext : rawExts)
108 if (testExt.CmpNoCase(wxString(ext.c_str(), wxConvLocal)) == 0)
116 #if defined __WXMAC__ || defined __WXOSX_COCOA__
118 #include <CoreFoundation/CFBundle.h>
119 #include "wx/osx/core/cfstring.h"
122 #include "wx/utils.h"
127 CFStringRef MacCreateCFStringWithWxString(
const wxString&
string)
129 return CFStringCreateWithCString(NULL,
130 (
const char*)
string.mb_str(wxConvUTF8),
131 kCFStringEncodingUTF8);
135 wxString MacGetPathToMainExecutableFileOfBundle(CFStringRef bundlePath)
137 wxString theResult = wxT(
"");
139 CFURLRef bundleURL = CFURLCreateWithFileSystemPath(NULL, bundlePath, kCFURLPOSIXPathStyle, TRUE);
141 if(bundleURL == NULL)
143 DEBUG_INFO(
"Mac: CFURL from string (" << bundlePath <<
") failed." );
147 CFBundleRef bundle = CFBundleCreate(NULL, bundleURL);
148 CFRelease(bundleURL);
152 DEBUG_INFO(
"Mac: CFBundleCreate (" << bundlePath <<
" ) failed" );
156 CFURLRef PTOurl = CFBundleCopyExecutableURL(bundle);
160 DEBUG_INFO(
"Mac: Cannot locate the executable in the bundle.");
164 CFURLRef PTOAbsURL = CFURLCopyAbsoluteURL( PTOurl );
166 if(PTOAbsURL == NULL)
168 DEBUG_INFO(
"Mac: Cannot convert the file path to absolute");
172 CFStringRef pathInCFString = CFURLCopyFileSystemPath(PTOAbsURL, kCFURLPOSIXPathStyle);
173 CFRelease( PTOAbsURL );
174 if(pathInCFString == NULL)
176 DEBUG_INFO(
"Mac: Failed to get URL in CFString");
180 CFRetain( pathInCFString );
181 theResult = wxCFStringRef(pathInCFString).AsString(wxLocale::GetSystemEncoding());
182 DEBUG_INFO(
"Mac: the executable's full path in the application bundle: " << theResult.mb_str(wxConvLocal));
190 wxString MacGetPathToMainExecutableFileOfRegisteredBundle(CFStringRef BundleIdentifier)
192 wxString theResult = wxT(
"");
196 FSRef actuallyLaunched;
198 FSRef documentArray[1];
199 LSLaunchFSRefSpec launchSpec;
202 err = LSFindApplicationForInfo(kLSUnknownCreator,
203 CFSTR(
"net.sourceforge.hugin.PTBatcherGUI"),
209 cout <<
"PTBatcherGui check failed \n" << endl;
210 wxMessageBox(wxString::Format(_(
"External program %s not found in the bundle, reverting to system path"), wxT(
"open")), _(
"Error"));
212 if(bundleURL == NULL)
214 DEBUG_INFO(
"Mac: CFURL from string (" << bundleURL <<
") failed." );
218 CFBundleRef bundle = CFBundleCreate(NULL, bundleURL);
219 CFRelease(bundleURL);
223 DEBUG_INFO(
"Mac: CFBundleCreate (" << bundleURL <<
" ) failed" );
227 CFURLRef PTOurl = CFBundleCopyExecutableURL(bundle);
231 DEBUG_INFO(
"Mac: Cannot locate the executable in the bundle.");
235 CFURLRef PTOAbsURL = CFURLCopyAbsoluteURL( PTOurl );
237 if(PTOAbsURL == NULL)
239 DEBUG_INFO(
"Mac: Cannot convert the file path to absolute");
243 CFStringRef pathInCFString = CFURLCopyFileSystemPath(PTOAbsURL, kCFURLPOSIXPathStyle);
244 CFRelease( PTOAbsURL );
245 if(pathInCFString == NULL)
247 DEBUG_INFO(
"Mac: Failed to get URL in CFString");
251 CFRetain( pathInCFString );
252 theResult = wxCFStringRef(pathInCFString).AsString(wxLocale::GetSystemEncoding());
253 DEBUG_INFO(
"Mac: the executable's full path in the application bundle: " << theResult.mb_str(wxConvLocal));
258 cout <<
"PTBatcherGui check returned value " << theResult <<
"\n" << endl;
262 #if defined MAC_SELF_CONTAINED_BUNDLE
264 wxString MacGetPathToBundledAppMainExecutableFile(CFStringRef appname)
266 wxString theResult = wxT(
"");
268 CFBundleRef mainbundle = CFBundleGetMainBundle();
269 if(mainbundle == NULL)
275 CFURLRef XRCurl = CFBundleCopyResourceURL(mainbundle, appname, NULL, NULL);
278 DEBUG_INFO(
"Mac: Cannot locate the bundle in bundle.");
282 CFBundleRef bundledBundle = CFBundleCreate(NULL, XRCurl);
285 if(bundledBundle == NULL)
291 CFURLRef PTOurl = CFBundleCopyExecutableURL(bundledBundle);
292 CFRelease( bundledBundle );
296 DEBUG_INFO(
"Mac: Cannot locate the executable in the bundle.");
300 CFURLRef PTOAbsURL = CFURLCopyAbsoluteURL( PTOurl );
302 if(PTOAbsURL == NULL)
304 DEBUG_INFO(
"Mac: Cannot convert the file path to absolute");
308 CFStringRef pathInCFString = CFURLCopyFileSystemPath(PTOAbsURL, kCFURLPOSIXPathStyle);
309 CFRelease( PTOAbsURL );
310 if(pathInCFString == NULL)
312 DEBUG_INFO(
"Mac: Failed to get URL in CFString");
316 CFRetain( pathInCFString );
317 theResult = wxCFStringRef(pathInCFString).AsString(wxLocale::GetSystemEncoding());
318 DEBUG_INFO(
"Mac: the executable's full path in the application bundle: " << theResult.mb_str(wxConvLocal));
328 wxString MacGetPathToBundledResourceFile(CFStringRef filename)
330 wxString theResult = wxT(
"");
332 CFBundleRef mainbundle = CFBundleGetMainBundle();
333 if(mainbundle == NULL)
339 CFURLRef XRCurl = CFBundleCopyResourceURL(mainbundle, filename, NULL, NULL);
342 DEBUG_INFO(
"Mac: Cannot locate the file in bundle.");
346 CFStringRef pathInCFString = CFURLCopyFileSystemPath(XRCurl, kCFURLPOSIXPathStyle);
348 if(pathInCFString == NULL)
350 DEBUG_INFO(
"Mac: Failed to get URL in CFString");
354 CFRetain( pathInCFString );
355 theResult = wxCFStringRef(pathInCFString).AsString(wxLocale::GetSystemEncoding());
356 DEBUG_INFO(
"Mac: the resource file's path in the application bundle: " << theResult.mb_str(wxConvLocal));
363 wxString MacGetPathToBundledFrameworksDirectory()
365 wxString theResult = wxT(
"");
367 CFBundleRef mainbundle = CFBundleGetMainBundle();
368 if(mainbundle == NULL)
374 CFURLRef XRCurl = CFBundleCopyBundleURL(mainbundle);
377 DEBUG_INFO(
"Mac: Cannot locate the file in bundle.");
381 CFStringRef pathInCFString = CFURLCopyFileSystemPath(XRCurl, kCFURLPOSIXPathStyle);
383 if(pathInCFString == NULL)
385 DEBUG_INFO(
"Mac: Failed to get URL in CFString");
389 CFRetain( pathInCFString );
390 theResult = wxCFStringRef(pathInCFString).AsString(wxLocale::GetSystemEncoding());
391 DEBUG_INFO(
"Mac: the Frameworks file's path in the application bundle: " << theResult.mb_str(wxConvLocal));
395 return theResult + wxT(
"/Contents/Frameworks");
398 wxString MacGetPathToBundledExecutableFile(CFStringRef filename)
400 wxString theResult = wxT(
"");
402 CFBundleRef mainbundle = CFBundleGetMainBundle();
403 if(mainbundle == NULL)
409 CFURLRef PTOurl = CFBundleCopyAuxiliaryExecutableURL(mainbundle, filename);
412 DEBUG_INFO(
"Mac: Cannot locate the file in the bundle.");
416 CFURLRef PTOAbsURL = CFURLCopyAbsoluteURL( PTOurl );
417 if(PTOAbsURL == NULL)
419 DEBUG_INFO(
"Mac: Cannot convert the file path to absolute");
423 CFStringRef pathInCFString = CFURLCopyFileSystemPath(PTOAbsURL, kCFURLPOSIXPathStyle);
424 CFRelease( PTOAbsURL );
425 if(pathInCFString == NULL)
427 DEBUG_INFO(
"Mac: Failed to get URL in CFString");
431 CFRetain( pathInCFString );
432 theResult = wxCFStringRef(pathInCFString).AsString(wxLocale::GetSystemEncoding());
433 DEBUG_INFO(
"Mac: executable's full path in the application bundle: " << theResult.mb_str(wxConvLocal));
442 wxString MacGetPathToUserDomainTempDir()
444 wxString tmpDirPath = wxT(
"");
447 OSErr err = FSFindFolder(kUserDomain, kTemporaryFolderType, kCreateFolder, &tempDirRef);
450 CFURLRef tempDirURL = CFURLCreateFromFSRef(kCFAllocatorSystemDefault, &tempDirRef);
451 if (tempDirURL != NULL)
453 CFStringRef tmpPath = CFURLCopyFileSystemPath(tempDirURL, kCFURLPOSIXPathStyle);
455 tmpDirPath = wxCFStringRef(tmpPath).AsString(wxLocale::GetSystemEncoding());
456 CFRelease(tempDirURL);
463 wxString MacGetPathToUserAppSupportAutoPanoFolder()
465 wxString appSupportAutoPanoFolder = wxT(
"");
467 FSRef appSupportFolder;
468 OSErr err = FSFindFolder(kUserDomain,kApplicationSupportFolderType,kDontCreateFolder,&appSupportFolder);
471 CFURLRef appSupportFolderURL = CFURLCreateFromFSRef(kCFAllocatorDefault,&appSupportFolder);
472 CFURLRef appSupportHugin = CFURLCreateCopyAppendingPathComponent(kCFAllocatorDefault,appSupportFolderURL,CFSTR(
"Hugin"),
true);
473 CFURLRef autopanoURL = CFURLCreateCopyAppendingPathComponent(kCFAllocatorDefault,appSupportHugin,CFSTR(
"Autopano"),
true);
474 CFStringRef tmpPath = CFURLCopyFileSystemPath(autopanoURL, kCFURLPOSIXPathStyle);
476 appSupportAutoPanoFolder = wxCFStringRef(tmpPath).AsString(wxLocale::GetSystemEncoding());
477 CFRelease(autopanoURL);
479 return appSupportAutoPanoFolder;
483 #endif // MAC_SELF_CONTAINED_BUNDLE
489 #if defined __WXMSW__
492 return wxEmptyString;
498 return wxT(
"*?<>|\"\\~");
504 if(stringToTest.IsEmpty())
507 for(
unsigned int j=0;j<forbiddenChars.size();j++)
509 if(stringToTest.Find(forbiddenChars[j])!=wxNOT_FOUND)
518 wxXmlResource::Get()->LoadDialog(&dlg, parent, wxT(
"dlg_warning_filename"));
519 XRCCTRL(dlg,
"dlg_warning_text", wxStaticText)->SetLabel(wxString::Format(_(
"The filename(s) contains one of the following invalid characters: %s\nHugin can not work with these filenames. Please rename your file(s) and try again."),
getInvalidCharacters().c_str()));
520 XRCCTRL(dlg,
"dlg_warning_list", wxListBox)->Append(filelist);
522 dlg.CenterOnScreen();
526 #if wxUSE_ON_FATAL_EXCEPTION
527 void GenerateReport(wxDebugReport::Context ctx)
530 wxDebugReportCompress report;
532 if (wxDebugReportPreviewStd().Show(report))
534 if (report.Process())
536 wxLogMessage(_(
"Debug report generated in \"%s\"."), report.GetCompressedFileName().c_str());
std::vector< std::string > GetRawExtensions()
return vector of known extensions of raw files, all lower case
std::vector< std::string > SplitString(const std::string &s, const std::string &sep)
split string s at given sep, returns vector of strings