aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/diffraction.c2
-rw-r--r--src/utils.c18
-rw-r--r--src/utils.h3
3 files changed, 21 insertions, 2 deletions
diff --git a/src/diffraction.c b/src/diffraction.c
index 8d26dc7c..25b8c3b4 100644
--- a/src/diffraction.c
+++ b/src/diffraction.c
@@ -136,6 +136,6 @@ void get_diffraction(struct image *image, UnitCell *cell)
image->sfacs[x + image->width*y] = f_lattice * f_molecule;
}
- printf("x=%i\n", x);
+ progress_bar(x, image->width-1);
}
}
diff --git a/src/utils.c b/src/utils.c
index fa239f90..d58f4db8 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -156,3 +156,21 @@ void mapping_rotate(double x, double y, double z,
*ddy = ny;
*ddz = nz;
}
+
+
+void progress_bar(int val, int total)
+{
+ double frac;
+ int n, i;
+ char s[1024];
+
+ frac = (double)val/total;
+ n = frac*80;
+
+ for ( i=0; i<n; i++ ) s[i] = '=';
+ for ( i=n; i<80; i++ ) s[i] = '.';
+ s[n] = '\0';
+ printf("\r|%s|", s);
+
+ if ( val == total ) printf("\n");
+}
diff --git a/src/utils.h b/src/utils.h
index 1de0ea09..7940d77f 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -50,7 +50,8 @@ extern int sign(double a);
extern void mapping_rotate(double x, double y, double z,
double *ddx, double *ddy, double *ddz,
double omega, double tilt);
-
+extern void progress_bar(int val, int total);
+
#define rad2deg(a) ((a)*180/M_PI)
#define deg2rad(a) ((a)*M_PI/180)