#include extern void setCamera(); extern void reset(); extern bool showGrid; extern float pixPerMeter; GLUI *ui = NULL; GLUI_Spinner *scaleSpinner; // // These two variables are needed for compatibility. // GLUI uses int's, while we use bool's. // int localShowGrid; enum {SHOW_GRID, SCALE, RESET, QUIT}; /////////////////////////////////////////////////////////// // // Tell the UI's variables that the corresponding // variables in the program have changed. // /////////////////////////////////////////////////////////// void syncVars() { if (ui != NULL) { scaleSpinner->set_float_val(pixPerMeter); } } /////////////////////////////////////////////////////////// // // This is called when the user interacts with a // widget on the user interface (UI). // The ID parameter identifies which widget was affected. // /////////////////////////////////////////////////////////// void handleGLUIEvent( int ID ) { switch (ID) { case SHOW_GRID: showGrid = (localShowGrid != 0); glutPostRedisplay(); break; case SCALE: setCamera(); glutPostRedisplay(); break; case RESET: reset(); setCamera(); syncVars(); glutPostRedisplay(); break; case QUIT: exit(0); } } /////////////////////////////////////////////////////////// // // Set up the graphical user interface (UI), // Which includes two checkboxes, two spinners, // and two buttons. // /////////////////////////////////////////////////////////// void setupUI (int mainWindowID) { localShowGrid = showGrid; ui = GLUI_Master.create_glui( "Window Controls", 0 ); ui->add_checkbox("Show Grid", &localShowGrid, SHOW_GRID, handleGLUIEvent); scaleSpinner = ui->add_spinner("Pixels/meter", GLUI_SPINNER_FLOAT, &pixPerMeter, SCALE, handleGLUIEvent ); ui->add_button("Reset", RESET, handleGLUIEvent); ui->add_button("Quit", QUIT, handleGLUIEvent); ui->set_main_gfx_window( mainWindowID ); GLUI_Master.set_glutIdleFunc( NULL ); glutMainLoop(); }