static gint colsb_left[NUMBER_OF_CONTESTS] = {55,55,55,54,54,57,54,54,54,54}; static gint itime_off = 0; static void rate_box(GtkWidget *widget, gint idraw); static void keyer_box(GtkWidget *widget, gint idraw); static void zone_box(GtkWidget *widget, gint idraw); static void summary_box(GtkWidget *widget, gint idraw); static void traffic_lights(GtkWidget *widget); static void beam_heading(GtkWidget *widget, guint istate); static gint vertical_switch_position(gint ibearing); static gdouble fact(gint num); static gdouble ci(gdouble x); static void rate_box(GtkWidget *widget, gint idraw) { GdkRectangle update_rect; gchar rate_hold[7]; gchar rate_calls[2][4], rate_labels[3][16], rate_lines[3][12]; gint i, j, col2, dt_qso, dt_off, last_calls[3]; gdouble rate; gint row1=4, col1=1, row2=8; col2 = colsb_left[isel_contest]-2; if(isel_contest==WW) col2 -= 14; if(fp_keyer && mode==CW) col2 -= 10; update_rect.x = col1*wcol; update_rect.y = row1*hrow; update_rect.width = (col2-col1-1)*wcol; update_rect.height = (row2-row1-1)*hrow; if(idraw) draw_box (row1, col1, row2, col2, 2, LT_GRAY, BLACK, "Rate", WHITE, "", LT_GRAY, SAVEPIX); draw_rectangle (&update_rect, RED, SAVEPIX); for(i=0; i<2; i++) { strcpy(rate_calls[i], set_screen_choices[i+7]); left_blank_pad (rate_calls[i], sizeof(rate_calls[i])); strcpy(rate_labels[i], "Last "); strcat(rate_labels[i], rate_calls[i]); strcat(rate_labels[i], " Calls"); } strcpy(rate_labels[2], "Overall Contest"); for(i=0; i<2; i++) last_calls[i] = atoi(rate_calls[i]); last_calls[2] = icall_count-1; for(i=0; i<3; i++) { if(icall_count>5 && icall_count>last_calls[i]) { dt_off = 0; for(j=icall_count; j>icall_count-last_calls[i]; j--) { dt_qso = idelta_time (cr_array[j-1].date, cr_array[j].date, cr_array[j-1].time, cr_array[j].time); if(dt_qso>60*atoi(set_screen_choices[9])) dt_off += dt_qso; } if(i==2) itime_off = dt_off/60; dt_qso = idelta_time (cr_array[icall_count-last_calls[i]].date, cr_array[icall_count].date, cr_array[icall_count-last_calls[i]].time, cr_array[icall_count].time); rate = ((gdouble) (last_calls[i]*3600))/ ((gdouble) (dt_qso-dt_off)); real_to_char (rate, rate_hold, 1); left_blank_pad (rate_hold, sizeof(rate_hold)); strcpy(rate_lines[i], rate_hold); strcat(rate_lines[i], "/hour"); } else strcpy(rate_lines[i], " N/A"); } for(i=0; i<3; i++) { write_line (row1+i, col1+1, rate_labels[i], WHITE, SAVEPIX); write_line (row1+i, col1+17, rate_lines[i], WHITE, SAVEPIX); } gtk_widget_queue_draw_area (widget, update_rect.x-idraw*wcol, update_rect.y-idraw*hrow, update_rect.width+idraw*2*wcol, update_rect.height+idraw*2*hrow); } static void keyer_box(GtkWidget *widget, gint idraw) { GdkRectangle update_rect; gint col1, col2; gchar spd[5]; gint row1=4, row2=8; col2 = colsb_left[isel_contest]-2; if(isel_contest==WW) col2 -= 14; col1 = col2-8; update_rect.x = col1*wcol; update_rect.y = row1*hrow; update_rect.width = (col2-col1-1)*wcol; update_rect.height = (row2-row1-1)*hrow; if(idraw) { draw_box (row1, col1, row2, col2, 2, LT_GRAY, BLACK, "Keyer", WHITE, "", LT_GRAY, SAVEPIX); black_bar (widget, row1, col1-1, row2, col1-1); } draw_rectangle (&update_rect, ORANGE, SAVEPIX); concat(spd, keyer_screen_choices[0], 1, 4, COPY); write_line (row1+1, col1+2, spd, WHITE, SAVEPIX); gtk_widget_queue_draw_area (widget, update_rect.x-idraw*wcol, update_rect.y-idraw*hrow, update_rect.width+idraw*2*wcol, update_rect.height+idraw*2*hrow); } static void message_box(GtkWidget *widget, const gchar *message_line, gint idraw, gint iclear) { GdkRectangle update_rect; gint i, col2, iamp, iamps; gchar mess1[123], mess2[123]; static gchar message_array[4][123]; gint maxml=4; gint row1=9, col1=1, row2=14; const gchar *amp = "&"; if(iclear) for(i=0; i<4; i++) message_array[i][0] = '\0'; if(strlen(message_line)) { for(i=maxml-1; i>0; i--) strcpy(message_array[i], message_array[i-1]); strcpy(message_array[0], message_line); } if(idisplay_type==IDT_SUMMARY) { col2 = colsb_left[isel_contest]-2; if(isel_contest==WW) { col2 -= 14; row2--; maxml--; } update_rect.x = col1*wcol; update_rect.y = row1*hrow; update_rect.width = (col2-col1-1)*wcol; update_rect.height = (row2-row1-1)*hrow; if(idraw) draw_box (row1, col1, row2, col2, 2, LT_GRAY, BLACK, "Messages", WHITE, "", LT_GRAY, SAVEPIX); draw_rectangle (&update_rect, MAGENTA, SAVEPIX); for(i=0; i-1 && iamps<0) { concat(mess1, message_array[i], 0, iamp-1, COPY); concat(mess2, message_array[i], iamp+1, strlen(message_array[i])-1, COPY); concat(message_array[i], mess1, 0, iamp-1, COPY); strcat(message_array[i], amp); concat(message_array[i], mess2, 0, strlen(mess2)-1, !COPY); } write_markup_line (row1+i, col1+1, message_array[i], WHITE, SAVEPIX); } gtk_widget_queue_draw_area (widget, update_rect.x-idraw*wcol, update_rect.y-idraw*hrow, update_rect.width+idraw*2*wcol, update_rect.height+idraw*2*hrow); } else { row1 = 23-log_lines[idisplay_type]; col1 = 1; row2 = row1+1; col2 = 80; update_rect.x = col1*wcol; update_rect.y = row1*hrow; update_rect.width = (col2-col1+1)*wcol; update_rect.height = (row2-row1)*hrow; black_bar (widget, row1, col1, row1, col2); write_markup_line (row1-1, col1, message_array[0], GREEN, SAVEPIX); if(strlen(message_array[1])) write_markup_line (row1-1, col1+strlen(message_array[0])+1, message_array[1], GREEN, SAVEPIX); gtk_widget_queue_draw_area (widget, update_rect.x, update_rect.y, update_rect.width, update_rect.height); } } static void knowledge_box(GtkWidget *widget, gint idraw) { GdkRectangle update_rect; gchar title[32], lc_abv[8], k_px[6], k_zn[3]; gint i, mb_color, col2, iscountry, k_idx, lcw, ipx, j; gint row1=15, col1=1, row2=17; const gchar *px10_char[10] = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"}; col2 = colsb_left[isel_contest]-2; if(isel_contest==WW) { col2 -= 14; row1--; } update_rect.x = col1*wcol; update_rect.y = row1*hrow; update_rect.width = (col2-col1-1)*wcol; update_rect.height = (row2-row1-1)*hrow; if(knowledge_index>MAX_COUNTRIES) { iscountry = FALSE; k_idx = knowledge_index-1000; } else { iscountry = TRUE; k_idx = knowledge_index; } if(k_idx<0) strcpy(title, "Knowledge"); else if(iscountry) strcpy(title, countries.country_name[k_idx]); else strcpy(title, loci.locus_name[k_idx]); if(idraw) draw_box (row1, col1, row2, col2, 2, LT_GRAY, BLACK, title, WHITE, "", LT_GRAY, SAVEPIX); draw_rectangle (&update_rect, BLUE, SAVEPIX); switch (isel_contest) { case DX : if(k_idx>-1) { write_line (row1, col1+1, countries.country_abv[k_idx], WHITE, SAVEPIX); for(i=0; i<6; i++) { if(countries.icountry_worked[i][k_idx]) mb_color = BLACK; else mb_color = YELLOW; write_line (row1, col2-30+5*i, bandw[i], mb_color, SAVEPIX); } } break; case WPX : if(k_idx>-1) { i = 0; ipx = -1; while(knowledge_prefix[i]) { if(isdigit(knowledge_prefix[i])) ipx = i; i++; } if(!ipx) { ipx = strlen(knowledge_prefix); ipx = ipx<5 ? ipx-1 : 3; concat(k_px, knowledge_prefix, 0, ipx, COPY); strcat(k_px, "0"); ipx++; } else if(ipx<0) { ipx = strlen(knowledge_prefix)<2 ? 0 : 1; concat(k_px, knowledge_prefix, 0, ipx, COPY); strcat(k_px, "0"); ipx++; } else { if(ipx>4) ipx = 4; concat(k_px, knowledge_prefix, 0, ipx, COPY); } k_px[ipx] = '\0'; write_line (row1, col1+1, k_px, WHITE, SAVEPIX); for(i=0; i<10; i++) { strcpy(cr_array[6499].prefix, k_px); strcat(cr_array[6499].prefix, px10_char[i]); search_px_tree (6499); if(px_tree.pmatch>0) mb_color = BLACK; else mb_color = YELLOW; write_line (row1, col2-39+4*i, px10_char[i], mb_color, SAVEPIX); } } break; case FD : if(k_idx>-1) { if(iscountry) strcpy(lc_abv, countries.country_abv[k_idx]); else strcpy(lc_abv, loci.locus_abv[k_idx]); write_line (row1, col1+1, lc_abv, WHITE, SAVEPIX); for(i=0; i<6; i++) { if(iscountry) lcw = countries.icountry_worked[i][k_idx]; else lcw = loci.locus_worked[6*mode+i][k_idx]; if(lcw) mb_color = BLACK; else mb_color = YELLOW; write_line (row1, col2-30+5*i, bandw[i], mb_color, SAVEPIX); } } break; case WW : if(k_idx>-1) { write_line (row1, col1+1, countries.country_abv[k_idx], WHITE, SAVEPIX); for(i=0; i<6; i++) { if(countries.icountry_worked[i][k_idx]) mb_color = BLACK; else mb_color = YELLOW; write_line (row1, col2-30+5*i, bandw[i], mb_color, SAVEPIX); } write_line (row1+1, col1+1, "Zone", WHITE, SAVEPIX); strcpy(k_zn, zone_chars[knowledge_zindex]); left_blank_unpad (k_zn); write_line (row1+1, col1+6, k_zn, WHITE, SAVEPIX); for(i=0; i<6; i++) { if(countries.izone_worked[i][knowledge_zindex]) mb_color = BLACK; else mb_color = YELLOW; write_line (row1+1, col2-30+5*i, bandw[i], mb_color, SAVEPIX); } } break; case SS : if(k_idx>-1) { if(iscountry) strcpy(lc_abv, countries.country_abv[k_idx]); else strcpy(lc_abv, loci.locus_abv[k_idx]); write_line (row1, col1+1, lc_abv, WHITE, SAVEPIX); for(i=0; i<2; i++) { mb_color = BLUE; if(i==mode) { mb_color = WHITE; for(j=0; j<6; j++) { if(iscountry) lcw = countries.icountry_worked[j][k_idx]; else lcw = loci.locus_worked[j][k_idx]; if(lcw) { mb_color = BLACK; break; } } } write_line (row1, col2-10+5*i, mode_char[i], mb_color, SAVEPIX); } } break; case A160 : if(k_idx>-1) { if(iscountry) strcpy(lc_abv, countries.country_abv[k_idx]); else strcpy(lc_abv, loci.locus_abv[k_idx]); write_line (row1, col1+1, lc_abv, WHITE, SAVEPIX); for(i=0; i<2; i++) { mb_color = BLUE; if(i==mode) { mb_color = WHITE; if(iscountry) lcw = countries.icountry_worked[i][k_idx]; else lcw = loci.locus_worked[i][k_idx]; if(lcw) mb_color = BLACK; } write_line (row1, col2-10+5*i, mode_char[i], mb_color, SAVEPIX); } } break; case TEN : if(k_idx>-1) { if(iscountry) strcpy(lc_abv, countries.country_abv[k_idx]); else strcpy(lc_abv, loci.locus_abv[k_idx]); write_line (row1, col1+1, lc_abv, WHITE, SAVEPIX); for(i=0; i<2; i++) { if(iscountry) lcw = countries.icountry_worked[i][k_idx]; else lcw = loci.locus_worked[i][k_idx]; if(lcw) mb_color = BLACK; else mb_color = WHITE; write_line (row1, col2-10+5*i, mode_char[i], mb_color, SAVEPIX); } } break; } gtk_widget_queue_draw_area (widget, update_rect.x-idraw*wcol, update_rect.y-idraw*hrow, update_rect.width+idraw*2*wcol, update_rect.height+idraw*2*hrow); } static void zone_box(GtkWidget *widget, gint idraw) { GdkRectangle update_rect; gint i, ii, mb, zone_color, jcol; gint col1, col2; gint ic=0; gint row1=4, row2=17; col2 = colsb_left[isel_contest]-2; col1=col2-12; jcol = col1-3; mb = iband; update_rect.x = col1*wcol; update_rect.y = row1*hrow; update_rect.width = (col2-col1-1)*wcol; update_rect.height = (row2-row1-1)*hrow; if(idraw) { draw_box (row1, col1, row2, col2, 2, LT_GRAY, BLACK, "Zones", WHITE, "", LT_GRAY, SAVEPIX); black_bar (widget, row1, col1-1, row2, col1-1); } draw_rectangle (&update_rect, RED, SAVEPIX); for(i=1; imax_band_score) max_band_score = istar_by_band[i]; if(istar_by_band[i]MAX_COUNTRIES) { iscountry = FALSE; b_idx = beam_index-1000; } else { iscountry = TRUE; b_idx = beam_index; } if(b_idx>-1) { lml = strlen(init_screen_choices[8]); if(lml) { operator_latitude = atof(init_screen_choices[8]); if(init_screen_choices[8][lml-1]=='S') operator_latitude *= -1; } lml = strlen(init_screen_choices[9]); if(lml) { operator_longitude = atof(init_screen_choices[9]); if(init_screen_choices[9][lml-1]=='E') operator_longitude *= -1; } if(istate==20) { strcpy(msg_line, "From: "); dest_lat = operator_latitude; dest_long = operator_longitude; if(iscountry) { op_lat = countries.country_lat[b_idx]; op_long = countries.country_long[b_idx]; } else { op_lat = loci.locus_lat[b_idx]; op_long = loci.locus_long[b_idx]; } } else { strcpy(msg_line, "To: "); op_lat = operator_latitude; op_long = operator_longitude; if(iscountry) { dest_lat = countries.country_lat[b_idx]; dest_long = countries.country_long[b_idx]; } else { dest_lat = loci.locus_lat[b_idx]; dest_long = loci.locus_long[b_idx]; } } range = miles_per_degree/rad_per_deg *acos(sin(rad_per_deg*op_lat) *sin(rad_per_deg*dest_lat)+cos(rad_per_deg*op_lat) *cos(rad_per_deg*dest_lat) *cos(rad_per_deg*(dest_long-op_long))); irange = nint(range); denom1 = fabs(sin(rad_per_deg*range/miles_per_degree)); denom2 = fabs(cos(rad_per_deg*op_lat)); if(denom1>0.001 && denom2>0.001) { bearing = acos((sin(rad_per_deg*dest_lat)-sin(rad_per_deg*op_lat) *cos(rad_per_deg*range/miles_per_degree)) /(sin(rad_per_deg*range/miles_per_degree) *cos(rad_per_deg*op_lat)))/rad_per_deg; if(sin(rad_per_deg*(dest_long-op_long))>=0) bearing = 360.-bearing; } if(denom1<=0.001) bearing = 0; if(denom2<=0.001) { bearing = dest_long; if(bearing<0) bearing += 360.; } ibearing = (nint(bearing))%360; lp = (ibearing+180)%360; int_to_char (irange, range_char); int_to_char (ibearing, sp_char); int_to_char (lp, lp_char); if(istate!=20 && (!strcmp(init_screen_choices[0], "WA1KKM") || !strcmp(init_screen_choices[0], "N2LBR"))) { ivertp = vertical_switch_position (ibearing); strcpy(sp_ind, bearing_ind[ivertp]); ivertp = vertical_switch_position (lp); strcpy(lp_ind, bearing_ind[ivertp]); } else { strcpy(sp_ind, bearing_ind[ivertp]); strcpy(lp_ind, bearing_ind[ivertp]); } if(iscountry) { if(countries.country_abv[b_idx][0]=='+') iplus = 1; concat(msg_line, countries.country_abv[b_idx], iplus, strlen(countries.country_abv[b_idx])-1, !COPY); strcat(msg_line, " - "); strcat(msg_line, countries.country_name[b_idx]); if(iplus) strcat(msg_line, " (Regional)"); } else { strcat(msg_line,loci.locus_abv[b_idx]); strcat(msg_line, " - "); strcat(msg_line, loci.locus_name[b_idx]); } lml = strlen(msg_line); if(lml>39) concat(msg[0], msg_line, 0, 38, COPY); else strcpy(msg[0], msg_line); strcpy(msg[1], sp_char); strcat(msg[1], deg_symbol); strcat(msg[1], " (Short Path) "); strcat(msg[1], sp_ind); strcat(msg[1], " "); strcat(msg[1], lp_char); strcat(msg[1], deg_symbol); strcat(msg[1], " (Long Path) "); strcat(msg[1], lp_ind); strcpy(msg[2], range_char); strcat(msg[2], " (SP Distance in Statute Miles)"); message_box (widget, msg[2], !REDRAW, CLEAR); message_box (widget, msg[1], !REDRAW, !CLEAR); message_box (widget, msg[0], !REDRAW, !CLEAR); } } static gint vertical_switch_position(gint ibearing) { gint i; gdouble beta, d, r, dr, term1, term2, term3, x1, x2, x3; gdouble del, terma, termb, phi, gain[3]; gint ivertp=4; gdouble xmax_gain=0., r0=36.565, el=.5; if(iband<2) ivertp = 0; else { beta = 2.*G_PI; d = .25*(iband-1); dr = beta*d; phi = (gdouble) (ibearing-55); if(phi<0.) phi = phi+360.; phi = phi*G_PI/180.; x1 = beta*d; term1 = ci(x1); x2 = beta*(sqrt(d*d+el*el)+el); term2 = ci(x2); x3 = beta*(sqrt(d*d+el*el)-el); term3 = ci(x3); r = 15.*(2.*term1-term2-term3); for(i=0; i<3; i++) { if(i==0) del = d; else if(i==1) del = -d; else del=0.; del = beta*del; terma = 2.*r0/(r0+r*cos(del)); termb = pow(cos((dr*cos(phi)+del)/2.), 2); gain[i] = 10.*log10(terma*termb); } gain[0] -= .01; gain[2] -= .01; for(i=0; i<3; i++) if(gain[i]>xmax_gain) { ivertp = i+1; xmax_gain = gain[i]; } } return ivertp; } static gdouble fact(gint num) { gint n; gdouble prod=1.; for(n=2; n<=num; n++) prod *= n; return prod; } static gdouble ci(gdouble x) { gdouble gamma, sum; gint i=2, isign=1; gamma = exp(0.5772156649); sum = log10(gamma*x); while(i<33) { isign *= -1; sum += isign*pow(x,i)/(fact(i)*i); i += 2; } return sum; }