/* ************************************************************** */ /* * Module BSCANUI * This module contains functions for the magnetic field scan * system user interface. * * Zachary Wolf * 11/25/02 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include #include /* Needed if linking in external compiler; harmless otherwise */ #include #include "vscanui.h" #include "bscanuir.h" #include "bscanui.h" #include "bscan.h" /* ************************************************************** */ /* PRIVATE PARAMETERS */ static struct bscan_param_struct bscan_param; /* ************************************************************** */ /* PRIVATE VARIABLES */ static int bscan_panel; static int bscanop_panel; /* ************************************************************** */ /* PRIVATE FUNCTION DECLARATIONS */ void bscanui_error(char* msg); /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * bscanui_init * This function initializes the user interface for the BSCAN 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 * bscan_par, bscan system parameters * * Zachary Wolf * 11/25/02 */ void bscanui_init(int top_pos, int left_pos, struct bscan_param_struct bscan_par) { /* Save parameters for future use */ bscan_param = bscan_par; /* Make sure the user interface panel is desired */ if (bscan_param.show_ui != BSCAN_TRUE) return; /* Open the bscan panel */ bscan_panel = LoadPanel(0, "c:\\dataccvi\\lib\\system\\bscan\\bscanuir.uir", BSCANPAN); if (bscan_panel < 0) { bscanui_error("Could not open user interface panel"); return; } /* Set the panel position */ SetPanelPos(bscan_panel, top_pos, left_pos); /* Display the panel */ DisplayPanel(bscan_panel); /* Done */ return; } /* ************************************************************** */ /* * bscanopui_init * This function initializes the user interface for the BSCAN 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 * * Zachary Wolf * 11/25/02 */ void bscanopui_init(int top_pos, int left_pos) { /* Open the bscanop panel */ bscanop_panel = LoadPanel(0, "bscanuir.uir", BSCANOP); if (bscan_panel < 0) { bscanui_error("Could not open user interface panel"); return; } /* Set the panel position */ SetPanelPos(bscanop_panel, top_pos, left_pos); /* Display the panel when the user interface runs */ DisplayPanel(bscanop_panel); /* Done */ return; } /* ************************************************************** */ void bscanui_clear_bsamp(void) { /* Check for the user interface */ if (bscan_param.show_ui != BSCAN_TRUE) return; /* Remove previous field sample plot */ DeleteGraphPlot(bscan_panel, BSCANPAN_GRAPH_B_SAMP, -1, VAL_IMMEDIATE_DRAW); /* Done */ return; } /* ************************************************************** */ void bscanui_plot_bsamp(int num_samp, double pos_samp[], double b_samp[], int color) { /* Check for the user interface */ if (bscan_param.show_ui != BSCAN_TRUE) return; /* Plot the field samples */ PlotXY(bscan_panel, BSCANPAN_GRAPH_B_SAMP, pos_samp, b_samp, num_samp, VAL_DOUBLE, VAL_DOUBLE, VAL_SCATTER, VAL_SMALL_SOLID_SQUARE, VAL_SOLID, 1, color); /* Done */ return; } /* ************************************************************** */ /* PRIVATE FUNCTIONS */ /* ************************************************************** */ /* * bscanui_error * This function handles error messages for the VTwire user interface. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 11/25/02 */ void bscanui_error(char* message) { /* Declare variables */ char buf[80]; /* Notify the operator of the error */ printf("\nBSCANUI 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); } /* ************************************************************** */ /* PRIVATE USER INTERFACE FUNCTIONS */ /* ************************************************************** */ int CVICALLBACK bscanui_quit(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: bscan_exit(); QuitUserInterface(0); break; } return 0; } /* ************************************************************** */ int CVICALLBACK bscanui_get_bsamp(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double start_pos, dist_move; double pos_samp[5000]; double v_samp[5000]; double b_samp[5000]; int num_samp; switch (event) { case EVENT_COMMIT: GetCtrlVal (panel, BSCANOP_START_POS, &start_pos); GetCtrlVal (panel, BSCANOP_DIST_MOVE, &dist_move); bscan_get_b(start_pos, dist_move, &num_samp, pos_samp, v_samp, b_samp); bscan_plt_b(num_samp, pos_samp, v_samp, b_samp); bscanui_clear_bsamp(); bscanui_plot_bsamp(num_samp, pos_samp, b_samp, VAL_RED); vscanui_clear_vsamp(); vscanui_plot_vsamp(num_samp, pos_samp, v_samp, VAL_BLUE); vscan_move_probe_abs(0.); break; case EVENT_RIGHT_CLICK: break; } return 0; }