diff options
-rw-r--r-- | src/crystfel_gui.c | 85 | ||||
-rw-r--r-- | src/gui_peaksearch.c | 1 | ||||
-rw-r--r-- | src/gui_project.c | 40 | ||||
-rw-r--r-- | src/gui_project.h | 1 |
4 files changed, 66 insertions, 61 deletions
diff --git a/src/crystfel_gui.c b/src/crystfel_gui.c index 1d4b082a..d7815a58 100644 --- a/src/crystfel_gui.c +++ b/src/crystfel_gui.c @@ -119,37 +119,14 @@ static void update_imageview(struct crystfelproject *proj) if ( proj->n_frames == 0 ) return; - if ( proj->stream != NULL ) { - - if ( stream_select_chunk(proj->stream, - proj->cur_frame) ) - { - ERROR("Failed to select new chunk\n"); - return; - } - - image = stream_read_chunk(proj->stream, - STREAM_REFLECTIONS - | STREAM_PEAKS - | STREAM_IMAGE_DATA); - - if ( image == NULL ) { - ERROR("Failed to read from stream\n"); - return; - } - - } else { - - image = image_read(proj->dtempl, - proj->filenames[proj->cur_frame], - proj->events[proj->cur_frame], - 0, 0); - - if ( image == NULL ) { - ERROR("Failed to load image\n"); - return; - } + image = image_read(proj->dtempl, + proj->filenames[proj->cur_frame], + proj->events[proj->cur_frame], + 0, 0); + if ( image == NULL ) { + ERROR("Failed to load image\n"); + return; } /* Give CrystFELImageView a chance to free resources */ @@ -249,6 +226,21 @@ static void add_files(struct crystfelproject *proj, GFile *folder, } +static void add_frames_from_stream(Stream *st, + DataTemplate *dtempl, + struct crystfelproject *proj) +{ + do { + struct image *image; + image = stream_read_chunk(st, 0); + if ( image == NULL ) break; + add_file_to_project(proj, image->filename, image->ev); + image_free(image); + + } while ( 1 ); +} + + struct finddata_ctx { struct crystfelproject *proj; @@ -337,7 +329,7 @@ static void finddata_response_sig(GtkWidget *dialog, gint resp, char *stream_filename; DataTemplate *dtempl; const char *geom_str; - int n_chunks; + char **streams; stream_filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(ctx->stream)); if ( stream_filename == NULL ) return; @@ -362,9 +354,6 @@ static void finddata_response_sig(GtkWidget *dialog, gint resp, crystfel_image_view_set_image(CRYSTFEL_IMAGE_VIEW(proj->imageview), NULL); - stream_close(proj->stream); - proj->stream = st; - data_template_free(proj->dtempl); proj->dtempl = dtempl; @@ -375,17 +364,17 @@ static void finddata_response_sig(GtkWidget *dialog, gint resp, proj->data_top_folder = NULL; proj->data_search_pattern = MATCH_EVERYTHING; - n_chunks = stream_scan_chunks(st); + add_frames_from_stream(st, proj->dtempl, proj); + proj->stream_filename = stream_filename; - if ( n_chunks == 0 ) { - ERROR("No chunks found (or error reading)\n"); - stream_close(st); - return; + streams = malloc(sizeof(char *)); + if ( streams != NULL ) { + streams[0] = strdup(stream_filename); + add_result(proj, + safe_basename(stream_filename), + streams, 1); } - proj->n_frames = n_chunks; - proj->stream_filename = stream_filename; - crystfel_image_view_set_show_peaks(CRYSTFEL_IMAGE_VIEW(proj->imageview), 1); @@ -993,10 +982,22 @@ int main(int argc, char *argv[]) proj.cur_frame = 0; if ( proj.geom_filename != NULL ) { + dtempl = data_template_new_from_file(proj.geom_filename); if ( dtempl != NULL ) { proj.dtempl = dtempl; } + } else if ( proj.stream_filename != NULL ) { + + Stream *st; + st = stream_open_for_read(proj.stream_filename); + if ( st != NULL ) { + char *geom_str = stream_geometry_file(st); + if ( geom_str != NULL ) { + proj.dtempl = data_template_new_from_string(geom_str); + } + } + stream_close(st); } w = gtk_ui_manager_get_action(proj.ui, "/mainwindow/view/peaks"); diff --git a/src/gui_peaksearch.c b/src/gui_peaksearch.c index 7c2f8a1f..24f35623 100644 --- a/src/gui_peaksearch.c +++ b/src/gui_peaksearch.c @@ -50,7 +50,6 @@ void update_peaks(struct crystfelproject *proj) { if ( proj->n_frames == 0 ) return; if ( proj->cur_image == NULL ) return; - if ( proj->stream != NULL ) return; crystfel_image_view_set_show_peaks(CRYSTFEL_IMAGE_VIEW(proj->imageview), proj->show_peaks); diff --git a/src/gui_project.c b/src/gui_project.c index d315bba8..ca9249d9 100644 --- a/src/gui_project.c +++ b/src/gui_project.c @@ -332,7 +332,6 @@ void clear_project_files(struct crystfelproject *proj) proj->max_frames = 0; proj->filenames = NULL; proj->events = NULL; - proj->stream = NULL; } @@ -517,11 +516,17 @@ int save_project(struct crystfelproject *proj) return 1; } - fprintf(fh, "geom %s\n", proj->geom_filename); - fprintf(fh, "data_folder %s\n", proj->data_top_folder); + if ( proj->geom_filename != NULL ) { + fprintf(fh, "geom %s\n", proj->geom_filename); + } + if ( proj->data_top_folder != NULL ) { + fprintf(fh, "data_folder %s\n", proj->data_top_folder); + } fprintf(fh, "search_pattern %s\n", str_matchtype(proj->data_search_pattern)); - fprintf(fh, "stream %s\n", proj->stream_filename); + if ( proj->stream_filename != NULL ) { + fprintf(fh, "stream %s\n", proj->stream_filename); + } fprintf(fh, "peak_search_params.method %s\n", str_peaksearch(proj->peak_search_params.method)); @@ -563,8 +568,10 @@ int save_project(struct crystfelproject *proj) proj->indexing_params.cell_file); } - fprintf(fh, "indexing.methods %s\n", - proj->indexing_params.indexing_methods); + if ( proj->indexing_params.indexing_methods != NULL ) { + fprintf(fh, "indexing.methods %s\n", + proj->indexing_params.indexing_methods); + } fprintf(fh, "indexing.multi_lattice %i\n", proj->indexing_params.multi); fprintf(fh, "indexing.no_refine %i\n", @@ -585,8 +592,10 @@ int save_project(struct crystfelproject *proj) fprintf(fh, "indexing.min_peaks %i\n", proj->indexing_params.min_peaks); - fprintf(fh, "indexing.new_job_title %s\n", - proj->indexing_new_job_title); + if ( proj->indexing_new_job_title != NULL ) { + fprintf(fh, "indexing.new_job_title %s\n", + proj->indexing_new_job_title); + } fprintf(fh, "indexing.backend %s\n", proj->backends[proj->indexing_backend_selected].name); @@ -617,14 +626,12 @@ int save_project(struct crystfelproject *proj) } fprintf(fh, "-----\n"); - if ( proj->stream == NULL ) { - for ( i=0; i<proj->n_frames; i++ ) { - if ( proj->events[i] != NULL ) { - fprintf(fh, "%s %s\n", - proj->filenames[i], proj->events[i]); - } else { - fprintf(fh, "%s\n", proj->filenames[i]); - } + for ( i=0; i<proj->n_frames; i++ ) { + if ( proj->events[i] != NULL ) { + fprintf(fh, "%s %s\n", + proj->filenames[i], proj->events[i]); + } else { + fprintf(fh, "%s\n", proj->filenames[i]); } } @@ -647,7 +654,6 @@ void default_project(struct crystfelproject *proj) proj->data_top_folder = NULL; proj->data_search_pattern = 0; proj->stream_filename = NULL; - proj->stream = NULL; proj->dtempl = NULL; proj->cur_image = NULL; proj->indexing_opts = NULL; diff --git a/src/gui_project.h b/src/gui_project.h index 798d0283..36438517 100644 --- a/src/gui_project.h +++ b/src/gui_project.h @@ -168,7 +168,6 @@ struct crystfelproject { enum match_type_id data_search_pattern; DataTemplate *dtempl; - Stream *stream; int n_frames; int max_frames; char **filenames; |