1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
| /****** Headers ******/
#include <list>
#include <cstring>
#include <cstdlib>
#include "geom_menu.h"
using namespace std;
/****** Menu Principal ******/
/*** Constantes ***/
const char *obj_name[6] = {"Point", "Line", "Circle", "Triangle", "Quadrilateral", "Polygon"};
/*** Variables Globales ***/
/* Elements Menu */
GLUI* glui_main; /* Menu principal */
GLUI* glui_edit[6]; /* Menus édition */
GLUI_Listbox* listbox_obj; /* Choix figure */
/* Live Variables */
int menu_view_axis = 1;
int menu_view_square = 1;
int menu_view_coord = 0;
int menu_mode = RADIOBUTTON_MODE_DRAW; /* Mode : Edit ou Draw */
int menu_obj = POINT; /* Figure courante */
int menu_obj_old = POINT; /* Précédente figure courante */
void MainInitMenu(void)
{
glui_main = GLUI_Master.create_glui_subwindow(win_main, GLUI_SUBWINDOW_RIGHT);
glui_main -> set_main_gfx_window(win_main);
GLUI_Panel *panel_view = glui_main -> add_panel("View");
glui_main -> add_checkbox_to_panel(panel_view, "Square", &menu_view_square);
glui_main -> add_checkbox_to_panel(panel_view, "Axis", &menu_view_axis);
glui_main -> add_checkbox_to_panel(panel_view, "Coordinate", &menu_view_coord);
glui_main -> add_button_to_panel(panel_view, "Origin", BUTTON_MOVEORIGIN, MainProcessMenu);
glui_main -> add_button_to_panel(panel_view, "Reset Zoom", BUTTON_RESETZOOM, MainProcessMenu);
GLUI_Panel *panel_mode = glui_main -> add_panel("Mode");
GLUI_RadioGroup *radiogroup_mode = glui_main -> add_radiogroup_to_panel(panel_mode, &menu_mode, RADIOBUTTON_MODE, MainProcessMenu);
glui_main -> add_radiobutton_to_group(radiogroup_mode, "Edit");
glui_main -> add_radiobutton_to_group(radiogroup_mode, "Draw");
listbox_obj = glui_main -> add_listbox_to_panel(panel_mode, "", &menu_obj, LISTBOX_OBJ, MainProcessMenu);
for(int k=0; k<6; k++)
{
listbox_obj -> add_item(k, obj_name[k]);
}
GLUI_Panel *panel_file = glui_main -> add_panel("File");
glui_main -> add_button_to_panel(panel_file, "Clear", BUTTON_CLEAR, MainProcessMenu);
glui_main -> add_button_to_panel(panel_file, "Quit", BUTTON_QUIT, MainProcessMenu);
}
void MainProcessMenu(int n)
{
switch(n)
{
case BUTTON_MOVEORIGIN :
X = -lX/2., Y = lY/2.;
break;
case BUTTON_RESETZOOM :
X = X + lX/2.; Y = Y - lY/2.;
if (Xview <= Yview)
{
lX = 2; lY = 2 * (float)Yview / (float)Xview;
}
else
{
lY = 2; lX = 2 * (float)Xview / (float)Yview;
}
X = X - lX/2.; Y = Y + lY/2.;
break;
case RADIOBUTTON_MODE :
if (menu_mode == RADIOBUTTON_MODE_EDIT)
{
listbox_obj -> disable();
glui_edit[menu_obj_old] -> hide();
}
else
{
listbox_obj -> enable();
glui_edit[menu_obj] -> show();
}
break;
case LISTBOX_OBJ :
glui_edit[menu_obj_old] -> hide();
glui_edit[menu_obj] -> show();
menu_obj_old = menu_obj;
break;
case BUTTON_CLEAR :
break;
case BUTTON_QUIT :
exit(0);
break;
}
glutPostRedisplay();
}
void PointInitMenu(void)
{
glui_edit[POINT] = GLUI_Master.create_glui(obj_name[POINT],0,650,50);
glui_edit[POINT] -> set_main_gfx_window(win_main);
GLUI_Panel *panel_type = glui_edit[POINT] -> add_panel("Type");
GLUI_Listbox *listbox_type = glui_edit[POINT] -> add_listbox_to_panel(panel_type, "", NULL, POINT_TYPE, PointProcessMenu);
listbox_type -> add_item(POINT_TYPE_POINT, "Point");
listbox_type -> add_item(POINT_TYPE_MIDDLE, "Middle");
listbox_type -> add_item(POINT_TYPE_INTERSECTION, "Intersection");
GLUI_Panel *panel_param = glui_edit[POINT] -> add_panel("Param 1");
GLUI_Panel *panel_properties = glui_edit[POINT] -> add_panel("Properties");
glui_edit[POINT] -> add_checkbox_to_panel(panel_properties, "Locked", NULL, POINT_PROPERTIES_LOCKED, PointProcessMenu);
glui_edit[POINT] -> add_button_to_panel(panel_properties, "Delete", POINT_PROPERTIES_DELETE, PointProcessMenu);
}
void PointProcessMenu(int n)
{
switch (n)
{
case POINT_TYPE :
break;
case POINT_PROPERTIES_LOCKED :
break;
case POINT_PROPERTIES_LABEL :
break;
case POINT_PROPERTIES_DELETE :
break;
}
}
void LineInitMenu(void)
{
glui_edit[LINE] = GLUI_Master.create_glui(obj_name[LINE],0,650,50);
glui_edit[LINE] -> set_main_gfx_window(win_main);
glui_edit[LINE] -> hide();
}
void LineProcessMenu(int n)
{
}
void CircleInitMenu(void)
{
glui_edit[CIRCLE] = GLUI_Master.create_glui(obj_name[CIRCLE],0,650,50);
glui_edit[CIRCLE] -> set_main_gfx_window(win_main);
glui_edit[CIRCLE] -> hide();
}
void CircleProcessMenu(int n)
{
}
void TriInitMenu(void)
{
glui_edit[TRI] = GLUI_Master.create_glui(obj_name[TRI],0,650,50);
glui_edit[TRI] -> set_main_gfx_window(win_main);
glui_edit[TRI] -> hide();
}
void TriProcessMenu(int n)
{
}
void QuadInitMenu(void)
{
glui_edit[QUAD] = GLUI_Master.create_glui(obj_name[QUAD],0,650,50);
glui_edit[QUAD] -> set_main_gfx_window(win_main);
glui_edit[QUAD] -> hide();
}
void QuadProcessMenu(int n)
{
}
void PolygonInitMenu(void)
{
glui_edit[POLYGON] = GLUI_Master.create_glui(obj_name[POLYGON],0,650,50);
glui_edit[POLYGON] -> set_main_gfx_window(win_main);
glui_edit[POLYGON] -> hide();
}
void PolygonProcessMenu(int n)
{
} |
Partager