Files Classes Functions Hierarchy
00001 #include <string> 00002 #include <cstdlib> 00003 using namespace std; 00004 00005 #include <graphmisc.h> 00006 #include <menusystemtest03.h> 00007 #include <stringconvert.h> 00008 #include <zpr.h> 00009 00010 string menusystemtest03::doc[] = 00011 { 00012 "", 00013 "Configuration menu" 00014 }; 00015 00016 menusystem * menusystemtest03::root = 0; 00017 00018 class menusystemtest03Main : public menusystem 00019 { 00020 public: 00021 00022 menusystemtest03Main() 00023 : menusystem(point2<int>(60,50),20) 00024 { 00025 visibleGraphics.push( new gobjglColor4f(1.0,0.0,0.0,0.8) ); 00026 00027 addfont12("[c] Configure parameters",1); 00028 00029 addfont12("[q] Quit",0); 00030 } 00031 00032 protected: 00033 00034 void readImmediate(charc ch) 00035 { 00036 switch (ch) 00037 { 00038 case 'q': exit(0); break; 00039 case 'c': transfercontroltosubmenu(0); break; 00040 } 00041 } 00042 }; 00043 00044 class menusystemtest03Config : public menusystem 00045 { 00047 menusystemtest03part & mypart; 00048 00050 uint id_index; 00052 uint model_number_index; 00054 uint rotate_axis_index; 00055 00057 uint state; 00058 public: 00059 00061 void update() 00062 { 00063 vItems[id_index]->name = mypart.id; 00064 vItems[model_number_index]->name = 00065 stringconvert::tostring(mypart.model_number); 00066 vItems[rotate_axis_index]->name = 00067 stringconvert::tostring(mypart.rotate_axis); 00068 } 00069 00070 menusystemtest03Config(menusystemtest03part & mypart_) 00071 : menusystem(point2<int>(60,50),20), mypart(mypart_) 00072 { 00073 visibleGraphics.push( new gobjglColor4f(1.0,0.0,0.0,0.8) ); 00074 00075 addfont12("[i] Part ID",0); 00076 X.x += 100; 00077 addfont12(id_index,"*****",1); 00078 addfont12("[m] Model Number",0); 00079 X.x += 100; 00080 addfont12(model_number_index,"*****",1); 00081 addfont12("[r] Rotate Axis",0); 00082 X.x += 100; 00083 addfont12(rotate_axis_index,"*****",2); 00084 00085 addfont12("[ESC] Back to main menu",0); 00086 00087 update(); 00088 } 00089 00090 void readImmediate(charc ch) 00091 { 00092 switch (ch) 00093 { 00094 case 'i': 00095 readBufferedString(id_index); 00096 state=3; 00097 break; 00098 case 'm': 00099 readBufferedString(model_number_index); 00100 state=1; 00101 break; 00102 case 'r': 00103 readBufferedString(rotate_axis_index); 00104 state=2; 00105 break; 00106 case 27: transfercontroltoparent(); break; 00107 } 00108 } 00109 00111 void readBufferedTerminationAction() 00112 { 00113 if (state==1) 00114 { 00115 cout << SHOW(readBufferedResult) << endl; 00116 stringconvert::fromstring(mypart.model_number,readBufferedResult); 00117 state=0; 00118 update(); 00119 } 00120 if (state==2) 00121 { 00122 cout << SHOW(readBufferedResult) << endl; 00123 stringconvert::fromstring(mypart.rotate_axis,readBufferedResult); 00124 state=0; 00125 update(); 00126 } 00127 if (state==3) 00128 { 00129 cout << SHOW(readBufferedResult) << endl; 00130 mypart.id = readBufferedResult; 00131 state=0; 00132 update(); 00133 } 00134 } 00135 00136 }; 00137 00138 menusystemtest03::menusystemtest03(int argc, char** argv) 00139 { 00140 mypart = menusystemtest03part("xg769-t3",22,7.2); 00141 00142 glutInit(&argc,argv); 00143 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); 00144 glutInitWindowSize(800,600); 00145 glutCreateWindow(""); 00146 glutDisplayFunc(display); 00147 glutKeyboardFunc(keyboard); 00148 00149 OpenGLinitialisation(); 00150 00151 glEnable(GL_DEPTH_TEST); 00152 glEnable(GL_CULL_FACE); 00153 glEnable(GL_NORMALIZE); 00154 00155 xGraphics.set(); 00156 00157 root = new menusystemtest03Main(); 00158 //root->fontcolor = point4<float>(1.0,0.0,0.0,0.8); 00159 00160 menusystem * m = new menusystemtest03Config(mypart); 00161 root->addsubmenu(m); 00162 root->currentset(); 00163 00164 gobjpush(new gobjglDisable(GL_LIGHTING)); 00165 gobjpush(root); 00166 00167 zpr zz; 00168 zz.update(); 00169 00170 glutMainLoop(); 00171 } 00172 00173 void menusystemtest03::display() 00174 { 00175 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00176 00177 gobj::global->draw(); 00178 00179 glerrordisplay(); 00180 00181 glutSwapBuffers(); 00182 } 00183 00184 void menusystemtest03::keyboard 00185 ( 00186 unsigned char key, 00187 int x, 00188 int y 00189 ) 00190 { 00191 assert(root!=0); 00192 root->read(key); 00193 } 00194 00195 00196 00197
1.5.8