31 #include <vigra/imageinfo.hxx>
36 wxString extensionString(
"*.");
37 extensionString.Append(ext);
38 if (wxFileName::IsCaseSensitive())
40 extensionString.Append(
";*.").Append(ext.Upper());
42 return extensionString;
47 wxString filterString;
48 const std::string extensions = vigra::impexListExtensions();
53 exts.push_back(
"tif");
54 exts.push_back(
"tiff");
55 exts.push_back(
"jpg");
56 exts.push_back(
"jpeg");
57 exts.push_back(
"png");
59 filterString.Append(_(
"All Image files")).Append(
"|");
60 for (
auto& ext : exts)
65 filterString.RemoveLast();
66 filterString.Append(
"|");
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(
"|*");
83 wxString filterString;
86 filterString.Append(
"|").Append(_(
"PNG files (*.png)")).Append(
"|").Append(
GetFilterExtensions(
"png"));
95 filterString.Append(_(
"Raw files")).Append(
"|");
96 for (
auto& ext : exts)
101 filterString.RemoveLast();
102 filterString.Append(
"|");
106 filterString.Append(
"|").Append(_(
"PNG files (*.png)")).Append(
"|").Append(
GetFilterExtensions(
"png"));
107 filterString.Append(
"|").Append(_(
"HDR files (*.hdr)")).Append(
"|").Append(
GetFilterExtensions(
"hdr"));
108 filterString.Append(
"|").Append(_(
"EXR files (*.exr)")).Append(
"|").Append(
GetFilterExtensions(
"exr"));
115 for (
auto& ext : rawExts)
117 if (testExt.CmpNoCase(wxString(ext.c_str(), wxConvLocal)) == 0)
125 #if defined __WXMAC__ || defined __WXOSX_COCOA__
127 #include <CoreFoundation/CFBundle.h>
128 #include "wx/osx/core/cfstring.h"
131 #include "wx/utils.h"
136 CFStringRef MacCreateCFStringWithWxString(
const wxString&
string)
138 return CFStringCreateWithCString(NULL,
139 (
const char*)
string.mb_str(wxConvUTF8),
140 kCFStringEncodingUTF8);
144 wxString MacGetPathToMainExecutableFileOfBundle(CFStringRef bundlePath)
146 wxString theResult = wxEmptyString;
148 CFURLRef bundleURL = CFURLCreateWithFileSystemPath(NULL, bundlePath, kCFURLPOSIXPathStyle, TRUE);
150 if(bundleURL == NULL)
152 DEBUG_INFO(
"Mac: CFURL from string (" << bundlePath <<
") failed." );
156 CFBundleRef bundle = CFBundleCreate(NULL, bundleURL);
157 CFRelease(bundleURL);
161 DEBUG_INFO(
"Mac: CFBundleCreate (" << bundlePath <<
" ) failed" );
165 CFURLRef PTOurl = CFBundleCopyExecutableURL(bundle);
169 DEBUG_INFO(
"Mac: Cannot locate the executable in the bundle.");
173 CFURLRef PTOAbsURL = CFURLCopyAbsoluteURL( PTOurl );
175 if(PTOAbsURL == NULL)
177 DEBUG_INFO(
"Mac: Cannot convert the file path to absolute");
181 CFStringRef pathInCFString = CFURLCopyFileSystemPath(PTOAbsURL, kCFURLPOSIXPathStyle);
182 CFRelease( PTOAbsURL );
183 if(pathInCFString == NULL)
185 DEBUG_INFO(
"Mac: Failed to get URL in CFString");
189 CFRetain( pathInCFString );
190 theResult = wxCFStringRef(pathInCFString).AsString();
191 DEBUG_INFO(
"Mac: the executable's full path in the application bundle: " << theResult.mb_str(wxConvLocal));
199 wxString MacGetPathToMainExecutableFileOfRegisteredBundle(CFStringRef BundleIdentifier)
201 wxString theResult = wxEmptyString;
205 FSRef actuallyLaunched;
207 FSRef documentArray[1];
208 LSLaunchFSRefSpec launchSpec;
211 err = LSFindApplicationForInfo(kLSUnknownCreator,
212 CFSTR(
"net.sourceforge.hugin.PTBatcherGUI"),
218 cout <<
"PTBatcherGui check failed \n" << endl;
219 hugin_utils::HuginMessageBox(wxString::Format(_(
"External program %s not found in the bundle, reverting to system path"),
"open"), _(
"Hugin"), wxOK, wxGetActiveWindow());
221 if(bundleURL == NULL)
223 DEBUG_INFO(
"Mac: CFURL from string (" << bundleURL <<
") failed." );
227 CFBundleRef bundle = CFBundleCreate(NULL, bundleURL);
228 CFRelease(bundleURL);
232 DEBUG_INFO(
"Mac: CFBundleCreate (" << bundleURL <<
" ) failed" );
236 CFURLRef PTOurl = CFBundleCopyExecutableURL(bundle);
240 DEBUG_INFO(
"Mac: Cannot locate the executable in the bundle.");
244 CFURLRef PTOAbsURL = CFURLCopyAbsoluteURL( PTOurl );
246 if(PTOAbsURL == NULL)
248 DEBUG_INFO(
"Mac: Cannot convert the file path to absolute");
252 CFStringRef pathInCFString = CFURLCopyFileSystemPath(PTOAbsURL, kCFURLPOSIXPathStyle);
253 CFRelease( PTOAbsURL );
254 if(pathInCFString == NULL)
256 DEBUG_INFO(
"Mac: Failed to get URL in CFString");
260 CFRetain( pathInCFString );
261 theResult = wxCFStringRef(pathInCFString).AsString();
262 DEBUG_INFO(
"Mac: the executable's full path in the application bundle: " << theResult.mb_str(wxConvLocal));
267 cout <<
"PTBatcherGui check returned value " << theResult <<
"\n" << endl;
271 #if defined MAC_SELF_CONTAINED_BUNDLE
273 wxString MacGetPathToBundledAppMainExecutableFile(CFStringRef appname)
275 wxString theResult = wxEmptyString;
277 CFBundleRef mainbundle = CFBundleGetMainBundle();
278 if(mainbundle == NULL)
284 CFURLRef XRCurl = CFBundleCopyResourceURL(mainbundle, appname, NULL, NULL);
287 DEBUG_INFO(
"Mac: Cannot locate the bundle in bundle.");
291 CFBundleRef bundledBundle = CFBundleCreate(NULL, XRCurl);
294 if(bundledBundle == NULL)
300 CFURLRef PTOurl = CFBundleCopyExecutableURL(bundledBundle);
301 CFRelease( bundledBundle );
305 DEBUG_INFO(
"Mac: Cannot locate the executable in the bundle.");
309 CFURLRef PTOAbsURL = CFURLCopyAbsoluteURL( PTOurl );
311 if(PTOAbsURL == NULL)
313 DEBUG_INFO(
"Mac: Cannot convert the file path to absolute");
317 CFStringRef pathInCFString = CFURLCopyFileSystemPath(PTOAbsURL, kCFURLPOSIXPathStyle);
318 CFRelease( PTOAbsURL );
319 if(pathInCFString == NULL)
321 DEBUG_INFO(
"Mac: Failed to get URL in CFString");
325 CFRetain( pathInCFString );
326 theResult = wxCFStringRef(pathInCFString).AsString();
327 DEBUG_INFO(
"Mac: the executable's full path in the application bundle: " << theResult.mb_str(wxConvLocal));
337 wxString MacGetPathToBundledResourceFile(CFStringRef filename)
339 wxString theResult = wxEmptyString;
341 CFBundleRef mainbundle = CFBundleGetMainBundle();
342 if(mainbundle == NULL)
348 CFURLRef XRCurl = CFBundleCopyResourceURL(mainbundle, filename, NULL, NULL);
351 DEBUG_INFO(
"Mac: Cannot locate the file in bundle.");
355 CFStringRef pathInCFString = CFURLCopyFileSystemPath(XRCurl, kCFURLPOSIXPathStyle);
357 if(pathInCFString == NULL)
359 DEBUG_INFO(
"Mac: Failed to get URL in CFString");
363 CFRetain( pathInCFString );
364 theResult = wxCFStringRef(pathInCFString).AsString();
365 DEBUG_INFO(
"Mac: the resource file's path in the application bundle: " << theResult.mb_str(wxConvLocal));
372 wxString MacGetPathToBundledFrameworksDirectory()
374 wxString theResult = wxEmptyString;
376 CFBundleRef mainbundle = CFBundleGetMainBundle();
377 if(mainbundle == NULL)
383 CFURLRef XRCurl = CFBundleCopyBundleURL(mainbundle);
386 DEBUG_INFO(
"Mac: Cannot locate the file in bundle.");
390 CFStringRef pathInCFString = CFURLCopyFileSystemPath(XRCurl, kCFURLPOSIXPathStyle);
392 if(pathInCFString == NULL)
394 DEBUG_INFO(
"Mac: Failed to get URL in CFString");
398 CFRetain( pathInCFString );
399 theResult = wxCFStringRef(pathInCFString).AsString();
400 DEBUG_INFO(
"Mac: the Frameworks file's path in the application bundle: " << theResult.mb_str(wxConvLocal));
404 return theResult +
"/Contents/Frameworks";
407 wxString MacGetPathToBundledExecutableFile(CFStringRef filename)
409 wxString theResult = wxEmptyString;
411 CFBundleRef mainbundle = CFBundleGetMainBundle();
412 if(mainbundle == NULL)
418 CFURLRef PTOurl = CFBundleCopyAuxiliaryExecutableURL(mainbundle, filename);
421 DEBUG_INFO(
"Mac: Cannot locate the file in the bundle.");
425 CFURLRef PTOAbsURL = CFURLCopyAbsoluteURL( PTOurl );
426 if(PTOAbsURL == NULL)
428 DEBUG_INFO(
"Mac: Cannot convert the file path to absolute");
432 CFStringRef pathInCFString = CFURLCopyFileSystemPath(PTOAbsURL, kCFURLPOSIXPathStyle);
433 CFRelease( PTOAbsURL );
434 if(pathInCFString == NULL)
436 DEBUG_INFO(
"Mac: Failed to get URL in CFString");
440 CFRetain( pathInCFString );
441 theResult = wxCFStringRef(pathInCFString).AsString();
442 DEBUG_INFO(
"Mac: executable's full path in the application bundle: " << theResult.mb_str(wxConvLocal));
451 wxString MacGetPathToUserDomainTempDir()
453 wxString tmpDirPath = wxEmptyString;
456 OSErr err = FSFindFolder(kUserDomain, kTemporaryFolderType, kCreateFolder, &tempDirRef);
459 CFURLRef tempDirURL = CFURLCreateFromFSRef(kCFAllocatorSystemDefault, &tempDirRef);
460 if (tempDirURL != NULL)
462 CFStringRef tmpPath = CFURLCopyFileSystemPath(tempDirURL, kCFURLPOSIXPathStyle);
464 tmpDirPath = wxCFStringRef(tmpPath).AsString();
465 CFRelease(tempDirURL);
472 wxString MacGetPathToUserAppSupportAutoPanoFolder()
474 wxString appSupportAutoPanoFolder = wxEmptyString;
476 FSRef appSupportFolder;
477 OSErr err = FSFindFolder(kUserDomain,kApplicationSupportFolderType,kDontCreateFolder,&appSupportFolder);
480 CFURLRef appSupportFolderURL = CFURLCreateFromFSRef(kCFAllocatorDefault,&appSupportFolder);
481 CFURLRef appSupportHugin = CFURLCreateCopyAppendingPathComponent(kCFAllocatorDefault,appSupportFolderURL,CFSTR(
"Hugin"),
true);
482 CFURLRef autopanoURL = CFURLCreateCopyAppendingPathComponent(kCFAllocatorDefault,appSupportHugin,CFSTR(
"Autopano"),
true);
483 CFStringRef tmpPath = CFURLCopyFileSystemPath(autopanoURL, kCFURLPOSIXPathStyle);
485 appSupportAutoPanoFolder = wxCFStringRef(tmpPath).AsString();
486 CFRelease(autopanoURL);
488 return appSupportAutoPanoFolder;
492 #endif // MAC_SELF_CONTAINED_BUNDLE
498 #if defined __WXMSW__
501 return wxEmptyString;
513 if(stringToTest.IsEmpty())
516 for(
unsigned int j=0;j<forbiddenChars.size();j++)
518 if(stringToTest.Find(forbiddenChars[j])!=wxNOT_FOUND)
527 wxXmlResource::Get()->LoadDialog(&dlg, parent,
"dlg_warning_filename");
528 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()));
529 XRCCTRL(dlg,
"dlg_warning_list", wxListBox)->Append(filelist);
531 dlg.CenterOnScreen();
535 #if wxUSE_ON_FATAL_EXCEPTION
536 void GenerateReport(wxDebugReport::Context ctx)
539 wxDebugReportCompress report;
541 if (wxDebugReportPreviewStd().Show(report))
543 if (report.Process())
545 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
int HuginMessageBox(const wxString &message, const wxString &caption, int style, wxWindow *parent)