Ejemplo n.º 1
0
static void set_defaults(ImageInfo *ii)
{
    // default filename
    char *basename = get_basename(ii->filename);
    char *def = appendStr(basename, "_aoi");
    if (strncmp_case(def, "LED-", 4) == 0 ||
        strncmp_case(def, "IMG-", 4) == 0 ||
        strncmp_case(def, "TRL-", 4) == 0 ||
        strncmp_case(def, "VOL-", 4) == 0)
    {
        char *tmp = STRDUP(def+4);
        free(def);
        def = tmp;
    }
    free(basename);
    put_string_to_entry("filename_entry", def);
    free(def);

    // default directory
    char *dir = get_dirname(ii->filename);
    if (dir && strlen(dir) > 0)
        put_string_to_entry("dir_entry", dir);
    else
        put_string_to_entry("dir_entry", "");
    FREE(dir);

    // default data to save (Pixel Values)
    set_combo_box_item("data_combobox", 0);
}
Ejemplo n.º 2
0
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);
    }
}
Ejemplo n.º 3
0
static void do_browse_ok_clicked(gpointer button)
{
  GtkWidget *browse_widget =
    GTK_WIDGET(g_object_get_data(G_OBJECT(button), "browse_widget"));
  char *entry_to_populate =
    (char*)g_object_get_data(G_OBJECT(browse_widget), "entry");

  GSList *files = gtk_file_chooser_get_filenames(
    GTK_FILE_CHOOSER(browse_widget));

  // done with this, now
  gtk_widget_destroy(browse_widget);

  if (files)
  {
    // we only have one file to add in the list
    gchar *s = (gchar *) files->data;
    put_string_to_entry(entry_to_populate, s);

    // now free up everything (use full-list freeing code, just in case)
    GSList *iter = files;
    do {
      g_free((gchar *) iter->data);
      iter =  iter->next;
    }
    while(iter);
    g_slist_free(files);
  }
}
Ejemplo n.º 4
0
void settings_set_end_date(long l)
{
    block_processing=TRUE;
    if (l < 0)
        put_string_to_entry("end_date_entry", "");
    else
        put_long_to_entry("end_date_entry", l);
    block_processing=FALSE;
}
Ejemplo n.º 5
0
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);
}
Ejemplo n.º 6
0
SIGNAL_CALLBACK void on_browse_button_clicked(GtkWidget *w)
{
    BROWSEINFO bi = { 0 };
    bi.lpszTitle = "Select Output Directory";
    LPITEMIDLIST pidl = SHBrowseForFolder ( &bi );
    if ( pidl != 0 )
    {
        TCHAR path[MAX_PATH];
        if ( SHGetPathFromIDList ( pidl, path ) )
            put_string_to_entry("dir_entry", path);
    }
}
Ejemplo n.º 7
0
SIGNAL_CALLBACK void ok_clicked(GtkWidget *w, gpointer user_data)
{
    GtkWidget *browse_widget = (GtkWidget *)user_data;
    GSList *files = gtk_file_chooser_get_filenames(
        GTK_FILE_CHOOSER(browse_widget));

    gtk_widget_hide(browse_widget);

    // we will actually never get more than one file back
    if (files) {
        GSList *iter = files;

        do {
          gchar *s = (gchar *) iter->data;
          put_string_to_entry("dir_entry", s);
          g_free(s);
          iter =  iter->next;
        }
        while(iter);

        g_slist_free(files);
    }
}
Ejemplo n.º 8
0
static void do_browse(const char *title, const char *entry_to_populate,
                      int filts)
{
#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;

    if (filts == (L_FILT | LED_FILT | ALL_CEOS_LEADER_FILT | XML_FILT | 
		  RSC_FILT | MOSAIC_FILT)) {
      of.lpstrFilter =
        "CEOS Level 1 Files\0*.L;LED-*\0"
        "RSAT/ERS CEOS L1\0*.L\0"
        "ALOS Leader Files\0LED-*\0"
	"TerraSAR-X/Radarsat-2\0*.xml\0"
	"ALOS mosaics\0*HDR.txt;*HDR\0"
	"ROI_PAC Files\0*.rsc\0"
        "All Files\0*\0";
    }
    else if (filts == (L_FILT | LED_FILT | ALL_CEOS_LEADER_FILT | XML_FILT)) {
      of.lpstrFilter =
        "CEOS Level 1 Files\0*.L;LED-*\0"
        "RSAT/ERS CEOS L1\0*.L\0"
        "ALOS Leader Files\0LED-*\0"
	"TerraSAR-X/Radarsat-2\0*.xml\0"
        "All Files\0*\0";
    }
    else if (filts == (L_FILT | LED_FILT | ALL_CEOS_LEADER_FILT | XML_FILT | ANN_FILT )) {
      of.lpstrFilter =
        "All Metadata Files\0*.L;LED-*;*.xml;*.ann\0"
        "CEOS Level 1 Files\0*.L;LED-*\0"
        "RSAT/ERS CEOS L1\0*.L\0"
        "ALOS Leader Files\0LED-*\0"
	"TerraSAR-X/Radarsat-2\0*.xml\0"
	"UAVSAR Annotation File\0*.ann\0"
        "All Files\0*\0";
    }
    else if (filts == BIN_FILT) {
      of.lpstrFilter =
        "PolSARPro Files\0*.bin\0"
        "All Files\0*\0";
    }
    else if (filts == ANN_FILT) {
      of.lpstrFilter =
        "UAVSAR Annotation File\0*.ann\0"
        "All Files\0*\0";
    } else {
      of.lpstrFilter = "All Files\0*\0";
    }

    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);
            put_string_to_entry(entry_to_populate, dir_and_file);
            p += strlen(p) + 1;
            free(dir_and_file);
        }
    }
    else {
      put_string_to_entry(entry_to_populate, dir);
    }

    free(dir);

#else // #ifdef win32

    GtkWidget *parent = get_widget_checked("asf_convert");

    GtkWidget *browse_widget = gtk_file_chooser_dialog_new(
        title, GTK_WINDOW(parent),
        GTK_FILE_CHOOSER_ACTION_OPEN,
        GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, //Cancel button
        GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,   //Open button
        NULL);

    // we need to extract the buttons, so we can connect them to our
    // button handlers, above
    GtkHButtonBox *box =
        (GtkHButtonBox*)(((GtkDialog*)browse_widget)->action_area);
    GList *buttons = box->button_box.box.children;

    GtkWidget *cancel_btn = ((GtkBoxChild*)buttons->data)->widget;
    GtkWidget *ok_btn = ((GtkBoxChild*)buttons->next->data)->widget;

    g_signal_connect((gpointer)cancel_btn, "clicked",
        G_CALLBACK(do_browse_cancel_clicked), NULL);
    g_signal_connect((gpointer)ok_btn, "clicked",
        G_CALLBACK(do_browse_ok_clicked), NULL);

    // store the entry that should be populated as aux data in the widget
    g_object_set_data(G_OBJECT(browse_widget), "entry",
                      (gpointer)entry_to_populate);

    // store a pointer to the browse widget as aux data in the buttons
    g_object_set_data(G_OBJECT(cancel_btn), "browse_widget",
                      (gpointer)browse_widget);
    g_object_set_data(G_OBJECT(ok_btn), "browse_widget",
                      (gpointer)browse_widget);

    // add the filters
    if (filts & ALL_CEOS_DATA_FILT) {
      GtkFileFilter *ceos_filt = gtk_file_filter_new();
      gtk_file_filter_set_name(ceos_filt, "All CEOS Level 1 Files");
      gtk_file_filter_add_pattern(ceos_filt, "*.D");
      gtk_file_filter_add_pattern(ceos_filt, "IMG-*");
      gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(browse_widget), ceos_filt);
    }
    if (filts & ALL_CEOS_LEADER_FILT) {
      GtkFileFilter *ceos_filt = gtk_file_filter_new();
      gtk_file_filter_set_name(ceos_filt, "All CEOS Level 1 Files");
      gtk_file_filter_add_pattern(ceos_filt, "*.L");
      gtk_file_filter_add_pattern(ceos_filt, "LED-*");
      gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(browse_widget), ceos_filt);
    }
    if (filts & D_FILT) {
      GtkFileFilter *D_filt = gtk_file_filter_new();
      gtk_file_filter_set_name(D_filt, "RSAT/ERS CEOS L1 (*.D)");
      gtk_file_filter_add_pattern(D_filt, "*.D");
      gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(browse_widget), D_filt);
    }
    if (filts & L_FILT) {
      GtkFileFilter *L_filt = gtk_file_filter_new();
      gtk_file_filter_set_name(L_filt, "RSAT/ERS CEOS L1 (*.L)");
      gtk_file_filter_add_pattern(L_filt, "*.L");
      gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(browse_widget), L_filt);
    }
    if (filts & LED_FILT) {
      GtkFileFilter *alos_filt = gtk_file_filter_new();
      gtk_file_filter_set_name(alos_filt, "ALOS Leader Files (LED-*)");
      gtk_file_filter_add_pattern(alos_filt, "LED-*");
      gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(browse_widget), alos_filt);
    }
    if (filts & IMG_FILT) {
      GtkFileFilter *img_filt = gtk_file_filter_new();
      gtk_file_filter_set_name(img_filt, "ALOS Data Files (IMG-*)");
      gtk_file_filter_add_pattern(img_filt, "IMG-*");
      gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(browse_widget), img_filt);
    }
    if (filts & BIN_FILT) {
      GtkFileFilter *polsarpro_filt = gtk_file_filter_new();
      gtk_file_filter_set_name(polsarpro_filt,
                               "PolSARpro Data Files (*.bin)");
      gtk_file_filter_add_pattern(polsarpro_filt, "*.bin");
      gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(browse_widget),
                                  polsarpro_filt);
    }
    if (filts & HDR_FILT) {
      GtkFileFilter *hdr_filt = gtk_file_filter_new();
      gtk_file_filter_set_name(hdr_filt, "PolSARPro Header Files (*.hdr)");
      gtk_file_filter_add_pattern(hdr_filt, "*.hdr");
      gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(browse_widget), hdr_filt);
    }
    if (filts & XML_FILT) {
      GtkFileFilter *xml_filt = gtk_file_filter_new();
      gtk_file_filter_set_name(xml_filt, "TerraSAR-X/Radarsat-2 Files (*.xml)");
      gtk_file_filter_add_pattern(xml_filt, "*.xml");
      gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(browse_widget), xml_filt);
    }
    if (filts & RSC_FILT) {
      GtkFileFilter *rsc_filt = gtk_file_filter_new();
      gtk_file_filter_set_name(rsc_filt, "ROI_PAC Files (*.rsc)");
      gtk_file_filter_add_pattern(rsc_filt, "*.rsc");
      gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(browse_widget), rsc_filt);
    }
    if (filts & MOSAIC_FILT) {
      GtkFileFilter *mosaic_filt = gtk_file_filter_new();
      gtk_file_filter_set_name(mosaic_filt, "ALOS mosaic Files (*HDR.txt, *HDR)");
      gtk_file_filter_add_pattern(mosaic_filt, "*HDR.txt");
      gtk_file_filter_add_pattern(mosaic_filt, "*HDR");
      gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(browse_widget), mosaic_filt);
    }
    if (filts & ANN_FILT) {
      GtkFileFilter *ann_filt = gtk_file_filter_new();
      gtk_file_filter_set_name(ann_filt, "UAVSAR Annotation File");
      gtk_file_filter_add_pattern(ann_filt, "*.ann");
      gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(browse_widget), ann_filt);
    }
    if (filts & DIR_FILT) {
      GtkFileFilter *dir_filt = gtk_file_filter_new();
      gtk_file_filter_set_name(dir_filt, "PolSARPro matrix directory");
      gtk_file_filter_add_pattern(dir_filt, "*.");
      gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(browse_widget), dir_filt);
    }

    GtkFileFilter *all_filt = gtk_file_filter_new();
    gtk_file_filter_set_name(all_filt, "All Files (*.*)");
    gtk_file_filter_add_pattern(all_filt, "*");
    gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(browse_widget), all_filt);

    // do not allow multi-select
    gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(browse_widget),
                                         FALSE);

    // we need to make these modal -- if the user opens multiple "open"
    // dialogs, we'll get confused on the callbacks
    gtk_window_set_modal(GTK_WINDOW(browse_widget), TRUE);
    gtk_window_set_destroy_with_parent(GTK_WINDOW(browse_widget), TRUE);
    gtk_dialog_set_default_response(GTK_DIALOG(browse_widget),
                                    GTK_RESPONSE_OK);

    gtk_widget_show(browse_widget);
#endif
}