Commit c275432a authored by Thomas White's avatar Thomas White
Browse files

Improve progress bar

parent 0a3ed720
......@@ -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 ) {
......
......@@ -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);
......
......@@ -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");
......
......@@ -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 */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment