예제 #1
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);
    }
}
예제 #2
0
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;
}
예제 #3
0
static int
show_section (CmdConfig *cmd_config, CameraWidget *section)
{
	CameraWidget *child, *parent;
	CameraWidgetType type;
	CDKSCROLL *scroll = NULL;
	const char *label;
	char *items[100];
	int count, x, selection;
	char title[1024];
	int show_parent = 0, show_child = 0;

	/* Create the scroll list */
	gp_widget_get_type (section, &type);
	gp_widget_get_label (section, &label);
	snprintf (title, sizeof (title), "<C></5>%s", label);
	if (type == GP_WIDGET_WINDOW)
		items[0] = copyChar (_("Exit"));
	else
		items[0] = copyChar (_("Back"));
	count = gp_widget_count_children (section);
	for (x = 0; x < count; x++) {
		gp_widget_get_child (section, x, &child);
		gp_widget_get_label (child, &label);
		items[x + 1] = copyChar ((char *) label);
	}
	count++;
	scroll = newCDKScroll (cmd_config->screen, CENTER, CENTER, RIGHT,
			       10, 50, title,
			       items, count, NUMBERS, A_REVERSE, TRUE, FALSE);
	if (!scroll)
		return (GP_ERROR);

	selection = activateCDKScroll (scroll, 0);
	if (scroll->exitType == vNORMAL) {
		if (selection)
			show_child = selection;
		else if (type != GP_WIDGET_WINDOW)
			show_parent = 1;
	}

	/* Clean up */
	destroyCDKScroll (scroll);

	if (show_parent) {
		gp_widget_get_parent (section, &parent);
		show_widget (cmd_config, parent);
	} else if (show_child) {
		gp_widget_get_child (section, show_child - 1, &child);
		show_widget (cmd_config, child);
	}

	return (GP_OK);
}
예제 #4
0
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;
}
예제 #5
0
static void close_subset_window(ImageInfo *ii)
{
    g_poly->show_extent = FALSE;
    fill_big(ii);

    show_widget("save_subset_window", FALSE);
}
예제 #6
0
파일: main_menu.cpp 프로젝트: Dqiyue/QT
void Main_Menu::createActions()
{
    exit = new QAction(this);
    exit->setText("退出");
    restore = new QAction(this);
    restore->setText("恢复");
    hide = new QAction(this);
    hide->setText("隐藏");
    min = new QAction(this);
    min->setText("最小化");
 //   turnPage = new QAction (this);
//    feedback = new QAction(this);
    myWidgetActiontop = new QWidgetAction(this);
    myWidgetActionbto =new QWidgetAction(this);
    myWidgettop = new QWidget();
    myWidgetbto = new QWidget();

    QLabel *lab_top = new QLabel(myWidgettop);
    QLabel *lab_bto = new QLabel(myWidgetbto);
    mylayouttop = new QVBoxLayout();
    mylayoutbto = new QVBoxLayout();
    lab_top->setGeometry(0,0,200,300);
    lab_bto->setGeometry(0,0,200,300);

    lab_top->setStyleSheet("background-color:#27ae64");
    lab_bto->setStyleSheet("background-color:#27ae64");


    myWidgettop->setLayout(mylayouttop);
    myWidgetActiontop->setDefaultWidget(myWidgettop);
    myWidgetbto->setLayout(mylayoutbto);
    myWidgetActionbto->setDefaultWidget(myWidgetbto);




    this->addAction(myWidgetActiontop);
    this->addAction(restore);
    this->addSeparator();
    this->addAction(hide);
    this->addSeparator();
    this->addAction(min);
    this->addSeparator();
    this->addAction(exit);
    this->addAction(myWidgetActionbto);




    //恢复
    connect(restore,SIGNAL(triggered()),this,SIGNAL(show_widget()));
    //退出
    connect(exit,SIGNAL(triggered()),this,SIGNAL(close_widget()));
    //隐藏
    connect(hide,SIGNAL(triggered()),this,SIGNAL(hide_widget()));
    //最小化
    connect(min,SIGNAL(triggered()),this,SIGNAL(show_min()));

}
예제 #7
0
static int
show_widget (CmdConfig *cmd_config, CameraWidget *widget)
{
	CameraWidget *parent;
	CameraWidgetType type;

	CHECK (gp_widget_get_type (widget, &type));
	switch (type) {
	case GP_WIDGET_WINDOW:
	case GP_WIDGET_SECTION:
		CHECK (show_section (cmd_config, widget));
		break;
	case GP_WIDGET_DATE:
		CHECK (show_date (cmd_config, widget));
		CHECK (show_time (cmd_config, widget));
		CHECK (gp_widget_get_parent (widget, &parent));
		CHECK (show_widget (cmd_config, parent));
		break;
	case GP_WIDGET_MENU:
	case GP_WIDGET_RADIO:
		CHECK (show_radio (cmd_config, widget));
		CHECK (gp_widget_get_parent (widget, &parent));
		CHECK (show_widget (cmd_config, parent));
		break;
	case GP_WIDGET_RANGE:
		CHECK (show_range (cmd_config, widget));
		CHECK (gp_widget_get_parent (widget, &parent));
		CHECK (show_widget (cmd_config, parent));
		break;
	case GP_WIDGET_TEXT:
		CHECK (show_text (cmd_config, widget));
		CHECK (gp_widget_get_parent (widget, &parent));
		CHECK (show_widget (cmd_config, parent));
		break;
	case GP_WIDGET_TOGGLE:
		CHECK (show_toggle (cmd_config, widget));
		CHECK (gp_widget_get_parent (widget, &parent));
		CHECK (show_widget (cmd_config, parent));
		break;
	default:
		return (GP_ERROR_NOT_SUPPORTED);
	}

	return (GP_OK);
}
예제 #8
0
void
gth_window_show_only_content (GthWindow *window,
			      gboolean   only_content)
{
	int i;

	if (only_content) {
		for (i = 0; i < window->priv->n_pages; i++)
			hide_widget (window->priv->toolbars[i]);
		hide_widget (window->priv->menubar);
		hide_widget (window->priv->toolbar);
		hide_widget (window->priv->statusbar);
	}
	else {
		for (i = 0; i < window->priv->n_pages; i++)
			show_widget (window->priv->toolbars[i]);
		show_widget (window->priv->menubar);
		show_widget (window->priv->toolbar);
		show_widget (window->priv->statusbar);
	}
}
예제 #9
0
파일: com.cpp 프로젝트: zqplus/arduino-ABC
void COM::button_callback()
{

    QString com;
    com = ui->comboBox->currentText();
    qApp->setProperty("my_global_string", com);

    //QWidget::activateWindow();
    //COM->close();

//    QTextStream out(stdout);
//    out << com;

    show_widget();
}
예제 #10
0
int
gp_cmd_config (Camera *camera, GPContext *context)
{
	CmdConfig cmd_config;
	CameraWidget *config;
	int result;
	CDKSCREEN *screen = NULL;
	WINDOW *window = NULL;

	if (!camera)
		return (GP_ERROR_BAD_PARAMETERS);

	result = gp_camera_get_config (camera, &config, context);
	if (result < 0)
		return (result);

	/* Set up CDK. */
	window = initscr ();
	screen = initCDKScreen (window);

	/* Set up CDK Colors. */
	initCDKColor ();

	/* Go! */
	cmd_config.camera  = camera;
	cmd_config.screen  = screen;
	cmd_config.window  = config;
	cmd_config.context = context;
	result = show_widget (&cmd_config, config);

	/* Clean up */
	destroyCDKScreen (screen);
	delwin (window);
	endCDK ();

	return (result);
}
예제 #11
0
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();
  }
}
예제 #12
0
SIGNAL_CALLBACK void
on_add_file_with_ancillary_dialog_delete_event(GtkWidget *widget)
{
  clear_entries();
  show_widget("add_file_with_ancillary_dialog", FALSE);
}
예제 #13
0
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
}
예제 #14
0
SIGNAL_CALLBACK void
on_add_file_with_ancillary_cancel_button_clicked(GtkWidget *w)
{
  clear_entries();
  show_widget("add_file_with_ancillary_dialog", FALSE);
}
예제 #15
0
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);
}
예제 #16
0
파일: asf_view.c 프로젝트: glshort/MapReady
int
main(int argc, char **argv)
{
    if (detect_flag_options(argc, argv, "-help", "--help", NULL))
      help();

    char band[512], lut[512], mask_file_name[512];

    strcpy(band, "");
    strcpy(mask_file_name, "");

    int band_specified = extract_string_options(&argc, &argv, band,
        "-band", "--band", "-b", NULL);
    int lut_specified = extract_string_options(&argc, &argv, lut,
        "-colormap", "--colormap", "-lut", "--lut", NULL);
    int planner_mode = extract_flag_options(&argc, &argv,
        "-plan", "--plan", NULL);
    int mask_specified = extract_string_options(&argc, &argv, mask_file_name,
        "-mask", "--mask", "--layover-mask", "--layover-mask", NULL);
    generic_specified = extract_flag_options(&argc, &argv,
        "-generic", "--generic", NULL);
    if (generic_specified) {
       char type[512];
       if (!extract_int_options(&argc, &argv, &generic_bin_width,
                "-width", "--width", "-cols", "--cols", NULL) ||
           !extract_int_options(&argc, &argv, &generic_bin_height,
                "-height", "--height", "-rows", "--rows", NULL)) {
         asfPrintError("When reading generic data, specify the size "
            "(--width, --height).\n");
       }
       generic_bin_byteswap =
         extract_flag_options(&argc, &argv,
                              "--byteswap", "-byteswap", NULL);
       if (extract_string_options(&argc, &argv, type,
                "-type", "--type", NULL))
       {
         if (strcmp_case(type, "BYTE") == 0 ||
             strcmp_case(type, "INT8") == 0) {
           generic_bin_datatype = BYTE;
         }
         else if (strcmp_case(type, "FLOAT") == 0 ||
                  strcmp_case(type, "REAL32") == 0) {
           generic_bin_datatype = REAL32;
         }
         else {
           asfPrintError("Unknown generic data type: %s\n", type);
         }
       } else {
         asfPrintStatus("Generic binary: assuming REAL32 data.\n");
         generic_bin_datatype = REAL32;
       }
    }

    if (planner_mode) {
      if (detect_flag_options(argc, argv, "-calibrate-reference", NULL)) {
        calibrate_planner_reference();
        exit(EXIT_SUCCESS);
      }
    }

    handle_common_asf_args(&argc, &argv, "ASF View");

    // point to "polygon 0" as the one we initially work on
    g_poly = &g_polys[0];

    // set up image array
    curr = &image_info[0];
    curr->data_name = curr->meta_name = NULL;
    int ii;

    if (argc < 2) {
        curr->filename = STRDUP(find_in_share("startup.jpg"));
    }
    else {
        n_images_loaded = 0;
	for (ii=1; ii<argc; ++ii) {
           if (strlen(argv[ii]) > 0) {
               image_info[n_images_loaded].filename = STRDUP(argv[ii]);
               ++n_images_loaded;
           }
        }    
    }


    if (n_images_loaded == 1) {
        asfPrintStatus("Loading 1 image: %s\n", image_info[0].filename);
    }
    else {
        asfPrintStatus("Loading %d images:\n", n_images_loaded);
        for (ii=0; ii<n_images_loaded; ++ii)
            asfPrintStatus("%d: %s\n", ii+1, image_info[ii].filename);
    }

    if (mask_specified)
        asfPrintStatus("Mask: %s\n", mask_file_name);

    // we could call load_file() here, but don't because this way we can
    // interleave the call to gtk_init() with some of the loading code --
    // which keeps the window from showing up until after it has been loaded,
    // which looks much nicer

    // initialize globals
    reset_globals(TRUE);

    // Get rid of leftover (temporary) colormap luts if they exist, say if asf_view errored out
    // rather than being exited normally
    char embedded_tiff_lut_file[1024];
    char embedded_asf_colormap_file[1024];
    char *lut_loc = (char *)MALLOC(sizeof(char)*(strlen(get_asf_share_dir())+64));
    sprintf(lut_loc, "%s%clook_up_tables", get_asf_share_dir(), DIR_SEPARATOR);
    sprintf(embedded_tiff_lut_file,"%s%c%s", lut_loc, DIR_SEPARATOR, EMBEDDED_TIFF_COLORMAP_LUT_FILE);
    sprintf(embedded_asf_colormap_file,"%s%c%s", lut_loc, DIR_SEPARATOR,
            EMBEDDED_ASF_COLORMAP_LUT_FILE);
    FREE(lut_loc);
    if (fileExists(embedded_tiff_lut_file)) remove(embedded_tiff_lut_file);
    if (fileExists(embedded_asf_colormap_file)) remove(embedded_asf_colormap_file);

    if (mask_specified) {
        curr = mask = &mask_info;
        mask->filename = STRDUP(mask_file_name);

        if (mask->filename[strlen(mask->filename)-1] == '.')
            mask->filename[strlen(mask->filename)-1] = '\0';
        
        read_file(mask->filename, NULL, FALSE, TRUE);
        //set_lut("layover_mask");
    }
    
    // load the image we're going to actually show last
    for (ii=n_images_loaded-1; ii>=0; --ii)
    {
        curr = &image_info[ii];
        
        // strip off any trailing "."
        if (curr->filename[strlen(curr->filename)-1] == '.')
            curr->filename[strlen(curr->filename)-1] = '\0';
        
        read_file(curr->filename, band_specified ? band : NULL, FALSE, TRUE);
        check_for_embedded_tiff_lut(curr->filename, &lut_specified, lut);
        if (lut_specified)
            set_lut(lut);
        
        assert(curr->data_name);
        assert(curr->meta_name);
        
        // we load the thumbnail data before bringing up the window, looks
        // much nicer.  When loading an image within the GUI, we don't need
        // to do get_thumbnail_data() as a separate step.
        ThumbnailData *thumbnail_data = get_thumbnail_data(curr);
        
        // first time through the loop only, set up GTK
        if (ii == n_images_loaded-1) {
            gtk_init(&argc, &argv);
            
            gchar *glade_xml_file = (gchar *)find_in_share("asf_view.glade");
            printf("Found asf_view.glade: %s\n", glade_xml_file);
            glade_xml = glade_xml_new(glade_xml_file, NULL, NULL);
            free(glade_xml_file);
            
            // set up window title, etc
            set_button_images();
            
            // set up the acquisition planner, if we are in that mode
            if (planner_mode) {
                setup_planner();
                
                // getting rid of the info section makes more room for the found
                // acquisitions, and isn't really necessary in the planner
                show_widget("info_hbox", FALSE);
            }
            
            // populate the look up table list, and apply the default
            // look-up-table, if there is one.  In this case, we will need to
            // apply it retroactively to the thumbnail data we already loaded
            // (In new.c, this kludge isn't required - we load/apply in the
            // same pass -- here it is required because we pre-load the thumbnail)
            populate_lut_combo();
            if (check_for_embedded_tiff_lut(curr->filename, &lut_specified, lut)) {
                GtkWidget *option_menu = get_widget_checked("lut_optionmenu");
                gtk_option_menu_set_history(GTK_OPTION_MENU(option_menu), get_tiff_lut_index());
                set_current_index(get_tiff_lut_index());
            }
            else if (is_colormap_ASF_file(curr->filename)) {
                /*
                * lut_specified = 1;
                * strcpy(lut, EMBEDDED_ASF_COLORMAP_LUT);
                * GtkWidget *option_menu = get_widget_checked("lut_optionmenu");
                * gtk_option_menu_set_history(GTK_OPTION_MENU(option_menu), get_asf_lut_index());
                * set_current_index(get_asf_lut_index());
                * check_lut();
                * apply_lut_to_data(thumbnail_data);
                */
            }
        }
        else if (ii == 0) {
            set_title(band_specified, band);
        }

        if (curr->meta && curr->meta->general)  {
            if (set_lut_based_on_image_type(curr->meta->general->image_data_type))
            {
                check_lut();
                // data we loaded needs to be lutted
                apply_lut_to_data(thumbnail_data);
            }
        }
        
        // load the metadata & image data, other setup
        setup_gdk_window_ids();
        setup_small_image_size();
        fill_small_have_data(thumbnail_data, curr);
        fill_big(curr);
        update_pixel_info(curr);
        update_zoom();
        set_font();
        fill_meta_info();
        update_map_settings(curr);
        fill_stats(curr);
        set_mapping_defaults(curr);
        setup_bands_tab(curr->meta);
        disable_meta_button_if_necessary();
        if (lut_specified)
            select_lut(lut);
    }

    if (n_images_loaded>0) {
        asfPrintStatus("Currently displaying %d: %s\n",
                       current_image_info_index, curr->filename);
    }

    glade_xml_signal_autoconnect(glade_xml);
    gtk_main ();

    // If the last viewed file left behind a (temporary) color map lut,
    // then get rid of it
    if (fileExists(embedded_tiff_lut_file))
      remove(embedded_tiff_lut_file);
    if (fileExists(embedded_asf_colormap_file))
      remove(embedded_asf_colormap_file);

    image_info_free(curr);
    free_shapes();
    exit (EXIT_SUCCESS);
}