add fileOpenDialog and enable loading of urdf from GUI

(will add .bullet file support soon)
Uses native Windows (getFileOpenFileName) and Mac OSX NSOpenPanel,
on Linux using pipe popen to zenity)
This commit is contained in:
Erwin Coumans
2014-08-31 11:53:44 -07:00
parent 8595928949
commit f199a4a972
14 changed files with 250 additions and 50 deletions

View File

@@ -959,4 +959,29 @@ b3KeyboardCallback X11OpenGLWindow::getKeyboardCallback()
{
return m_data->m_keyboardCallback;
}
#include <stdio.h>
int X11OpenGLWindow::fileOpenDialog(char* filename, int maxNameLength)
{
int len = 0;
FILE * output = popen("zenity --file-selection --file-filter=\"*.urdf\" --file-filter=\"*.*\"","r");
if (output)
{
while( fgets(filename, maxNameLength-1, output) != NULL )
{
len=strlen(filename);
if (len>0)
{
filename[len-1]=0;
printf("file open (length=%d) = %s\n", len,filename);
}
}
pclose(output);
} else
{
printf("Error: fileOpenDialog no popen output, perhaps install zenity?\n");
}
XRaiseWindow(m_data->m_dpy, m_data->m_win);
return len;
}