From a3480ec447f420a49bdf89f80a500c0dc3aecc2e Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 13 Jul 2023 17:19:42 +0200 Subject: Implement data_template_group_info() --- libcrystfel/src/datatemplate.c | 37 +++++++++++++++++++++++++++++++++++++ libcrystfel/src/datatemplate.h | 10 ++++++++++ 2 files changed, 47 insertions(+) (limited to 'libcrystfel/src') diff --git a/libcrystfel/src/datatemplate.c b/libcrystfel/src/datatemplate.c index 6adfb9f3..fd7f2761 100644 --- a/libcrystfel/src/datatemplate.c +++ b/libcrystfel/src/datatemplate.c @@ -2623,3 +2623,40 @@ int data_template_write_to_file(const DataTemplate *dtempl, const char *filename fclose(fh); return 0; } + + +static void add_group_info(struct dg_group_info *ginfo, int *ppos, + struct panel_group_template *group, + int serial, int level, int c_mul) +{ + int j; + int i = *ppos; + (*ppos)++; + + ginfo[i].name = group->name; + ginfo[i].serial = serial; + ginfo[i].hierarchy_level = level; + + for ( j=0; jn_children; j++ ) { + add_group_info(ginfo, ppos, group->children[j], + serial+c_mul*(j+1), level+1, c_mul*100); + } +} + + +struct dg_group_info *data_template_group_info(const DataTemplate *dtempl, int *n) +{ + struct dg_group_info *ginfo; + int i; + struct panel_group_template *group; + + ginfo = malloc(sizeof(struct dg_group_info)*dtempl->n_groups); + if ( ginfo == NULL ) return NULL; + + group = find_group(dtempl, "all"); + i = 0; + add_group_info(ginfo, &i, group, 0, 0, 100); + + *n = dtempl->n_groups; + return ginfo; +} diff --git a/libcrystfel/src/datatemplate.h b/libcrystfel/src/datatemplate.h index c20cbcce..07f2387d 100644 --- a/libcrystfel/src/datatemplate.h +++ b/libcrystfel/src/datatemplate.h @@ -43,6 +43,14 @@ typedef struct _datatemplate DataTemplate; +struct dg_group_info +{ + const char *name; + int serial; + int hierarchy_level; +}; + + #ifdef __cplusplus extern "C" { #endif @@ -98,6 +106,8 @@ extern int data_template_rotate_group(DataTemplate *dtempl, extern int data_template_write_to_file(const DataTemplate *dtempl, const char *filename); +extern struct dg_group_info *data_template_group_info(const DataTemplate *dtempl, int *n); + #ifdef __cplusplus } #endif -- cgit v1.2.3