Commit 1657f19c05c1e5d59e1bc2d415ded0bd93e3ae22
1 parent
518258d3
fixed selective visualization that only shows the fibers near the last line clik…
…ed. Should make segmentation much easier, changes to the glObj class
Showing
1 changed file
with
51 additions
and
11 deletions
Show diff stats
stim/visualization/glObj.h
@@ -43,11 +43,8 @@ private: | @@ -43,11 +43,8 @@ private: | ||
43 | } | 43 | } |
44 | 44 | ||
45 | void | 45 | void |
46 | - Create(GLenum mode, bool blend = false, float opacity = 1.0, stim::vec3<float> point = stim::vec<float>(-10000.0, -10000.0, -10000.0)) | 46 | + Create(GLenum mode, bool blend = false, float opacity = 1.0) |
47 | { | 47 | { |
48 | -// GLuint selectBuf[2048]; | ||
49 | -// GLint hits; | ||
50 | -// glSelectBuffer(2048, selectBuf); | ||
51 | 48 | ||
52 | if(blend) | 49 | if(blend) |
53 | { | 50 | { |
@@ -57,7 +54,6 @@ private: | @@ -57,7 +54,6 @@ private: | ||
57 | int len = (int) stim::obj<T>::numL(); | 54 | int len = (int) stim::obj<T>::numL(); |
58 | std::vector< stim::vec<float> > line; | 55 | std::vector< stim::vec<float> > line; |
59 | glNewList(dList, GL_COMPILE); | 56 | glNewList(dList, GL_COMPILE); |
60 | - // glColor3f(0.0, 1.0, 0.0); | ||
61 | glLineWidth(3.5); | 57 | glLineWidth(3.5); |
62 | for(int i = 0; i < len; i++){ | 58 | for(int i = 0; i < len; i++){ |
63 | line = stim::obj<T>::getL_V(i); | 59 | line = stim::obj<T>::getL_V(i); |
@@ -66,14 +62,13 @@ private: | @@ -66,14 +62,13 @@ private: | ||
66 | glLoadName(i); | 62 | glLoadName(i); |
67 | } | 63 | } |
68 | if(blend == false) | 64 | if(blend == false) |
65 | + { | ||
69 | glColor3f(0.0, 1.0, 0.05); | 66 | glColor3f(0.0, 1.0, 0.05); |
70 | - | ||
71 | - else if(blend && point[0] < -9999.9) | 67 | + } |
68 | + else | ||
72 | { | 69 | { |
73 | glColor4f(50.0/256.0,205.0/256.0, 50.0/256.0, opacity); ///Dark Green. | 70 | glColor4f(50.0/256.0,205.0/256.0, 50.0/256.0, opacity); ///Dark Green. |
74 | - } else { | ||
75 | -// ??????? | ||
76 | - } | 71 | + } |
77 | //glColor3ub(rand()%255, rand()%255, rand()%255); | 72 | //glColor3ub(rand()%255, rand()%255, rand()%255); |
78 | glBegin(GL_LINE_STRIP); | 73 | glBegin(GL_LINE_STRIP); |
79 | for(int j = 0; j < line.size(); j++){ | 74 | for(int j = 0; j < line.size(); j++){ |
@@ -91,6 +86,51 @@ private: | @@ -91,6 +86,51 @@ private: | ||
91 | CHECK_OPENGL_ERROR | 86 | CHECK_OPENGL_ERROR |
92 | } | 87 | } |
93 | 88 | ||
89 | + ///Method for drawing selectively opaque things. | ||
90 | + void | ||
91 | + Create(GLenum mode, stim::vec3<float> point) | ||
92 | + { | ||
93 | + float l, opacity; | ||
94 | + glEnable(GL_BLEND); | ||
95 | + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | ||
96 | + int len = (int) stim::obj<T>::numL(); | ||
97 | + std::vector< stim::vec<float> > line; | ||
98 | + glNewList(dList, GL_COMPILE); | ||
99 | + glLineWidth(3.5); | ||
100 | + for(int i = 0; i < len; i++){ | ||
101 | + line = stim::obj<T>::getL_V(i); | ||
102 | + if(mode == GL_SELECT) | ||
103 | + { | ||
104 | + glLoadName(i); | ||
105 | + } | ||
106 | + | ||
107 | + glBegin(GL_LINE_STRIP); | ||
108 | + for(int j = 0; j < line.size(); j++){ | ||
109 | + | ||
110 | + l = sqrt(pow((point[0] - line[j][0]),2) + pow((point[1] - line[j][1]),2) + pow((point[2] - line[j][2]),2)); | ||
111 | + if(l < 10) | ||
112 | + { | ||
113 | + opacity = 1.0; | ||
114 | + } else if( l > 40) { | ||
115 | + opacity = 0.0; | ||
116 | + } else { | ||
117 | + opacity = l*(-1.0/30.0) + 4.0/3.0; | ||
118 | + } | ||
119 | + | ||
120 | + glColor4f(50.0/256.0,205.0/256.0, 50.0/256.0, opacity); ///Dark Green. | ||
121 | + glVertex3f( | ||
122 | + line[j][0], | ||
123 | + line[j][1], | ||
124 | + line[j][2] | ||
125 | + ); | ||
126 | + } | ||
127 | + glEnd(); | ||
128 | + } | ||
129 | + glDisable(GL_BLEND); | ||
130 | + glEndList(); | ||
131 | + CHECK_OPENGL_ERROR | ||
132 | + } | ||
133 | + | ||
94 | public: | 134 | public: |
95 | glObj() | 135 | glObj() |
96 | { | 136 | { |
@@ -111,7 +151,7 @@ public: | @@ -111,7 +151,7 @@ public: | ||
111 | { | 151 | { |
112 | // glPopMatrix(); | 152 | // glPopMatrix(); |
113 | init(); | 153 | init(); |
114 | - Create(mode, true, 1.0, point); | 154 | + Create(mode, point); |
115 | // glPushMatrix(); | 155 | // glPushMatrix(); |
116 | } | 156 | } |
117 | 157 |