aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2009-11-25 18:12:14 +0100
committerThomas White <taw@physics.org>2009-11-25 18:12:14 +0100
commitc275432adfec54341839aa903c19a78cde2a734c (patch)
treea7353d6de885d3ef50d3f623d9c03d0a0139d1a5
parent0a3ed7206e2bc009ba86a8072530a3f18196cf8f (diff)
Improve progress bar
-rw-r--r--src/detector.c2
-rw-r--r--src/diffraction.c3
-rw-r--r--src/sfac.c3
-rw-r--r--src/utils.c11
-rw-r--r--src/utils.h2
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");
}
}
diff --git a/src/sfac.c b/src/sfac.c
index 290b4836..40ae8db4 100644
--- a/src/sfac.c
+++ b/src/sfac.c
@@ -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 */