aboutsummaryrefslogtreecommitdiff
path: root/src/hdfsee.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2010-01-12 14:47:59 +0100
committerThomas White <taw@physics.org>2010-01-12 14:47:59 +0100
commitf15a2bd9185819365e3d84f878d1225822a93e3e (patch)
tree2dbf116ac52d58d6459a60caafc27fb9a520cc0f /src/hdfsee.c
parent0b17be9c96c4082b7cf2334c6a2cc35bb6a5814c (diff)
Allow hdfsee to read peak list at startup
Diffstat (limited to 'src/hdfsee.c')
-rw-r--r--src/hdfsee.c70
1 files changed, 57 insertions, 13 deletions
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;