diff options
-rw-r--r-- | data/hdfsee.ui | 1 | ||||
-rw-r--r-- | doc/man/hdfsee.1 | 2 | ||||
-rw-r--r-- | src/dw-hdfsee.c | 29 | ||||
-rw-r--r-- | src/dw-hdfsee.h | 1 |
4 files changed, 30 insertions, 3 deletions
diff --git a/data/hdfsee.ui b/data/hdfsee.ui index b67f973a..9294d932 100644 --- a/data/hdfsee.ui +++ b/data/hdfsee.ui @@ -41,6 +41,7 @@ <menuitem name="eventprevious" action="EventPreviousAction" /> <menuitem name="eventnext" action="EventNextAction" /> <menuitem name="gotoevent" action="GotoEventAction" /> + <menuitem name="randomevent" action="RandomEventAction" /> </menu> <menu name="help" action="HelpAction"> diff --git a/doc/man/hdfsee.1 b/doc/man/hdfsee.1 index 77f7dd2b..7a4dddb6 100644 --- a/doc/man/hdfsee.1 +++ b/doc/man/hdfsee.1 @@ -98,7 +98,7 @@ Calibration mode allows you to visually adjust the locations of panels. To ente Most of these actions can also be accessed from the Calibration menu, which becomes aptive when calibration mode is toggled once .SH EVENT NAVIGATION -When multi-event files are opened, the Events menu in the menubar becomes active, and some event navigation tools become available. The title bar shows, in addition to the file name, the name of the event currently displayed (See \fBman crystfel_geometry\fR and \fBman indexamajig\fR for a description of event naming). Press 'n' to move to the next event in the file, and 'p' to move to the previous one'. Press 'e' to jump to a specific event, by providing an event name (Use the \fBlist_events\fR program to get a list of the events included in a file). These actions are also accessible from the Events menu in the menubar. +When multi-event files are opened, the Events menu in the menubar becomes active, and some event navigation tools become available. The title bar shows, in addition to the file name, the name of the event currently displayed (See \fBman crystfel_geometry\fR and \fBman indexamajig\fR for a description of event naming). Press 'n' to move to the next event in the file, and 'p' to move to the previous one'. Press 'e' to jump to a specific event, by providing an event name (Use the \fBlist_events\fR program to get a list of the events included in a file). Press 'r' to jump to a random event. These actions are also accessible from the Events menu in the menubar. .SH AUTHOR This page was written by Thomas White and Valerio Mariani. diff --git a/src/dw-hdfsee.c b/src/dw-hdfsee.c index 0c5852c5..833ac01c 100644 --- a/src/dw-hdfsee.c +++ b/src/dw-hdfsee.c @@ -964,6 +964,18 @@ static gint displaywindow_newevent(DisplayWindow *dw, int new_event) } +static gint displaywindow_randomevent(GtkWidget *widget, DisplayWindow *dw) +{ + int rand_event; + + if ( dw->not_ready_yet ) return 0; + + rand_event = gsl_rng_uniform_int(&dw->rng, dw->ev_list->num_events); + + return displaywindow_newevent(dw, rand_event); +} + + static gint displaywindow_set_newevent_response(GtkWidget *widget, gint response, DisplayWindow *dw) @@ -1489,6 +1501,11 @@ static void set_events_menu_sensitivity(DisplayWindow *dw, int val) { gtk_action_set_sensitive(GTK_ACTION(a), val); a = gtk_ui_manager_get_action(dw->ui, "/ui/displaywindow/events/gotevent"); + gtk_action_set_sensitive(GTK_ACTION(a), val); + a = gtk_ui_manager_get_action(dw->ui, + "/ui/displaywindow/events/randomevent"); + gtk_action_set_sensitive(GTK_ACTION(a), val); + } @@ -2110,8 +2127,6 @@ static void calibmode_prev(GtkWidget *widget, DisplayWindow *dw) } - - static void event_next(GtkWidget *widget, DisplayWindow *dw) { int new_event; @@ -2184,6 +2199,8 @@ static void displaywindow_addmenubar(DisplayWindow *dw, GtkWidget *vbox, G_CALLBACK(event_next) }, { "GotoEventAction", NULL, "Go To Event", "e", NULL, G_CALLBACK(displaywindow_set_newevent) }, + { "RandomEventAction", NULL, "Go To Random Event", "r", NULL, + G_CALLBACK(displaywindow_randomevent) }, { "HelpAction", NULL, "_Help", NULL, NULL, NULL }, { "AboutAction", GTK_STOCK_ABOUT, "_About hdfsee...", @@ -2742,6 +2759,14 @@ DisplayWindow *displaywindow_open(char *filename, char *geom_filename, dw->statusbar = NULL; dw->multi_event = 0; dw->ev_list = NULL; + dw->rng = *gsl_rng_alloc(gsl_rng_mt19937); + FILE *fh; + unsigned long int seed; + fh = fopen("/dev/urandom", "r"); + fread(&seed, sizeof(seed), 1, fh); + fclose(fh); + gsl_rng_set(&dw->rng, seed); + if ( geom_filename != NULL ) { dw->geom_filename = strdup(geom_filename); } else { diff --git a/src/dw-hdfsee.h b/src/dw-hdfsee.h index 9bb849a1..db6a81ce 100644 --- a/src/dw-hdfsee.h +++ b/src/dw-hdfsee.h @@ -146,6 +146,7 @@ typedef struct { struct event_list *ev_list; int curr_event; + gsl_rng rng; } DisplayWindow; |