00001 #include "VMenu.h"
00002
00003 VMenu::VMenu(void){
00004 shMenu = true;
00005 hMenu = false;
00006 lFile = false;
00007 mPos = 0;
00008 actPos = 0;
00009 }
00010
00011 void VMenu::draw(void){
00012
00013 GLenum err = glGetError();
00014 if (err != GL_NO_ERROR)
00015 cout << "GL Error: " << gluErrorString(err) << endl;
00016
00017 GLint matrixMode;
00018 GLboolean lightingOn;
00019 GLboolean depthOn;
00020 char *ch;
00021 shMenu = true;
00022
00023 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00024
00025
00026 depthOn = glIsEnabled(GL_DEPTH_TEST);
00027 if (depthOn) glDisable(GL_DEPTH_TEST);
00028 glEnable (GL_BLEND);
00029 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00030
00031 lightingOn= glIsEnabled(GL_LIGHTING);
00032 if (lightingOn) glDisable(GL_LIGHTING);
00033
00034 glGetIntegerv(GL_MATRIX_MODE, &matrixMode);
00035
00036 glMatrixMode(GL_PROJECTION);
00037 glPushMatrix();
00038 glLoadIdentity();
00039 gluOrtho2D(0.0, 1.0, 0.0, 1.0);
00040 glMatrixMode(GL_MODELVIEW);
00041 glPushMatrix();
00042 glLoadIdentity();
00043 glPushAttrib(GL_COLOR_BUFFER_BIT);
00044
00045
00046 glColor4f(0.0f,0.0f,0.0f,0.25f);
00047 DrawBox(0.0f,0.0f,-1.0f,1.0f,1.0f);
00048
00049 if (hMenu){
00050 mPos = 7;
00051
00052 glColor4f(0.0f,0.3f,0.6f,0.9f);
00053 DrawBox(0.25f,0.05f,-1.0f,0.25f,1.0f);
00054 }
00055 else{
00056
00057 glColor4f(0.0f,0.3f,0.6f,0.9f);
00058 DrawBox(0.25f,0.28f,-1.0f,0.25f,1.0f);
00059 }
00060
00061
00062 glColor4f(0.79f,0.8f,1.0f,0.5f);
00063 DrawBox(0.25f,0.59f,-1.0f,0.30f,0.04f);
00064
00065
00066
00067 glColor4f(1.0f,1.0f,1.0f,0.2f);
00068 DrawBox(0.25f,(0.445f-(actPos*0.05)),0.0f,0.25f,0.03f);
00069
00070
00071
00072
00073 char Entry0[40],Entry1[40],Entry2[40],Entry3[40],Entry4[40],Entry5[40],Entry6[40],Entry7[40];
00074
00075
00076 if (hMenu){
00077 sprintf(Entry0," Help Menu");
00078 sprintf(Entry1," 1..3D View");
00079 sprintf(Entry2," 2..Side View");
00080 sprintf(Entry3," 3..Front View");
00081 sprintf(Entry4," 4..Top View");
00082 sprintf(Entry5," +..Next Slice");
00083 sprintf(Entry6," -..Previous Slice");
00084 sprintf(Entry7," Return");
00085 }
00086 else if (lFile){
00087 sprintf(Entry0," Choose Dataset");
00088 sprintf(Entry1," Lobster");
00089 sprintf(Entry2," Head");
00090 sprintf(Entry3," Beetle");
00091 }
00092 else {
00093 sprintf(Entry0," VisLU");
00094 sprintf(Entry1," Load File");
00095 sprintf(Entry2," Help");
00096 sprintf(Entry3," Exit");
00097 }
00098
00099
00100 glColor3f(1.0, 1.0, 1.0);
00101 glRasterPos3f(0.252, 0.60, 0.0);
00102 for(ch= Entry0; *ch; ch++) {
00103 glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, (int)*ch);
00104 }
00105
00106 glRasterPos3f(0.26, 0.45, 1.0);
00107 for(ch= Entry1; *ch; ch++) {
00108 glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, (int)*ch);
00109 }
00110
00111 glRasterPos3f(0.26, 0.40, 1.0);
00112 for(ch= Entry2; *ch; ch++) {
00113 glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, (int)*ch);
00114 }
00115 if (!hMenu){
00116 glRasterPos3f(0.26, 0.35, 1.0);
00117 for(ch= Entry3; *ch; ch++) {
00118 glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, (int)*ch);
00119
00120 }
00121 }
00122
00123 if (hMenu){
00124 glRasterPos3f(0.26, 0.30, 1.0);
00125 for(ch= Entry4; *ch; ch++) {
00126 glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, (int)*ch);
00127 }
00128 glRasterPos3f(0.26, 0.25, 1.0);
00129 for(ch= Entry5; *ch; ch++) {
00130 glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, (int)*ch);
00131 }
00132 glRasterPos3f(0.26, 0.20, 1.0);
00133 for(ch= Entry6; *ch; ch++) {
00134 glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, (int)*ch);
00135 }
00136 glRasterPos3f(0.26, 0.10, 1.0);
00137 for(ch= Entry7; *ch; ch++) {
00138 glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, (int)*ch);
00139 }
00140 }
00141
00142 glRasterPos3f(0.8, 0.05, 1.0);
00143 for(ch= "a visualization by Klepp/Moreau"; *ch; ch++) {
00144 glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, (int)*ch);
00145 }
00146 glPopAttrib();
00147 glPopMatrix();
00148 glMatrixMode(GL_PROJECTION);
00149 glPopMatrix();
00150 glMatrixMode(matrixMode);
00151 if (lightingOn) glEnable(GL_LIGHTING);
00152 if (depthOn) glEnable(GL_DEPTH_TEST);
00153 glDisable (GL_BLEND);
00154 }
00155
00156 void VMenu::DrawBox(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height)
00157 {
00158 glBegin(GL_QUADS);
00159 glVertex3f(x,y,z);
00160 glVertex3f(x+width,y,z);
00161 glVertex3f(x+width,y+height,z);
00162 glVertex3f(x,y+height,z);
00163 glEnd();
00164 }
00165
00166 void VMenu::setMouse(float _x, float _y){
00167 this->mouseX = _x;
00168 this->mouseY = _y;
00169
00170 if (this->lFile){
00171 if ( mouseY > 0.20){
00172 if(mouseY < 1-0.45)
00173 actPos = 0;
00174 else if(mouseY < 1-0.40)
00175 actPos = 1;
00176 else if(mouseY < 1-0.35)
00177 actPos = 2;
00178 }
00179 }
00180 else if (this->hMenu){
00181 actPos = 7;
00182 }
00183 else if (this->shMenu){
00184 if ( mouseY > 0.20){
00185 if(mouseY < 1-0.45)
00186 actPos = 0;
00187 else if(mouseY < 1-0.40)
00188 actPos = 1;
00189 else if(mouseY < 1-0.35)
00190 actPos = 2;
00191 }
00192 }
00193
00194 }
00195
00196 void VMenu::click(void){
00197 this->mPos = this->actPos;
00198 this->actPos = 0;
00199 }
00200
00201 void VMenu::showMenu(bool _shMenu){
00202 shMenu = _shMenu;
00203 }
00204
00205 void VMenu::helpMenu(bool _helpMenu){
00206 hMenu = _helpMenu;
00207 }
00208
00209 void VMenu::loadFile(bool _loadFile){
00210 lFile = _loadFile;
00211 }
00212
00213 bool VMenu::showMenu(void){
00214 return shMenu;
00215 }
00216
00217 bool VMenu::helpMenu(void){
00218 return hMenu;
00219 }
00220
00221 bool VMenu::loadFile(void){
00222 return lFile;
00223 }
00224
00225 int VMenu::menuPos (void){
00226 return mPos;
00227 }
00228
00229 void VMenu::menuPos(int _pos){
00230 mPos = _pos;
00231 }
00232
00233 void VMenu::incmenuPos(void){
00234 mPos++;
00235 }
00236
00237 void VMenu::decmenuPos(void){
00238 mPos--;
00239 }