/*------------------------------------------------------------------------------*/ int mbview_plotprofile(size_t instance) { /* local variables */ char *function_name = "mbview_plotprofile"; int status = MB_SUCCESS; struct mbview_world_struct *view; struct mbview_struct *data; float left, right, top, bottom; double zcenter, zmin, zmax; double scale; float yzmin, yzmax; float x, y; int clip; int i; /* print starting debug statements */ if (mbv_verbose >= 2) { fprintf(stderr,"\ndbg2 MBIO function <%s> called\n", function_name); fprintf(stderr,"dbg2 MB-system Version %s\n",MB_VERSION); fprintf(stderr,"dbg2 Input arguments:\n"); fprintf(stderr,"dbg2 instance: %ld\n", instance); } /* get view */ view = &(mbviews[instance]); data = &(view->data); /* If there is a profile plot it */ if (data->profile_view_mode == MBV_VIEW_ON) { /* get scaling */ scale = MBV_OPENGL_WIDTH / data->profile.length; left = -0.1 * MBV_OPENGL_WIDTH; right = 1.1 * MBV_OPENGL_WIDTH; zcenter = 0.5 * (data->profile.zmax + data->profile.zmin); top = 0.5 * (right - left) * view->praspect_ratio; bottom = -top; zmin = zcenter - 0.5 * view->praspect_ratio * data->profile.length / data->profile_exageration; zmax = zcenter + 0.5 * view->praspect_ratio * data->profile.length / data->profile_exageration; yzmin = scale * data->profile_exageration * (zmin - zcenter); yzmax = scale * data->profile_exageration * (zmax - zcenter); clip = MB_NO; /* set projection to 2D */ #ifdef MBV_DEBUG_GLX fprintf(stderr,"%s:%d:%s instance:%ld glXMakeCurrent(%lu,%lu,%lu)\n", __FILE__,__LINE__,function_name,instance,(size_t)view->dpy,(size_t)XtWindow(view->prglwmda),(size_t)view->prglx_context); #endif glXMakeCurrent(view->dpy,XtWindow(view->prglwmda),view->prglx_context); #ifdef MBV_GET_GLX_ERRORS mbview_glerrorcheck(instance, __FILE__, __LINE__, function_name); #endif glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(left, right, bottom, top, MBV_OPENGL_ZMIN2D, MBV_OPENGL_ZMAX2D); /* set up translations */ glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslated (0.0, 0.0, MBV_OPENGL_ZMIN2D); /* set background color */ glClearColor(1.0, 1.0, 1.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); /* draw profile */ glLineWidth(1.0); glBegin(GL_QUADS); for (i=0;i<data->profile.npoints-1;i++) { if (data->profile.points[i].boundary == MB_NO || data->profile.points[i+1].boundary == MB_NO) { if (data->profile.points[i].slope < data->profile_slopethreshold) { glColor3f(colortable_object_red[MBV_COLOR_BLACK], colortable_object_green[MBV_COLOR_BLACK], colortable_object_blue[MBV_COLOR_BLACK]); } else { glColor3f(colortable_object_red[MBV_COLOR_RED], colortable_object_green[MBV_COLOR_RED], colortable_object_blue[MBV_COLOR_RED]); } x = scale * data->profile.points[i].distance; y = scale * data->profile_exageration * (data->profile.points[i].zdata - zcenter); if (y < yzmin) { clip = MB_YES; y = yzmin; } if (y > yzmax) { clip = MB_YES; y = yzmax; } glVertex3f(x, yzmin, MBV_OPENGL_ZPROFILE1); glVertex3f(x, y, MBV_OPENGL_ZPROFILE1); x = scale * data->profile.points[i+1].distance; y = scale * data->profile_exageration * (data->profile.points[i+1].zdata - zcenter); if (y < yzmin) { clip = MB_YES; y = yzmin; } if (y > yzmax) { clip = MB_YES; y = yzmax; } glVertex3f(x, y, MBV_OPENGL_ZPROFILE1); glVertex3f(x, yzmin, MBV_OPENGL_ZPROFILE1); } } glEnd(); /* draw boundaries */ glColor3f(colortable_object_red[MBV_COLOR_GREEN], colortable_object_green[MBV_COLOR_GREEN], colortable_object_blue[MBV_COLOR_GREEN]); glLineWidth(2.0); glBegin(GL_LINES); for (i=0;i<data->profile.npoints;i++) { if (data->profile.points[i].boundary == MB_YES) { x = scale * data->profile.points[i].distance; glVertex3f(x, yzmin, MBV_OPENGL_ZPROFILE1); glVertex3f(x, yzmax, MBV_OPENGL_ZPROFILE1); } } glEnd(); /* draw box */ if (clip == MB_NO) glColor3f(colortable_object_red[MBV_COLOR_BLACK], colortable_object_green[MBV_COLOR_BLACK], colortable_object_blue[MBV_COLOR_BLACK]); else glColor3f(colortable_object_red[MBV_COLOR_RED], colortable_object_green[MBV_COLOR_RED], colortable_object_blue[MBV_COLOR_RED]); glLineWidth(2.0); glBegin(GL_LINE_LOOP); glVertex3f((float)(0.0), yzmin, (float)(MBV_OPENGL_ZPROFILE1)); glVertex3f((float)(MBV_OPENGL_WIDTH), yzmin, (float)(MBV_OPENGL_ZPROFILE1)); glVertex3f((float)(MBV_OPENGL_WIDTH), yzmax, (float)(MBV_OPENGL_ZPROFILE1)); glVertex3f((float)(0.0), yzmax, (float)(MBV_OPENGL_ZPROFILE1)); glEnd(); #ifdef MBV_GETERRORS mbview_glerrorcheck(instance, __FILE__, __LINE__, function_name); #endif /* flush opengl buffers */ glFlush(); #ifdef MBV_GETERRORS mbview_glerrorcheck(instance, 2, function_name); #endif /* swap opengl buffers */ glXSwapBuffers (XtDisplay(view->prglwmda), XtWindow(view->prglwmda)); #ifdef MBV_GETERRORS mbview_glerrorcheck(instance, 3, function_name); #endif /* update info label */ mbview_profile_text(instance); } /* print output debug statements */ if (mbv_verbose >= 2) { fprintf(stderr,"\ndbg2 MBIO function <%s> completed\n", function_name); fprintf(stderr,"dbg2 Return status:\n"); fprintf(stderr,"dbg2 status: %d\n",status); } /* return */ return(status); }
/*------------------------------------------------------------------------------*/ int mbview_drawvector(size_t instance, int rez) { /* local variables */ char *function_name = "mbview_drawvector"; int status = MB_SUCCESS; struct mbview_world_struct *view; struct mbview_struct *data; GLUquadricObj *globj; int stride; int icolor; int ivec, jpoint; float red, green, blue; double xx, yy; double ballsize; int k0, k1; /* print starting debug statements */ if (mbv_verbose >= 2) { fprintf(stderr, "\ndbg2 MBIO function <%s> called\n", function_name); fprintf(stderr, "dbg2 MB-system Version %s\n", MB_VERSION); fprintf(stderr, "dbg2 Input arguments:\n"); fprintf(stderr, "dbg2 instance: %zu\n", instance); fprintf(stderr, "dbg2 rez: %d\n", rez); } /* get view */ view = &(mbviews[instance]); data = &(view->data); /* set decimation */ if (rez == MBV_REZ_FULL) stride = 1; else if (rez == MBV_REZ_HIGH) stride = data->hirez_navdecimate; else stride = data->lorez_navdecimate; /* draw vectors */ if (shared.shareddata.vector_mode != MBV_VECTOR_OFF && data->vector_view_mode == MBV_VIEW_ON && shared.shareddata.nvector > 0) { /* get size according to viewbounds */ k0 = data->viewbounds[0] * data->primary_n_rows + data->viewbounds[2]; k1 = data->viewbounds[1] * data->primary_n_rows + data->viewbounds[3]; xx = data->primary_x[k1] - data->primary_x[k0]; yy = data->primary_y[k1] - data->primary_y[k0]; ballsize = 0.001 * sqrt(xx * xx + yy * yy); /* make list for ball */ glNewList((GLuint)MBV_GLLIST_VECTORBALL, GL_COMPILE); globj = gluNewQuadric(); gluSphere(globj, ballsize, 10, 10); gluDeleteQuadric(globj); glEndList(); /* loop over the vecs plotting xyz vectors */ for (ivec = 0; ivec < shared.shareddata.nvector; ivec++) { icolor = shared.shareddata.vectors[ivec].color; /* plot lines */ /* glLineWidth((float)(shared.shareddata.vectors[ivec].size)); glBegin(GL_LINE_STRIP); */ /* plot balls */ for (jpoint = 0; jpoint < shared.shareddata.vectors[ivec].npoints; jpoint += stride) { /* set color */ mbview_getcolor(shared.shareddata.vectors[ivec].vectorpts[jpoint].data, shared.shareddata.vectors[ivec].datamax, shared.shareddata.vectors[ivec].datamin, MBV_COLORTABLE_NORMAL, (float)0.0, (float)0.0, (float)1.0, (float)0.0, (float)0.0, (float)0.0, colortable_bright_red, colortable_bright_green, colortable_bright_blue, &red, &green, &blue); if (shared.shareddata.vectors[ivec].vectorpts[jpoint].selected == MB_YES || (jpoint < shared.shareddata.vectors[ivec].npoints - 1 && shared.shareddata.vectors[ivec].vectorpts[jpoint + 1].selected == MB_YES)) { glColor3f(colortable_object_red[MBV_COLOR_RED], colortable_object_green[MBV_COLOR_RED], colortable_object_blue[MBV_COLOR_RED]); } else { glColor3f(red, green, blue); } /* draw points in line */ /* glVertex3f((float)(shared.shareddata.vectors[ivec].vectorpts[jpoint].point.xdisplay[instance]), (float)(shared.shareddata.vectors[ivec].vectorpts[jpoint].point.ydisplay[instance]), (float)(shared.shareddata.vectors[ivec].vectorpts[jpoint].point.zdisplay[instance])); */ /* draw points as balls */ glTranslatef((float)(shared.shareddata.vectors[ivec].vectorpts[jpoint].point.xdisplay[instance]), (float)(shared.shareddata.vectors[ivec].vectorpts[jpoint].point.ydisplay[instance]), (float)(shared.shareddata.vectors[ivec].vectorpts[jpoint].point.zdisplay[instance])); glCallList((GLuint)MBV_GLLIST_VECTORBALL); glTranslatef((float)(-shared.shareddata.vectors[ivec].vectorpts[jpoint].point.xdisplay[instance]), (float)(-shared.shareddata.vectors[ivec].vectorpts[jpoint].point.ydisplay[instance]), (float)(-shared.shareddata.vectors[ivec].vectorpts[jpoint].point.zdisplay[instance])); } /* glEnd();*/ } } #ifdef MBV_GETERRORS mbview_glerrorcheck(instance, 1, function_name); #endif /* print output debug statements */ if (mbv_verbose >= 2) { fprintf(stderr, "\ndbg2 MBIO function <%s> completed\n", function_name); fprintf(stderr, "dbg2 Return status:\n"); fprintf(stderr, "dbg2 status: %d\n", status); } /* return */ return (status); }
/*------------------------------------------------------------------------------*/ int mbview_reset_prglx(size_t instance) { /* local variables */ char *function_name = "mbview_reset_prglx"; int status = MB_SUCCESS; struct mbview_world_struct *view; struct mbview_struct *data; Dimension scrolledWindow_width; Dimension scrolledWindow_height; /* print starting debug statements */ if (mbv_verbose >= 2) { fprintf(stderr,"\ndbg2 MBIO function <%s> called\n", function_name); fprintf(stderr,"dbg2 MB-system Version %s\n",MB_VERSION); fprintf(stderr,"dbg2 Input arguments:\n"); fprintf(stderr,"dbg2 instance: %ld\n", instance); } /* get view */ view = &(mbviews[instance]); data = &(view->data); /* If profile view enabled update opengl plotting widget */ if (data->profile_view_mode == MBV_VIEW_ON) { /* delete old glx_context if it exists */ if (view->prglx_init == MB_YES) { glXDestroyContext(view->dpy, view->prglx_context); view->prglx_init = MB_NO; } /* get and set sizes of the drawingArea */ XtVaGetValues(view->mb3dview.mbview_scrolledWindow_profile, XmNwidth, &scrolledWindow_width, XmNheight, &scrolledWindow_height, NULL); data->prheight = scrolledWindow_height - 35; data->prwidth = data->profile_widthfactor * (scrolledWindow_width -20); /* set drawing area size */ ac = 0; XtSetArg(args[ac], XmNwidth, data->prwidth); ac++; XtSetArg(args[ac], XmNheight, data->prheight); ac++; XtSetValues(view->mb3dview.mbview_drawingArea_profile, args, ac); ac = 0; /* set prglwda size */ XtSetArg(args[ac], XmNwidth, data->prwidth); ac++; XtSetArg(args[ac], XmNheight, data->prheight); ac++; XtSetValues(view->prglwmda, args, ac); /* set up a new opengl context */ ac = 0; XtSetArg(args[ac], mbGLwNvisualInfo, &(view->prvi)); ac++; XtGetValues(view->prglwmda, args, ac); #ifdef MBV_DEBUG_GLX fprintf(stderr,"%s:%d:%s instance:%ld glXCreateContext(%lu,%lu)\n", __FILE__,__LINE__,function_name,instance,(size_t)view->dpy,(size_t)view->prvi); #endif view->prglx_context = glXCreateContext(view->dpy, view->prvi, NULL, GL_TRUE); #ifdef MBV_DEBUG_GLX fprintf(stderr,"%s:%d:%s instance:%ld glXMakeCurrent(%lu,%lu,%lu)\n", __FILE__,__LINE__,function_name,instance,(size_t)view->dpy,(size_t)XtWindow(view->prglwmda),(size_t)view->prglx_context); #endif glXMakeCurrent(view->dpy,XtWindow(view->prglwmda),view->prglx_context); #ifdef MBV_GET_GLX_ERRORS mbview_glerrorcheck(instance, __FILE__, __LINE__, function_name); #endif view->prglx_init = MB_YES; glViewport(0, 0, data->prwidth, data->prheight); view->praspect_ratio = ((float)data->prheight) / ((float)data->prwidth); } /* print output debug statements */ if (mbv_verbose >= 2) { fprintf(stderr,"\ndbg2 MBIO function <%s> completed\n", function_name); fprintf(stderr,"dbg2 Return status:\n"); fprintf(stderr,"dbg2 status: %d\n",status); fprintf(stderr,"dbg2 view->dpy: %lu\n", (size_t)view->dpy); fprintf(stderr,"dbg2 view->prvi: %lu\n", (size_t)view->prvi); fprintf(stderr,"dbg2 view->prglwmda: %lu\n", (size_t)view->prglwmda); fprintf(stderr,"dbg2 view->prglx_context: %lu\n", (size_t)view->prglx_context); fprintf(stderr,"dbg2 view->prglx_init: %d\n", view->prglx_init); } /* return */ return(status); }