diff options
author | Thomas White <taw@physics.org> | 2022-12-01 16:45:30 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2022-12-13 17:10:16 +0100 |
commit | 6379e859edfa6003acca688ecabf09a55dfa05d8 (patch) | |
tree | 357765723ead99e38cc4e94a56931879d412a0c7 | |
parent | e6fecaa7b2f3cd7931b51781b55808cb07b66b0f (diff) |
GUI: FoM graph, part 2: Data API
-rw-r--r-- | src/crystfelfomgraph.c | 10 | ||||
-rw-r--r-- | src/crystfelfomgraph.h | 7 | ||||
-rw-r--r-- | src/gui_fom.c | 44 |
3 files changed, 61 insertions, 0 deletions
diff --git a/src/crystfelfomgraph.c b/src/crystfelfomgraph.c index c3d679fa..f8457808 100644 --- a/src/crystfelfomgraph.c +++ b/src/crystfelfomgraph.c @@ -37,6 +37,8 @@ #include <gtk/gtk.h> #include <glib-object.h> +#include <fom.h> + #include "crystfelfomgraph.h" @@ -126,3 +128,11 @@ GtkWidget *crystfel_fom_graph_new() return GTK_WIDGET(fg); } + + +void crystfel_fom_graph_set_data(CrystFELFoMGraph *fg, + double *shell_centers, int n_shells, + enum fom_type *fom_types, double **fom_values, + int n_foms) +{ +} diff --git a/src/crystfelfomgraph.h b/src/crystfelfomgraph.h index b38752ef..ebe1e1ba 100644 --- a/src/crystfelfomgraph.h +++ b/src/crystfelfomgraph.h @@ -33,6 +33,8 @@ #include <config.h> #endif +#include <fom.h> + #define CRYSTFEL_TYPE_FOM_GRAPH (crystfel_fom_graph_get_type()) #define CRYSTFEL_FOM_GRAPH(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \ @@ -72,4 +74,9 @@ typedef struct _crystfelfomgraphclass CrystFELFoMGraphClass; extern GType crystfel_fom_graph_get_type(void); extern GtkWidget *crystfel_fom_graph_new(void); +extern void crystfel_fom_graph_set_data(CrystFELFoMGraph *fg, + double *shell_centers, int n_shells, + enum fom_type *fom_types, + double **fom_values, int n_foms); + #endif /* CRYSTFELFOMGRAPH_H */ diff --git a/src/gui_fom.c b/src/gui_fom.c index 160e84e3..3aaa3602 100644 --- a/src/gui_fom.c +++ b/src/gui_fom.c @@ -113,6 +113,39 @@ static void show_fom(enum fom_type fom, } +static double *make_shell_centers(struct fom_shells *shells) +{ + int i; + double *vals; + + vals = malloc(shells->nshells*sizeof(double)); + if ( vals == NULL ) return NULL; + + for ( i=0; i<shells->nshells; i++ ) { + vals[i] = fom_shell_centre(shells, i); + } + + return vals; +} + + +static double *make_fom_vals(struct fom_context *fctx, + struct fom_shells *shells) +{ + int i; + double *vals; + + vals = malloc(shells->nshells*sizeof(double)); + if ( vals == NULL ) return NULL; + + for ( i=0; i<shells->nshells; i++ ) { + vals[i] = fom_shell_value(fctx, i); + } + + return vals; +} + + static int load_dataset(struct gui_merge_result *result, int need_ano, UnitCell *cell, double min_res, double max_res, @@ -385,6 +418,9 @@ static void fom_response_sig(GtkWidget *dialog, gint resp, continue; } + double *shell_centers = malloc(shells->nshells*sizeof(double)); + double **fom_values = malloc(f->n_foms*sizeof(double *)); + for ( fom=0; fom<f->n_foms; fom++ ) { struct fom_context *fctx; @@ -402,8 +438,16 @@ static void fom_response_sig(GtkWidget *dialog, gint resp, continue; } show_fom(f->fom_types[fom], fctx, shells); + + fom_values[fom] = make_fom_vals(fctx, shells); + } + shell_centers = make_shell_centers(shells); + crystfel_fom_graph_set_data(CRYSTFEL_FOM_GRAPH(f->graph), + shell_centers, shells->nshells, + f->fom_types, fom_values, f->n_foms); + reflist_free(all_refls); reflist_free(all_refls_anom); free_symoplist(sym); |