/* ************************************************************** */ /* * Module BLSCANUI * This module contains functions for the integrated field * strength measurement user interface. * * Zachary Wolf * 3/17/00 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include /* Needed if linking in external compiler; harmless otherwise */ #include #include #include "blscanuir.h" #include "blscanui.h" #include "blscan.h" /* ************************************************************** */ /* PRIVATE PARAMETERS */ static struct blscan_param_struct blscan_param; /* ************************************************************** */ /* PRIVATE VARIABLES */ static int blscan_panel; /* ************************************************************** */ /* PRIVATE FUNCTION DECLARATIONS */ void blscanui_error(char* msg); /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * blscanui_init * This function initializes the user interface for the BLscan system. * * Input: * top_pos, vertical position of top left panel corner in screen coordinates * left_pos, horizontal position of top left panel corner in screen coordinates * blscan_par, blscan system parameters * * Zachary Wolf * 3/17/00 */ void blscanui_init(int top_pos, int left_pos, struct blscan_param_struct blscan_param_in) { /* Save parameters for future use */ blscan_param = blscan_param_in; /* Make sure the user interface panel is desired */ if (blscan_param.show_ui != BLSCAN_TRUE) return; /* Open the BLwire panel */ blscan_panel = LoadPanel(0, "c:\\dataccvi\\wirescan\\src\\blscan\\blscanuir.uir", BLSCANPAN); if (blscan_panel < 0) { blscanui_error("Could not open user interface panel"); return; } /* Set the panel position */ SetPanelPos(blscan_panel, top_pos, left_pos); /* Display the panel */ DisplayPanel(blscan_panel); /* Done */ return; } /* ************************************************************** */ /* * blscanui_scale_vt_vs_x * This function sets the scale on the horizontal axis of the VT vs X * plot. * * Input: * num_x_pos, number of x positions * x_pos[0 to num_x_pos - 1], x positions * * Zachary Wolf * 3/17/00 */ void blscanui_scale_vt_vs_x(int num_x_pos, double x_pos[]) { /* Declare variables */ double x_min, x_max; int min_index, max_index; /* Make sure the user interface panel is being used */ if (blscan_param.show_ui != BLSCAN_TRUE) return; /* Determine the minimum and maximum x positions */ MaxMin1D(x_pos, num_x_pos, &x_max, &max_index, &x_min, &min_index); x_min = x_min - .01; x_max = x_max + .01; /* Set the horizontal scale of the VT vs X plot */ SetAxisRange(blscan_panel, BLSCANPAN_GRAPH_VT_VS_X, VAL_MANUAL, x_min, x_max, VAL_AUTOSCALE, 0., 0.); /* Done */ return; } /* ************************************************************** */ /* * blscanui_plot_vt_vs_x * This function adds points to the VT vs X plot. * * Input: * num_samp, number of VT samples to take as the wire is moved * x[0 to n], x[0] is the starting position, x[1 to n] are the positions of the samples (m) * vt[0 to n], vt[0] = 0, vt[1 to n] = n measured integrated voltage samples (Vs) * color, color of the plotted points * * Zachary Wolf * 3/17/00 */ void blscanui_plot_vt_vs_x(int num_samp, double x[], double vt[], int color) { /* Check for the user interface */ if (blscan_param.show_ui != BLSCAN_TRUE) return; /* Plot the BL samples */ PlotXY(blscan_panel, BLSCANPAN_GRAPH_VT_VS_X, x, vt, num_samp + 1, VAL_DOUBLE, VAL_DOUBLE, VAL_CONNECTED_POINTS, VAL_SMALL_SOLID_SQUARE, VAL_SOLID, 1, color); /* Done */ return; } /* ************************************************************** */ /* * blscanui_clear_vt_vs_x * This function clears the VT vs X plot. * * Zachary Wolf * 2/14/00 */ void blscanui_clear_vt_vs_x(void) { /* Check for the user interface */ if (blscan_param.show_ui != BLSCAN_TRUE) return; /* Remove previous plot */ DeleteGraphPlot(blscan_panel, BLSCANPAN_GRAPH_VT_VS_X, -1, VAL_IMMEDIATE_DRAW); /* Done */ return; } /* ************************************************************** */ /* * blscanui_scale_vt_coeff * This function sets the scale on the horizontal axis of the * VT coefficient plot. * * Input: * fit_order, order of the polynomial fit * * Zachary Wolf * 3/23/00 */ void blscanui_scale_vt_coeff(int fit_order) { /* Declare variables */ double min, max; /* Make sure the user interface panel is being used */ if (blscan_param.show_ui != BLSCAN_TRUE) return; /* Determine the minimum and maximum magnet currents */ min = 0.; max = fit_order + 1; /* Set the horizontal scale of the BL vs X plot */ SetAxisRange(blscan_panel, BLSCANPAN_GRAPH_VT_COEFF, VAL_MANUAL, min, max, VAL_AUTOSCALE, 0., 0.); /* Done */ return; } /* ************************************************************** */ /* * blscanui_plot_vt_coeff * This function plots the coefficients in the polynomial fit * to the VT vs X data. * * Input: * fit_order, order of the polynomial fit * vt_coeff[0 to fit_order], polynomial coefficients * * Zachary Wolf * 3/23/00 */ void blscanui_plot_vt_coeff(int fit_order, double vt_coeff[]) { /* Declare variables */ double num[BLSCAN_MAX_NUM_HAR + 1]; int i; /* Check for the user interface */ if (blscan_param.show_ui != BLSCAN_TRUE) return; /* Fill the x axis points */ for (i = 0; i <= fit_order; i++) num[i] = i; /* Plot the data */ PlotXY(blscan_panel, BLSCANPAN_GRAPH_VT_COEFF, num, vt_coeff, fit_order + 1, VAL_DOUBLE, VAL_DOUBLE, VAL_SCATTER, VAL_SOLID_SQUARE, VAL_SOLID, 1, VAL_BLUE); /* Done */ return; } /* ************************************************************** */ /* * blscanui_clear_vt_coeff * This function clears the VT coefficients plot. * * Zachary Wolf * 3/23/00 */ void blscanui_clear_vt_coeff(void) { /* Check for the user interface */ if (blscan_param.show_ui != BLSCAN_TRUE) return; /* Remove previous plot */ DeleteGraphPlot(blscan_panel, BLSCANPAN_GRAPH_VT_COEFF, -1, VAL_IMMEDIATE_DRAW); /* Done */ return; } /* ************************************************************** */ /* PRIVATE FUNCTIONS */ /* ************************************************************** */ /* * blscanui_error * This function handles error messages for the BLwire user interface. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 9/18/98 */ void blscanui_error(char* message) { /* Declare variables */ char buf[80]; /* Notify the operator of the error */ printf("\nBLSCANUI ERROR: %s\n", message); Beep(); Delay(.5); Beep(); /* Terminate the program if the operator desires */ printf("Press ENTER to continue.\nPress any key then ENTER to terminate program.\n"); fgets(buf, 80, stdin); if (buf[0] == '\n') return; else exit(0); }