📄 xbcview.c
字号:
XtSetArg(args[0], XtNwidth, &t); lblwd = 1; lh_min = XtNameToWidget(form, "*lh_min"); XtGetValues(lh_min, args, 1); if (t > lblwd) lblwd = t; lh_max = XtNameToWidget(form, "*lh_max"); XtGetValues(lh_max, args, 1); if (t > lblwd) lblwd = t; lv_min = XtNameToWidget(form, "*lv_min"); XtGetValues(lv_min, args, 1); if (t > lblwd) lblwd = t; lv_max = XtNameToWidget(form, "*lv_max"); XtGetValues(lv_max, args, 1); if (t > lblwd) lblwd = t; XtVaSetValues(lh_min, XtNwidth, lblwd, NULL); XtVaSetValues(lh_max, XtNwidth, lblwd, NULL); XtVaSetValues(lv_min, XtNwidth, lblwd, NULL); XtVaSetValues(lv_max, XtNwidth, lblwd, NULL); XtVaGetValues(di_h_min, XtNwidth, &wd, NULL); #ifdef LINUX /* if Linux Athena Widgets */ XtVaGetValues(form, XtNdefaultDistance, &dd, NULL); #else /* get the default distance, */ dd = 4; /* if Sun or HP Athena Widgets, */ #endif /* set the default distance */ wd += lblwd +dd; /* compute the listbox width */ if (wd < LISTWD) wd = LISTWD; /* and set it */ XtVaSetValues(rview, XtNwidth, wd, NULL); XtVaSetValues(lview, XtNwidth, wd, NULL); XtVaSetValues(ok, XtNwidth, wd, NULL); XtVaSetValues(cancel, XtNwidth, wd, NULL); wd -= lblwd +dd; /* compute the input field width */ XtVaSetValues(di_h_min, XtNwidth, wd, NULL); XtVaSetValues(di_h_max, XtNwidth, wd, NULL); XtVaSetValues(di_v_min, XtNwidth, wd, NULL); XtVaSetValues(di_v_max, XtNwidth, wd, NULL); /* --- install translations --- */ tla = XtParseTranslationTable( "<Btn1Down>,<Btn1Up>: Set()Notify()\n" "<Btn1Down>(2+): dclick()"); XtAugmentTranslations(di_h_att, tla); XtAugmentTranslations(di_v_att, tla); tla = XtParseTranslationTable( "<Key>Home : beginning-of-line()\n" "<Key>End : end-of-line()\n"); tlo = XtParseTranslationTable( "Shift<Key>Tab : db_next(-1)\n" "<Key>Tab : db_next(+1)\n" "Shift<Key>Return: db_close(ok)\n" "<Key>Return : db_close(apply)\n" "<Key>Escape : db_close(cancel)\n" "!Alt<Key>o : db_close(ok)\n" "!Alt<Key>c : db_close(cancel)\n" "<Btn1Down> : db_focus()\n"); XtAugmentTranslations (di_h_min, tla); XtOverrideTranslations(di_h_min, tlo); XtAugmentTranslations (di_h_max, tla); XtOverrideTranslations(di_h_max, tlo); XtAugmentTranslations (di_v_min, tla); XtOverrideTranslations(di_v_min, tlo); XtAugmentTranslations (di_v_max, tla); XtOverrideTranslations(di_v_max, tlo); XtInstallAllAccelerators(form, form); db_atts = shell; /* install actions and accelerators */ } /* and note the created dialog box */ mn_enable(menu, MN_MENU, 0); /* disable menu bar */ /* --- fill dialog box fields --- */ if (!names || (attcnt <= 0)){ /* if the name list is not valid */ XawListChange(di_h_att, &empty, 1, 0, 1); XawListChange(di_v_att, &empty, 1, 0, 1); XtSetArg(args[0], XtNstring, ""); XtSetValues(di_h_min, args, 1); /* clear the list boxes */ XtSetValues(di_h_max, args, 1); /* and the input gadgets */ XtSetValues(di_v_min, args, 1); XtSetValues(di_v_max, args, 1); } else { /* if the name list is valid */ XawListChange(di_h_att, (String*)names, attcnt, 0, 1); XawListHighlight(di_h_att, attinfo.h_att); XawListChange(di_v_att, (String*)names, attcnt, 0, 1); XawListHighlight(di_v_att, attinfo.v_att); sprintf(buf, "%g", attinfo.h_rng.min); XtVaSetValues(di_h_min, XtNstring, buf, NULL); sprintf(buf, "%g", attinfo.h_rng.max); XtVaSetValues(di_h_max, XtNstring, buf, NULL); sprintf(buf, "%g", attinfo.v_rng.min); XtVaSetValues(di_v_min, XtNstring, buf, NULL); sprintf(buf, "%g", attinfo.v_rng.max); XtVaSetValues(di_v_max, XtNstring, buf, NULL); } /* set attribute names and ranges */ XtVaSetValues(XtParent(di_h_att), XtNheight, LISTHT, NULL); XtVaSetValues(XtParent(di_v_att), XtNheight, LISTHT, NULL); /* --- show dialog box --- */ XtVaGetValues(w_top, XtNx, &x, XtNy, &y, NULL); XtVaSetValues(db_atts, XtNx, x, XtNy, y, NULL); XtPopup(db_atts, XtGrabExclusive); /* place and show dialog box */ XtSetKeyboardFocus(db_atts, di_h_min); /* and set keyboard focus */ if (shell) { /* if dialog box has been created */ XtVaGetValues(shell, XtNwidth, &wd, XtNheight, &ht, NULL); XtVaSetValues(shell, XtNminWidth, wd, XtNminHeight, ht, NULL); XtOverrideTranslations(shell, XtParseTranslationTable("<Message>WM_PROTOCOLS: db_close()")); XSetWMProtocols(XtDisplay(shell), XtWindow(shell), &wm_delwin, 1); /* override window manager delete */ }} /* atts() *//*--------------------------------------------------------------------*/static void colors (Widget w, XEvent *e, String *s, Cardinal *c){ /* --- Actions > Colors... */ void *p; /* temporary buffer */ char buf[32]; /* ditto, for texts */ if (!psh_color) { /* if property sheet not created yet */ psh_color = psh_create("colorDlg", w_top, 1); if (!psh_color) return; /* create a property sheet */ if ((psh_addline(psh_color, "ldist") != 0) || (psh_additem(psh_color, "dist", PSH_MENU, 0) != 0) || (psh_menuadd(psh_color, "dist", "prob") != 0) || (psh_menuadd(psh_color, "dist", "fuzzy") != 0) || (psh_menuadd(psh_color, "dist", "poss") != 0) || (psh_addline(psh_color, "lmode") != 0) || (psh_additem(psh_color, "mode", PSH_MENU, 0) != 0) || (psh_menuadd(psh_color, "mode", "color") != 0) || (psh_menuadd(psh_color, "mode", "grey") != 0) || (psh_addline(psh_color, "lcoloff") != 0) || (psh_additem(psh_color, "coloff", PSH_EDIT, 0) != 0) || (psh_addline(psh_color, "lbase") != 0) || (psh_additem(psh_color, "base", PSH_MENU, 0) != 0) || (psh_menuadd(psh_color, "base", "black") != 0) || (psh_menuadd(psh_color, "base", "white") != 0) || (psh_addline(psh_color, "lshdcnt") != 0) || (psh_additem(psh_color, "shdcnt", PSH_EDIT, 0) != 0) || (psh_addline(psh_color, "lndwgt") != 0) || (psh_additem(psh_color, "ndwgt", PSH_EDIT, 0) != 0)) { psh_delete(psh_color); error(E_DIALOG); return; } } /* add dialog items */ mn_enable(menu, MN_MENU, 0); /* disable menu bar */ if (colinfo.dist == DT_FUZZY) p = (void*)1; else if (colinfo.dist == DT_POSS) p = (void*)2; else p = (void*)0; psh_setval(psh_color, "dist", p); /* set distribution type */ psh_setval(psh_color, "mode", /* set shade mode */ (const char*)((colinfo.colcnt > 0) ? 0 : 1)); sprintf(buf, "%g", colinfo.coloff); psh_setval(psh_color, "coloff", buf); /* set color offset */ psh_setval(psh_color, "base", /* set shade base */ (const char*)((colinfo.shdbase == SHD_BLACK) ? 0 : 1)); sprintf(buf, "%d", colinfo.shdcnt); psh_setval(psh_color, "shdcnt", buf); /* set number of shades */ sprintf(buf, "%g", colinfo.ndwgt); psh_setval(psh_color, "ndwgt", buf); /* set weight of normal dist. */ psh_handle(psh_color, dcb_colors); /* and handle dialog */} /* colors() *//*--------------------------------------------------------------------*/static void marks (Widget w, XEvent *e, String *s, Cardinal *c){ /* --- Actions > Markers... */ char buf[32]; /* buffer for texts */ if (!psh_marks) { /* if property sheet not created yet */ psh_marks = psh_create("marksDlg", w_top, 1); if (!psh_marks) return; /* create a property sheet */ if ((psh_addline(psh_marks, NULL) != 0) || (psh_additem(psh_marks, "color", PSH_TOGGLE, 0) != 0) || (psh_addline(psh_marks, NULL) != 0) || (psh_additem(psh_marks, "center", PSH_TOGGLE, 0) != 0) || (psh_addline(psh_marks, NULL) != 0) || (psh_additem(psh_marks, "ell1s", PSH_TOGGLE, 0) != 0) || (psh_addline(psh_marks, NULL) != 0) || (psh_additem(psh_marks, "ell2s", PSH_TOGGLE, 0) != 0) || (psh_addline(psh_marks, NULL) != 0) || (psh_additem(psh_marks, "ell3s", PSH_TOGGLE, 0) != 0) || (psh_addline(psh_marks, NULL) != 0) || (psh_additem(psh_marks, "data", PSH_TOGGLE, 0) != 0) || (psh_addline(psh_marks, "lsize") != 0) || (psh_additem(psh_marks, "size", PSH_EDIT, 0) != 0)) { psh_delete(psh_marks); error(E_DIALOG); return; } } /* add dialog items */ mn_enable(menu, MN_MENU, 0); /* disable menu bar */ psh_setval(psh_marks, "color", (void*)(mrkflgs & MRK_COLOR ? 1 : 0)); psh_setval(psh_marks, "center",(void*)(mrkflgs & MRK_CENTER ? 1 : 0)); psh_setval(psh_marks, "ell1s", (void*)(mrkflgs & MRK_ELL1S ? 1 : 0)); psh_setval(psh_marks, "ell2s", (void*)(mrkflgs & MRK_ELL2S ? 1 : 0)); psh_setval(psh_marks, "ell3s", (void*)(mrkflgs & MRK_ELL3S ? 1 : 0)); psh_setval(psh_marks, "data", (void*)(mrkflgs & MRK_DATA ? 1 : 0)); sprintf(buf, "%d", mrksize); psh_setval(psh_marks, "size", buf); psh_handle(psh_marks,dcb_marks); /* set marker flags */} /* marks() */ /* and handle dialog *//*--------------------------------------------------------------------*/static void redraw (Widget w, XEvent *e, String *s, Cardinal *c){ /* --- Actions > Redraw */ static Dimension owd = 0; /* old window width */ static Dimension oht = 0; /* old window height */ int i, k, n; /* loop variable, buffer */ int clscnt; /* number of classes/clusters */ int colcnt; /* number of colors */ Dimension wd, ht; /* window extensions */ XRectangle rc; /* clipping rectangle */ int x, y, x_prev; /* pixel coordinates */ double rx, ry; /* real coordinates */ double dx, dy; /* standard deviations */ double xoff, yoff; /* offsets of window borders */ double xscl, yscl; /* scaling factors */ double val, sum, max; /* function value, sum and maximum */ PIXEL pxl, pxl_prev; /* current and previous pixel value */ PIXEL mrk; /* pixel value for markers */ int col, shd, shdcnt; /* color, shade, and number of shades */ XEvent de; /* dummy event */ double a, b; /* transformation constants */ int xid, yid, clsid; /* attribute identifiers */ int xtype, ytype; /* attribute types */ TUPLE *tpl; /* to traverse the data tuples */ float f; /* temporary buffer */ int cmin, cmax; /* minimal and maximal coordinate */ double t0, t1, t2; /* temporary buffers */ /* --- initialize graphics --- */ if (!gc) { /* if graphics context not created */ gc = XCreateGC(display, window, 0, NULL); if (!gc) { error(E_GRAPH); return; } } /* create a graphics context */ if (!bvnorm || !attset || !shades) { XClearWindow(display, window); return; /* if there is no drawing data, */ } /* clear the window and abort */ XtVaGetValues(w_view, XtNwidth, &wd, XtNheight, &ht, NULL); if (e && (e->type == Expose) /* if the window was exposed, */ && (wd == owd) && (ht == oht)) { /* but not resized */ rc.x = e->xexpose.x; /* build and set */ rc.y = e->xexpose.y; /* clipping rectangle */ rc.width = e->xexpose.width; rc.height = e->xexpose.height; XSetClipRectangles(display, gc, 0, 0, &rc, 1, Unsorted); } else { /* if the window was resized */ rc.x = rc.y = 0; /* or this is a forced redraw, */ rc.width = wd; /* redraw all of the window */ rc.height = ht; /* (set full window rectangle) */ while (XCheckTypedWindowEvent(display, window, Expose, &de)); } /* remove all exposure events */ owd = wd; oht = ht; /* note (new) window dimensions */ /* --- initialize normal distributions --- */ clscnt = bc_bvnorm(); /* init. the normal distributions */ if (clscnt < 0) return; /* and check for success */ /* --- draw rectangle contents --- */ xoff = ranges[attinfo.h_att].min; /* get coordinate offsets and */ yoff = ranges[attinfo.v_att].max; /* compute the scaling factors */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -