⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scope_trig.c

📁 Source code for an Numeric Cmputer
💻 C
📖 第 1 页 / 共 2 页
字号:
    trig->position =	(GTK_ADJUSTMENT(trig->pos_adj))->value / TRIG_POS_RESOLUTION;    /* connect the slider to a function that re-sets trigger position */    gtk_signal_connect(GTK_OBJECT(trig->pos_adj), "value_changed",	GTK_SIGNAL_FUNC(pos_changed), NULL);    gtk_widget_show(trig->pos_slider);    /* level display */    gtk_hseparator_new_in_box(ctrl_usr->trig_info_win, 3);    gtk_label_new_in_box("Level", ctrl_usr->trig_info_win, FALSE, FALSE, 0);    trig->level_label =	gtk_label_new_in_box(" ---- ", ctrl_usr->trig_info_win, FALSE, FALSE,	0);    /* define a button to set the trigger edge */    ctrl_shm->trig_edge = 1;    trig->edge_button = gtk_button_new_with_label("Rising");    trig->edge_label = (GTK_BIN(trig->edge_button))->child;    gtk_box_pack_start(GTK_BOX(ctrl_usr->trig_info_win),	trig->edge_button, FALSE, FALSE, 0);    gtk_signal_connect(GTK_OBJECT(trig->edge_button), "clicked",	GTK_SIGNAL_FUNC(edge_button_clicked), NULL);    gtk_widget_show(trig->edge_button);    /* define a button to set the trigger source */    trig->source_button = gtk_button_new_with_label("Source\nNone");    trig->source_label = (GTK_BIN(trig->source_button))->child;    gtk_box_pack_start(GTK_BOX(ctrl_usr->trig_info_win),	trig->source_button, FALSE, FALSE, 0);    gtk_signal_connect(GTK_OBJECT(trig->source_button), "clicked",	GTK_SIGNAL_FUNC(source_button_clicked), NULL);    gtk_widget_show(trig->source_button);}static void dialog_select_trigger_source(void){    scope_vert_t *vert;    scope_trig_t *trig;    dialog_generic_t dialog;    gchar *title, *msg;    int n, colwidth;    gchar *strs[2], *titles[2];    gchar buf[BUFLEN + 1];    GtkWidget *label, *button, *scrolled_window, *trig_list;    /* is acquisition in progress? */    if (ctrl_shm->state != IDLE) {	/* yes, 'push' the stop button */	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ctrl_usr->		rm_stop_button), TRUE);    }    vert = &(ctrl_usr->vert);    trig = &(ctrl_usr->trig);    title = "Trigger Source";    msg = "Select a channel to use for triggering.";    /* create dialog window, disable resizing */    dialog.retval = 0;    dialog.window = gtk_dialog_new();    /* set initial height of window */    gtk_widget_set_usize(GTK_WIDGET(dialog.window), -2, 400);    /* allow user to grow but not shrink the window */    gtk_window_set_policy(GTK_WINDOW(dialog.window), FALSE, TRUE, FALSE);    /* set title */    gtk_window_set_title(GTK_WINDOW(dialog.window), title);    /* display message */    label = gtk_label_new(msg);    gtk_misc_set_padding(GTK_MISC(label), 15, 5);    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog.window)->vbox), label, FALSE,	TRUE, 0);    /* Create a scrolled window to display the list */    scrolled_window = gtk_scrolled_window_new(NULL, NULL);    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),	GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog.window)->vbox),	scrolled_window, TRUE, TRUE, 5);    gtk_widget_show(scrolled_window);    /* create a list to hold the data */    titles[0] = "Chan";    titles[1] = "Source";    trig_list = gtk_clist_new_with_titles(2, titles);    gtk_clist_column_titles_passive(GTK_CLIST(trig_list));    /* set up a callback for when the user selects a line */    gtk_signal_connect(GTK_OBJECT(trig_list), "select_row",	GTK_SIGNAL_FUNC(trigger_selection_made), &dialog);    /* It isn't necessary to shadow the border, but it looks nice :) */    gtk_clist_set_shadow_type(GTK_CLIST(trig_list), GTK_SHADOW_OUT);    /* set list for single selection only */    gtk_clist_set_selection_mode(GTK_CLIST(trig_list), GTK_SELECTION_BROWSE);    /* put the list into the scrolled window */    gtk_container_add(GTK_CONTAINER(scrolled_window), trig_list);    gtk_widget_show(trig_list);    /* populate the trigger source list */    gtk_clist_clear(GTK_CLIST(trig_list));    for (n = 0; n < 16; n++) {	snprintf(buf, BUFLEN, "%d", n + 1);	strs[0] = buf;	if (ctrl_usr->chan[n].name != NULL) {	    strs[1] = ctrl_usr->chan[n].name;	} else {	    strs[1] = "----";	}	gtk_clist_append(GTK_CLIST(trig_list), strs);    }    /* set column width */    colwidth = gtk_clist_optimal_column_width(GTK_CLIST(trig_list), 1);    gtk_clist_set_column_min_width(GTK_CLIST(trig_list), 1,	(colwidth * 17) / 16);    /* was a channel previously selected? */    if (ctrl_shm->trig_chan > 0) {	/* yes, preselect appropriate line */	gtk_clist_select_row(GTK_CLIST(trig_list), ctrl_shm->trig_chan - 1,	    1);    }    /* set up a callback function when the window is destroyed */    gtk_signal_connect(GTK_OBJECT(dialog.window), "destroy",	GTK_SIGNAL_FUNC(dialog_generic_destroyed), &dialog);    /* make Cancel button */    button = gtk_button_new_with_label("Cancel");    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog.window)->action_area),	button, TRUE, TRUE, 4);    gtk_signal_connect(GTK_OBJECT(button), "clicked",	GTK_SIGNAL_FUNC(dialog_generic_button2), &dialog);    /* make window transient and modal */    gtk_window_set_transient_for(GTK_WINDOW(dialog.window),	GTK_WINDOW(ctrl_usr->main_win));    gtk_window_set_modal(GTK_WINDOW(dialog.window), TRUE);    gtk_widget_show_all(dialog.window);    gtk_main();    /* we get here when the user makes a selection, hits Cancel, or closes       the window */    trig_list = NULL;}int set_trigger_source(int chan_num){    ctrl_shm->trig_chan = chan_num;    if (ctrl_usr->chan[ctrl_shm->trig_chan - 1].name == NULL) {	/* selected channel has no source */	ctrl_shm->trig_chan = 0;    }    refresh_trigger();    return 0;}/* If we come here, then the user has selected a row in the list. */static void trigger_selection_made(GtkWidget * clist, gint row, gint column,    GdkEventButton * event, dialog_generic_t * dptr){    GdkEventType type;    if ((event == NULL) || (clist == NULL)) {	/* We get spurious events when the lists are populated I don't know	   why.  If either clist or event is null, it's a bad one! */	return;    }    type = event->type;    if (type != 4) {	/* We also get bad callbacks if you drag the mouse across the list	   with the button held down.  They can be distinguished because	   their event type is 3, not 4. */	return;    }    /* If we get here, it should be a valid selection */    set_trigger_source(row + 1);    /* set return value of dialog */    dptr->retval = 1;    /* destroy window to cause dialog_generic_destroyed() to be called */    gtk_widget_destroy(dptr->window);    return;}int set_trigger_level(double setting){    scope_trig_t *trig;    GtkAdjustment *adj;    /* range check setting */    if (( setting < 0.0 ) || ( setting > 1.0 )) {	return -1;    }    /* point to data */    trig = &(ctrl_usr->trig);    /* set level */    trig->level = setting;    /* set level slider based on new setting */    adj = GTK_ADJUSTMENT(trig->level_adj);    gtk_adjustment_set_value(adj, trig->level * TRIG_LEVEL_RESOLUTION);    refresh_trigger();    return 0;}static void level_changed(GtkAdjustment * adj, gpointer gdata){    set_trigger_level(adj->value / TRIG_LEVEL_RESOLUTION);}int set_trigger_pos(double setting){    scope_trig_t *trig;    GtkAdjustment *adj;    /* range check setting */    if (( setting < 0.0 ) || ( setting > 1.0 )) {	return -1;    }    /* point to data */    trig = &(ctrl_usr->trig);    /* is acquisition in progress? */    if (ctrl_shm->state != IDLE) {	/* yes, 'push' the stop button */	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ctrl_usr->		rm_stop_button), TRUE);    }    /* set position */    trig->position = setting;    /* set position slider based on new setting */    adj = GTK_ADJUSTMENT(trig->pos_adj);    gtk_adjustment_set_value(adj, trig->position * TRIG_POS_RESOLUTION);    refresh_trigger();    return 0;}static void pos_changed(GtkAdjustment * adj, gpointer gdata){    set_trigger_pos(adj->value / TRIG_POS_RESOLUTION);}int set_trigger_polarity(int setting){    if (setting == 0) {	ctrl_shm->trig_edge = 0;    } else if ( setting == 1 ) {	ctrl_shm->trig_edge = 1;    } else {	return -1;    }    refresh_trigger();    return 0;}static void edge_button_clicked(GtkWidget * widget, gpointer * gdata){    if (ctrl_shm->trig_edge == 0) {	/* was falling edge, make rising */	set_trigger_polarity(1);    } else {	/* was rising edge, make falling */	set_trigger_polarity(0);    }}int set_trigger_mode(int mode){    GtkWidget *button;    if ( mode == 0 ) {	/* normal mode */	button = ctrl_usr->trig.normal_button;    } else if ( mode == 1 ) {	/* auto mode */	button = ctrl_usr->trig.auto_button;    } else {	/* illegal mode */	return -1;    }    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), 1);    return 0;}static void normal_button_clicked(GtkWidget * widget, gpointer * gdata){    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)) != TRUE) {	/* not pressed, ignore it */	return;    }    ctrl_shm->auto_trig = 0;}static void auto_button_clicked(GtkWidget * widget, gpointer * gdata){    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)) != TRUE) {	/* not pressed, ignore it */	return;    }    ctrl_shm->auto_trig = 1;}static void force_button_clicked(GtkWidget * widget, gpointer * gdata){    ctrl_shm->force_trig = 1;}static void source_button_clicked(GtkWidget * widget, gpointer * gdata){    dialog_select_trigger_source();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -