⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xbcview.c

📁 BCView - Bayes Classifier Visualization Download xbcview Linux executable (218 kb) wbcview.exe W
💻 C
📖 第 1 页 / 共 5 页
字号:
  if ((code > 0) || (code < E_UNKNOWN))    code = E_UNKNOWN;           /* check error code */  msg = errmsgs -code;          /* get error message data */  if (!msg->name) msg = errmsgs -E_UNKNOWN;  va_start(va, code);           /* get list of variable arguments */  for (argc = 0; (int)argc < msg->argc; argc++)    argv[argc] = va_arg(va, String);  va_end(va);                   /* get message arguments */  if (strcmp(msg->name, "error") == 0)  /* if name is ``error'' */    XtAppErrorMsg(appctx, msg->name, msg->type, msg->class,      msg->dflt, argv, &argc);  /* print error message */  else {                        /* if name is ``warning'' */    XtAppGetErrorDatabaseText(appctx, msg->name, msg->type,      msg->class, msg->dflt, fmt, FMT_MAX, NULL);    va_start(va, code);         /* list of variable arguments */    vsprintf(buf, fmt, va);     /* get and format message */    va_end(va);                 /* end variable argument evaluation */    mn_enable(menu, MN_MENU,0); /* disable menu bar and show dialog */    if (db_alert(w_top, dcb_nop, buf) != 0) {      mn_enable(menu, MN_MENU, 1);  /* enable menu bar */      XtAppWarningMsg(appctx, msg->name, msg->type, msg->class,        msg->dflt, argv, &argc);/* if the alert dialog box */    }                           /* cannot be shown, */  }                             /* print a warning message */}  /* error() *//*----------------------------------------------------------------------  Color Functions----------------------------------------------------------------------*/static void col_delete (void){                               /* --- delete color shades */  if (datcols) { shd_delete(datcols); datcols = NULL; }  if (shades)  { shd_delete(shades);  shades  = NULL; }}  /* col_delete() */           /* delete all shades/colors *//*--------------------------------------------------------------------*/static int col_create (void){                               /* --- create color shades */  int      clscnt;              /* number of classes/clusters */  Colormap colmap;              /* default colormap */  if (!attset) return 0;        /* check for an existing classifier */  col_delete();                 /* delete existing shades/colors */  if      (nbc) clscnt = nbc_clscnt(nbc);  else if (fbc) clscnt = fbc_clscnt(fbc);  else          clscnt = cls_clscnt(clset);  if (colinfo.colcnt > 0)       /* get the number of classes/clusters */    colinfo.colcnt = clscnt;    /* and note the number of colors */  colmap = DefaultColormap(display, screen);  shades = shd_create(display, colmap, colinfo.coloff,  colinfo.colcnt,                                       colinfo.shdbase, colinfo.shdcnt);  if (!shades) return -1;       /* create color shades for distribs. */  datcols = shd_create(display, colmap, colinfo.coloff, clscnt,                                        SHD_BLACK,      1);  if (!datcols) { col_delete(); return -1; }  return 0;                     /* get colors for data points */}  /* col_create() */           /* and return `ok' *//*----------------------------------------------------------------------  Dialog Box Callback Functions----------------------------------------------------------------------*/static void dcb_class (Widget widget, XtPointer ok, XtPointer fname){                               /* --- 'Load Classifier...' callback */  int r;                        /* result of bc_load */  mn_enable(menu, MN_MENU, 1);  /* enable menu bar */  if (!ok) return;              /* if not ok pressed, abort */  r = bc_load(fname);           /* load a classifier/set of clusters */  if (r != 0) { error(r, fname); return; }  if (col_create() != 0) {      /* get new color shades */    error(E_COLOR); return; }   /* and marker colors */  if ((int)ok < 2)              /* if not called on startup, */    redraw(NULL,NULL,NULL,NULL);/* redraw the window contents */}  /* dcb_class() *//*--------------------------------------------------------------------*/static void dcb_data (Widget widget, XtPointer ok, XtPointer fname){                               /* --- 'Load Data...' callback */  int    r;                     /* result of bc_data */  TFSERR *err;                  /* error information */  mn_enable(menu, MN_MENU, 1);  /* enable menu bar */  if (!ok || !attset) return;   /* if not ok pressed, abort */  r = bc_data(fname);           /* load a data table */  if (r != 0) {                 /* if an error occurred, */    err = as_err(attset);       /* get the error information */    error(r, fname, recno, err->s, err->fld, err->exp); return;  }                             /* show an error message */  mrkflgs |= MRK_DATA;          /* enforce marks at the data points */  redraw(NULL,NULL,NULL,NULL);  /* redraw the window contents */}  /* dcb_data() *//*--------------------------------------------------------------------*/static void dcb_format (Widget widget, XtPointer ok, XtPointer call){                               /* --- 'Data Format...' callback */  mn_enable(menu, MN_MENU, 1);  /* enable menu bar */  if (!ok) return;              /* if not ok pressed, abort */  fmtinfo.first = (int)psh_getval(psh_fmt, "first");  strncpy(fmtinfo.blanks,  psh_getval(psh_fmt, "blank"),   FMTCHRLEN);  fmtinfo.blanks [FMTCHRLEN] = '\0';  /* get blank characters */  strncpy(fmtinfo.fldseps, psh_getval(psh_fmt, "field"),   FMTCHRLEN);  fmtinfo.fldseps[FMTCHRLEN] = '\0';  /* get field separators */  strncpy(fmtinfo.recseps, psh_getval(psh_fmt, "record"),  FMTCHRLEN);  fmtinfo.recseps[FMTCHRLEN] = '\0';  /* get record separators */  strncpy(fmtinfo.uvchars, psh_getval(psh_fmt, "unknown"), FMTCHRLEN);  fmtinfo.uvchars[FMTCHRLEN] = '\0';  /* get unknown value characters */}  /* dcb_format() *//*--------------------------------------------------------------------*/static void dcb_colors (Widget widget, XtPointer ok, XtPointer call){                               /* --- 'Colors...' callback */  int  clscnt, k;               /* number of classes/clusters, buffer */  char buf[32];                 /* temporary buffer */  mn_enable(menu, MN_MENU, 1);  /* enable menu bar */  if (!ok) return;              /* if not ok pressed, abort */  k = (int)psh_getval(psh_color, "dist");    /* get the */  if      (k == 1) colinfo.dist = DT_FUZZY;  /* distribution */  else if (k == 2) colinfo.dist = DT_POSS;   /* type */  else             colinfo.dist = DT_PROB;  if      (fbc)    clscnt = fbc_clscnt(fbc);  else if (nbc)    clscnt = nbc_clscnt(nbc);  else if (clset)  clscnt = cls_clscnt(clset);  else             clscnt = 1;  /* get the number of classes */  colinfo.colcnt  = (psh_getval(psh_color, "mode") == (void*)0)                  ? clscnt : 0; /* get shading mode */  strncpy(buf, psh_getval(psh_color, "coloff"), 32); buf[31] = '\0';  colinfo.coloff  = atof(buf);  /* get color offset (angle) */  colinfo.shdbase = (psh_getval(psh_color, "base") == (void*)0)                  ? SHD_BLACK : SHD_WHITE;  /* get shade base */  strncpy(buf, psh_getval(psh_color, "shdcnt"), 32); buf[31] = '\0';  colinfo.shdcnt  = atoi(buf);  /* get number of shades */  if (colinfo.shdcnt < 1)          colinfo.shdcnt = 1;  if (colinfo.shdcnt > SHD_MAXCNT) colinfo.shdcnt = SHD_MAXCNT;  strncpy(buf, psh_getval(psh_color, "ndwgt"),  32); buf[31] = '\0';  colinfo.ndwgt   = atof(buf);  /* get weight of normal dist. */  if (colinfo.ndwgt < 0) colinfo.ndwgt  = 0;  if (colinfo.ndwgt > 1) colinfo.ndwgt  = 1;  colinfo.cowgt = 1.0 -colinfo.ndwgt;  if (col_create() != 0)        /* get new color shades */    error(E_COLOR);             /* and marker colors */  redraw(NULL,NULL,NULL,NULL);  /* redraw the window contents */}  /* dcb_colors() *//*--------------------------------------------------------------------*/static void dcb_marks (Widget widget, XtPointer ok, XtPointer call){                               /* --- 'Markers...' callback */  mn_enable(menu, MN_MENU, 1);  /* enable menu bar */  if (!ok) return;              /* if not ok pressed, abort */  if (psh_getval(psh_marks, "color"))  mrkflgs |=  MRK_COLOR;  else                                 mrkflgs &= ~MRK_COLOR;  if (psh_getval(psh_marks, "center")) mrkflgs |=  MRK_CENTER;  else                                 mrkflgs &= ~MRK_CENTER;  if (psh_getval(psh_marks, "ell1s"))  mrkflgs |=  MRK_ELL1S;  else                                 mrkflgs &= ~MRK_ELL1S;  if (psh_getval(psh_marks, "ell2s"))  mrkflgs |=  MRK_ELL2S;  else                                 mrkflgs &= ~MRK_ELL2S;  if (psh_getval(psh_marks, "ell3s"))  mrkflgs |=  MRK_ELL3S;  else                                 mrkflgs &= ~MRK_ELL3S;  if (psh_getval(psh_marks, "data"))   mrkflgs |=  MRK_DATA;  else                                 mrkflgs &= ~MRK_DATA;  mrksize = atoi(psh_getval(psh_marks, "size"));  if (mrksize <= 0) mrksize = 1;/* get toggle states, set flags, */  redraw(NULL,NULL,NULL,NULL);  /* and redraw the window contents */}  /* dcb_marks() *//*--------------------------------------------------------------------*/static void dcb_atts (Widget widget, XtPointer ok, XtPointer call){                               /* --- 'Attributes...' callback */  int    i;                     /* list index */  String s;                     /* text in input gadgets */  if (((int)ok != 2)            /* if not to keep dialog open */  && (((int)ok != 1) || ((int)call != 2))) {    XtPopdown(db_atts);         /* close dialog box */    mn_enable(menu, MN_MENU, 1);/* enable menu bar */  }  if ((int)ok == 0) return;     /* if not ok pressed, abort */  i = XawListShowCurrent(di_h_att)->list_index;  if (i != XAW_LIST_NONE) {     /* if an attribute is selected, */    attinfo.h_att = i;          /* note it for the horizontal dir. */    XtVaGetValues(di_h_min, XtNstring, &s, NULL);    ranges[attinfo.h_att].min = attinfo.h_rng.min = atof(s);    XtVaGetValues(di_h_max, XtNstring, &s, NULL);    ranges[attinfo.h_att].max = attinfo.h_rng.max = atof(s);  }                             /* get the range of values */  i = XawListShowCurrent(di_v_att)->list_index;  if (i != XAW_LIST_NONE) {     /* if an attribute is selected, */    attinfo.v_att = i;          /* note it for the vertical dir. */    XtVaGetValues(di_v_min, XtNstring, &s, NULL);    ranges[attinfo.v_att].min = attinfo.v_rng.min = atof(s);    XtVaGetValues(di_v_max, XtNstring, &s, NULL);    ranges[attinfo.v_att].max = attinfo.v_rng.max = atof(s);  }                             /* get the range of values */  redraw(NULL,NULL,NULL,NULL);  /* redraw the window contents */}  /* dcb_atts() *//*----------------------------------------------------------------------  Menu Callback Functions----------------------------------------------------------------------*/static void mcb_class  (Widget widget, XtPointer client, XtPointer call){ ld_class(NULL, NULL, NULL, NULL); }static void mcb_data   (Widget widget, XtPointer client, XtPointer call){ ld_data(NULL, NULL, NULL, NULL); }static void mcb_format (Widget widget, XtPointer client, XtPointer call){ format(NULL, NULL, NULL, NULL); }static void mcb_quit   (Widget widget, XtPointer client, XtPointer call){ quit(NULL, NULL, NULL, NULL); }static void mcb_colors (Widget widget, XtPointer client, XtPointer call){ colors(NULL, NULL, NULL, NULL); }static void mcb_marks  (Widget widget, XtPointer client, XtPointer call){ marks(NULL, NULL, NULL, NULL); }static void mcb_atts   (Widget widget, XtPointer client, XtPointer call){ atts(NULL, NULL, NULL, NULL); }static void mcb_redraw (Widget widget, XtPointer client, XtPointer call){ redraw(NULL, NULL, NULL, NULL); }static void mcb_about  (Widget widget, XtPointer client, XtPointer call){ about(NULL, NULL, NULL, NULL); }/*----------------------------------------------------------------------  List Callback Function----------------------------------------------------------------------*/static void lcb_att (Widget widget, XtPointer client, XtPointer call){                               /* --- attribute list callback */  int  i;                       /* list index */  char buf[32];                 /* conversion buffer */  i = ((XawListReturnStruct*)call)->list_index;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -