diff options
author | Thomas White <taw@physics.org> | 2022-01-12 16:33:47 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2022-01-12 16:34:14 +0100 |
commit | a50a84632be02a4a5a9653e6e19a1bf27ee7bc41 (patch) | |
tree | f26fae46cd1212f8aa163ca3e846d0f5697dd860 | |
parent | 48c02e71e5bf548180c0191645bb77dec01a5559 (diff) |
GUI: Try to get geometry from result (stream), if not explicitly provided
Fixes: https://gitlab.desy.de/thomas.white/crystfel/-/issues/56
-rw-r--r-- | src/crystfel_gui.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/crystfel_gui.c b/src/crystfel_gui.c index 177b6499..31f2b4d2 100644 --- a/src/crystfel_gui.c +++ b/src/crystfel_gui.c @@ -885,6 +885,50 @@ static void add_log_menu_items(GtkTextView *textview, } +static void try_load_geom_from_result(struct crystfelproject *proj) +{ + struct gui_indexing_result *res; + Stream *st; + char *geom_str; + const char *res_name = selected_result(proj); + + STATUS("No geometry file specified in project file.\n"); + if ( strcmp(res_name, "crystfel-gui-internal") == 0 ) { + if ( proj->n_results == 0 ) { + ERROR("No indexing results found. " + "No geometry information!\n"); + return; + } + res_name = proj->results[0].name; + } + + res = find_indexing_result_by_name(proj, res_name); + if ( res == NULL ) { + ERROR("Couldn't find results '%s'\n", res_name); + return; + } + + st = stream_open_for_read(res->streams[0]); + if ( st == NULL ) { + ERROR("Couldn't open stream '%s' from result '%s'\n", + res->streams[0], res_name); + return; + } + + geom_str = stream_geometry_file(st); + if ( geom_str == NULL ) { + ERROR("No geometry in stream '%s' from result '%s'\n", + res->streams[0], res_name); + return; + } + + proj->dtempl = data_template_new_from_string(geom_str); + stream_close(st); + + STATUS("Using geometry from result '%s'\n", res_name); +} + + int main(int argc, char *argv[]) { int c; @@ -1102,6 +1146,8 @@ int main(int argc, char *argv[]) if ( dtempl != NULL ) { proj.dtempl = dtempl; } + } else { + try_load_geom_from_result(&proj); } update_imageview(&proj); |