aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2013-05-28 17:03:49 +0200
committerThomas White <taw@physics.org>2013-05-28 17:03:49 +0200
commit91899fb435a6cac477a2ec11ca14d4387f8b0312 (patch)
tree4aac9072556b7b5968a12f981411460b212e5dc4
parentb9523ce11a532ff579ad60299070281fd4167d62 (diff)
Colours in peak box display (via ncurses)
-rw-r--r--libcrystfel/Makefile.am2
-rw-r--r--libcrystfel/src/integration.c56
2 files changed, 47 insertions, 11 deletions
diff --git a/libcrystfel/Makefile.am b/libcrystfel/Makefile.am
index 2812fa52..2b2d1437 100644
--- a/libcrystfel/Makefile.am
+++ b/libcrystfel/Makefile.am
@@ -1,5 +1,5 @@
lib_LTLIBRARIES = libcrystfel.la
-libcrystfel_la_LIBADD = ../lib/libgnu.la @LIBCRYSTFEL_LIBS@
+libcrystfel_la_LIBADD = ../lib/libgnu.la @LIBCRYSTFEL_LIBS@ -lncurses
libcrystfel_la_LDFLAGS = -version-info 2:0:0
libcrystfel_la_SOURCES = src/reflist.c src/utils.c src/cell.c src/detector.c \
diff --git a/libcrystfel/src/integration.c b/libcrystfel/src/integration.c
index 9c5c8825..3c0a2f1e 100644
--- a/libcrystfel/src/integration.c
+++ b/libcrystfel/src/integration.c
@@ -37,6 +37,7 @@
#include <gsl/gsl_vector.h>
#include <gsl/gsl_linalg.h>
#include <gsl/gsl_eigen.h>
+#include <ncurses.h>
#include "reflist.h"
#include "cell.h"
@@ -240,36 +241,71 @@ static void show_peak_box(struct intcontext *ic, struct peak_box *bx)
{
int q;
- printf("Pixel values ");
- printf("Box flags ");
- printf("Fitted background\n");
+ initscr();
+ start_color();
+ init_pair(1, COLOR_WHITE, COLOR_BLUE) ; /* Background */
+ init_pair(2, COLOR_WHITE, COLOR_RED); /* Peak */
+
+ printw("Pixel values ");
+ printw("Box flags ");
+ printw("Fitted background\n");
for ( q=ic->w-1; q>=0; q-- ) {
int p;
for ( p=0; p<ic->w; p++ ) {
- printf("%5.0f ", boxi(ic, bx, p, q));
+ switch ( bx->bm[p+q*ic->w] ) {
+
+ case BM_BG :
+ attron(COLOR_PAIR(1));
+ break;
+
+ case BM_PK :
+ attron(COLOR_PAIR(2));
+ break;
+
+ default:
+ break;
+
+ }
+ printw("%5.0f ", boxi(ic, bx, p, q));
+ switch ( bx->bm[p+q*ic->w] ) {
+
+ case BM_BG :
+ attroff(COLOR_PAIR(1));
+ break;
+
+ case BM_PK :
+ attroff(COLOR_PAIR(2));
+ break;
+
+ default:
+ break;
+
+ }
}
printf(" ");
for ( p=0; p<ic->w; p++ ) {
- printf("%i ", bx->bm[p+q*ic->w]);
+ printw("%i ", bx->bm[p+q*ic->w]);
}
printf(" ");
for ( p=0; p<ic->w; p++ ) {
- printf("%5.0f ", bx->a*p + bx->b*q + bx->c);
+ printw("%5.0f ", bx->a*p + bx->b*q + bx->c);
}
- printf("\n");
+ printw("\n");
}
- printf("Reference profile number %i\n", bx->rp);
- printf("Background parameters: a=%.2f, b=%.2f, c=%.2f\n",
+ printw("Reference profile number %i\n", bx->rp);
+ printw("Background parameters: a=%.2f, b=%.2f, c=%.2f\n",
bx->a, bx->b, bx->c);
-
+ getch();
+ refresh();
+ endwin();
}