From f15a2bd9185819365e3d84f878d1225822a93e3e Mon Sep 17 00:00:00 2001 From: Thomas White Date: Tue, 12 Jan 2010 14:47:59 +0100 Subject: Allow hdfsee to read peak list at startup --- src/hdfsee.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 57 insertions(+), 13 deletions(-) (limited to 'src/hdfsee.c') 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 #include +#include #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= 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