From 91899fb435a6cac477a2ec11ca14d4387f8b0312 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Tue, 28 May 2013 17:03:49 +0200 Subject: Colours in peak box display (via ncurses) --- libcrystfel/src/integration.c | 56 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 10 deletions(-) (limited to 'libcrystfel/src/integration.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 #include #include +#include #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; pw; 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; pw; p++ ) { - printf("%i ", bx->bm[p+q*ic->w]); + printw("%i ", bx->bm[p+q*ic->w]); } printf(" "); for ( p=0; pw; 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(); } -- cgit v1.2.3