diff options
-rw-r--r-- | src/detector.c | 2 | ||||
-rw-r--r-- | src/diffraction.c | 3 | ||||
-rw-r--r-- | src/sfac.c | 3 | ||||
-rw-r--r-- | src/utils.c | 11 | ||||
-rw-r--r-- | src/utils.h | 2 |
5 files changed, 11 insertions, 10 deletions
diff --git a/src/detector.c b/src/detector.c index fae37126..16972b56 100644 --- a/src/detector.c +++ b/src/detector.c @@ -182,7 +182,7 @@ void record_image(struct image *image) image->hdr[x + image->width*y] = counts; } - progress_bar(x, image->width-1); + progress_bar(x, image->width-1, "Adding water and noise"); } if ( do_bloom ) { diff --git a/src/diffraction.c b/src/diffraction.c index 8cf3f4ed..f1322c04 100644 --- a/src/diffraction.c +++ b/src/diffraction.c @@ -166,7 +166,6 @@ void get_diffraction(struct image *image) get_reflections_cached(image->molecule, image->xray_energy); } - progress_bar(0, image->width-1); for ( x=0; x<image->width; x++ ) { for ( y=0; y<image->height; y++ ) { @@ -185,6 +184,6 @@ void get_diffraction(struct image *image) image->sfacs[x + image->width*y] = val; } - progress_bar(x, image->width-1); + progress_bar(x, image->width-1, "Calculating lattice factors"); } } @@ -454,7 +454,8 @@ double complex *get_reflections(struct molecule *mol, double en) //} } - progress_bar((k+INDMAX)+IDIM*(h+INDMAX), IDIM*IDIM-1); + progress_bar((k+INDMAX)+IDIM*(h+INDMAX), IDIM*IDIM-1, + "Calculating structure factors"); } } //printf("Total scattered = %f, F000 = %f\n", tscat, F00); diff --git a/src/utils.c b/src/utils.c index faf78502..4f5f7da3 100644 --- a/src/utils.c +++ b/src/utils.c @@ -53,19 +53,20 @@ void chomp(char *s) } -void progress_bar(int val, int total) +void progress_bar(int val, int total, const char *text) { double frac; int n, i; char s[1024]; + const int width = 50; frac = (double)val/total; - n = (int)(frac*80); + n = (int)(frac*width); for ( i=0; i<n; i++ ) s[i] = '='; - for ( i=n; i<80; i++ ) s[i] = '.'; - s[80] = '\0'; - printf("\r|%s|", s); + for ( i=n; i<width; i++ ) s[i] = '.'; + s[width] = '\0'; + printf("\r%s: |%s|", text, s); if ( val == total ) printf("\n"); diff --git a/src/utils.h b/src/utils.h index 54cfdcfb..c89466c3 100644 --- a/src/utils.h +++ b/src/utils.h @@ -54,7 +54,7 @@ extern double angle_between(double x1, double y1, double z1, double x2, double y2, double z2); extern size_t skipspace(const char *s); extern void chomp(char *s); -extern void progress_bar(int val, int total); +extern void progress_bar(int val, int total, const char *text); extern double poisson_noise(double expected); /* Keep these ones inline, to avoid function call overhead */ |