aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-02-19 11:29:08 +0100
committerThomas White <taw@physics.org>2021-02-19 11:29:08 +0100
commitc967e898771711498964016a93f2530ba0e0dbe9 (patch)
tree3874327f09a0e7b9b7ed1ed5bf37a967402f8c5c /src
parentdf4b2e604dc0984879e2f417ca5ae1ab7066f539 (diff)
GUI: Don't re-scan streams so often
It only makes sense to re-scan if there is a job running, but this also adds a manual re-scan button for rare exceptions.
Diffstat (limited to 'src')
-rw-r--r--src/crystfel_gui.c48
-rw-r--r--src/gui_project.c19
-rw-r--r--src/gui_project.h5
3 files changed, 59 insertions, 13 deletions
diff --git a/src/crystfel_gui.c b/src/crystfel_gui.c
index 1c27ac7b..3c8b14e4 100644
--- a/src/crystfel_gui.c
+++ b/src/crystfel_gui.c
@@ -150,6 +150,22 @@ const char *selected_result(struct crystfelproject *proj)
}
+/* Return non-zero if there are any jobs running.
+ * If not, it makes no sense to re-scan any result streams.
+ * Possible future improvement: exclude jobs which don't produce streams
+ * (i.e. merging) */
+static int have_running_jobs(struct crystfelproject *proj)
+{
+ int i;
+
+ for ( i=0; i<proj->n_running_tasks; i++ ) {
+ if ( proj->tasks[i].running ) return 1;
+ }
+
+ return 0;
+}
+
+
/* Bring the image view up to date after changing the selected image */
void update_imageview(struct crystfelproject *proj)
{
@@ -197,10 +213,13 @@ void update_imageview(struct crystfelproject *proj)
if ( strcmp(results_name, "crystfel-gui-internal") == 0 ) {
update_peaks(proj);
} else {
- struct image *res_im = find_indexed_image(proj,
- results_name,
- image->filename,
- image->ev);
+ struct image *res_im;
+
+ res_im = find_indexed_image(proj,
+ results_name,
+ image->filename,
+ image->ev,
+ have_running_jobs(proj));
if ( res_im != NULL ) {
swap_data_arrays(image, res_im);
image_free(proj->cur_image);
@@ -599,6 +618,24 @@ static gint save_sig(GtkWidget *widget, struct crystfelproject *proj)
}
+static gint rescan_sig(GtkWidget *widget, struct crystfelproject *proj)
+{
+ const char *results_name;
+
+ results_name = gtk_combo_box_get_active_id(GTK_COMBO_BOX(proj->results_combo));
+ if ( strcmp(results_name, "crystfel-gui-internal") != 0 ) {
+ struct gui_indexing_result *res;
+ res = find_indexing_result_by_name(proj, results_name);
+ if ( res != NULL ) {
+ update_result_index(res);
+ } else {
+ ERROR("Couldn't find result '%s'\n", results_name);
+ }
+ }
+ return FALSE;
+}
+
+
static gint first_frame_sig(GtkWidget *widget,
struct crystfelproject *proj)
{
@@ -772,6 +809,7 @@ static void add_menu_bar(struct crystfelproject *proj, GtkWidget *vbox)
" <menuitem name=\"labelrefls\" action=\"LabelReflsAction\" />"
"</menu>"
"<menu name=\"tools\" action=\"ToolsAction\" >"
+ " <menuitem name=\"rescan\" action=\"RescanAction\" />"
"</menu>"
"<menu name=\"help\" action=\"HelpAction\">"
" <menuitem name=\"about\" action=\"AboutAction\" />"
@@ -789,6 +827,8 @@ static void add_menu_bar(struct crystfelproject *proj, GtkWidget *vbox)
{ "ViewAction", NULL, "_View", NULL, NULL, NULL },
{ "ToolsAction", NULL, "_Tools", NULL, NULL, NULL },
+ { "RescanAction", NULL, "Rescan streams", NULL, NULL,
+ G_CALLBACK(rescan_sig) },
{ "HelpAction", NULL, "_Help", NULL, NULL, NULL },
{ "AboutAction", GTK_STOCK_ABOUT, "_About", NULL, NULL,
diff --git a/src/gui_project.c b/src/gui_project.c
index abc80276..29d4ceb3 100644
--- a/src/gui_project.c
+++ b/src/gui_project.c
@@ -1230,17 +1230,12 @@ struct gui_merge_result *find_merge_result_by_name(struct crystfelproject *proj,
}
-static void update_result_index(struct gui_indexing_result *result)
+void update_result_index(struct gui_indexing_result *result)
{
int i;
-
for ( i=0; i<result->n_streams; i++ ) {
-
- /* FIXME: Skip if already up to date */
-
stream_index_free(result->indices[i]);
result->indices[i] = stream_make_index(result->streams[i]);
-
}
}
@@ -1259,10 +1254,17 @@ struct gui_indexing_result *find_indexing_result_by_name(struct crystfelproject
}
+static int ever_scanned(struct gui_indexing_result *result)
+{
+ return ( result->indices[0] != NULL );
+}
+
+
struct image *find_indexed_image(struct crystfelproject *proj,
const char *results_name,
const char *filename,
- const char *event)
+ const char *event,
+ int permit_rescan)
{
Stream *st;
int i;
@@ -1284,7 +1286,8 @@ struct image *find_indexed_image(struct crystfelproject *proj,
}
}
- if ( !found ) {
+ if ( !found && (permit_rescan || !ever_scanned(result)) ) {
+ /* Re-scan and try again */
update_result_index(result);
for ( i=0; i<result->n_streams; i++ ) {
if ( stream_select_chunk(NULL,
diff --git a/src/gui_project.h b/src/gui_project.h
index 7ab607d2..2289ffff 100644
--- a/src/gui_project.h
+++ b/src/gui_project.h
@@ -348,7 +348,10 @@ extern int add_indexing_result(struct crystfelproject *proj,
extern struct image *find_indexed_image(struct crystfelproject *proj,
const char *result_name,
const char *filename,
- const char *event);
+ const char *event,
+ int permit_rescan);
+
+extern void update_result_index(struct gui_indexing_result *result);
extern struct gui_indexing_result *find_indexing_result_by_name(struct crystfelproject *proj,
const char *name);