aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/hdfsee.ui12
-rw-r--r--libcrystfel/src/detector.c1
-rw-r--r--src/dw-hdfsee.c799
-rw-r--r--src/dw-hdfsee.h10
4 files changed, 498 insertions, 324 deletions
diff --git a/data/hdfsee.ui b/data/hdfsee.ui
index 0dc4eb92..b67f973a 100644
--- a/data/hdfsee.ui
+++ b/data/hdfsee.ui
@@ -29,8 +29,18 @@
<menuitem name="peaks" action="PeaksAction" />
</menu>
+ <menu name="calibration" action="CalibrationAction">
+ <menuitem name="calibrationprevious" action="CalibPreviousAction" />
+ <menuitem name="calibrationnext" action="CalibNextAction" />
+ <menuitem name="switchcalibmode" action="SwitchCalibModeAction" />
+ <menuitem name="focus" action="ToggleFocusAction" />
+ <menuitem name="savegeometry" action="SaveGeometryAction" />
+ </menu>
+
<menu name="events" action="EventsAction">
- <menuitem name="about" action="AboutAction" />
+ <menuitem name="eventprevious" action="EventPreviousAction" />
+ <menuitem name="eventnext" action="EventNextAction" />
+ <menuitem name="gotoevent" action="GotoEventAction" />
</menu>
<menu name="help" action="HelpAction">
diff --git a/libcrystfel/src/detector.c b/libcrystfel/src/detector.c
index e7d53343..c9fb0431 100644
--- a/libcrystfel/src/detector.c
+++ b/libcrystfel/src/detector.c
@@ -2033,7 +2033,6 @@ int write_detector_geometry_2(const char *geometry_filename,
fh = fopen(output_filename, "w");
if ( fh == NULL ) {
- fclose(fh);
return 1;
}
diff --git a/src/dw-hdfsee.c b/src/dw-hdfsee.c
index 83cbc4e3..a018df5e 100644
--- a/src/dw-hdfsee.c
+++ b/src/dw-hdfsee.c
@@ -144,7 +144,7 @@ static void draw_panel_rectangle(cairo_t *cr, cairo_matrix_t *basic_m,
}
-int render_adsc_uint16(DisplayWindow *dw, const char *filename)
+static int render_adsc_uint16(DisplayWindow *dw, const char *filename)
{
int x, y, fs, ss;
double dfs, dss;
@@ -904,6 +904,195 @@ static gint displaywindow_set_boostint(GtkWidget *widget, DisplayWindow *dw)
}
+static void do_filters(DisplayWindow *dw)
+{
+ if ( dw->median_filter > 0 ) {
+ filter_median(dw->image, dw->median_filter);
+ }
+
+ if ( dw->noisefilter ) {
+ filter_noise(dw->image);
+ }
+}
+
+
+static gint displaywindow_newevent(DisplayWindow *dw, int new_event)
+{
+ int fail;
+ int i;
+ char title[1024];
+ char *bn;
+
+ if ( dw->not_ready_yet ) return 0;
+
+ float *old_data = dw->image->data;
+ uint16_t *old_flags = dw->image->flags;
+ float **old_dp = dw->image->dp;
+ int **old_bad = dw->image->bad;
+
+ fail = hdf5_read2(dw->hdfile, dw->image,
+ dw->ev_list->events[new_event], 0);
+ if ( fail ) {
+ ERROR("Couldn't load image");
+ dw->image->data = old_data;
+ dw->image->flags = old_flags;
+ dw->image->dp = old_dp;
+ dw->image->bad = old_bad;
+ return 1;
+ }
+
+ dw->curr_event = new_event;
+
+ do_filters(dw);
+ displaywindow_update(dw);
+
+ bn = safe_basename(dw->image->filename);
+ sprintf(title, "%s - event: %s - hdfsee", bn,
+ get_event_string(dw->ev_list->events[dw->curr_event]));
+ gtk_window_set_title(GTK_WINDOW(dw->window), title);
+ free(bn);
+
+ for (i = 0; i < dw->image->det->n_panels; i++) {
+ free(old_dp[i]);
+ free(old_bad[i]);
+ }
+ free(old_data);
+ free(old_flags);
+ free(old_dp);
+ free(old_bad);
+ return 0;
+}
+
+
+static gint displaywindow_set_newevent_response(GtkWidget *widget,
+ gint response,
+ DisplayWindow *dw)
+{
+ int ei;
+ int matched_event;
+ int done = 1;
+
+ if ( response == GTK_RESPONSE_OK ) {
+
+ const char *sevent;
+
+
+
+ sevent = gtk_entry_get_text(
+ GTK_ENTRY(dw->event_dialog->entry));
+
+ matched_event = -1;
+
+ for ( ei=0; ei<dw->ev_list->num_events; ei++ ) {
+
+ char *ei_ev_string;
+
+ ei_ev_string = get_event_string(dw->ev_list->events[ei]);
+ if ( strcmp(ei_ev_string, sevent) == 0 ) {
+ matched_event = ei;
+ break;
+ }
+ }
+
+ if ( matched_event == -1 ) {
+ displaywindow_error(dw, "Cannot find event.\n");
+ done = 0;
+ } else {
+ displaywindow_newevent(dw, matched_event);
+ displaywindow_update(dw);
+ }
+ }
+
+ if ( done ) {
+ gtk_widget_destroy(dw->event_dialog->window);
+ }
+
+ return 0;
+}
+
+
+static gint displaywindow_set_newevent_destroy(GtkWidget *widget,
+ DisplayWindow *dw)
+{
+ free(dw->event_dialog);
+ dw->event_dialog = NULL;
+ return 0;
+}
+
+
+static gint displaywindow_set_newevent_response_ac(GtkWidget *widget,
+ DisplayWindow *dw)
+{
+ return displaywindow_set_newevent_response(widget, GTK_RESPONSE_OK, dw);
+}
+
+
+/* Create a window to ask the user for a new intensity boost factor */
+static gint displaywindow_set_newevent(GtkWidget *widget, DisplayWindow *dw)
+{
+ EventDialog *ed;
+ GtkWidget *vbox;
+ GtkWidget *hbox;
+ GtkWidget *table;
+ GtkWidget *label;
+ char tmp[1024];
+
+ if ( dw->event_dialog != NULL ) {
+ return 0;
+ }
+
+ if ( dw->hdfile == NULL ) {
+ return 0;
+ }
+
+ ed = malloc(sizeof(EventDialog));
+ if ( ed == NULL ) return 0;
+ dw->event_dialog = ed;
+
+ ed->window = gtk_dialog_new_with_buttons("Intensity Boost",
+ GTK_WINDOW(dw->window),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CLOSE,
+ GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
+
+ vbox = gtk_vbox_new(FALSE, 0);
+ hbox = gtk_hbox_new(TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(GTK_DIALOG(ed->window)->vbox),
+ GTK_WIDGET(hbox), FALSE, FALSE, 7);
+ gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(vbox), FALSE, FALSE, 5);
+
+ table = gtk_table_new(3, 2, FALSE);
+ gtk_table_set_row_spacings(GTK_TABLE(table), 5);
+ gtk_table_set_col_spacings(GTK_TABLE(table), 5);
+ gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(table), FALSE, FALSE, 0);
+
+ label = gtk_label_new("Boost Factor:");
+ gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
+ gtk_table_attach_defaults(GTK_TABLE(table), GTK_WIDGET(label),
+ 1, 2, 3, 4);
+
+ ed->entry = gtk_entry_new();
+ snprintf(tmp, 1023, "%s",
+ get_event_string(dw->ev_list->events[dw->curr_event]));
+ gtk_entry_set_text(GTK_ENTRY(ed->entry), tmp);
+ gtk_table_attach_defaults(GTK_TABLE(table), GTK_WIDGET(ed->entry),
+ 2, 3, 3, 4);
+
+ g_signal_connect(G_OBJECT(ed->entry), "activate",
+ G_CALLBACK(displaywindow_set_newevent_response_ac),
+ dw);
+ g_signal_connect(G_OBJECT(ed->window), "response",
+ G_CALLBACK(displaywindow_set_newevent_response), dw);
+ g_signal_connect(G_OBJECT(ed->window), "destroy",
+ G_CALLBACK(displaywindow_set_newevent_destroy), dw);
+ gtk_window_set_resizable(GTK_WINDOW(ed->window), FALSE);
+ gtk_widget_show_all(ed->window);
+ gtk_widget_grab_focus(GTK_WIDGET(ed->entry));
+
+ return 0;
+}
+
+
static gint displaywindow_set_ringradius_response(GtkWidget *widget,
gint response,
DisplayWindow *dw)
@@ -1211,7 +1400,7 @@ static gint displaywindow_about(GtkWidget *widget, DisplayWindow *dw)
}
-static int save_geometry_file(DisplayWindow *dw)
+static int save_geometry_file(GtkWidget *widget, DisplayWindow *dw)
{
GtkWidget *d;
gchar *output_filename;
@@ -1229,9 +1418,11 @@ static int save_geometry_file(DisplayWindow *dw)
w = write_detector_geometry_2(dw->geom_filename, output_filename,
dw->image->det, "Manually optimized with "
"hdfsee", 0);
- if ( w != 0 ) {
- ERROR("Error saving geometry!\n");
+ if ( w != 0 && w!=2 ) {
+ displaywindow_error(dw,
+ "Unable to save the detector geometry.");
}
+
gtk_widget_destroy(d);
g_free(output_filename);
return w;
@@ -1258,6 +1449,49 @@ static gint displaywindow_peak_overlay(GtkWidget *widget, DisplayWindow *dw)
}
+static void set_calibration_menu_sensitivity(DisplayWindow *dw, int val) {
+
+ GtkAction * a;
+
+ a = gtk_ui_manager_get_action(dw->ui,
+ "/ui/displaywindow/calibration");
+ gtk_action_set_sensitive(GTK_ACTION(a), val);
+ a = gtk_ui_manager_get_action(dw->ui,
+ "/ui/displaywindow/calibration/calibrationprevious");
+ gtk_action_set_sensitive(GTK_ACTION(a), val);
+ a = gtk_ui_manager_get_action(dw->ui,
+ "/ui/displaywindow/calibration/calibrationnext");
+ gtk_action_set_sensitive(GTK_ACTION(a), val);
+ a = gtk_ui_manager_get_action(dw->ui,
+ "/ui/displaywindow/calibration/switchcalibmode");
+ gtk_action_set_sensitive(GTK_ACTION(a), val);
+ a = gtk_ui_manager_get_action(dw->ui,
+ "/ui/displaywindow/calibration/focus");
+ gtk_action_set_sensitive(GTK_ACTION(a), val);
+ a = gtk_ui_manager_get_action(dw->ui,
+ "/ui/displaywindow/calibration/savegeometry");
+ gtk_action_set_sensitive(GTK_ACTION(a), val);
+}
+
+
+static void set_events_menu_sensitivity(DisplayWindow *dw, int val) {
+
+ GtkAction * a;
+
+ a = gtk_ui_manager_get_action(dw->ui,
+ "/ui/displaywindow/events");
+ gtk_action_set_sensitive(GTK_ACTION(a), val);
+ a = gtk_ui_manager_get_action(dw->ui,
+ "/ui/displaywindow/events/eventprevious");
+ gtk_action_set_sensitive(GTK_ACTION(a), val);
+ a = gtk_ui_manager_get_action(dw->ui,
+ "/ui/displaywindow/events/eventnext");
+ gtk_action_set_sensitive(GTK_ACTION(a), val);
+ a = gtk_ui_manager_get_action(dw->ui,
+ "/ui/displaywindow/events/gotevent");
+}
+
+
static gint displaywindow_set_calibmode(GtkWidget *d, DisplayWindow *dw)
{
GtkWidget *w, *vbox;
@@ -1305,6 +1539,8 @@ static gint displaywindow_set_calibmode(GtkWidget *d, DisplayWindow *dw)
dw->calib_mode_curr_p = dw->calib_mode_curr_rg->panels[0];
}
+ set_calibration_menu_sensitivity(dw, TRUE);
+
dw->calib_mode = CALIBMODE_PANELS;
dw->statusbar = gtk_statusbar_new();
@@ -1320,6 +1556,8 @@ static gint displaywindow_set_calibmode(GtkWidget *d, DisplayWindow *dw)
} else {
+ set_calibration_menu_sensitivity(dw, FALSE);
+
dw->calib_mode = CALIBMODE_NONE;
gtk_widget_destroy(dw->statusbar);
dw->statusbar = NULL;
@@ -1696,6 +1934,209 @@ static gint displaywindow_setscale(GtkWidget *widget, GtkRadioAction *action,
return 0;
}
+static int curr_rg_pointer_index(DisplayWindow *dw)
+{
+ int r;
+
+ for ( r=0; r<dw->rg_coll->n_rigid_groups; ++r) {
+ if ( dw->rg_coll->rigid_groups[r] == dw->calib_mode_curr_rg ) {
+ return r;
+ }
+ }
+
+ /* Never reached (we hope) */
+ return 999;
+}
+
+static int curr_p_pointer_index(DisplayWindow *dw)
+{
+ int p;
+
+ for ( p=0; p<dw->image->det->n_panels; ++p) {
+ if ( &dw->image->det->panels[p] == dw->calib_mode_curr_p ) {
+ return p;
+ }
+ }
+
+ /* Never reached (we hope) */
+ return 999;
+}
+
+
+static void select_next_group(DisplayWindow *dw, int num_rg)
+{
+ if ( dw->calib_mode_curr_rg == dw->rg_coll->rigid_groups[num_rg-1] ) {
+ dw->calib_mode_curr_rg = dw->rg_coll->rigid_groups[0];
+ } else {
+ dw->calib_mode_curr_rg =
+ dw->rg_coll->rigid_groups[curr_rg_pointer_index(dw)+1];
+ }
+}
+
+
+static void select_prev_group(DisplayWindow *dw, int num_rg)
+{
+ if ( dw->calib_mode_curr_rg == dw->rg_coll->rigid_groups[0] ) {
+ dw->calib_mode_curr_rg = dw->rg_coll->rigid_groups[num_rg-1];
+ } else {
+ dw->calib_mode_curr_rg =
+ dw->rg_coll->rigid_groups[curr_rg_pointer_index(dw)-1];
+ }
+}
+
+
+static void select_next_panel(DisplayWindow *dw, int num_p)
+{
+ if ( dw->calib_mode_curr_p == &dw->image->det->panels[num_p-1] ) {
+ dw->calib_mode_curr_p = &dw->image->det->panels[0];
+ } else {
+ dw->calib_mode_curr_p =
+ &dw->image->det->panels[curr_p_pointer_index(dw)+1];
+ }
+}
+
+
+static void select_prev_panel(DisplayWindow *dw, int num_p)
+{
+ if ( dw->calib_mode_curr_p == &dw->image->det->panels[0] ) {
+ dw->calib_mode_curr_p = &dw->image->det->panels[num_p-1];
+ } else {
+ dw->calib_mode_curr_p =
+ &dw->image->det->panels[curr_p_pointer_index(dw)-1];
+ }
+}
+
+
+static void toggle_calibmode_groupmode(GtkWidget *widget, DisplayWindow *dw)
+{
+ struct rigid_group *rg;
+ struct detector *det = dw->image->det;
+
+ switch ( dw->calib_mode ) {
+
+ case CALIBMODE_NONE:
+ break;
+
+ case CALIBMODE_PANELS:
+ if ( det->n_rigid_groups != det->n_panels ) {
+ /* Only change if there are any rigid groups defined */
+ dw->calib_mode = CALIBMODE_GROUPS;
+ rg = find_corresponding_rigid_group(dw,
+ dw->calib_mode_curr_p);
+ if ( rg == NULL) {
+ dw->calib_mode = CALIBMODE_ALL;
+ } else {
+ dw->calib_mode_curr_rg = rg;
+ }
+
+ } else {
+ /* ...otherwise skip to ALL mode */
+ dw->calib_mode = CALIBMODE_ALL;
+ }
+ break;
+
+ case CALIBMODE_GROUPS:
+ dw->calib_mode = CALIBMODE_ALL;
+ break;
+
+ case CALIBMODE_ALL:
+ dw->calib_mode = CALIBMODE_PANELS;
+ dw->calib_mode_curr_p = dw->calib_mode_curr_rg->panels[0];
+ break;
+
+ }
+ redraw_window(dw);
+}
+
+
+static void toggle_calibmode_focus(GtkWidget *widget, DisplayWindow *dw)
+{
+ dw->calib_mode_show_focus = 1 - dw->calib_mode_show_focus;
+ redraw_window(dw);
+}
+
+
+static void calibmode_next(GtkWidget *widget, DisplayWindow *dw)
+{
+ int n;
+
+ switch ( dw->calib_mode ) {
+
+ case CALIBMODE_NONE:
+ break;
+
+ case CALIBMODE_PANELS:
+ n = dw->image->det->n_panels;
+ select_next_panel(dw, n);
+ break;
+
+ case CALIBMODE_GROUPS:
+ n = dw->image->det->n_rigid_groups;
+ select_next_group(dw, n);
+ break;
+
+ case CALIBMODE_ALL:
+ break;
+
+ }
+ redraw_window(dw);
+}
+
+
+static void calibmode_prev(GtkWidget *widget, DisplayWindow *dw)
+{
+ int n;
+
+ switch ( dw->calib_mode ) {
+
+ case CALIBMODE_NONE:
+ break;
+
+ case CALIBMODE_PANELS:
+ n = dw->image->det->n_panels;
+ select_prev_panel(dw, n);
+ break;
+
+ case CALIBMODE_GROUPS:
+ n = dw->image->det->n_rigid_groups;
+ select_prev_group(dw, n);
+ break;
+
+ case CALIBMODE_ALL:
+ break;
+
+ }
+ redraw_window(dw);
+}
+
+
+
+
+static void event_next(GtkWidget *widget, DisplayWindow *dw)
+{
+ int new_event;
+
+ if ( dw->curr_event == dw->ev_list->num_events-1 ) {
+ new_event = 0;
+ } else {
+ new_event = dw->curr_event+1;
+ }
+ displaywindow_newevent(dw, new_event);
+}
+
+
+static void event_prev(GtkWidget *widget, DisplayWindow *dw)
+{
+ int new_event;
+
+ if ( dw->curr_event == 0 ) {
+ new_event = dw->ev_list->num_events-1;
+ } else {
+ new_event = dw->curr_event-1;
+ }
+ displaywindow_newevent(dw, new_event);
+}
+
static void displaywindow_addmenubar(DisplayWindow *dw, GtkWidget *vbox,
int colscale)
@@ -1724,7 +2165,25 @@ static void displaywindow_addmenubar(DisplayWindow *dw, GtkWidget *vbox,
{ "PeaksAction", NULL, "Load Feature List...", NULL, NULL,
G_CALLBACK(displaywindow_peak_overlay) },
- { "EventsAction", NULL, "_Events", NULL, NULL, NULL },
+ { "CalibrationAction", NULL, "_Calibration", NULL, NULL, NULL },
+ { "CalibPreviousAction", NULL, "Previous Item", "minus", NULL,
+ G_CALLBACK(calibmode_prev) },
+ { "CalibNextAction", NULL, "Next Item", "plus", NULL,
+ G_CALLBACK(calibmode_next) },
+ { "SwitchCalibModeAction", NULL, "Toggle Panel/Group/All", "g",
+ NULL, G_CALLBACK(toggle_calibmode_groupmode) },
+ { "ToggleFocusAction", NULL, "Toggle Focus Rectangle", "i",
+ NULL, G_CALLBACK(toggle_calibmode_focus) },
+ { "SaveGeometryAction", NULL, "Save Geometry", "s", NULL,
+ G_CALLBACK(save_geometry_file) },
+
+ { "EventsAction", NULL, "_Event", NULL, NULL, NULL },
+ { "EventPreviousAction", NULL, "Previous", "p", NULL,
+ G_CALLBACK(event_prev) },
+ { "EventNextAction", NULL, "Next", "n", NULL,
+ G_CALLBACK(event_next) },
+ { "GotoEventAction", NULL, "Go To Event", "e", NULL,
+ G_CALLBACK(displaywindow_set_newevent) },
{ "HelpAction", NULL, "_Help", NULL, NULL, NULL },
{ "AboutAction", GTK_STOCK_ABOUT, "_About hdfsee...",
@@ -1781,17 +2240,6 @@ static void displaywindow_addmenubar(DisplayWindow *dw, GtkWidget *vbox,
}
-static void do_filters(DisplayWindow *dw)
-{
- if ( dw->median_filter > 0 ) {
- filter_median(dw->image, dw->median_filter);
- }
-
- if ( dw->noisefilter ) {
- filter_noise(dw->image);
- }
-}
-
struct newhdf {
DisplayWindow *dw;
GtkWidget *widget;
@@ -1960,102 +2408,6 @@ static int displaywindow_update_menus(DisplayWindow *dw, const char *selectme)
}
-static gint displaywindow_newevent(GtkMenuItem *item, struct newev *ne)
-{
- gboolean a;
- int fail;
- int i;
-
- if ( ne->dw->not_ready_yet ) return 0;
-
- a = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(ne->widget));
- if ( !a ) return 0;
-
- float *old_data = ne->dw->image->data;
- uint16_t *old_flags = ne->dw->image->flags;
- float **old_dp = ne->dw->image->dp;
- int **old_bad = ne->dw->image->bad;
-
- fail = hdf5_read2(ne->dw->hdfile, ne->dw->image,
- ne->dw->ev_list->events[ne->new_ev], 0);
- if ( fail ) {
- ERROR("Couldn't load image");
- return 1;
- }
-
- ne->dw->curr_event = ne->new_ev;
-
- do_filters(ne->dw);
- displaywindow_update(ne->dw);
- for (i = 0; i < ne->dw->image->det->n_panels; i++) {
- free(old_dp[i]);
- free(old_bad[i]);
- }
- free(old_data);
- free(old_flags);
- free(old_dp);
- free(old_bad);
- return 0;
-}
-
-
-static int displaywindow_update_event_menu(DisplayWindow *dw,
- struct event_list *ev_list,
- int curr_event)
-{
-
- int ei;
- GtkWidget *w;
- GtkWidget *ww;
- GSList *grp = NULL;
-
- w = gtk_ui_manager_get_widget(dw->ui, "/ui/displaywindow/events");
- ww = gtk_menu_new();
-
- for ( ei=0; ei<ev_list->num_events; ei++ ) {
-
- GtkWidget *www;
- struct newev *ne;
- char *ev_string;
-
- ev_string = get_event_string(ev_list->events[ei]);
- www = gtk_radio_menu_item_new_with_label(grp, ev_string);
- free(ev_string);
-
- ne = malloc(sizeof(struct newev));
- if ( ne != NULL ) {
-
- ne->widget = www;
- ne->dw = dw;
- ne->new_ev = ei;
-
- g_signal_connect(G_OBJECT(www), "toggled",
- G_CALLBACK(displaywindow_newevent), ne);
-
- }
-
- if ( ei == dw->curr_event ) {
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(www),
- TRUE);
- } else {
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(www),
- FALSE);
- }
-
- gtk_menu_shell_append(GTK_MENU_SHELL(ww), www);
-
- grp = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(www));
- gtk_widget_show_all(www);
-
- }
-
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(w), ww);
-
- return 0;
-}
-
-
-
static gint displaywindow_release(GtkWidget *widget, GdkEventButton *event,
DisplayWindow *dw)
{
@@ -2153,174 +2505,6 @@ static gint displaywindow_press(GtkWidget *widget, GdkEventButton *event,
return 0;
}
-
-static int curr_rg_pointer_index(DisplayWindow *dw)
-{
- int r;
-
- for ( r=0; r<dw->rg_coll->n_rigid_groups; ++r) {
- if ( dw->rg_coll->rigid_groups[r] == dw->calib_mode_curr_rg ) {
- return r;
- }
- }
-
- /* Never reached (we hope) */
- return 999;
-}
-
-
-static int curr_p_pointer_index(DisplayWindow *dw)
-{
- int p;
-
- for ( p=0; p<dw->image->det->n_panels; ++p) {
- if ( &dw->image->det->panels[p] == dw->calib_mode_curr_p ) {
- return p;
- }
- }
-
- /* Never reached (we hope) */
- return 999;
-}
-
-
-static void select_next_group(DisplayWindow *dw, int num_rg)
-{
- if ( dw->calib_mode_curr_rg == dw->rg_coll->rigid_groups[num_rg-1] ) {
- dw->calib_mode_curr_rg = dw->rg_coll->rigid_groups[0];
- } else {
- dw->calib_mode_curr_rg =
- dw->rg_coll->rigid_groups[curr_rg_pointer_index(dw)+1];
- }
-}
-
-
-static void select_prev_group(DisplayWindow *dw, int num_rg)
-{
- if ( dw->calib_mode_curr_rg == dw->rg_coll->rigid_groups[0] ) {
- dw->calib_mode_curr_rg = dw->rg_coll->rigid_groups[num_rg-1];
- } else {
- dw->calib_mode_curr_rg =
- dw->rg_coll->rigid_groups[curr_rg_pointer_index(dw)-1];
- }
-}
-
-
-static void select_next_panel(DisplayWindow *dw, int num_p)
-{
- if ( dw->calib_mode_curr_p == &dw->image->det->panels[num_p-1] ) {
- dw->calib_mode_curr_p = &dw->image->det->panels[0];
- } else {
- dw->calib_mode_curr_p =
- &dw->image->det->panels[curr_p_pointer_index(dw)+1];
- }
-}
-
-
-static void select_prev_panel(DisplayWindow *dw, int num_p)
-{
- if ( dw->calib_mode_curr_p == &dw->image->det->panels[0] ) {
- dw->calib_mode_curr_p = &dw->image->det->panels[num_p-1];
- } else {
- dw->calib_mode_curr_p =
- &dw->image->det->panels[curr_p_pointer_index(dw)-1];
- }
-}
-
-
-static void toggle_calibmode_groupmode(DisplayWindow *dw)
-{
- struct rigid_group *rg;
- struct detector *det = dw->image->det;
-
- switch ( dw->calib_mode ) {
-
- case CALIBMODE_NONE:
- break;
-
- case CALIBMODE_PANELS:
- if ( det->n_rigid_groups != det->n_panels ) {
- /* Only change if there are any rigid groups defined */
- dw->calib_mode = CALIBMODE_GROUPS;
- rg = find_corresponding_rigid_group(dw,
- dw->calib_mode_curr_p);
- if ( rg == NULL) {
- dw->calib_mode = CALIBMODE_ALL;
- } else {
- dw->calib_mode_curr_rg = rg;
- }
-
- } else {
- /* ...otherwise skip to ALL mode */
- dw->calib_mode = CALIBMODE_ALL;
- }
- break;
-
- case CALIBMODE_GROUPS:
- dw->calib_mode = CALIBMODE_ALL;
- break;
-
- case CALIBMODE_ALL:
- dw->calib_mode = CALIBMODE_PANELS;
- dw->calib_mode_curr_p = dw->calib_mode_curr_rg->panels[0];
- break;
-
- }
-}
-
-
-static void calibmode_next(DisplayWindow *dw)
-{
- int n;
-
- switch ( dw->calib_mode ) {
-
- case CALIBMODE_NONE:
- break;
-
- case CALIBMODE_PANELS:
- n = dw->image->det->n_panels;
- select_next_panel(dw, n);
- break;
-
- case CALIBMODE_GROUPS:
- n = dw->image->det->n_rigid_groups;
- select_next_group(dw, n);
- break;
-
- case CALIBMODE_ALL:
- break;
-
- }
-}
-
-
-static void calibmode_prev(DisplayWindow *dw)
-{
- int n;
-
- switch ( dw->calib_mode ) {
-
- case CALIBMODE_NONE:
- break;
-
- case CALIBMODE_PANELS:
- n = dw->image->det->n_panels;
- select_prev_panel(dw, n);
- break;
-
- case CALIBMODE_GROUPS:
- n = dw->image->det->n_rigid_groups;
- select_prev_group(dw, n);
- break;
-
- case CALIBMODE_ALL:
- break;
-
- }
-}
-
-
static void calibmode_up(DisplayWindow *dw)
{
int pi;
@@ -2440,7 +2624,6 @@ static void calibmode_right(DisplayWindow *dw)
static gint displaywindow_keypress(GtkWidget *widget, GdkEventKey *event,
DisplayWindow *dw)
{
- int s;
if ( !dw->calib_mode ) {
return 0;
@@ -2472,38 +2655,13 @@ static gint displaywindow_keypress(GtkWidget *widget, GdkEventKey *event,
redraw_window(dw);
break;
- case GDK_plus:
case GDK_KP_Add:
- calibmode_next(dw);
- redraw_window(dw);
+ calibmode_next(NULL, dw);
break;
- case GDK_minus:
case GDK_KP_Subtract:
- calibmode_prev(dw);
- redraw_window(dw);
- break;
-
- case GDK_f:
- dw->calib_mode_show_focus = 1 - dw->calib_mode_show_focus;
- redraw_window(dw);
+ calibmode_prev(NULL, dw);
break;
-
- case GDK_g:
- toggle_calibmode_groupmode(dw);
- redraw_window(dw);
- break;
-
- case GDK_s:
- s = save_geometry_file(dw);
- if ( s != 0 ) {
- if ( s != 2 ) {
- displaywindow_error(dw,
- "Unable to save the detector geometry.");
- }
- }
- break;
-
}
return 0;
@@ -2523,11 +2681,10 @@ DisplayWindow *displaywindow_open(char *filename, char *geom_filename,
int median_filter)
{
DisplayWindow *dw;
- char *title;
GtkWidget *vbox;
int check;
GtkWidget *w;
- GtkWidget *ww;
+ char title[1024];
dw = calloc(1, sizeof(DisplayWindow));
if ( dw == NULL ) return NULL;
@@ -2661,11 +2818,15 @@ DisplayWindow *displaywindow_open(char *filename, char *geom_filename,
dw->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
char *bn = safe_basename(filename);
- title = malloc(strlen(bn)+14);
- sprintf(title, "%s - hdfsee", bn);
+ if ( dw->multi_event == 0 ) {
+ sprintf(title, "%s - hdfsee", bn);
+ } else {
+ sprintf(title, "%s - event: %s - hdfsee", bn,
+ get_event_string(dw->ev_list->events[dw->curr_event]));
+ }
+
free(bn);
gtk_window_set_title(GTK_WINDOW(dw->window), title);
- free(title);
g_signal_connect(G_OBJECT(dw->window), "destroy",
G_CALLBACK(displaywindow_closed), dw);
@@ -2696,13 +2857,12 @@ DisplayWindow *displaywindow_open(char *filename, char *geom_filename,
gtk_widget_set_sensitive(GTK_WIDGET(w), FALSE);
}
- ww = gtk_ui_manager_get_widget(dw->ui,
- "/ui/displaywindow/events");
-
if ( dw->image->det == dw->simple_geom || dw->multi_event == 0) {
- gtk_widget_set_sensitive(GTK_WIDGET(ww), FALSE);
+ set_events_menu_sensitivity(dw, FALSE);
}
+ set_calibration_menu_sensitivity(dw, FALSE);
+
displaywindow_update(dw);
gtk_widget_add_events(GTK_WIDGET(dw->drawingarea),
@@ -2723,11 +2883,6 @@ 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 ) {
- displaywindow_update_event_menu(dw, dw->ev_list,
- dw->curr_event);
- }
}
dw->not_ready_yet = 0;
diff --git a/src/dw-hdfsee.h b/src/dw-hdfsee.h
index 81108213..9bb849a1 100644
--- a/src/dw-hdfsee.h
+++ b/src/dw-hdfsee.h
@@ -59,6 +59,12 @@ typedef struct {
} RingRadiusDialog;
+typedef struct {
+ GtkWidget *window;
+ GtkWidget *entry;
+} EventDialog;
+
+
struct numberswindow {
GtkWidget *window;
GtkWidget *labels[17*17];
@@ -83,6 +89,9 @@ typedef struct {
GtkWidget *scrollarea;
GtkUIManager *ui;
GtkActionGroup *action_group;
+ GtkActionGroup *calibration_action_group;
+ GtkActionGroup *events_action_group;
+
int n_pixbufs;
GdkPixbuf **pixbufs;
gulong motion_callback;
@@ -102,6 +111,7 @@ typedef struct {
BinningDialog *binning_dialog;
BoostIntDialog *boostint_dialog;
RingRadiusDialog *ringradius_dialog;
+ EventDialog *event_dialog;
struct numberswindow *numbers_window;
int width;