diff options
author | Thomas White <taw@physics.org> | 2020-06-10 12:01:35 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2020-07-29 18:53:44 +0200 |
commit | 761026b65852d3ce1af632d2514b939f78170262 (patch) | |
tree | 1f8053be565979ee3b9e95e35850b1f08ed71654 | |
parent | c4336e0ff01455470036b5d17b368d21a2838424 (diff) |
Add data_template_panel_name_to_number and rename data_template_panel_name
-rw-r--r-- | libcrystfel/src/datatemplate.c | 17 | ||||
-rw-r--r-- | libcrystfel/src/datatemplate.h | 8 |
2 files changed, 23 insertions, 2 deletions
diff --git a/libcrystfel/src/datatemplate.c b/libcrystfel/src/datatemplate.c index 2593a7f9..7117a62e 100644 --- a/libcrystfel/src/datatemplate.c +++ b/libcrystfel/src/datatemplate.c @@ -1303,6 +1303,23 @@ const char *data_template_panel_name(const DataTemplate *dt, int pn) } +int data_template_panel_name_to_number(const DataTemplate *dt, + const char *panel_name, + int *pn) +{ + if ( panel_name == NULL ) return 1; + + for ( i=0; i<dt->n_panels; i++ ) { + if ( strcmp(panel_name, dt->panels[i].name) == 0 ) { + *pn = i; + return 0; + } + } + + return 1; +} + + void data_template_add_copy_header(DataTemplate *dt, const char *header) { diff --git a/libcrystfel/src/datatemplate.h b/libcrystfel/src/datatemplate.h index 9cb60bf1..a4520ba2 100644 --- a/libcrystfel/src/datatemplate.h +++ b/libcrystfel/src/datatemplate.h @@ -54,8 +54,12 @@ extern "C" { extern DataTemplate *data_template_new_from_file(const char *filename); extern void data_template_free(DataTemplate *dt); -extern const char *data_template_panel_name(const DataTemplate *dt, - int pn); +extern const char *data_template_panel_number_to_name(const DataTemplate *dt, + int pn); + +extern int data_template_panel_name_to_number(const DataTemplate *dt, + const char *panel_name, + int *pn); extern int data_template_file_to_panel_coords(const DataTemplate *dt, float *pfs, float *pss, |