Eigene Dateien/uni/visualisierung/vislu/bsp1/VisLu/VRenderMode.cpp

Go to the documentation of this file.
00001 #include "VRenderMode.h"
00002 #include <iostream>
00003 #include "V2Ddraw.h"
00004 #include "corona.h"
00005 #include "VTexture.h"
00006 
00007 using namespace std;
00008 using namespace corona;
00009 
00010 VRenderMode::VRenderMode(int* width, int* height, unsigned int* fps, int* _actPos):
00011         GUIelement(width,height,fps)
00012 {
00013         float * col = new float[3];
00014         col[0] = col[1] = 1.0;
00015         col[2] = 0.0;
00016         this->width = (int)(0.15*(*this->wwidth));
00017         this->height = (int)(0.2*(*this->wheight));
00018         this->x = (int) *(this->wwidth)*0.78;
00019         this->y = (int) *(this->wheight)*0.02;
00020         this->bg = new float[4];
00021         this->bg[0] = 1.0f;
00022         this->bg[1] = 1.0f;
00023         this->bg[2] = 1.0f;
00024         this->bg[3] = 1.0f;
00025         pos = 1;
00026         this->actPos = _actPos;
00027         *actPos = 1;
00028         this->tex = new VTexture("transferfunc.tga");
00029         this->dragging = false;
00030 }
00031 
00032 VRenderMode::~VRenderMode(void)
00033 {
00034         //delete exit;
00035         delete bg;
00036         delete tex;
00037 }
00038 
00039 void VRenderMode::motion(int xm, int ym) {
00040         //exit->inside(xm,ym);
00041         if ((ym-this->y) < this->y+(this->height/4.0f)*0.9){
00042                 pos = 1;
00043         }
00044         else if((ym-this->y) < this->y+(this->height/4.0f)*2*0.9){
00045                 pos = 2;
00046         }
00047         else if((ym-this->y) < this->y+(this->height/4.0f)*3*0.9){
00048                 pos = 3;
00049         }
00050         else if((ym-this->y) < this->y+(this->height/4.0f)*4*0.9){
00051                 pos = 4;
00052         }
00053 }
00054 
00055 void VRenderMode::render() {
00056         if(!this->active && this->blend) { //einblenden
00057                 float frames = (float)*(this->fps);
00058                 this->alpha+=sin((1.3/frames));
00059                 this->bg[3] = this->alpha;
00060                 this->draw();
00061                 if(this->alpha >= 0.6) {
00062                         this->alpha = 1;
00063                         this->setActive(true);
00064                 }
00065         }
00066         if(this->active && !this->blend) { //ausblenden
00067                 float frames = (float)*(this->fps);
00068                 this->alpha-=sin((1.3/frames));
00069                 this->bg[3] = this->alpha;
00070                 this->draw();
00071                 if(this->alpha <= 0) {
00072                         this->alpha = 0;
00073                         this->setActive(false);
00074                 }
00075 
00076         }
00077         if(this->active && this->blend) { //aktiv
00078                 this->draw();
00079         }
00080 }
00081 
00082 void VRenderMode::draw() {
00083         glColor4fv(bg);
00084         glEnable(GL_BLEND);
00085         glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
00086         glEnable(GL_TEXTURE_2D);
00087         this->tex->bind();
00088         V2Ddraw::drawBox(this->x,this->y,this->width,this->height, 1);
00089         glDisable(GL_TEXTURE_2D);
00090         
00091         char Entry0[40],Entry1[40],Entry2[40],Entry3[40];
00092         sprintf(Entry0," Levoy");
00093         sprintf(Entry1," MIP");
00094         sprintf(Entry2," Average"); 
00095         sprintf(Entry3," First Hit");
00096         if (pos){
00097         //Draw Selected Item 
00098         glColor4f(1.0f,1.0f,1.0f,this->alpha*0.1f);    // White Color 
00099         V2Ddraw::drawBox(this->x+10, (this->y)+(this->height/4.0f)*this->pos*0.9-17.0f,this->width*0.8f,20.0f);
00100         }
00101 
00102         glColor4f(1.0f,1.0f,1.0f,this->alpha*0.3f);    // White Color 
00103         V2Ddraw::drawBox(this->x+10, (this->y)+(this->height/4.0f)* *(this->actPos)*0.9-17.0f,this->width*0.8f,20.0f);
00104 
00105         char *ch;
00106         glColor4f(1.0, 1.0, 1.0, this->alpha);
00107         glRasterPos3f(this->x+10, this->y+(this->height/4.0f)*0.9, 0.0);                                                        // Draws the title
00108         for(ch= Entry0; *ch; ch++) {                                                    // so that it is in the title bar, and so its white
00109                 glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, (int)*ch);
00110         }
00111         
00112         glRasterPos3f(this->x+10, this->y+(this->height/4.0f)*2*0.9, 0.0);      
00113         for(ch= Entry1; *ch; ch++) {
00114                 glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, (int)*ch);
00115         }
00116         
00117         glRasterPos3f(this->x+10, this->y+(this->height/4.0f)*3*0.9, 0.0);      
00118         for(ch= Entry2; *ch; ch++) {
00119                 glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, (int)*ch);
00120         }
00121 
00122         glRasterPos3f(this->x+10, this->y+(this->height/4.0f)*4*0.9, 0.0);      
00123         for(ch= Entry3; *ch; ch++) {
00124                 glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, (int)*ch);
00125         }
00126         //exit->draw();
00127 }
00128 
00129 void VRenderMode::released(int xm, int ym) {
00130         if(!this->dragging) { //click
00131                 /*if(exit->isInside(xm,ym))
00132                         this->setBlend(false);
00133                 else {*/
00134                         if ((ym-this->y) < this->y+(this->height/4.0f)*0.9){
00135                                 *(this->actPos) = 1;
00136                                 this->setBlend(false);
00137                         }
00138                         else if((ym-this->y) < this->y+(this->height/4.0f)*2*0.9){
00139                                 *(this->actPos) = 2;
00140                                 this->setBlend(false);
00141                         }
00142                         else if((ym-this->y) < this->y+(this->height/4.0f)*3*0.9){
00143                                 *(this->actPos) = 3;
00144                                 this->setBlend(false);
00145                         }
00146                         else if((ym-this->y) < this->y+(this->height/4.0f)*4*0.9){
00147                                 *(this->actPos) = 4;
00148                                 this->setBlend(false);
00149                         }
00150                 //}
00151         }
00152         this->dragging = false;
00153 }
00154 
00155 void VRenderMode::drag(int x, int y) {
00156         this->dragging = true;
00157 }
00158 
00159 bool VRenderMode::isInside(int xm, int ym) {
00160         return xm > this->x && xm < this->x+this->width && ym > this->y && ym < this->y+this->width;
00161 }

Generated on Wed Dec 6 11:07:59 2006 for VisLU by  doxygen 1.5.1-p1