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

Go to the documentation of this file.
00001 #include "VTransferFunctionElement.h"
00002 #include <iostream>
00003 #include "V2Ddraw.h"
00004 #include "VHistogram.h"
00005 #include <GL/glew.h>
00006 #include <GL/glut.h>
00007 
00008 using namespace std;
00009 
00010 VTransferFunctionElement::VTransferFunctionElement(int* width, int* height, unsigned int* fps,int* hist):
00011         GUIelement(width,height,fps)
00012 {
00013         this->x = 10;
00014         this->y = 10;
00015         this->width = (int)(0.6*(*this->wwidth));
00016         this->height = (int)(0.3*(*this->wheight));
00017         //this->alpha = 0.2;
00018         //background color blue
00019         this->bg = new float[3];
00020         this->bg[0] = (float)84/265;
00021         this->bg[1] = (float)160/256;
00022         this->bg[2] = (float)192/256;
00023         //foreground color black
00024         this->fg = new float[3];
00025         this->fg[0] = this->fg[1] = this->fg[2] = 0.0;
00026         //histogram color yellow
00027         this->histcol = new float[3];
00028         this->histcol[0] = this->histcol[1] = 1.0;
00029         this->histcol[2] = 0.0;
00030         //Transfer Function Elements
00031         this->background = new VTexture("transferfunc.tga");
00032         this->exit = new VExitBox(this->width+this->x-15,this->y+10,10,this->fg,this->histcol,&(this->alpha));
00033         this->hist = new VHistogram(hist,4096,this->x+10,this->y+10,this->width-30,this->height-50);
00034         this->function = new VTransferFunction(this->x+10,this->y+10,this->width-30,this->height-50,&(this->alpha));
00035         this->dragging = false;
00036 }
00037 
00038 VTransferFunctionElement::~VTransferFunctionElement(void)
00039 {
00040         delete exit;
00041         delete bg;
00042         delete fg;
00043         delete histcol;
00044         delete hist;
00045         delete background;
00046 }
00047 
00048 void VTransferFunctionElement::render() {
00049         if(!this->active && this->blend) { //einblenden
00050                 float frames = (float)*(this->fps);
00051                 this->alpha+=sin((1.5/frames));
00052                 this->draw();
00053                 if(this->alpha >= 1) {
00054                         this->alpha = 1;
00055                         this->setActive(true);
00056                 }
00057         }
00058         if(this->active && !this->blend) { //ausblenden
00059                 float frames = (float)*(this->fps);
00060                 this->alpha-=sin((1.6/frames));
00061                 this->draw();
00062                 if(this->alpha <= 0) {
00063                         this->alpha = 0;
00064                         this->setActive(false);
00065                 }
00066 
00067         }
00068         if(this->active && this->blend) { //aktiv
00069                 this->draw();
00070         }
00071 }
00072 
00073 void VTransferFunctionElement::draw() {
00074         //draw background box
00075         glColor4f(1.0,1.0,1.0,this->alpha);
00076         //glColor4f(this->bg[0],this->bg[1],this->bg[2],this->alpha);
00077         V2Ddraw::drawTexBox(this->background,this->x,this->y,this->width,this->height);
00078         //draw exit box
00079         this->exit->draw();
00080         //draw histogram
00081         glColor4f(this->histcol[0],this->histcol[1],this->histcol[2],this->alpha);
00082         this->hist->draw();
00083         //draw transferfunction
00084         glColor4f(this->fg[0],this->fg[1],this->fg[2],this->alpha);
00085         this->function->draw();
00086 }
00087 
00088 void VTransferFunctionElement::motion(int x, int y) {
00089         exit->inside(x,y);
00090 }
00091 
00092 void VTransferFunctionElement::pressed(int x, int y) {
00093         if(this->function->isInside(x,y))
00094                 this->function->pressed(x,y);
00095 }
00096 
00097 void VTransferFunctionElement::released(int x, int y) {
00098         if(this->dragging) this->dragging = false;
00099         else {
00100                 if(this->exit->isInside(x,y))
00101                         this->setBlend(false);
00102         }
00103         if(this->function->isInside(x,y))
00104                 this->function->released(x,y);
00105         this->function->getTexture();
00106 }
00107 
00108 void VTransferFunctionElement::drag(int x,int y) {
00109         this->dragging = true;
00110         if(this->function->isInside(x,y)) {
00111                 this->function->drag(x,y);
00112         }
00113 }
00114 
00115 bool VTransferFunctionElement::isInside(int xm, int ym) {
00116         return xm > this->x && xm < this->x + this->width && ym > this->y && ym < this->y + this->height;
00117 }
00118 
00119 GLuint * VTransferFunctionElement::getTexture() {
00120         return this->function->getTexture();
00121 }

Generated on Wed Dec 6 11:08:00 2006 for VisLU by  doxygen 1.5.1-p1