static void apply_settings_to_gui(Settings *s) { put_string_to_entry("csv_directory_entry", s->csv_dir); put_string_to_entry("output_directory_entry", s->output_dir); put_int_to_entry("next_obs_request_number_entry", s->obs_req_num); put_int_to_entry("next_obs_request_id_entry", s->obs_req_id_aadn); put_int_to_entry("next_obs_request_id_tdrs_entry", s->obs_req_id_tdrs); put_int_to_entry("next_acq_request_number_entry", s->acq_req_num); put_int_to_entry("odl0_sequence_number_entry", s->odl0_seq_num); put_int_to_entry("next_odl0_request_id_entry", s->odl0_req_id); int i; for (i=0; i<MAX_STATIONS; ++i) { char widget_name[128]; int visible = strlen(s->acq_req_stn_codes[i]) > 0; snprintf(widget_name, 128, "next_acq_request_id_label%d", i+1); if (visible) put_string_to_label(widget_name, "Next Request ID (%s): ", s->acq_req_stn_codes[i]); else put_string_to_label(widget_name, ""); show_widget(widget_name, visible); snprintf(widget_name, 128, "next_acq_request_id_entry%d", i+1); if (visible) put_int_to_entry(widget_name, s->acq_req_ids[i]); else put_string_to_entry(widget_name, ""); show_widget(widget_name, visible); } }
static void single_band(const char *str) { show_widget("hbox_single", TRUE); show_widget("hbox_multi", FALSE); if (strlen(str)>0 && strcmp(str, MAGIC_UNSET_STRING)!=0) { char tmp[128]; snprintf(tmp, 128, "Band: %s", str); put_string_to_label("single_band_label", tmp); } else put_string_to_label("single_band_label", "Bands: -"); is_multiband = FALSE; }
static void put_double_to_label(const char *widget_name, const char *format, double value) { char buf[128]; snprintf(buf, sizeof(buf), format, value); put_string_to_label(widget_name, buf); }
static void multi_band(const char *str) { show_widget("hbox_single", FALSE); show_widget("hbox_multi", TRUE); char tmp[128]; snprintf(tmp, 128, "Bands: %s", br(str)); put_string_to_label("multi_band_label", tmp); is_multiband = TRUE; }
void update_poly_extents(meta_parameters *meta) { int size_x, size_y; compute_extent(meta, &g_poly->extent_y_min, &g_poly->extent_y_max, &g_poly->extent_x_min, &g_poly->extent_x_max, &size_y, &size_x); char subset_info[128]; snprintf(subset_info, 128, "Extent: Line %d-%d, Sample %d-%d\nOutput will be %dx%d LxS", g_poly->extent_y_min, g_poly->extent_y_max, g_poly->extent_x_min, g_poly->extent_x_max, size_y, size_x); put_string_to_label("subset_info_label", subset_info); }
void clear_entries() { put_string_to_entry("add_file_with_ancillary_gamma_baseline_entry", ""); put_string_to_entry("add_file_with_ancillary_gamma_slave_entry", ""); put_string_to_entry("add_file_with_ancillary_gamma_coh_entry", ""); put_string_to_entry("add_file_with_ancillary_gamma_igram_entry", ""); put_string_to_entry("add_file_with_ancillary_gamma_data_entry", ""); put_string_to_entry("add_file_with_ancillary_gamma_metadata_entry", ""); put_string_to_entry("add_file_with_ancillary_polsarpro_image_entry", ""); put_string_to_entry("add_file_with_ancillary_polsarpro_ceos_entry", ""); put_string_to_label("add_with_ancillary_error_label", ""); put_string_to_entry("add_file_with_ancillary_uavsar_annotation_file_entry", ""); GList *l, *uavsar_proc_types = get_widgets_prefix_checked("uavsar_proc_type_"); for(l = uavsar_proc_types; l; l = l->next) gtk_toggle_button_set_active(l->data, FALSE); g_list_free(uavsar_proc_types); }
void process() { clear_results_message(); child_params_t *cp = MALLOC(sizeof(child_params_t)); strcpy(cp->in_file, get_string_from_entry("input_file_entry")); char *odir = get_string_from_entry("output_directory_entry"); char *ofile = get_string_from_entry("output_file_entry"); if (strlen(odir) > 0) { #ifdef win32 if (odir[strlen(odir)-1]=='/' || odir[strlen(odir)-1]=='\\') #else if (odir[strlen(odir)-1]=='/') #endif sprintf(cp->out_file, "%s%s", odir, ofile); else sprintf(cp->out_file, "%s/%s", odir, ofile); } else { strcpy(cp->out_file, ofile); } if (strlen(cp->in_file)==0) { message_box("No input file specified!"); free(cp); return; } else if (strlen(cp->out_file)==0) { message_box("No output file selected!"); free(cp); return; } else if (!fileExists(cp->in_file)) { message_box("Input file \"%s\" not found!", cp->in_file); free(cp); return; } int input_format = get_combo_box_item("input_format_combobox"); int output_format = get_combo_box_item("output_format_combobox"); if (input_format==INPUT_AUTO) { select_defaults_by_file_type(cp->in_file, FALSE); input_format = get_combo_box_item("input_format_combobox"); if (input_format==INPUT_AUTO) { message_box("Can't figure out which type of data this is.\n" "Please select the input format manually."); free(cp); return; } } strcpy(cp->in_format, input_format_to_str(input_format)); strcpy(cp->out_format, output_format_to_str(output_format)); char *logFile = appendExt(cp->out_file, ".log"); #ifdef win32 STARTUPINFO si; PROCESS_INFORMATION pi; memset(&si, 0, sizeof(si)); memset(&pi, 0, sizeof(pi)); si.cb = sizeof(si); char *cmd = MALLOC(sizeof(char)* (strlen(cp->in_file) + strlen(cp->out_file) + strlen(get_asf_bin_dir_win()) + 512)); sprintf(cmd, "\"%s/convert2vector.exe\" " "-log \"%s\" " "-input-format %s -output-format %s \"%s\" \"%s\"", get_asf_bin_dir_win(), logFile, cp->in_format, cp->out_format, cp->in_file, cp->out_file); // clear out any previously existing log file fLog = fopen(logFile, "a"); FCLOSE(fLog); if (!CreateProcess(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { DWORD dw = GetLastError(); //printf( "CreateProcess failed (%ld)\n", dw ); LPVOID lpMsgBuf; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dw, MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL); printf("CreateProcess() failed with error %ld: %s\n", dw, (char*)lpMsgBuf); printf("Failed command: %s\n", cmd); } DWORD dwWaitResult; // now wait for process to finish do { while (gtk_events_pending()) gtk_main_iteration(); dwWaitResult = WaitForSingleObject(pi.hProcess, 50); } while (dwWaitResult == WAIT_TIMEOUT); #else asfFork(child_func, (void*)cp, parent_func, NULL); #endif char message[1024]; strcpy(message, "-"); int success=FALSE; FILE *lfp = fopen(logFile, "r"); if (!lfp) { sprintf(message, "Error Opening Log File '%s': %s\n", logFile, strerror(errno)); } else { char *output = NULL; char line[1024]; while (fgets(line, 1024, lfp)) { if (output) { output = realloc(output, sizeof(char)*(strlen(output)+strlen(line)+1)); strcat(output, line); } else { output = malloc(sizeof(char)*(strlen(line)+1)); strcpy(output, line); } } fclose(lfp); //unlink(logFile); char *p = output, *q; while (p) { q = strchr(p+1, '\n'); if (q) { *q = '\0'; if (strstr(p, "Error")!=NULL || strstr(p, "ERROR")!=NULL) { *q = '\n'; int i,n = 0; do { p = q + 1; q = strchr(p, '\n') - 1; while (isspace(*q)) --q; if (q - p > 2) { // First 220 characters of the error string, unless line ends // first. Don't cut off in the middle of a word, though strcpy(message, "Error: "); strncat(message, p, 220); while (isalnum(message[strlen(message)-1])) message[strlen(message)-1] = '\0'; for (n=0; n<strlen(message); ++n) if (message[n] == '\n' || message[n] == '*') message[n] = ' '; int eating=FALSE; for (n=0,i=0; n<strlen(message); ++n) { if (isspace(message[n])) { if (!eating) { eating=TRUE; message[i++] = message[n]; } } else { eating=FALSE; message[i++] = message[n]; } } message[i]='\0'; char *eoe = strstr(message, "End of error"); if (eoe) *eoe = '\0'; else if (strlen(message)>200) strcat(message, " ..."); break; } } while (*p != '*' && ++n<5); // * flags the end of the error message } if (strstr(p,"Successful completion!") != NULL) { strcpy(message, "Processed successfully!"); success=TRUE; break; } *q = '\n'; } p=q; } if (strlen(message)==0) { // Did not find an error message, or the success message! // So, assume there was an error, but we don't know why strcpy(message, "Processing failed!"); } FREE(output); } int open_output = get_checked("open_output_checkbutton"); if (!success) open_output = FALSE; put_string_to_label("result_label", message); asfPrintStatus(message); asfPrintStatus("\n\nDone.\n\n"); if (open_output) { switch (output_format) { case OUTPUT_KML: open_in_google_earth(cp->out_file); break; case OUTPUT_ALOS_CSV: open_in_excel(cp->out_file); default: // do nothing, output type has no natural associated app break; } } free(cp); }
SIGNAL_CALLBACK void on_add_file_with_ancillary_ok_button_clicked(GtkWidget * w) { const char *type = get_string_from_label("add_with_ancillary_format_label"); int sel = -1; if (strcmp_case(type, "GAMMA") == 0) sel = ADD_FILE_WITH_ANCILLARY_FORMAT_GAMMA; else if (strcmp_case(type, "PolSARPro") == 0) sel = ADD_FILE_WITH_ANCILLARY_FORMAT_POLSARPRO; else if (strcmp_case(type, "UAVSAR") == 0) sel = ADD_FILE_WITH_ANCILLARY_FORMAT_UAVSAR; GtkTreeIter iter; int ok = TRUE; char *dataFile = NULL, *data = NULL, *ceos = NULL; char *aux_info = ""; switch (sel) { case ADD_FILE_WITH_ANCILLARY_FORMAT_POLSARPRO: { GtkWidget *ok_button = get_widget_checked("add_file_with_ancillary_ok_button"); gtk_widget_set_sensitive(ok_button, FALSE); dataFile = get_string_from_entry("add_file_with_ancillary_polsarpro_image_entry"); char *matrixType=NULL, *error, *decompositionType, *derror; char *serror, *perror; int is_polsarpro_matrix = isPolsarproMatrix(dataFile, &matrixType, &error); int is_polsarpro_decomposition = isPolsarproDecomposition(dataFile, &decompositionType, &derror); int is_polsarpro_segmentation = isPolsarproSegmentation(dataFile, &serror); int is_polsarpro_parameter = isPolsarproParameter(dataFile, &perror); if (is_polsarpro_matrix && !is_polsarpro_decomposition && !is_polsarpro_segmentation && !is_polsarpro_parameter) { data = (char *) MALLOC(sizeof(char) * (strlen(dataFile) + 15)); if (!is_dir(dataFile)) { char *tmp = (char *) MALLOC(sizeof(char) * (strlen(dataFile) + 1)); tmp = get_dirname(dataFile); dataFile[strlen(tmp) - 1] = '\0'; FREE(tmp); } if (strcmp(matrixType, "T3") == 0 || strcmp(matrixType, "T4") == 0) sprintf(data, "%s/T11.bin", dataFile); else if (strcmp(matrixType, "C2") == 0 || strcmp(matrixType, "C3") == 0 || strcmp(matrixType, "C4") == 0) sprintf(data, "%s/C11.bin", dataFile); } else data = STRDUP(dataFile); FREE(matrixType); int is_geocoded = isGeocoded(data); if (!is_geocoded) ceos = get_string_from_entry ("add_file_with_ancillary_polsarpro_ceos_entry"); if (!is_geocoded && (strlen(ceos) == 0 || strlen(data) == 0)) { put_string_to_label("add_with_ancillary_error_label", "Please choose all required files!"); return; } else { GtkWidget *browse_option_menu = get_widget_checked("browse_select_colormap_optionmenu"); GtkWidget *menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(browse_option_menu)); GtkWidget *selected_item = gtk_menu_get_active(GTK_MENU(menu)); GtkWidget *combo = get_widget_checked("browse_select_image_data_type_optionmenu"); int image_data_type = gtk_combo_box_get_active(GTK_COMBO_BOX(combo)); char *lut_basename = g_object_get_data(G_OBJECT(selected_item), "file"); aux_info = encode_polsarpro_aux_info(image_data_type, lut_basename); put_string_to_label("add_with_ancillary_error_label", ""); ok = add_to_files_list_iter(data, ceos, NULL, aux_info, NULL, NULL, NULL, NULL, NULL, &iter); free(aux_info); } break; } case ADD_FILE_WITH_ANCILLARY_FORMAT_GAMMA: { GtkWidget *ok_button = get_widget_checked("add_file_with_ancillary_ok_button"); gtk_widget_set_sensitive(ok_button, TRUE); data = get_string_from_entry("add_file_with_ancillary_gamma_data_entry"); char *meta = get_string_from_entry("add_file_with_ancillary_gamma_metadata_entry"); if (strlen(data) == 0 || strlen(meta) == 0) { put_string_to_label("add_with_ancillary_error_label", "Please choose all required files!"); return; } else { put_string_to_label("add_with_ancillary_error_label", ""); char *interferogram, *coherence, *slave_metadata, *baseline; interferogram = get_string_from_entry("add_file_with_ancillary_gamma_igram_entry"); coherence = get_string_from_entry("add_file_with_ancillary_gamma_coh_entry"); slave_metadata = get_string_from_entry("add_file_with_ancillary_gamma_slave_entry"); baseline = get_string_from_entry("add_file_with_ancillary_gamma_baseline_entry"); if (strlen(interferogram) == 0) { FREE(interferogram); interferogram = NULL; } if (strlen(coherence) == 0) { FREE(coherence); coherence = NULL; } if (strlen(slave_metadata) == 0) { FREE(slave_metadata); slave_metadata = NULL; } if (strlen(baseline) == 0) { FREE(baseline); baseline = NULL; } ok = add_to_files_list_iter(data, ceos, meta, aux_info, NULL, interferogram, coherence, slave_metadata, baseline, &iter); } break; } case ADD_FILE_WITH_ANCILLARY_FORMAT_UAVSAR: { GtkWidget *ok_button = get_widget_checked("add_file_with_ancillary_ok_button"); gtk_widget_set_sensitive(ok_button, TRUE); GtkWidget *ann_file_entry = get_widget_checked("add_file_with_ancillary_uavsar_annotation_file_entry"); const gchar *annotation_file = gtk_entry_get_text(GTK_ENTRY(ann_file_entry)); GList *l, *uavsar_proc_types = get_widgets_prefix_checked("uavsar_proc_type_"); for(l = uavsar_proc_types; l; l = l->next) { gpointer proc_type_check_button = l->data; if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(proc_type_check_button))) { const gchar *name = gtk_widget_get_name(GTK_WIDGET(proc_type_check_button)); ok = add_to_files_list_iter(annotation_file, NULL, NULL, NULL, name + strlen("uavsar_proc_types_") - 1, NULL, NULL, NULL, NULL, &iter); if(!ok) break; } } g_list_free(uavsar_proc_types); } break; } if (!ok) { if (data) { char *msg = MALLOC(sizeof(char) * (strlen(data) + 128)); sprintf(msg, "Unrecognized file:\n %s\n\n" "The file may be of a type not supported by MapReady.\n", data); message_box(msg); free(msg); } else { char *msg = MALLOC(sizeof(char) * 256); sprintf(msg, "Unrecognized file!\n\n" "The file may be of a type not supported by MapReady.\n"); message_box(msg); free(msg); } } else { show_widget("add_file_with_ancillary_dialog", FALSE); clear_entries(); } }
SIGNAL_CALLBACK void on_browse_input_files_button_clicked(GtkWidget *widget) { GtkWidget *combo = get_widget_checked("browse_format_combobox"); GtkWidget *browse_select_colormap_optionmenu = get_widget_checked("browse_select_colormap_optionmenu"); GtkWidget *browse_select_colormap_label = get_widget_checked("browse_select_colormap_label"); GtkWidget *browse_select_image_data_type_optionmenu = get_widget_checked("browse_select_colormap_optionmenu"); GtkWidget *browse_select_image_data_type_label = get_widget_checked("browse_select_colormap_label"); GtkWindow *ancillary_dialog = GTK_WINDOW(get_widget_checked("add_file_with_ancillary_dialog")); GtkWindow *main_window = GTK_WINDOW(get_widget_checked("asf_convert")); int sel = gtk_combo_box_get_active(GTK_COMBO_BOX(combo)); GtkWidget *ok_button = get_widget_checked("add_file_with_ancillary_ok_button"); // open the "add with ancillary" if needed, otherwise we'll use the // normal 'open file' dialog if (sel==FORMAT_GAMMA || sel==FORMAT_POLSARPRO || sel==FORMAT_UAVSAR) { show_widget("hbox_polsarpro", sel==FORMAT_POLSARPRO); show_widget("hbox_gamma", sel==FORMAT_GAMMA); show_widget("vbox_uavsar", sel==FORMAT_UAVSAR); switch (sel) { case FORMAT_GAMMA: put_string_to_label("add_with_ancillary_format_label", "GAMMA"); show_widget("hbox_gamma_description", TRUE); gtk_widget_set_sensitive(ok_button, TRUE); break; case FORMAT_UAVSAR: put_string_to_label("add_with_ancillary_format_label", "UAVSAR"); show_widget("hbox_gamma_description", FALSE); gtk_widget_set_sensitive(ok_button, FALSE); break; case FORMAT_POLSARPRO: put_string_to_label("add_with_ancillary_format_label", "PolSARPro"); show_widget("hbox_gamma_description", FALSE); gtk_widget_show(browse_select_colormap_optionmenu); gtk_widget_show(browse_select_colormap_label); gtk_widget_show(browse_select_image_data_type_optionmenu); gtk_widget_show(browse_select_image_data_type_label); gtk_widget_set_sensitive(ok_button, FALSE); init_image_data_type_combobox(); polsarpro_image_data_type_changed(); break; default: put_string_to_label("add_with_ancillary_format_label", "Unknown"); break; } gtk_window_set_transient_for(ancillary_dialog, main_window); gtk_widget_show(GTK_WIDGET(ancillary_dialog)); return; } // normal case -- not requiring ancillary files #ifdef win32 OPENFILENAME of; int retval; char fname[1024]; fname[0] = '\0'; memset(&of, 0, sizeof(of)); #ifdef OPENFILENAME_SIZE_VERSION_400 of.lStructSize = OPENFILENAME_SIZE_VERSION_400; #else of.lStructSize = sizeof(of); #endif of.hwndOwner = NULL; switch (sel) { case FORMAT_CEOS: of.lpstrFilter = "CEOS Level 1 Files\0*.L;LED-*;*.LEA;*.lea;LEA_*;lea_*;*.ldr;*.sarl\0" "RSAT/ERS CEOS L1 (*.L)\0*.L\0" "ALOS Files (LED-*)\0LED-*\0" "LEA Leader Files (LEA_*, lea_*, *.lea, *.LEA)\0LEA_*;lea_*;*.lea;*.LEA\0" "LDR Leader Files (*.ldr)\0*.ldr\0" "SARL Leader Files (*.sarl)\0*.sarl\0" "All Files\0*\0"; break; case FORMAT_AIRSAR: of.lpstrFilter = "AirSAR Files (*.airsar)\0*.airsar\0" "All Files\0*\0"; break; case FORMAT_UAVSAR: of.lpstrFilter = "UAVSAR Files (*.ann)\0*.ann\0" "All Files\0*\0"; break; case FORMAT_TERRASARX: of.lpstrFilter = "TerraSAR-X Metadata Files (*.xml)\0*.xml\0" "All Files\0*\0"; break; case FORMAT_RADARSAT2: of.lpstrFilter = "Radarsat-2 Metadata Files (*.xml)\0*.xml\0" "All Files\0*\0"; break; case FORMAT_ROIPAC: of.lpstrFilter = "ROI_PAC Metadata Files (*.rsc)\0*.rsc\0" "All Files\0*\0"; break; case FORMAT_ALOS_MOSAIC: of.lpstrFilter = "ALOS mosaic Metadata Files (*HDR.txt, *HDR.txt)\0*HDR.txt;*HDR\0" "All Files\0*\0"; break; case FORMAT_GEOTIFF: of.lpstrFilter = "GeoTIFF Files (*.tif, *.tiff)\0*.tif;*.tiff\0" "All Files\0*\0"; break; case FORMAT_ASF_INTERNAL: of.lpstrFilter = "ASF Internal Files (*.img)\0*.img\0" "All Files\0*\0"; break; } of.lpstrCustomFilter = NULL; of.nFilterIndex = 1; of.lpstrFile = fname; of.nMaxFile = sizeof(fname); of.lpstrFileTitle = NULL; of.lpstrInitialDir = "."; of.lpstrTitle = "Select File"; of.lpstrDefExt = NULL; of.Flags = OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT | OFN_EXPLORER; retval = GetOpenFileName(&of); if (!retval) { if (CommDlgExtendedError()) message_box("File dialog box error"); return; } /* the returned "fname" has the following form: */ /* <directory>\0<first file>\0<second file>\0<third ... */ char * dir = STRDUP(fname); char * p = fname + strlen(dir) + 1; if (*p) { while (*p) { char * dir_and_file = malloc(sizeof(char)*(strlen(dir)+strlen(p)+5)); sprintf(dir_and_file, "%s%c%s", dir, DIR_SEPARATOR, p); add_to_files_list(dir_and_file); p += strlen(p) + 1; free(dir_and_file); } } else { add_to_files_list(dir); } free(dir); #else // #ifdef win32 /* Linux version -- use GtkFileChooser if possible */ #ifdef USE_GTK_FILE_CHOOSER if (GTK_IS_WIDGET(browse_widget)) gtk_widget_destroy(browse_widget); create_file_chooser_dialog(sel); gtk_widget_show(browse_widget); #else // #ifdef USE_GTK_FILE_CHOOSER GtkWidget *file_selection_dialog = get_widget_checked("input_file_selection"); gtk_widget_show(file_selection_dialog); #endif // #ifdef USE_GTK_FILE_CHOOSER #endif // #ifdef win32 }
SIGNAL_CALLBACK void on_change_page(GtkWidget *widget) { set_settings_saved_label(""); put_string_to_label("generate_label", ""); update_output_file(); }
static void fill_stats_label(ImageInfo *ii) { char s[1024]; strcpy(s, ""); if (ii->data_ci->data_type == RGB_FLOAT || ii->data_ci->data_type == RGB_BYTE) { double r_min = calc_rgb_min(&ii->stats_r); double r_max = calc_rgb_max(&ii->stats_r); double g_min = calc_rgb_min(&ii->stats_g); double g_max = calc_rgb_max(&ii->stats_g); double b_min = calc_rgb_min(&ii->stats_b); double b_max = calc_rgb_max(&ii->stats_b); double rb = -r_min*255.0/(r_max-r_min); double gb = -g_min*255.0/(g_max-g_min); double bb = -b_min*255.0/(b_max-b_min); sprintf(&s[strlen(s)], "Average: %.3f, %.3f, %.3f\n" "Standard Deviation: %.3f, %.3f, %.3f\n" "Mapping Fn for pixels:\n" " Y = %.3f * X %c %.3f (red)\n" " Y = %.3f * X %c %.3f (green)\n" " Y = %.3f * X %c %.3f (blue)\n", ii->stats_r.avg, ii->stats_g.avg, ii->stats_b.avg, ii->stats_r.stddev, ii->stats_g.stddev, ii->stats_b.stddev, 255.0/(r_max-r_min), rb > 0 ? '+' : '-', fabs(rb), 255.0/(g_max-g_min), gb > 0 ? '+' : '-', fabs(gb), 255.0/(b_max-b_min), bb > 0 ? '+' : '-', fabs(bb)); } else { // greyscale case double m, b; if (ii->stats.truncate) { m = 1.0; b = 0.0; } else { m = 255.0/(ii->stats.map_max-ii->stats.map_min); b = -ii->stats.map_min*255.0/(ii->stats.map_max-ii->stats.map_min); } // we will take charge of displaying the sign char c = b>0 ? '+' : '-'; b = fabs(b); sprintf(&s[strlen(s)], "Average: %.3f\n" "Standard Deviation: %.3f\n" "Mapping Fn for pixels:\n" " Y = %.3f * X %c %.3f", ii->stats.avg, ii->stats.stddev, m, c, b); } put_string_to_label("stats_label", s); }