diff options
-rw-r--r-- | src/displaywindow.c | 8 | ||||
-rw-r--r-- | src/displaywindow.h | 3 | ||||
-rw-r--r-- | src/hdfsee.c | 70 |
3 files changed, 66 insertions, 15 deletions
diff --git a/src/displaywindow.c b/src/displaywindow.c index 008aa19f..f78977e9 100644 --- a/src/displaywindow.c +++ b/src/displaywindow.c @@ -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 diff --git a/src/displaywindow.h b/src/displaywindow.h index 63124d7b..04199cd3 100644 --- a/src/displaywindow.h +++ b/src/displaywindow.h @@ -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 */ diff --git a/src/hdfsee.c b/src/hdfsee.c index a4dec359..269f90a0 100644 --- a/src/hdfsee.c +++ b/src/hdfsee.c @@ -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; |