aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorValerio Mariani <valerio.mariani@desy.de>2015-02-05 14:33:04 +0100
committerThomas White <taw@physics.org>2015-02-05 17:13:54 +0100
commit39db07ff9e7b345660780477632da88dfb8cc86f (patch)
treeeca91d0e6f3c0fd4fee2350c560de268bb28fc32 /src
parent7eb824c40a6bc6ef532c0e385843bace533b79e1 (diff)
Fixed hdfsee handling of rigid group collections
Diffstat (limited to 'src')
-rw-r--r--src/dw-hdfsee.c69
-rw-r--r--src/dw-hdfsee.h1
-rw-r--r--src/hdfsee.c4
3 files changed, 55 insertions, 19 deletions
diff --git a/src/dw-hdfsee.c b/src/dw-hdfsee.c
index bd13dbe9..e92dcd1e 100644
--- a/src/dw-hdfsee.c
+++ b/src/dw-hdfsee.c
@@ -312,10 +312,27 @@ static void show_simple_ring(cairo_t *cr, DisplayWindow *dw,
cairo_stroke(cr);
}
+static struct rigid_group *find_corresponding_rigid_group(DisplayWindow *dw,
+ struct panel *p) {
+
+ int gi;
+
+ for (gi=0; gi<dw->rg_coll->n_rigid_groups; gi++) {
+ if (panel_is_in_rigid_group(dw->rg_coll->rigid_groups[gi],
+ p)) {
+ return dw->rg_coll->rigid_groups[gi];
+ }
+ }
+
+ return NULL;
+}
+
static void maybe_draw_focus(DisplayWindow *dw, cairo_t *cr, int i,
cairo_matrix_t *basic_m)
{
+ struct rigid_group *rg = NULL;
+
switch ( dw->calib_mode ) {
case CALIBMODE_NONE:
@@ -329,9 +346,9 @@ static void maybe_draw_focus(DisplayWindow *dw, cairo_t *cr, int i,
break;
case CALIBMODE_GROUPS:
- if ( dw->image->det->panels[i].rigid_group ==
- dw->calib_mode_curr_rg )
- {
+ rg = find_corresponding_rigid_group(dw,
+ &dw->image->det->panels[i]);
+ if (rg == dw->calib_mode_curr_rg) {
draw_calib_focus_rectangle(cr, basic_m, dw, i);
cairo_stroke(cr);
}
@@ -1251,6 +1268,26 @@ static gint displaywindow_set_calibmode(GtkWidget *d, DisplayWindow *dw)
return 0;
}
+ if (dw->rg_coll_name == NULL) {
+ dw->rg_coll = dw->image->det->rigid_group_collections[0];
+ if (dw->rg_coll == NULL) {
+ ERROR("Cannot find asuitable rigid group collection.\n");
+ gtk_check_menu_item_set_state(GTK_CHECK_MENU_ITEM(w),
+ 0);
+ return 0;
+ }
+ } else {
+ dw->rg_coll = find_rigid_group_collection_by_name(dw->image->det,
+ dw->rg_coll_name);
+ if (dw->rg_coll == NULL) {
+ ERROR("Cannot find rigid group collection: %s\n",
+ dw->rg_coll_name);
+ gtk_check_menu_item_set_state(GTK_CHECK_MENU_ITEM(w),
+ 0);
+ return 0;
+ }
+ }
+
/* Get new value */
val = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w));
@@ -2203,8 +2240,14 @@ static void toggle_calibmode_groupmode(DisplayWindow *dw)
if ( det->n_rigid_groups != det->n_panels ) {
/* Only change if there are any rigid groups defined */
dw->calib_mode = CALIBMODE_GROUPS;
- rg = dw->calib_mode_curr_p->rigid_group;
- dw->calib_mode_curr_rg = rg;
+ 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;
@@ -2521,6 +2564,12 @@ DisplayWindow *displaywindow_open(char *filename, char *geom_filename,
} else {
dw->geom_filename = NULL;
}
+ if (rgcoll_name != NULL) {
+ dw->rg_coll_name = strdup(rgcoll_name);
+ } else {
+ dw->rg_coll_name = NULL;
+ }
+
dw->image->det = det_geom;
dw->image->beam = beam;
dw->image->lambda = 0.0;
@@ -2645,16 +2694,6 @@ DisplayWindow *displaywindow_open(char *filename, char *geom_filename,
gtk_widget_set_sensitive(GTK_WIDGET(w), FALSE);
}
- if ( rgcoll_name != NULL ) {
-
- dw->rg_coll = dw->image->det->rigid_group_collections[0];
- if ( dw->rg_coll == NULL ) {
- ERROR("Cannot find suitable rigid group collection.\n",
- rgcoll_name);
- return NULL;
- }
- }
-
ww = gtk_ui_manager_get_widget(dw->ui,
"/ui/displaywindow/events");
diff --git a/src/dw-hdfsee.h b/src/dw-hdfsee.h
index 39b82250..81108213 100644
--- a/src/dw-hdfsee.h
+++ b/src/dw-hdfsee.h
@@ -96,6 +96,7 @@ typedef struct {
struct image *image;
char *geom_filename;
+ char *rg_coll_name;
/* Dialog boxes */
BinningDialog *binning_dialog;
diff --git a/src/hdfsee.c b/src/hdfsee.c
index c5557c38..89b8bf95 100644
--- a/src/hdfsee.c
+++ b/src/hdfsee.c
@@ -300,10 +300,6 @@ int main(int argc, char *argv[])
return 1;
}
- if (rgcoll_name == NULL) {
- rgcoll_name = strdup("default");
- }
-
if ( cscale == NULL ) cscale = strdup("colour");
if ( strcmp(cscale, "mono") == 0 ) {
colscale = SCALE_MONO;