Esempio n. 1
0
int
main(int argc, char **argv)
{
    gtk_init(&argc, &argv);

    gchar *glade_xml_file = (gchar *) find_in_share("proj2proj.glade");
    printf("Found proj2proj.glade: %s\n", glade_xml_file);
    glade_xml = glade_xml_new(glade_xml_file, NULL, NULL);
    free(glade_xml_file);

    set_font();

    glade_xml_signal_autoconnect(glade_xml);

    // default to lat/lon -> UTM
    GtkWidget *w = get_widget_checked("source_projection_option_menu");
    set_combo_box_item(w, 5);

    geocode_options_changed(TRUE);
    geocode_options_changed(FALSE);

    if (argc > 1) {
        put_file_in_textview(argv[1], "source_textview");
        forward();
    }

    set_toolbar_images();

    gtk_main ();

    exit (EXIT_SUCCESS);
}
Esempio n. 2
0
void terrcorr_options_changed()
{
  GtkWidget *terrcorr_vbox;
  GtkWidget *dem_checkbutton;
  GtkWidget *hbox_terrcorr_items;
  GtkWidget *interp_dem_holes_checkbutton;
  GtkWidget *top_vbox_terrcorr; // TOP TOP level vbox for terrain correction tab
  GtkWidget *terrcorr_tab_label;

  hbox_terrcorr_items = get_widget_checked("hbox_terrcorr_items");

  gboolean dem_is_checked;

  terrcorr_vbox = get_widget_checked("terrcorr_vbox");
  dem_checkbutton = get_widget_checked("dem_checkbutton");
  top_vbox_terrcorr = get_widget_checked("top_vbox_terrcorr");
  terrcorr_tab_label = get_widget_checked("terrcorr_tab_label");
  interp_dem_holes_checkbutton =
      get_widget_checked("interp_dem_holes_checkbutton");

  dem_is_checked =
    gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dem_checkbutton));

  gtk_widget_set_sensitive(terrcorr_vbox, dem_is_checked);
  gtk_widget_set_sensitive(interp_dem_holes_checkbutton, dem_is_checked);
  gtk_widget_set_sensitive(top_vbox_terrcorr, dem_is_checked);
  gtk_widget_set_sensitive(terrcorr_tab_label, dem_is_checked);

  if (dem_is_checked) {
      GtkWidget *rb_terrcorr;
      GtkWidget *hbox_tc_pixel_size;
      GtkWidget *rb_mask_file, *rb_auto_water_mask;
      GtkWidget *tc_pixel_size_checkbutton;
      GtkWidget *interpolate_checkbutton;
      GtkWidget *mask_checkbutton, *mask_entry;
      GtkWidget *radiometric_checkbutton;
      //GtkWidget *save_incid_angles_checkbutton;
      GtkWidget *layover_mask_checkbutton;
      GtkWidget *save_dem_checkbutton;
      GtkWidget *tc_matching_checkbutton, *hbox_tc_matching;

      gboolean tc_pixel_size_is_checked;
      gboolean tc_matching_is_checked;
      gboolean terrcorr_is_checked;
      gboolean mask_is_checked, mask_file_is_checked; // rad_corr_is_checked;

      gtk_widget_set_sensitive(hbox_terrcorr_items, TRUE);

      rb_terrcorr = get_widget_checked("rb_terrcorr");
      terrcorr_is_checked =
          gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(rb_terrcorr));

      rb_mask_file = get_widget_checked("rb_mask_file");
      rb_auto_water_mask = get_widget_checked("rb_auto_water_mask");
      mask_checkbutton = get_widget_checked("mask_checkbutton");
      mask_entry = get_widget_checked("mask_entry");

      mask_is_checked =
          gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mask_checkbutton));

      mask_file_is_checked = mask_is_checked &&
          gtk_toggle_button_get_active(
              GTK_TOGGLE_BUTTON(rb_mask_file));

      tc_pixel_size_checkbutton =
          get_widget_checked("tc_pixel_size_checkbutton");

      tc_pixel_size_is_checked = terrcorr_is_checked &&
          gtk_toggle_button_get_active(
              GTK_TOGGLE_BUTTON(tc_pixel_size_checkbutton));

      hbox_tc_pixel_size = get_widget_checked("hbox_tc_pixel_size");

      tc_matching_checkbutton =
          get_widget_checked("tc_matching_checkbutton");
      tc_matching_is_checked = terrcorr_is_checked &&
          gtk_toggle_button_get_active(
              GTK_TOGGLE_BUTTON(tc_matching_checkbutton));
      hbox_tc_matching = get_widget_checked("hbox_tc_matching");

      gtk_widget_set_sensitive(hbox_tc_pixel_size, tc_pixel_size_is_checked);
      gtk_widget_set_sensitive(hbox_tc_matching, !tc_matching_is_checked);
      gtk_widget_set_sensitive(mask_entry, mask_file_is_checked);
      //gtk_widget_set_sensitive(hbox_terrcorr_items, terrcorr_is_checked);
      gtk_widget_set_sensitive(rb_auto_water_mask, mask_is_checked);
      gtk_widget_set_sensitive(rb_mask_file, mask_is_checked);

      interpolate_checkbutton = get_widget_checked("interpolate_checkbutton");
      radiometric_checkbutton = get_widget_checked("radiometric_checkbutton");
      //save_incid_angles_checkbutton = get_widget_checked("save_incid_angles_checkbutton");
      save_dem_checkbutton = get_widget_checked("save_dem_checkbutton");
      layover_mask_checkbutton =
          get_widget_checked("layover_mask_checkbutton");

      //rad_corr_is_checked = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radiometric_checkbutton));
      //gtk_widget_set_sensitive(save_incid_angles_checkbutton, rad_corr_is_checked);

      gtk_widget_set_sensitive(tc_pixel_size_checkbutton, terrcorr_is_checked);
      gtk_widget_set_sensitive(tc_matching_checkbutton, terrcorr_is_checked);
      gtk_widget_set_sensitive(interpolate_checkbutton, terrcorr_is_checked);
      gtk_widget_set_sensitive(radiometric_checkbutton, terrcorr_is_checked);
      gtk_widget_set_sensitive(layover_mask_checkbutton, terrcorr_is_checked);
      gtk_widget_set_sensitive(save_dem_checkbutton, terrcorr_is_checked);
  }
  else
  {
      gtk_widget_set_sensitive(hbox_terrcorr_items, FALSE);
  }

  // must now update the geocode settings as well, since the average
  // height checkbutton is disabled by terrain correction
  geocode_options_changed();
}
int
main(int argc, char **argv)
{
    GtkWidget *widget;
    gchar *glade_xml_file;

    gtk_init(&argc, &argv);
    set_font();
    get_asf_share_dir_with_argv0(argv[0]);
    set_tiff_warning_handler();

    asfPrintStatus("\nASF MapReady:\n");
    const char *share_dir = get_asf_share_dir();

    if (!share_dir)
      // this actually should never happen with the current implementation
      // of get_asf_share_dir() -- always sets the share dir to something
      // even if it is a bad guess... in which case the next check will fail
      asfPrintError("Could not find the ASF share directory!\n");

    glade_xml_file = (gchar *)find_in_share("mapready.glade");
    if (!glade_xml_file)
      asfPrintError("Could not find the mapready.glade file!\n"
                    "It should be in the share files directory, here:\n"
                    "  %s\n", share_dir);
    glade_xml = glade_xml_new(glade_xml_file, NULL, NULL);
    if (!glade_xml)
      asfPrintError("Could not load the mapready.glade file!\n"
                    "This file may be corrupt. mapready.glade was found in:\n"
                    "  %s\n", share_dir);
    g_free(glade_xml_file);

    asfPrintStatus("Using share files directory: %s\n\n", share_dir);

    /* thumbnails supported in GTK 2.4 or greater */
#ifdef G_THREADS_ENABLED
    use_thumbnails = gtk_major_version >= 2 && gtk_minor_version >= 4;
#else
    use_thumbnails = FALSE;
#endif

#ifdef win32
    // On windows, ensure that our installed sh.exe is the one that is found,
    // by severely restricting the path.
    char pathenv[1024];
    sprintf(pathenv, "PATH=%s", get_asf_bin_dir());
    putenv(pathenv);
#endif

    if (!use_thumbnails)
    {
        printf("GTK Version < 2.4 -- output thumbnails disabled.\n");
    }
    else
    {
        // We will want to load thumbnails in other threads.
        if ( !g_thread_supported () ) {
            g_thread_init (NULL);
        }
    }

    /* allow FOPEN, FREAD, FWRITE to fail without aborting */
    caplib_behavior_on_error = BEHAVIOR_ON_ERROR_CONTINUE;

    /* add version number to window title, request a default size */
    char gtitle [256];
    sprintf (gtitle, "ASF MapReady: Version %s",
             MAPREADY_VERSION_STRING);

    widget = get_widget_checked("asf_convert");
    gtk_window_set_title(GTK_WINDOW(widget), gtitle);
    // commenting this out - now supported within glade
    //gtk_window_resize(GTK_WINDOW(widget), 1000, 700);

    /* select defaults for dropdowns & buttons & labeling */
    widget = get_widget_checked("scaling_method_combobox");
    set_combo_box_item(widget, SCALING_METHOD_SIGMA);

    widget = get_widget_checked("import_checkbutton");
    gtk_widget_set_sensitive(widget, FALSE);

    widget = get_widget_checked("input_data_type_combobox");
    set_combo_box_item(widget, INPUT_TYPE_AMP);

    widget = get_widget_checked("resample_option_menu");
    set_combo_box_item(widget, RESAMPLE_BILINEAR);

    // Populate the colormap drop-downs on both the import tab and in the
    // browse dialog
    populate_polsarpro_classification_optionmenu();
    widget = get_widget_checked("browse_select_colormap_optionmenu");
    gtk_option_menu_set_history(GTK_OPTION_MENU(widget), 0);

    widget = get_widget_checked("output_format_combobox");
    set_combo_box_item(widget, OUTPUT_FORMAT_JPEG);

    widget = get_widget_checked("geocode_checkbutton");
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE);
    geocode_options_changed();
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), FALSE);

    widget = get_widget_checked("about_dialog_copyright_label");
    gtk_label_set_text(GTK_LABEL(widget), ASF_COPYRIGHT_STRING);

    // Hide latitude selection stuff until we start supporting
    // swath products (level 0) again
    widget = get_widget_checked("latitude_checkbutton");
    gtk_widget_hide(widget);
    widget = get_widget_checked("latitude_low_label");
    gtk_widget_hide(widget);
    widget = get_widget_checked("latitude_hi_label");
    gtk_widget_hide(widget);
    widget = get_widget_checked("latitude_low_entry");
    gtk_widget_hide(widget);
    widget = get_widget_checked("latitude_hi_entry");
    gtk_widget_hide(widget);

    // For now, do not allow manual offsets
    show_widget("hbox_tc_matching", FALSE);

    // This option is deprecated -- we always apply the fix now
    // and don't give the user the option of turning it off.  Probably
    // we can just delete all code associated with it, but for now we
    // just turn it on, and hide it.
    set_checked("apply_metadata_fix_checkbutton", TRUE);
    widget = get_widget_checked("apply_metadata_fix_checkbutton");
    gtk_widget_hide(widget);

    // Muck with the fonts in the About dialog
    widget = get_widget_checked("about_dialog_mapready_label");
    gchar *str = gtitle;
    gchar *text;
    PangoAttrList *attrs;
    sprintf(gtitle,
                "\n<b>ASF MapReady</b>\n"
                "<i>Remote Sensing Toolkit</i>\n"
                "ver. %s",
                MAPREADY_VERSION_STRING);
    if (strlen(SVN_REV)>0)
        sprintf(gtitle, "%s (build %s)", gtitle, SVN_REV);
    else
        strcat(gtitle, " (custom build)");

    pango_parse_markup(str, -1, 0, &attrs, &text, NULL, NULL);
    gtk_label_set_attributes(GTK_LABEL(widget), attrs);
    gtk_label_set_text(GTK_LABEL(widget), text);
    PangoFontDescription *font_desc =
      pango_font_description_from_string("Sans 12");
    gtk_widget_modify_font(widget, font_desc);

    // Muck with the "Select Processing Steps" label
    widget = get_widget_checked("select_processing_steps_label");
    str = gtitle;
    sprintf(gtitle, "<b><i>  Select Processing Steps:</i></b>");
    pango_parse_markup(str, -1, 0, &attrs, &text, NULL, NULL);
    gtk_label_set_attributes(GTK_LABEL(widget), attrs);
    gtk_label_set_text(GTK_LABEL(widget), text);
    font_desc = pango_font_description_from_string("Sans 12");
    gtk_widget_modify_font(widget, font_desc);

    /* fire handlers for hiding/showing stuff */
    output_format_combobox_changed();
    input_data_type_changed();
    geocode_options_changed();
    load_external_commands();
    external_settings_changed();
    set_toolbar_images();
    show_execute_button(TRUE);

    /* build columns in the files section */
    show_full_paths = FALSE; // Set before setup_files_list(), default to FALSE
    widget = get_widget_checked("show_full_path_names_checkbutton");
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), FALSE);
    setup_files_list();

    /* allow multiple selects */
    widget = get_widget_checked("input_file_selection");
    gtk_file_selection_set_select_multiple(GTK_FILE_SELECTION(widget), TRUE);

    /* drag-n-drop setup */
    setup_dnd();

    /* right-click menu setup */
    setup_popup_menu();

    /* bands dropdown setup*/
    setup_band_comboboxes();

    current_naming_scheme = naming_scheme_default();

    /* set initial vpanel setting */
    //widget = get_widget_checked("vertical_pane");
    //gtk_paned_set_position(GTK_PANED(widget), 240);

    /* Connect signal handlers.  */
    glade_xml_signal_autoconnect (glade_xml);

    /* initial flag settings */
    processing = FALSE;
    settings_on_execute = NULL;

    /* explicit call to the function that refreshes the "summary" */
    /* section when options are changed, so get the settings      */
    /* initially in there                                         */
    input_data_formats_changed();
    input_data_type_combobox_changed();
    default_to_terrcorr_on();
    default_to_keep_temp();
    terrcorr_options_changed();
    init_browse_format_combobox();

    /* For some reason, it did not work to set this via glade        */
    /* So, we have to select our default faraday rotation style here */
    rb_select("rb_fr_global", TRUE);
    polarimetry_settings_changed();

    /* put files on the command-line into the files section */
    populate_files_list(argc, argv);

    /* set up the rgb stuff on the export tab */
    rgb_combo_box_setup();

    /* enters the main GTK loop */
    gtk_main ();

    /* clean up, application has been closed */
    if (settings_on_execute)
        settings_delete(settings_on_execute);

    if (output_directory)
        g_free(output_directory);

    if (current_naming_scheme)
        naming_scheme_delete(current_naming_scheme);

    release_predefined_projections();

    exit (EXIT_SUCCESS);
}