From 1657f19c05c1e5d59e1bc2d415ded0bd93e3ae22 Mon Sep 17 00:00:00 2001 From: pgovyadi Date: Thu, 22 Sep 2016 15:33:11 -0500 Subject: [PATCH] fixed selective visualization that only shows the fibers near the last line cliked. Should make segmentation much easier, changes to the glObj class --- stim/visualization/glObj.h | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 11 deletions(-) diff --git a/stim/visualization/glObj.h b/stim/visualization/glObj.h index 1eeab52..40e7175 100644 --- a/stim/visualization/glObj.h +++ b/stim/visualization/glObj.h @@ -43,11 +43,8 @@ private: } void - Create(GLenum mode, bool blend = false, float opacity = 1.0, stim::vec3 point = stim::vec(-10000.0, -10000.0, -10000.0)) + Create(GLenum mode, bool blend = false, float opacity = 1.0) { -// GLuint selectBuf[2048]; -// GLint hits; -// glSelectBuffer(2048, selectBuf); if(blend) { @@ -57,7 +54,6 @@ private: int len = (int) stim::obj::numL(); std::vector< stim::vec > line; glNewList(dList, GL_COMPILE); - // glColor3f(0.0, 1.0, 0.0); glLineWidth(3.5); for(int i = 0; i < len; i++){ line = stim::obj::getL_V(i); @@ -66,14 +62,13 @@ private: glLoadName(i); } if(blend == false) + { glColor3f(0.0, 1.0, 0.05); - - else if(blend && point[0] < -9999.9) + } + else { glColor4f(50.0/256.0,205.0/256.0, 50.0/256.0, opacity); ///Dark Green. - } else { -// ??????? - } + } //glColor3ub(rand()%255, rand()%255, rand()%255); glBegin(GL_LINE_STRIP); for(int j = 0; j < line.size(); j++){ @@ -91,6 +86,51 @@ private: CHECK_OPENGL_ERROR } + ///Method for drawing selectively opaque things. + void + Create(GLenum mode, stim::vec3 point) + { + float l, opacity; + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + int len = (int) stim::obj::numL(); + std::vector< stim::vec > line; + glNewList(dList, GL_COMPILE); + glLineWidth(3.5); + for(int i = 0; i < len; i++){ + line = stim::obj::getL_V(i); + if(mode == GL_SELECT) + { + glLoadName(i); + } + + glBegin(GL_LINE_STRIP); + for(int j = 0; j < line.size(); j++){ + + l = sqrt(pow((point[0] - line[j][0]),2) + pow((point[1] - line[j][1]),2) + pow((point[2] - line[j][2]),2)); + if(l < 10) + { + opacity = 1.0; + } else if( l > 40) { + opacity = 0.0; + } else { + opacity = l*(-1.0/30.0) + 4.0/3.0; + } + + glColor4f(50.0/256.0,205.0/256.0, 50.0/256.0, opacity); ///Dark Green. + glVertex3f( + line[j][0], + line[j][1], + line[j][2] + ); + } + glEnd(); + } + glDisable(GL_BLEND); + glEndList(); + CHECK_OPENGL_ERROR + } + public: glObj() { @@ -111,7 +151,7 @@ public: { // glPopMatrix(); init(); - Create(mode, true, 1.0, point); + Create(mode, point); // glPushMatrix(); } -- libgit2 0.21.4