aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2011-02-20 22:04:25 -0800
committerThomas White <taw@physics.org>2012-02-22 15:27:15 +0100
commit758fc675ab242bbd92130d9f644b8b96f8b52216 (patch)
treeee359617f796b862c9aa2bbd108785bf5acc0d74
parent98a5819959910f9c82e21efb7192a1c1f4c0d7f7 (diff)
hdfsee: Add --image option
-rw-r--r--src/displaywindow.c23
-rw-r--r--src/displaywindow.h3
-rw-r--r--src/hdfsee.c13
3 files changed, 29 insertions, 10 deletions
diff --git a/src/displaywindow.c b/src/displaywindow.c
index c2e94e71..36dc7e5b 100644
--- a/src/displaywindow.c
+++ b/src/displaywindow.c
@@ -1112,7 +1112,8 @@ static gint displaywindow_press(GtkWidget *widget, GdkEventButton *event,
DisplayWindow *displaywindow_open(const char *filename, const char *peaks,
int boost, int binning, int cmfilter,
- int noisefilter, int colscale)
+ int noisefilter, int colscale,
+ const char *element)
{
DisplayWindow *dw;
char *title;
@@ -1163,12 +1164,22 @@ DisplayWindow *displaywindow_open(const char *filename, const char *peaks,
if ( dw->hdfile == NULL ) {
ERROR("Couldn't open file '%s'\n", filename);
displaywindow_disable(dw);
- } else if ( hdfile_set_first_image(dw->hdfile, "/") ) {
- ERROR("Couldn't select path\n");
- displaywindow_disable(dw);
} else {
- dw->image = calloc(1, sizeof(struct image));
- hdf5_read(dw->hdfile, dw->image, 0, 0.0);
+ int fail = -1;
+
+ if ( element == NULL ) {
+ fail = hdfile_set_first_image(dw->hdfile, "/");
+ } else {
+ fail = hdfile_set_image(dw->hdfile, element);
+ }
+
+ if ( !fail ) {
+ dw->image = calloc(1, sizeof(struct image));
+ hdf5_read(dw->hdfile, dw->image, 0, 0.0);
+ } else {
+ ERROR("Couldn't select path\n");
+ displaywindow_disable(dw);
+ }
}
} else {
diff --git a/src/displaywindow.h b/src/displaywindow.h
index 870a3d5b..9d078bf8 100644
--- a/src/displaywindow.h
+++ b/src/displaywindow.h
@@ -75,7 +75,8 @@ typedef struct {
extern DisplayWindow *displaywindow_open(const char *filename,
const char *peaks, int boost,
int binning, int cmfilter,
- int noisefilter, int colscale);
+ int noisefilter, int colscale,
+ const char *element);
#endif /* DISPLAYWINDOW_H */
diff --git a/src/hdfsee.c b/src/hdfsee.c
index 3213d061..57a1d025 100644
--- a/src/hdfsee.c
+++ b/src/hdfsee.c
@@ -49,6 +49,8 @@ static void show_help(const char *s)
" colour : Colour scale:\n"
" black-blue-pink-red-orange-\n"
" -yellow-white.\n"
+" -e, --image=<element> Start up displaying this image from the\n"
+" HDF5 file. Example: /data/data0.\n"
"\n");
}
@@ -91,6 +93,7 @@ int main(int argc, char *argv[])
int config_noisefilter = 0;
int colscale = SCALE_COLOUR;
char *cscale = NULL;
+ char *element = NULL;
/* Long options */
const struct option longopts[] = {
@@ -101,13 +104,14 @@ int main(int argc, char *argv[])
{"filter-cm", 0, &config_cmfilter, 1},
{"filter-noise", 0, &config_noisefilter, 1},
{"colscale", 1, NULL, 'c'},
+ {"image", 1, NULL, 'e'},
{0, 0, NULL, 0}
};
gtk_init(&argc, &argv);
/* Short options */
- while ((c = getopt_long(argc, argv, "hp:b:i:c:",
+ while ((c = getopt_long(argc, argv, "hp:b:i:c:e:",
longopts, NULL)) != -1) {
switch (c) {
@@ -138,6 +142,10 @@ int main(int argc, char *argv[])
cscale = strdup(optarg);
break;
+ case 'e' :
+ element = strdup(optarg);
+ break;
+
case 0 :
break;
@@ -169,13 +177,12 @@ int main(int argc, char *argv[])
}
free(cscale);
-
for ( i=0; i<nfiles; i++ ) {
main_window_list[i] = displaywindow_open(argv[optind+i], peaks,
boost, binning,
config_cmfilter,
config_noisefilter,
- colscale);
+ colscale, element);
if ( main_window_list[i] == NULL ) {
ERROR("Couldn't open display window\n");
} else {