# HG changeset patch # User Eleni Maria Stea # Date 1393881133 -7200 # Node ID 0f4fff558737b579b5508e47039b343671b917e9 # Parent add30e2d525314e2c1460d5e6f8c34932e11c45a transfer function diff -r add30e2d5253 -r 0f4fff558737 src/main.cc --- a/src/main.cc Mon Feb 03 02:52:46 2014 +0200 +++ b/src/main.cc Mon Mar 03 23:12:13 2014 +0200 @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -22,7 +23,9 @@ static bool init_xfer(void); static void display_xfer(void); static void reshape_xfer(int x, int y); +static void mouse_xfer(int button, int state, int x, int y); static void motion_xfer(int x, int y); +//todo keyb esc static int mainwin_id, xferwin_id; @@ -320,6 +323,7 @@ xferwin_id = glutCreateWindow("Transfer Function"); glutDisplayFunc(display_xfer); glutReshapeFunc(reshape_xfer); + glutMouseFunc(mouse_xfer); glutMotionFunc(motion_xfer); return true; @@ -342,7 +346,34 @@ high = thres; } - glBegin(GL_QUADS); + //drawing the transfer function curve + + glLineWidth(3); + glBegin(GL_LINE_STRIP); + glColor3f(0.8, 0.3, 0.8); + for(int i=0; i 0.001) { + mesh->clear(); + ui->sync_live(); + } + select_thres = 0; + } + } +} + static void motion_xfer(int x, int y) { - //to pontiki sto kontinotero akro - //glutPostRedisplay k sta 2 win + if(!select_thres) + return; + + int width = glutGet(GLUT_WINDOW_WIDTH); + float xpos = (float)x / (float)width; + + *select_thres = xpos; + + glutPostRedisplay(); + glutSetWindow(mainwin_id); + glutPostRedisplay(); }