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(_(
"HDR files (*.hdr)")).Append(
"|").Append(
GetFilterExtensions(
"hdr"));
75 filterString.Append(
"|").Append(_(
"EXR files (*.exr)")).Append(
"|").Append(
GetFilterExtensions(
"exr"));
76 filterString.Append(
"|").Append(_(
"All files (*)")).Append(
"|*");
82 wxString filterString;
85 filterString.Append(
"|").Append(_(
"PNG files (*.png)")).Append(
"|").Append(
GetFilterExtensions(
"png"));
94 filterString.Append(_(
"Raw files")).Append(
"|");
95 for (
auto& ext : exts)
100 filterString.RemoveLast();
101 filterString.Append(
"|");
105 filterString.Append(
"|").Append(_(
"PNG files (*.png)")).Append(
"|").Append(
GetFilterExtensions(
"png"));
106 filterString.Append(
"|").Append(_(
"HDR files (*.hdr)")).Append(
"|").Append(
GetFilterExtensions(
"hdr"));
107 filterString.Append(
"|").Append(_(
"EXR files (*.exr)")).Append(
"|").Append(
GetFilterExtensions(
"exr"));
114 for (
auto& ext : rawExts)
116 if (testExt.CmpNoCase(wxString(ext.c_str(), wxConvLocal)) == 0)
124 #if defined __WXMAC__ || defined __WXOSX_COCOA__
126 #include <CoreFoundation/CFBundle.h>
127 #include "wx/osx/core/cfstring.h"
130 #include "wx/utils.h"
135 CFStringRef MacCreateCFStringWithWxString(
const wxString&
string)
137 return CFStringCreateWithCString(NULL,
138 (
const char*)
string.mb_str(wxConvUTF8),
139 kCFStringEncodingUTF8);
143 wxString MacGetPathToMainExecutableFileOfBundle(CFStringRef bundlePath)
145 wxString theResult = wxT(
"");
147 CFURLRef bundleURL = CFURLCreateWithFileSystemPath(NULL, bundlePath, kCFURLPOSIXPathStyle, TRUE);
149 if(bundleURL == NULL)
151 DEBUG_INFO(
"Mac: CFURL from string (" << bundlePath <<
") failed." );
155 CFBundleRef bundle = CFBundleCreate(NULL, bundleURL);
156 CFRelease(bundleURL);
160 DEBUG_INFO(
"Mac: CFBundleCreate (" << bundlePath <<
" ) failed" );
164 CFURLRef PTOurl = CFBundleCopyExecutableURL(bundle);
168 DEBUG_INFO(
"Mac: Cannot locate the executable in the bundle.");
172 CFURLRef PTOAbsURL = CFURLCopyAbsoluteURL( PTOurl );
174 if(PTOAbsURL == NULL)
176 DEBUG_INFO(
"Mac: Cannot convert the file path to absolute");
180 CFStringRef pathInCFString = CFURLCopyFileSystemPath(PTOAbsURL, kCFURLPOSIXPathStyle);
181 CFRelease( PTOAbsURL );
182 if(pathInCFString == NULL)
184 DEBUG_INFO(
"Mac: Failed to get URL in CFString");
188 CFRetain( pathInCFString );
189 theResult = wxCFStringRef(pathInCFString).AsString(wxLocale::GetSystemEncoding());
190 DEBUG_INFO(
"Mac: the executable's full path in the application bundle: " << theResult.mb_str(wxConvLocal));
198 wxString MacGetPathToMainExecutableFileOfRegisteredBundle(CFStringRef BundleIdentifier)
200 wxString theResult = wxT(
"");
204 FSRef actuallyLaunched;
206 FSRef documentArray[1];
207 LSLaunchFSRefSpec launchSpec;
210 err = LSFindApplicationForInfo(kLSUnknownCreator,
211 CFSTR(
"net.sourceforge.hugin.PTBatcherGUI"),
217 cout <<
"PTBatcherGui check failed \n" << endl;
218 wxMessageBox(wxString::Format(_(
"External program %s not found in the bundle, reverting to system path"), wxT(
"open")), _(
"Error"));
220 if(bundleURL == NULL)
222 DEBUG_INFO(
"Mac: CFURL from string (" << bundleURL <<
") failed." );
226 CFBundleRef bundle = CFBundleCreate(NULL, bundleURL);
227 CFRelease(bundleURL);
231 DEBUG_INFO(
"Mac: CFBundleCreate (" << bundleURL <<
" ) failed" );
235 CFURLRef PTOurl = CFBundleCopyExecutableURL(bundle);
239 DEBUG_INFO(
"Mac: Cannot locate the executable in the bundle.");
243 CFURLRef PTOAbsURL = CFURLCopyAbsoluteURL( PTOurl );
245 if(PTOAbsURL == NULL)
247 DEBUG_INFO(
"Mac: Cannot convert the file path to absolute");
251 CFStringRef pathInCFString = CFURLCopyFileSystemPath(PTOAbsURL, kCFURLPOSIXPathStyle);
252 CFRelease( PTOAbsURL );
253 if(pathInCFString == NULL)
255 DEBUG_INFO(
"Mac: Failed to get URL in CFString");
259 CFRetain( pathInCFString );
260 theResult = wxCFStringRef(pathInCFString).AsString(wxLocale::GetSystemEncoding());
261 DEBUG_INFO(
"Mac: the executable's full path in the application bundle: " << theResult.mb_str(wxConvLocal));
266 cout <<
"PTBatcherGui check returned value " << theResult <<
"\n" << endl;
270 #if defined MAC_SELF_CONTAINED_BUNDLE
272 wxString MacGetPathToBundledAppMainExecutableFile(CFStringRef appname)
274 wxString theResult = wxT(
"");
276 CFBundleRef mainbundle = CFBundleGetMainBundle();
277 if(mainbundle == NULL)
283 CFURLRef XRCurl = CFBundleCopyResourceURL(mainbundle, appname, NULL, NULL);
286 DEBUG_INFO(
"Mac: Cannot locate the bundle in bundle.");
290 CFBundleRef bundledBundle = CFBundleCreate(NULL, XRCurl);
293 if(bundledBundle == NULL)
299 CFURLRef PTOurl = CFBundleCopyExecutableURL(bundledBundle);
300 CFRelease( bundledBundle );
304 DEBUG_INFO(
"Mac: Cannot locate the executable in the bundle.");
308 CFURLRef PTOAbsURL = CFURLCopyAbsoluteURL( PTOurl );
310 if(PTOAbsURL == NULL)
312 DEBUG_INFO(
"Mac: Cannot convert the file path to absolute");
316 CFStringRef pathInCFString = CFURLCopyFileSystemPath(PTOAbsURL, kCFURLPOSIXPathStyle);
317 CFRelease( PTOAbsURL );
318 if(pathInCFString == NULL)
320 DEBUG_INFO(
"Mac: Failed to get URL in CFString");
324 CFRetain( pathInCFString );
325 theResult = wxCFStringRef(pathInCFString).AsString(wxLocale::GetSystemEncoding());
326 DEBUG_INFO(
"Mac: the executable's full path in the application bundle: " << theResult.mb_str(wxConvLocal));
336 wxString MacGetPathToBundledResourceFile(CFStringRef filename)
338 wxString theResult = wxT(
"");
340 CFBundleRef mainbundle = CFBundleGetMainBundle();
341 if(mainbundle == NULL)
347 CFURLRef XRCurl = CFBundleCopyResourceURL(mainbundle, filename, NULL, NULL);
350 DEBUG_INFO(
"Mac: Cannot locate the file in bundle.");
354 CFStringRef pathInCFString = CFURLCopyFileSystemPath(XRCurl, kCFURLPOSIXPathStyle);
356 if(pathInCFString == NULL)
358 DEBUG_INFO(
"Mac: Failed to get URL in CFString");
362 CFRetain( pathInCFString );
363 theResult = wxCFStringRef(pathInCFString).AsString(wxLocale::GetSystemEncoding());
364 DEBUG_INFO(
"Mac: the resource file's path in the application bundle: " << theResult.mb_str(wxConvLocal));
371 wxString MacGetPathToBundledFrameworksDirectory()
373 wxString theResult = wxT(
"");
375 CFBundleRef mainbundle = CFBundleGetMainBundle();
376 if(mainbundle == NULL)
382 CFURLRef XRCurl = CFBundleCopyBundleURL(mainbundle);
385 DEBUG_INFO(
"Mac: Cannot locate the file in bundle.");
389 CFStringRef pathInCFString = CFURLCopyFileSystemPath(XRCurl, kCFURLPOSIXPathStyle);
391 if(pathInCFString == NULL)
393 DEBUG_INFO(
"Mac: Failed to get URL in CFString");
397 CFRetain( pathInCFString );
398 theResult = wxCFStringRef(pathInCFString).AsString(wxLocale::GetSystemEncoding());
399 DEBUG_INFO(
"Mac: the Frameworks file's path in the application bundle: " << theResult.mb_str(wxConvLocal));
403 return theResult + wxT(
"/Contents/Frameworks");
406 wxString MacGetPathToBundledExecutableFile(CFStringRef filename)
408 wxString theResult = wxT(
"");
410 CFBundleRef mainbundle = CFBundleGetMainBundle();
411 if(mainbundle == NULL)
417 CFURLRef PTOurl = CFBundleCopyAuxiliaryExecutableURL(mainbundle, filename);
420 DEBUG_INFO(
"Mac: Cannot locate the file in the bundle.");
424 CFURLRef PTOAbsURL = CFURLCopyAbsoluteURL( PTOurl );
425 if(PTOAbsURL == NULL)
427 DEBUG_INFO(
"Mac: Cannot convert the file path to absolute");
431 CFStringRef pathInCFString = CFURLCopyFileSystemPath(PTOAbsURL, kCFURLPOSIXPathStyle);
432 CFRelease( PTOAbsURL );
433 if(pathInCFString == NULL)
435 DEBUG_INFO(
"Mac: Failed to get URL in CFString");
439 CFRetain( pathInCFString );
440 theResult = wxCFStringRef(pathInCFString).AsString(wxLocale::GetSystemEncoding());
441 DEBUG_INFO(
"Mac: executable's full path in the application bundle: " << theResult.mb_str(wxConvLocal));
450 wxString MacGetPathToUserDomainTempDir()
452 wxString tmpDirPath = wxT(
"");
455 OSErr err = FSFindFolder(kUserDomain, kTemporaryFolderType, kCreateFolder, &tempDirRef);
458 CFURLRef tempDirURL = CFURLCreateFromFSRef(kCFAllocatorSystemDefault, &tempDirRef);
459 if (tempDirURL != NULL)
461 CFStringRef tmpPath = CFURLCopyFileSystemPath(tempDirURL, kCFURLPOSIXPathStyle);
463 tmpDirPath = wxCFStringRef(tmpPath).AsString(wxLocale::GetSystemEncoding());
464 CFRelease(tempDirURL);
471 wxString MacGetPathToUserAppSupportAutoPanoFolder()
473 wxString appSupportAutoPanoFolder = wxT(
"");
475 FSRef appSupportFolder;
476 OSErr err = FSFindFolder(kUserDomain,kApplicationSupportFolderType,kDontCreateFolder,&appSupportFolder);
479 CFURLRef appSupportFolderURL = CFURLCreateFromFSRef(kCFAllocatorDefault,&appSupportFolder);
480 CFURLRef appSupportHugin = CFURLCreateCopyAppendingPathComponent(kCFAllocatorDefault,appSupportFolderURL,CFSTR(
"Hugin"),
true);
481 CFURLRef autopanoURL = CFURLCreateCopyAppendingPathComponent(kCFAllocatorDefault,appSupportHugin,CFSTR(
"Autopano"),
true);
482 CFStringRef tmpPath = CFURLCopyFileSystemPath(autopanoURL, kCFURLPOSIXPathStyle);
484 appSupportAutoPanoFolder = wxCFStringRef(tmpPath).AsString(wxLocale::GetSystemEncoding());
485 CFRelease(autopanoURL);
487 return appSupportAutoPanoFolder;
491 #endif // MAC_SELF_CONTAINED_BUNDLE
497 #if defined __WXMSW__
500 return wxEmptyString;
506 return wxT(
"*?<>|\"\\~");
512 if(stringToTest.IsEmpty())
515 for(
unsigned int j=0;j<forbiddenChars.size();j++)
517 if(stringToTest.Find(forbiddenChars[j])!=wxNOT_FOUND)
526 wxXmlResource::Get()->LoadDialog(&dlg, parent, wxT(
"dlg_warning_filename"));
527 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()));
528 XRCCTRL(dlg,
"dlg_warning_list", wxListBox)->Append(filelist);
530 dlg.CenterOnScreen();
534 #if wxUSE_ON_FATAL_EXCEPTION
535 void GenerateReport(wxDebugReport::Context ctx)
538 wxDebugReportCompress report;
540 if (wxDebugReportPreviewStd().Show(report))
542 if (report.Process())
544 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