aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2014-12-14 15:15:14 +0100
committerThomas White <taw@physics.org>2014-12-14 15:15:26 +0100
commita365b27b2186dfd7b3e7f9c10dac5144addd290e (patch)
tree06ad6dab7c09e57f64332a90fae44ec60672227c
parent96dba6ec96dc90bd5795b9ca0517c82fa5aad2c6 (diff)
hdfsee: Select the correct event at the start
-rw-r--r--libcrystfel/src/events.c40
-rw-r--r--libcrystfel/src/events.h1
-rw-r--r--src/dw-hdfsee.c4
3 files changed, 43 insertions, 2 deletions
diff --git a/libcrystfel/src/events.c b/libcrystfel/src/events.c
index d431a851..93d67a68 100644
--- a/libcrystfel/src/events.c
+++ b/libcrystfel/src/events.c
@@ -206,6 +206,46 @@ struct event_list *copy_event_list(struct event_list *el)
}
+static int events_equal(struct event *ev1, struct event *ev2)
+{
+ int i;
+
+ if ( ev1->path_length != ev2->path_length ) return 0;
+ if ( ev1->dim_length != ev2->dim_length ) return 0;
+
+ for ( i=0; i<ev1->path_length; i++ ) {
+ if ( strcmp(ev1->path_entries[i], ev2->path_entries[i]) != 0 ) {
+ return 0;
+ }
+ }
+
+ for ( i=0; i<ev1->dim_length; i++ ) {
+ if ( ev1->dim_entries[i] != ev2->dim_entries[i] ) return 0;
+ }
+
+ return 1;
+}
+
+
+/**
+ * find_event:
+ * @ev: An event structure
+ * @el: An event list
+ *
+ * Returns: the indexing into @el of the event matching @ev, of el->num_events
+ * if no such event is found.
+ **/
+int find_event(struct event *ev, struct event_list *el)
+{
+ int i;
+
+ for ( i=0; i<el->num_events; i++ ) {
+ if ( events_equal(ev, el->events[i]) ) return i;
+ }
+
+ return i;
+}
+
void free_event(struct event *ev)
{
diff --git a/libcrystfel/src/events.h b/libcrystfel/src/events.h
index 3dfaf0ec..ff4cf1fb 100644
--- a/libcrystfel/src/events.h
+++ b/libcrystfel/src/events.h
@@ -92,6 +92,7 @@ extern int append_event_to_event_list(struct event_list *ev_list,
int add_non_existing_event_to_event_list(struct event_list *ev_list,
struct event *ev);
extern struct event_list *copy_event_list(struct event_list *el);
+extern int find_event(struct event *ev, struct event_list *el);
extern void free_event_list(struct event_list *el);
diff --git a/src/dw-hdfsee.c b/src/dw-hdfsee.c
index 0475126d..78f691b6 100644
--- a/src/dw-hdfsee.c
+++ b/src/dw-hdfsee.c
@@ -2544,8 +2544,8 @@ DisplayWindow *displaywindow_open(char *filename, char *geom_filename,
if ( dw->multi_event ) {
struct event *ev;
if ( event != NULL ) {
- dw->curr_event = 0; /* Probably wrong */
ev = get_event_from_event_string(event);
+ dw->curr_event = find_event(ev, dw->ev_list);
} else {
dw->curr_event = 0;
ev = dw->ev_list->events[dw->curr_event];
@@ -2645,7 +2645,7 @@ DisplayWindow *displaywindow_open(char *filename, char *geom_filename,
if ( dw->image->det == dw->simple_geom ) {
displaywindow_update_menus(dw, element);
} else {
- if ( dw->multi_event != 0 ) {
+ if ( dw->multi_event ) {
displaywindow_update_event_menu(dw, dw->ev_list,
dw->curr_event);
}