Esempio n. 1
0
File: bandmap.c Progetto: patlc/tlf
void bandmap_show() {
/*
 * display depending on filter state
 * - all bands on/off
 * - all mode  on/off
 * - dupes     on/off
 *
 * If more entries to show than place in window, show around current frequency
 *
 * mark entries according to age, source and worked state. Mark new multis
 * - new 	brigth blue
 * - normal	blue
 * - aged	black
 * - worked	small caps
 * - new multi	underlined
 * - self announced stations
 *   		small preceeding letter for reporting station
 *
 * maybe show own frequency as dashline in other color 
 * (maybee green highlighted)
 * - highligth actual spot if near its frequency 
 *
 * Allow selection of one of the spots (switches to S&P)
 * - Ctrl-G as known
 * - '.' and cursor plus 'Enter'
 * - Test mouseclick...
 *
 * '.' goes into map, shows help line above and supports
 * - cursormovement
 * - 'ESC' leaves mode
 * - 'Enter' selects spot
 * - 'B', 'D', 'M' switches filtering for band, dupes and mode on or off.
 */

    GList *list;
    spot *data;
    int cols = 0;
    int curx, cury;
    int bm_x, bm_y;
    int i,j;
    short dupe;

    if (!bm_initialized) {
	bm_init();
	bm_initialized = 1;
    }

    /* acquire mutex 
     * do not add new spots to allspots during
     * - aging and
     * - filtering
     * furthermore do not allow call lookup as long as
     * filter array is build anew */
    pthread_mutex_lock( &bm_mutex );

    bandmap_age();			/* age entries in bandmap */

    /* make array of spots to display
     * filter spotlist according to settings */

    if (spots) 
	g_ptr_array_free( spots, TRUE);		/* free array */

    spots = g_ptr_array_sized_new( 128 );	/* allocate new one */

    list = allspots;

    while (list) {
	data = list->data;

	/* if spot is allband or allmode is set or band or mode matches
	 * actual one than add it to the filtered 'spot' array
	 */

	dupe = bm_isdupe(data->call, data->band);

	if ((bm_config.allband || (data->band == bandinx)) && 
		(bm_config.allmode || (data->mode == trxmode)) &&
		(bm_config.showdupes || !dupe)) {
	
	    data -> dupe = dupe;
	    g_ptr_array_add( spots, data );
	}

	list = list->next;
    }

    pthread_mutex_unlock( &bm_mutex );


    /* afterwards display filtered list around own QRG +/- some offest 
     * (offset gets resest if we change frequency */

    /** \todo Auswahl des Display Bereiches */
    getyx( stdscr, cury, curx);		/* remember cursor */

    /* start in line 14, column 0 */
    bm_y = 14;
    bm_x = 0;

    /* clear space for bandmap */
    attrset(COLOR_PAIR(CB_DUPE)|A_BOLD);

    move(bm_y,0);			/* do not overwrite # frequency */
    for (j = 0; j < 67; j++)
	addch(' ');

    for (i = bm_y + 1; i < bm_y + 10; i++) {
	move (i,0);
	for (j = 0; j < 80; j++)
	    addch (' ');
    }

    bm_show_info();
    /** \fixme Darstellung des # Speichers */

    for (i = 0; i < spots->len; i++) 
    {
	data = g_ptr_array_index( spots, i );

	attrset(COLOR_PAIR(CB_DUPE)|A_BOLD);
	mvprintw (bm_y, bm_x, "%7.1f %c ", (float)(data->freq/1000.), 
		(data->node == thisnode ? '*' : data->node));

	if (data -> timeout > SPOT_NORMAL) 
	    attrset(COLOR_PAIR(CB_NEW)|A_BOLD);

	else if (data -> timeout > SPOT_OLD)
	    attrset(COLOR_PAIR(CB_NORMAL));

	else
	    attrset(COLOR_PAIR(CB_OLD));

	if (bm_ismulti(data->call))
	    attron(A_STANDOUT);

       if (data->dupe) {
	   if (bm_config.showdupes) {
	       attrset(COLOR_PAIR(CB_DUPE)|A_BOLD);
	       attroff(A_STANDOUT);
	       printw ("%-12s", g_ascii_strdown(data->call, -1));
	   }
	}
	else {
	    printw ("%-12s", data->call);
	}

	attroff (A_BOLD);

	bm_y++;
	if (bm_y == 24) {
	    bm_y = 14;
	    bm_x += 22;
	    cols++;
	    if (cols > 2)
		break;
	}
    }
    
    move(cury, curx);			/* reset cursor */

    refreshp();
}
Esempio n. 2
0
void bandmap_show() {
/*
 * display depending on filter state
 * - all bands on/off
 * - all mode  on/off
 * - dupes     on/off
 *
 * If more entries to show than room in window, show around current frequency
 *
 * mark entries according to age, source and worked state. Mark new multis
 * - new 	brigth blue
 * - normal	blue
 * - aged	black
 * - worked	small caps
 * - new multi	underlined
 * - self announced stations
 *   		small preceeding letter for reporting station
 *
 * maybe show own frequency as dashline in other color
 * (maybee green highlighted)
 * - highligth actual spot if near its frequency
 *
 * Allow selection of one of the spots (switches to S&P)
 * - Ctrl-G as known
 * - '.' and cursor plus 'Enter' \Todo
 * - Test mouseclick..           \Todo
 *
 * '.' goes into map, shows help line above and supports
 * - cursormovement
 * - 'ESC' leaves mode
 * - 'Enter' selects spot
 * - 'B', 'D', 'M' switches filtering for band, dupes and mode on or off.
 */

    GList *list;
    spot *data;
    int curx, cury;
    int bm_x, bm_y;
    int i,j;
    short dupe;
    float centerfrequency;

    if (!bm_initialized) {
	bm_init();
	bm_initialized = 1;
    }

    /* acquire mutex
     * do not add new spots to allspots during
     * - aging and
     * - filtering
     * furthermore do not allow call lookup as long as
     * filtered spot array is build anew */

    pthread_mutex_lock( &bm_mutex );

    /* make array of spots to display
     * filter spotlist according to settings */

    if (spots)
	g_ptr_array_free( spots, TRUE);		/* free array */

    spots = g_ptr_array_sized_new( 128 );	/* allocate new one */

    list = allspots;

    while (list) {
	data = list->data;

	/* if spot is allband or allmode is set or band or mode matches
	 * actual one than add it to the filtered 'spot' array
	 * drop spots on WARC bands if in contest mode
	 */

	dupe = bm_isdupe(data->call, data->band);
	if (    (!contest || !IsWarcIndex(data->band))         &&
		(bm_config.allband || (data->band == bandinx)) &&
		(bm_config.allmode || (data->mode == trxmode)) &&
		(bm_config.showdupes || !dupe)) {

	    data -> dupe = dupe;
	    g_ptr_array_add( spots, data );
	}

	list = list->next;
    }

    pthread_mutex_unlock( &bm_mutex );


    /* afterwards display filtered list around own QRG +/- some offest
     * (offset gets reset if we change frequency */

    getyx( stdscr, cury, curx);		/* remember cursor */

    /* start in line 14, column 0 */
    bm_y = 14;
    bm_x = 0;

    /* clear space for bandmap */
    attrset(COLOR_PAIR(CB_DUPE)|A_BOLD);

    move(bm_y,0);			/* do not overwrite # frequency */
    for (j = 0; j < 67; j++)
	addch(' ');

    for (i = bm_y + 1; i < bm_y + 10; i++) {
	move (i,0);
	for (j = 0; j < 80; j++)
	    addch (' ');
    }

    /* show info text */
    bm_show_info();

    /* split bandmap into two parts below and above current QRG.
     * Give both both parts equal size.
     * If there are less spots then reserved in the half
     * give the remaining room to the other half.
     *
     * These results in maximized usage of the bandmap display while
     * trying to keep the actual frequency in the center.
     */
    unsigned int below_qrg = 0;
    unsigned int on_qrg = 0;
    unsigned int startindex, stopindex;

    centerfrequency = bm_get_center(bandinx, trxmode);

    /* calc number of spots below your current QRG */
    for (i = 0; i < spots->len; i++) {
	data = g_ptr_array_index( spots, i );

	if (data->freq <= (centerfrequency*1000 - TOLERANCE))
	    below_qrg++;
	else
	    break;
    }

    /* check if current QRG is on a spot */
    if (below_qrg < spots->len) {
	data = g_ptr_array_index( spots, below_qrg );

	if (!(data->freq > centerfrequency*1000 + TOLERANCE))
	    on_qrg = 1;
    }

    /* calc the index into the spot array of the first spot to show */
    {
	unsigned int max_below;
	unsigned int above_qrg = spots->len - below_qrg - on_qrg;

	if (above_qrg < 14) {
	    max_below = 30 - above_qrg - 1;
	}
	else
	    max_below = 15;

	startindex = (below_qrg < max_below)? 0 : (below_qrg - max_below);
    }

    /* calculate the index+1 of the last spot to show */
    stopindex  = (spots->len < startindex + 30 - (1 - on_qrg))
	? spots->len
	: (startindex + 30 - (1 - on_qrg));

    /* correct calculations if we have no rig frequency to show */
    if (trx_control == 0) {
	if (on_qrg) {
	    on_qrg = 0;
	} else {
	    stopindex += 1;
	}
	if (spots->len < stopindex)
	    stopindex = spots->len;
    }

    /* show spots below QRG */
    for (i = startindex; i < below_qrg; i++)
    {
	move (bm_y, bm_x);
	show_spot(g_ptr_array_index( spots, i ));
	next_spot_position(&bm_y, &bm_x);
    }

    /* show highlighted frequency marker or spot on QRG if rig control
     * is active */
    if (trx_control != 0) {
	move (bm_y, bm_x);
	attrset(COLOR_PAIR(C_HEADER) | A_STANDOUT);
	if (!on_qrg) {
	    printw ("%7.1f   %s", centerfrequency,  "============");
	}
	else {
	    show_spot_on_qrg(g_ptr_array_index( spots, below_qrg ));
	}
	next_spot_position(&bm_y, &bm_x);
    }

    /* show spots above QRG */
    for (i = below_qrg + on_qrg; i < stopindex; i++)
    {
	move (bm_y, bm_x);
	show_spot(g_ptr_array_index( spots, i ));
	next_spot_position(&bm_y, &bm_x);
    }

    attroff (A_BOLD);
    move(cury, curx);			/* reset cursor */

    refreshp();
}