📄 gtkseisviewgl.c
字号:
tex_coord_bottom = j != (private->tex_fast_num - 1) ? 1.0 - tex_coord_offset : 1.0; glBindTexture (GL_TEXTURE_2D, private->tex_id[i * private->tex_fast_num + j]); glBegin (GL_QUADS); glTexCoord2d (tex_coord_top, tex_coord_left); glVertex2d (tex_vertex_left, tex_vertex_top); glTexCoord2d (tex_coord_top, tex_coord_right); glVertex2d (tex_vertex_right, tex_vertex_top); glTexCoord2d (tex_coord_bottom, tex_coord_right); glVertex2d (tex_vertex_right, tex_vertex_bottom); glTexCoord2d (tex_coord_bottom, tex_coord_left); glVertex2d (tex_vertex_left, tex_vertex_bottom); glEnd (); } } glBindTexture (GL_TEXTURE_2D, 0); glDisable (GL_TEXTURE_2D); if (GTK_SEIS_VIEW_TEX_PALETTED == private->tex_color_mode) glDisable (GL_SHARED_TEXTURE_PALETTE_EXT); else if (GTK_SEIS_VIEW_TEX_FRAG_COLOR == private->tex_color_mode) { private->shaders->glUseProgramObjectARB (0); private->gl13->glActiveTexture (GL_TEXTURE1); glBindTexture (GL_TEXTURE_1D, 0); glDisable (GL_TEXTURE_1D); private->gl13->glActiveTexture (GL_TEXTURE0); } } else { /* Simply put a one-color rectangle underneath the traces if the variable density mode is disabled */ glBegin (GL_QUADS); glVertex2f (private->data_vis.slow_start_object, private->data_vis.fast_start_object); glVertex2f (private->data_vis.slow_start_object + private->data_vis.slow_size_object, private->data_vis.fast_start_object); glVertex2f (private->data_vis.slow_start_object + private->data_vis.slow_size_object, private->data_vis.fast_start_object + private->data_vis.fast_size_object); glVertex2f (private->data_vis.slow_start_object, private->data_vis.fast_start_object + private->data_vis.fast_size_object); glEnd (); } /* Distance between traces in the object space */ gfloat trace_dist = slow_data_to_object_scale / (gfloat)(private->slow_num); /* Start locations of the first trace */ gfloat trace_slow_start = tex_slow_start + trace_dist / 2.0; gfloat trace_fast_start = tex_fast_start; GLuint va_list_base = private->va_fill_mode == GTK_SEIS_VIEW_VA_POSITIVE ? private->va_list_pos_base : private->va_list_neg_base; GLuint *traces_va_vbo = private->va_fill_mode == GTK_SEIS_VIEW_VA_POSITIVE ? private->traces_va_pos_vbo : private->traces_va_neg_vbo; GLsizei *va_index_num = private->va_fill_mode == GTK_SEIS_VIEW_VA_POSITIVE ? private->va_pos_num : private->va_neg_num; GLdouble win_x, win_y, win_z; GLdouble obj_x1, obj_x2, obj_y, obj_z; GLdouble min_trace_dist; guint trace_step_index = 1, trace_start_index = 0, trace_end_index = 0; win_z = 0; /* We are going to calculate a distance in the object space corresponding to a distance of 3 pixels in the screen space. We need it to calculate the minimum allowable distance between traces in the object space */ win_x = private->data_vis.slow_start_screen; win_y = GTK_WIDGET (self)->allocation.height - private->data_vis.fast_start_screen; gluUnProject (win_x, win_y, win_z, private->data_vis.model_view, private->data_vis.projection, private->data_vis.viewport, &obj_x1, &obj_y, &obj_z); win_x += 3; gluUnProject (win_x, win_y, win_z, private->data_vis.model_view, private->data_vis.projection, private->data_vis.viewport, &obj_x2, &obj_y, &obj_z); min_trace_dist = obj_x2 - obj_x1; /* Trace increment according to the minimum allowable distance */ trace_step_index = min_trace_dist / trace_dist + 0.5; while (trace_dist * trace_step_index < min_trace_dist) trace_step_index += 1; /* Indices of the first and the last traces we are going to render */ trace_start_index = (private->data_vis.slow_start_object - trace_slow_start - trace_dist * private->trace_scale) / trace_dist; trace_end_index = (private->data_vis.slow_start_object + private->data_vis.slow_size_object - trace_slow_start + trace_dist * private->trace_scale) / trace_dist; if (trace_start_index > private->slow_num) trace_start_index = 0; if (trace_end_index >= private->slow_num) trace_end_index = private->slow_num - 1; if (trace_step_index == private->last_trace_step_index) { while (((abs ((gint)trace_start_index - (gint)private->last_trace_start_index)) % trace_step_index) && trace_start_index != 0) trace_start_index -= 1; } else private->last_trace_step_index = trace_step_index; private->last_trace_start_index = trace_start_index; guint trace_hlight_start_index = private->slow_num, trace_hlight_end_index = private->slow_num; if (private->hlight_start_data >= 0 && private->hlight_size_data >= 0) { trace_hlight_start_index = private->hlight_start_data * slow_data_to_object_scale / trace_dist; trace_hlight_end_index = trace_hlight_start_index + private->hlight_size_data * slow_data_to_object_scale / trace_dist; trace_hlight_start_index = (gint)(trace_hlight_start_index / trace_step_index + 1.0) * trace_step_index - 0.5; trace_hlight_end_index = (gint)(trace_hlight_end_index / trace_step_index + 1.0) * trace_step_index - 0.5; if (trace_hlight_end_index < trace_start_index || trace_hlight_start_index > trace_end_index) { trace_hlight_start_index = private->slow_num; trace_hlight_end_index = private->slow_num; } else if (trace_hlight_start_index < trace_start_index) trace_hlight_start_index = trace_start_index; else if (trace_hlight_end_index > trace_end_index) trace_hlight_end_index = trace_end_index; if (trace_hlight_end_index < trace_hlight_start_index) trace_hlight_end_index = trace_hlight_start_index; }/*#ifdef DEBUG g_printf ("Rendering traces from number %u to number %u with step %u\n", trace_start_index, trace_end_index, trace_step_index);#endif*/ gfloat trace_scale = private->trace_scale; if (private->inverse_polarity) { trace_scale = -trace_scale; glFrontFace (GL_CCW); } glColor3f (private->trace_color.red / (gfloat)G_MAXUINT16, private->trace_color.green / (gfloat)G_MAXUINT16, private->trace_color.blue / (gfloat)G_MAXUINT16); if (private->vbo && private->has_wiggles) { /* VBOs */ glEnableClientState (GL_VERTEX_ARRAY); glEnableClientState (GL_INDEX_ARRAY); if ((private->display_mode & (GTK_SEIS_VIEW_VA | GTK_SEIS_VIEW_WIGGLE)) == (GTK_SEIS_VIEW_VA | GTK_SEIS_VIEW_WIGGLE) || (trace_hlight_start_index < private->slow_num && GTK_SEIS_VIEW_VD == private->display_mode)) { /* Wiggle + variable area */ if (private->display_mode != GTK_SEIS_VIEW_VD) { for (i = trace_start_index; i <= trace_end_index; i += trace_step_index) { if (i >= trace_hlight_start_index && i <= trace_hlight_end_index) continue; glPushMatrix (); glTranslatef (trace_slow_start + trace_dist * i, trace_fast_start, 0); glScalef (slow_data_to_object_scale * trace_scale * trace_step_index, fast_data_to_object_scale, 0); private->vbo->glBindBufferARB (GL_ARRAY_BUFFER_ARB, private->traces_wiggle_vbo[i]); glVertexPointer (2, GL_FLOAT, 0, NULL); glDrawArrays (GL_LINE_STRIP, 0, private->wiggle_num[i]); private->vbo->glBindBufferARB (GL_ELEMENT_ARRAY_BUFFER_ARB, traces_va_vbo[i]); glIndexPointer (GL_INT, 0, NULL); glDrawElements (GL_TRIANGLE_STRIP, va_index_num[i], GL_UNSIGNED_INT, NULL); glPopMatrix (); } } /* Highlight */ if (trace_hlight_start_index < private->slow_num && trace_hlight_start_index < private->slow_num) { glColor3f (private->highlight_color.red / (gfloat)G_MAXUINT16, private->highlight_color.green / (gfloat)G_MAXUINT16, private->highlight_color.blue / (gfloat)G_MAXUINT16); for (i = trace_hlight_start_index; i <= trace_hlight_end_index; i += trace_step_index) { glPushMatrix (); glTranslatef (trace_slow_start + trace_dist * i, trace_fast_start, 0); glScalef (slow_data_to_object_scale * trace_scale * trace_step_index, fast_data_to_object_scale, 0); private->vbo->glBindBufferARB (GL_ARRAY_BUFFER_ARB, private->traces_wiggle_vbo[i]); glVertexPointer (2, GL_FLOAT, 0, NULL); glDrawArrays (GL_LINE_STRIP, 0, private->wiggle_num[i]); private->vbo->glBindBufferARB (GL_ELEMENT_ARRAY_BUFFER_ARB, traces_va_vbo[i]); glIndexPointer (GL_INT, 0, NULL); glDrawElements (GL_TRIANGLE_STRIP, va_index_num[i], GL_UNSIGNED_INT, NULL); glPopMatrix (); } } } else if (private->display_mode & GTK_SEIS_VIEW_VA) { /* Only variable area */ for (i = trace_start_index; i <= trace_end_index; i += trace_step_index) { if (i >= trace_hlight_start_index && i <= trace_hlight_end_index) continue; glPushMatrix (); glTranslatef (trace_slow_start + trace_dist * i, trace_fast_start, 0); glScalef (slow_data_to_object_scale * trace_scale * trace_step_index, fast_data_to_object_scale, 0); private->vbo->glBindBufferARB (GL_ARRAY_BUFFER_ARB, private->traces_wiggle_vbo[i]); glVertexPointer (2, GL_FLOAT, 0, NULL); private->vbo->glBindBufferARB (GL_ELEMENT_ARRAY_BUFFER_ARB, traces_va_vbo[i]); glIndexPointer (GL_INT, 0, NULL); glDrawElements (GL_TRIANGLE_STRIP, va_index_num[i], GL_UNSIGNED_INT, NULL); glPopMatrix (); } /* Highlight */ if (trace_hlight_start_index < private->slow_num && trace_hlight_start_index < private->slow_num) { glColor3f (private->highlight_color.red / (gfloat)G_MAXUINT16, private->highlight_color.green / (gfloat)G_MAXUINT16, private->highlight_color.blue / (gfloat)G_MAXUINT16); for (i = trace_hlight_start_index; i <= trace_hlight_end_index; i += trace_step_index) { glPushMatrix (); glTranslatef (trace_slow_start + trace_dist * i, trace_fast_start, 0); glScalef (slow_data_to_object_scale * trace_scale * trace_step_index, fast_data_to_object_scale, 0); private->vbo->glBindBufferARB (GL_ARRAY_BUFFER_ARB, private->traces_wiggle_vbo[i]); glVertexPointer (2, GL_FLOAT, 0, NULL); private->vbo->glBindBufferARB (GL_ELEMENT_ARRAY_BUFFER_ARB, traces_va_vbo[i]); glIndexPointer (GL_INT, 0, NULL); glDrawElements (GL_TRIANGLE_STRIP, va_index_num[i], GL_UNSIGNED_INT, NULL); glPopMatrix (); } } } else if (private->display_mode & GTK_SEIS_VIEW_WIGGLE) { /* Only wiggle */ for (i = trace_start_index; i <= trace_end_index; i += trace_step_index) { if (i >= trace_hlight_start_index && i <= trace_hlight_end_index) continue; glPushMatrix (); glTranslatef (trace_slow_start + trace_dist * i, trace_fast_start, 0); glScalef (slow_data_to_object_scale * trace_scale * trace_step_index, fast_data_to_object_scale, 0); private->vbo->glBindBufferARB (GL_ARRAY_BUFFER_ARB, private->traces_wiggle_vbo[i]); glVertexPointer (2, GL_FLOAT, 0, NULL); glDrawArrays (GL_LINE_STRIP, 0, private->wiggle_num[i]); glPopMatrix (); } /* Highlight */ if (trace_hlight_start_index < private->slow_num && trace_hlight_start_index < private->slow_num) { glColor3f (private->highlight_color.red / (gfloat)G_MAXUINT16, private->highlight_color.green / (gfloat)G_MAXUINT16, private->highlight_color.blue / (gfloat)G_MAXUINT16); for (i = trace_hlight_start_index; i <= trace_hlight_end_index; i += trace_step_index) { glPushMatrix (); glTranslatef (trace_slow_start + trace_dist * i, trace_fast_start, 0); glScalef (slow_data_to_object_scale * trace_scale * trace_step_index, fast_data_to_object_scale, 0); private->vbo->glBindBufferARB (GL_ARRAY_BUFFER_ARB, private->traces_wiggle_vbo[i]); glVertexPointer (2, GL_FLOAT, 0, NULL); glDrawArrays (GL_LINE_STRIP, 0, private->wiggle_num[i]); glPopMatrix (); } } } glDisableClientState (GL_INDEX_ARRAY); glDisableClientState (GL_VERTEX_ARRAY); } else if (private->has_wiggles) { /* Display lists */ if ((private->display_mode & (GTK_SEIS_VIEW_VA | GTK_SEIS_VIEW_WIGGLE)) == (GTK_SEIS_VIEW_VA | GTK_SEIS_VIEW_WIGGLE) || (trace_hlight_start_index < private->slow_num && GTK_SEIS_VIEW_VD == private->display_mode)) { /* Wiggle + variable area */ if (private->display_mode != GTK_SEIS_VIEW_VD) { for (i = trace_start_index; i <= trace_end_index; i += trace_step_index) { if (i >= trace_hlight_start_index && i <= trace_hlight_end_index) continue; glPushMatrix (); glTranslatef (trace_slow_start + trace_dist * i, trace_fast_start, 0); glScalef (slow_data_to_object_scale * trace_scale * trace_step_index, fast_data_to_object_scale, 0); glCallList (private->wiggle_list_base + i); glCallList (va_list_base + i); glPopMatrix (); } } /* Highlight */ if (trace_hlight_start_index < private->slow_num && trace_hlight_start_index < private->slow_num) { glColor3f (private->highlight_color.red / (gfloat)G_MAXUINT16, private->highlight_color.green / (gfloat)G_MAXUINT16, private->highlight_color.blue / (gfloat)G_MAXUINT16); for (i = trace_hlight_start_index; i <= trace_hlight_end_index; i += trace_step_index) { glPushMatrix (); glTranslatef (trace_slow_start + trace_dist * i, trace_fast_start, 0); glScalef (slow_data_to_object_scale * trace_scale * trace_step_index, fast_data_to_object_scale, 0); glCallList (private->wiggle_list_base + i); glCallList (va_list_base + i); glPopMatrix (); } } } else if (private->display_mode & GTK_SEIS_VIEW_VA) { /* Only variable area */ for (i = trace_start_index; i <= trace_end_index; i += trace_step_index) { if (i >= trace_hlight_start_index && i <= trace_hlight_end_index) continue; glPushMatrix (); glTranslatef (trace_slow_start + trace_dist * i, trace_fast_start, 0); glScalef (slow_data_to_object_scale * trace_scale * trace_step_index, fast_data_to_object_scale, 0); glCallList (va_list_base + i); glPopMatrix (); } /* Highlight */ if (trace_hlight_start_index < private->slow_num && trace_hlight_start_index < pri
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -