Commit f15a2bd9 authored by Thomas White's avatar Thomas White
Browse files

Allow hdfsee to read peak list at startup

parent 0b17be9c
......@@ -929,7 +929,7 @@ static gint displaywindow_press(GtkWidget *widget, GdkEventButton *event,
}
DisplayWindow *displaywindow_open(const char *filename)
DisplayWindow *displaywindow_open(const char *filename, const char *peaks)
{
DisplayWindow *dw;
char *title;
......@@ -994,6 +994,12 @@ DisplayWindow *displaywindow_open(const char *filename)
dw->binning = INITIAL_BINNING;
displaywindow_update(dw);
/* Peak list provided at startup? */
if ( peaks != NULL ) {
load_features_from_file(hdfile_get_image(dw->hdfile), peaks);
displaywindow_update(dw);
}
gtk_widget_add_events(GTK_WIDGET(dw->drawingarea),
GDK_BUTTON_PRESS_MASK
| GDK_BUTTON_RELEASE_MASK
......
......@@ -66,7 +66,8 @@ typedef struct {
} DisplayWindow;
/* Open an image display window showing the given filename, or NULL */
extern DisplayWindow *displaywindow_open(const char *filename);
extern DisplayWindow *displaywindow_open(const char *filename,
const char *peaks);
#endif /* DISPLAYWINDOW_H */
......@@ -16,6 +16,7 @@
#include <gtk/gtk.h>
#include <glib/gthread.h>
#include <getopt.h>
#include "displaywindow.h"
#include "utils.h"
......@@ -26,6 +27,19 @@ DisplayWindow *main_window_list[64];
size_t main_n_windows = 0;
static void show_help(const char *s)
{
printf("Syntax: %s [options] image.h5\n\n", s);
printf(
"Quick HDF5 image viewer.\n"
"\n"
" -h, --help Display this help message.\n"
"\n"
" -p, --peak-overlay=<filename> Draw circles in positions listed in file.\n"
"\n");
}
/* Called to notify that an image display window has been closed */
void hdfsee_window_closed(DisplayWindow *dw)
{
......@@ -54,31 +68,61 @@ void hdfsee_window_closed(DisplayWindow *dw)
int main(int argc, char *argv[])
{
int c;
size_t i;
int nfiles;
char *peaks = NULL;
/* Long options */
const struct option longopts[] = {
{"help", 0, NULL, 'h'},
{"peak-overlay", 1, NULL, 'p'},
{0, 0, NULL, 0}
};
g_thread_init(NULL);
gtk_init(&argc, &argv);
if ( argc == 1 ) {
/* Short options */
while ((c = getopt_long(argc, argv, "hp:", longopts, NULL)) != -1) {
main_n_windows = 1;
main_window_list[0] = displaywindow_open(NULL);
if ( main_window_list[0] == NULL ) {
ERROR("Couldn't open display window\n");
switch (c) {
case 'h' : {
show_help(argv[0]);
return 0;
}
} else {
case 'p' : {
peaks = strdup(optarg);
break;
}
size_t i;
case 0 : {
break;
}
main_n_windows = argc - 1;
for ( i=0; i<main_n_windows; i++ ) {
main_window_list[i] = displaywindow_open(argv[i+1]);
if ( main_window_list[i] == NULL ) {
ERROR("Couldn't open display window\n");
}
default : {
return 1;
}
}
}
nfiles = argc-optind;
if ( nfiles < 1 ) {
ERROR("You need to give me a file to open!\n");
return -1;
}
for ( i=0; i<nfiles; i++ ) {
main_window_list[i] = displaywindow_open(argv[optind+i], peaks);
if ( main_window_list[i] == NULL ) {
ERROR("Couldn't open display window\n");
} else {
main_n_windows++;
}
}
gtk_main();
return 0;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment