diff options
author | taw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1> | 2007-10-03 23:15:53 +0000 |
---|---|---|
committer | taw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1> | 2007-10-03 23:15:53 +0000 |
commit | 6c4cc88d5248507a3ce9970e1ed8eca60b60952a (patch) | |
tree | 83b1a1f4ab5846bfed8774f2091c76993dd9e0e5 /src/main.c | |
parent | 2314f19f1502e713cf9aa54330273820e652e6f6 (diff) |
Alter the semantics of caching
git-svn-id: svn://cook.msm.cam.ac.uk:745/diff-tomo/dtr@152 bf6ca9ba-c028-0410-8290-897cf20841d1
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 68 |
1 files changed, 37 insertions, 31 deletions
@@ -37,15 +37,14 @@ void main_do_reconstruction(ControlContext *ctx) { - if ( (ctx->inputfiletype != INPUT_CACHE) && (ctx->inputfiletype != INPUT_DRX) ) { + if ( ctx->cache_filename ) { prealign_sum_stack(ctx); + ctx->reflectionlist = cache_load(ctx->cache_filename); + printf("Loading cached reflections from '%s'\n", ctx->cache_filename); + } else if ( ctx->inputfiletype != INPUT_DRX ) { mapping_create(ctx); } - if ( (ctx->inputfiletype != INPUT_CACHE) && ctx->reflectionlist && ctx->savecache ) { - cache_save(ctx->filename, ctx->reflectionlist); - } - if ( ctx->reflectionlist ) { ctx->dw = displaywindow_open(ctx); } else { @@ -67,6 +66,7 @@ static gint main_method_window_response(GtkWidget *method_window, gint response, case 2 : ctx->psmode = PEAKSEARCH_LSQ; break; case 3 : ctx->psmode = PEAKSEARCH_ZAEFFERER; break; case 4 : ctx->psmode = PEAKSEARCH_STAT; break; + case 5 : ctx->psmode = PEAKSEARCH_CACHED; break; default: ctx->psmode = PEAKSEARCH_NONE; break; /* This happens when reading from a cache file */ } @@ -76,11 +76,7 @@ static gint main_method_window_response(GtkWidget *method_window, gint response, ctx->prealign = FALSE; } - if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ctx->checkbox_savecache)) ) { - ctx->savecache = TRUE; - } else { - ctx->savecache = FALSE; - } + ctx->cache_filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(ctx->cache_file_selector)); gtk_widget_destroy(method_window); while ( gtk_events_pending() ) gtk_main_iteration(); @@ -90,9 +86,6 @@ static gint main_method_window_response(GtkWidget *method_window, gint response, val = qdrp_read(ctx); } else if ( ctx->inputfiletype == INPUT_MRC ) { val = mrc_read(ctx); - } else if ( ctx->inputfiletype == INPUT_CACHE ) { - ctx->reflectionlist = cache_load(ctx->filename); - if ( !ctx->reflectionlist ) val = 1; } else if ( ctx->inputfiletype == INPUT_DRX ) { ctx->reflectionlist = dirax_load(ctx->filename); if ( !ctx->reflectionlist ) val = 1; @@ -117,6 +110,18 @@ static gint main_method_window_response(GtkWidget *method_window, gint response, } +static gint main_peaksearch_changed(GtkWidget *method_window, ControlContext *ctx) { + + if ( gtk_combo_box_get_active(GTK_COMBO_BOX(ctx->combo_peaksearch)) == 5 ) { + gtk_widget_set_sensitive(GTK_WIDGET(ctx->cache_file_selector), TRUE); + } else { + gtk_widget_set_sensitive(GTK_WIDGET(ctx->cache_file_selector), FALSE); + } + + return 0; + +} + void main_method_dialog_open(ControlContext *ctx) { GtkWidget *method_window; @@ -124,14 +129,16 @@ void main_method_dialog_open(ControlContext *ctx) { GtkWidget *hbox; GtkWidget *table; GtkWidget *peaksearch_label; + GtkWidget *cache_file_selector_label; method_window = gtk_dialog_new_with_buttons("Reconstruction Parameters", NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_CLOSE, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); + gtk_window_set_default_size(GTK_WINDOW(method_window), 400, -1); vbox = gtk_vbox_new(FALSE, 0); hbox = gtk_hbox_new(TRUE, 0); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(method_window)->vbox), GTK_WIDGET(hbox), FALSE, FALSE, 7); - gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(vbox), FALSE, FALSE, 10); + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(vbox), FALSE, TRUE, 10); table = gtk_table_new(3, 2, FALSE); gtk_table_set_row_spacings(GTK_TABLE(table), 5); @@ -145,17 +152,22 @@ void main_method_dialog_open(ControlContext *ctx) { gtk_combo_box_append_text(GTK_COMBO_BOX(ctx->combo_peaksearch), "Least-Squares Fit"); gtk_combo_box_append_text(GTK_COMBO_BOX(ctx->combo_peaksearch), "Zaefferer Gradient Search"); gtk_combo_box_append_text(GTK_COMBO_BOX(ctx->combo_peaksearch), "Iterative Statistical Analysis"); + gtk_combo_box_append_text(GTK_COMBO_BOX(ctx->combo_peaksearch), "Get From Cache File"); gtk_combo_box_set_active(GTK_COMBO_BOX(ctx->combo_peaksearch), 3); gtk_table_attach_defaults(GTK_TABLE(table), ctx->combo_peaksearch, 2, 3, 1, 2); + g_signal_connect(G_OBJECT(ctx->combo_peaksearch), "changed", G_CALLBACK(main_peaksearch_changed), ctx); - ctx->checkbox_prealign = gtk_check_button_new_with_label("Pre-align image stack"); - gtk_table_attach_defaults(GTK_TABLE(table), ctx->checkbox_prealign, 1, 3, 2, 3); + cache_file_selector_label = gtk_label_new("Cache File to Load: "); + gtk_table_attach_defaults(GTK_TABLE(table), cache_file_selector_label, 1, 2, 2, 3); + gtk_misc_set_alignment(GTK_MISC(cache_file_selector_label), 1, 0.5); + ctx->cache_file_selector = gtk_file_chooser_button_new("Select Cache File to Load", GTK_FILE_CHOOSER_ACTION_OPEN); + gtk_table_attach_defaults(GTK_TABLE(table), ctx->cache_file_selector, 2, 3, 2, 3); + gtk_widget_set_sensitive(GTK_WIDGET(ctx->cache_file_selector), FALSE); - ctx->checkbox_savecache = gtk_check_button_new_with_label("Save 3D mapping cache file"); - gtk_table_attach_defaults(GTK_TABLE(table), ctx->checkbox_savecache, 1, 3, 3, 4); + ctx->checkbox_prealign = gtk_check_button_new_with_label("Manually pre-align the image stack"); + gtk_table_attach_defaults(GTK_TABLE(table), ctx->checkbox_prealign, 1, 3, 3, 4); if ( ctx->inputfiletype == INPUT_CACHE ) { - gtk_combo_box_append_text(GTK_COMBO_BOX(ctx->combo_peaksearch), "3D coordinates from cache file"); gtk_widget_set_sensitive(GTK_WIDGET(ctx->combo_peaksearch), FALSE); gtk_combo_box_set_active(GTK_COMBO_BOX(ctx->combo_peaksearch), 5); } @@ -176,7 +188,6 @@ void main_method_dialog_open(ControlContext *ctx) { int main(int argc, char *argv[]) { - char *filename; ControlContext *ctx; struct stat stat_buffer; FILE *fh; @@ -198,26 +209,23 @@ int main(int argc, char *argv[]) { return 1; } - filename = argv[1]; ctx = control_ctx_new(); + ctx->filename = strdup(argv[1]); - fh = fopen(filename, "r"); + fh = fopen(ctx->filename, "r"); if ( !fh ) { - printf("Couldn't open file '%s'\n", filename); + printf("Couldn't open file '%s'\n", ctx->filename); return 1; } fclose(fh); - if ( qdrp_is_qdrprc(filename) ) { + if ( qdrp_is_qdrprc(ctx->filename) ) { printf("QDRP input file detected.\n"); ctx->inputfiletype = INPUT_QDRP; - } else if ( mrc_is_mrcfile(filename) ) { + } else if ( mrc_is_mrcfile(ctx->filename) ) { printf("MRC tomography file detected.\n"); ctx->inputfiletype = INPUT_MRC; - } else if ( cache_is_cachefile(filename) ) { - printf("Cached reflection file detected.\n"); - ctx->inputfiletype = INPUT_CACHE; - } else if ( dirax_is_drxfile(filename) ) { + } else if ( dirax_is_drxfile(ctx->filename) ) { printf("Dirax input file detected.\n"); ctx->inputfiletype = INPUT_DRX; } else { @@ -225,8 +233,6 @@ int main(int argc, char *argv[]) { return 1; } - ctx->filename = strdup(argv[1]); - if ( stat(argv[1], &stat_buffer) == -1 ) { fprintf(stderr, "File '%s' not found\n", argv[1]); return 1; |