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

📄 xbcview.c

📁 BCView - Bayes Classifier Visualization Download xbcview Linux executable (218 kb) wbcview.exe W
💻 C
📖 第 1 页 / 共 5 页
字号:
/*----------------------------------------------------------------------  File    : xbcview.c  Contents: Bayes classifier visualization program for X11  Author  : Christian Borgelt  History : 05.01.2000 file created from file xskel.c            12.01.2000 adapted to module dlgutil            14.01.2000 naive Bayes classifier loading programmed            17.01.2000 data table loading programmed            18.01.2000 colored markers for data points added            27.01.2000 log file replaced by terminal output            30.01.2000 adapted to data files without a class column            02.02.2000 general ellipses drawing function added            03.02.2000 data format settings made more flexible            08.02.2000 fuzzy cluster loading programmed            18.02.2000 adapted to new module nbvload            19.02.2001 fuzzy membership degree coloring added            07.05.2002 variable marker size added            12.04.2003 clustering result visualization added            18.05.2003 bug in (co)variance handling for clusters fixed            27.04.2004 redrawing simplified with function bvn_dist            15.05.2005 drawing of data markers improved----------------------------------------------------------------------*/#include <stdio.h>#include <stdlib.h>#include <stdarg.h>#include <string.h>#include <math.h>#include <time.h>#include <assert.h>#include <X11/Intrinsic.h>#include <X11/StringDefs.h>#include <X11/Core.h>#include <X11/Shell.h>#include <X11/Xaw/Form.h>#include <X11/Xaw/Label.h>#include <X11/Xaw/Command.h>#include <X11/Xaw/Viewport.h>#include <X11/Xaw/List.h>#include <X11/Xaw/AsciiText.h>#include "menu.h"#include "dialog.h"#include "fselect.h"#include "xshades.h"#include "bcload.h"/*----------------------------------------------------------------------  Preprocessor Definitions----------------------------------------------------------------------*//* --- extensions --- */#define MINXEXT      120        /* minimal x-extension of window */#define MINYEXT       90        /* minimal y-extension of window */#define INITXEXT     320        /* initial x-extension of window */#define INITYEXT     320        /* initial y-extension of window */#define LISTWD       150        /* minimal list width */#define LISTHT       120        /* minimal list width *//* --- marker flags --- */#define MRK_DATA    0x01        /* mark data points */#define MRK_COLOR   0x02        /* use color on colored shades */#define MRK_CENTER  0x10        /* mark centers of normal dists. */#define MRK_ELL1S   0x20        /* draw 1 sigma ellipses */#define MRK_ELL2S   0x40        /* draw 2 sigma ellipses */#define MRK_ELL3S   0x80        /* draw 3 sigma ellipses *//* --- distribution types --- */#define DT_PROB        0        /* probabilistic */#define DT_FUZZY       1        /* fuzzy (probabilistic) */#define DT_POSS        2        /* fuzzy (possibilistic) *//* --- error codes --- */#define OK             0        /* no error */#define E_NONE         0        /* no error */#define E_NOMEM      (-1)       /* not enough memory */#define E_FOPEN      (-2)       /* cannot open file */#define E_FREAD      (-3)       /* read error on file */#define E_FWRITE     (-4)       /* write error on file */#define E_INIT       (-9)       /* initialization failed */#define E_WIDGET    (-10)       /* widget creation failed */#define E_DIALOG    (-11)       /* cannot create dialog box */#define E_COLOR     (-12)       /* color allocation failed */#define E_GRAPH     (-13)       /* cannot create graphics context */#define E_UNKNOWN   (-21)       /* unkown error */#define FMT_MAX      256        /* max. len. of error message format *//*----------------------------------------------------------------------  Type Definitions----------------------------------------------------------------------*/typedef struct {                /* --- error message data --- */  const char *name, *type;      /* name and type of the error message */  const char *class;            /* resource class of error message */  const char *dflt;             /* default message */  int        argc;              /* number of arguments */} ERRMSG;                       /* (error message) *//*----------------------------------------------------------------------  Action Function Prototypes----------------------------------------------------------------------*/static void ld_class (Widget w, XEvent *e, String *s, Cardinal *c);static void ld_data  (Widget w, XEvent *e, String *s, Cardinal *c);static void format   (Widget w, XEvent *e, String *s, Cardinal *c);static void quit     (Widget w, XEvent *e, String *s, Cardinal *c);static void colors   (Widget w, XEvent *e, String *s, Cardinal *c);static void marks    (Widget w, XEvent *e, String *s, Cardinal *c);static void atts     (Widget w, XEvent *e, String *s, Cardinal *c);static void redraw   (Widget w, XEvent *e, String *s, Cardinal *c);static void about    (Widget w, XEvent *e, String *s, Cardinal *c);static void dclick   (Widget w, XEvent *e, String *s, Cardinal *c);/*----------------------------------------------------------------------  Constants----------------------------------------------------------------------*/#include "xbcview.rsc"          /* fallback resources */static XtActionsRec actions[] = {  { "ld_class", ld_class },     /* File    > Load Classifier... */  { "ld_data",  ld_data  },     /* File    > Load Data... */  { "format",   format   },     /* File    > Data Format... */  { "quit",     quit     },     /* File    > Quit */  { "redraw",   redraw   },     /* Actions > Redraw */  { "colors",   colors   },     /* Actions > Colors... */  { "marks",    marks    },     /* Actions > Markers... */  { "atts",     atts     },     /* Actions > Attributes... */  { "about",    about    },     /* Help    > About XBCView... */  { "dclick",   dclick   },     /* double click in attribute list */  { "db_focus", db_focus },     /* set focus to input gadget */  { "db_next",  db_next  },     /* switch to next input gadget */  { "db_close", db_close } };   /* close dialog box *//* --- error messages --- */static const ERRMSG errmsgs[] = {   /* error message data */  /* E_NONE      0 */  { "error",   "none",    "XBCView.Error",                         "no error",                               0 },  /* E_NOMEM    -1 */  { "error",   "nomem",   "XBCView.Error",                         "not enough memory",                      0 },  /* E_FOPEN    -2 */  { "warning", "fopen",   "XBCView.Warning",                         "cannot open file:\n%s",                  1 },  /* E_FREAD    -3 */  { "warning", "fread",   "XBCView.Warning",                         "read error on file:\n%s",                1 },  /* E_FWRITE   -4 */  { "warning", "fwrite",  "XBCView.Warning",                         "write error on file:\n%s",               1 },  /* E_PARSE    -5 */  { "warning", "parse",   "XBCView.Warning",                         "parse error on file:\n%s\n(see terminal "                         "output for more information)",           1 },  /* E_CREATE   -6 */  { "warning", "create",  "XBCView.Error",                         "cannot create classifier",               0 },  /* E_ATTCNT   -7 */  { "warning", "attcnt",  "XBCView.Error",                         "no numeric attributes",                  0 },  /* E_DATA     -8 */  { "warning", "data",    "XBCView.Error",                         "a classifier must be loaded first",      0 },  /* E_INIT     -9 */  { "error",   "init",    "XBCView.Error",                         "initialization failed",                  0 },  /* E_WIDGET  -10 */  { "error",   "widget",  "XBCView.Error",                         "widget creation failed",                 0 },  /* E_DIALOG  -11 */  { "warning", "dialog",  "XBCView.Warning",                         "cannot create dialog box",               0 },  /* E_COLOR   -12 */  { "warning", "color",   "XBCView.Warning",                         "color allocation failed",                0 },  /* E_GRAPH   -13 */  { "error",   "gc",      "XBCView.Error",                         "cannot create graphics context",         0 },  /*      -14, -15 */  { NULL }, { NULL },  /* E_VALUE   -16 */  { "warning", "value",   "XBCView.Error",                         "file %s, record %d:\n"                           "illegal value %s in field %d",         4 },  /* E_FLDCNT  -17 */  { "warning", "fldcnt",  "XBCView.Error",                         "file %s, record %d:\n"                           "%s%d field(s) instead of %d",          5 },  /* E_EMPFLD  -18 */  { "warning", "empfld",  "XBCView.Error",                         "file %s, record %d:\n"                           "empty name%s in field %d",             4 },  /* E_DUPFLD  -19 */  { "warning", "dupfld",  "XBCView.Error",                         "file %s, record %d:\n"                           "duplicate field name %s",              3 },  /* E_MISFLD  -20 */  { "warning", "misfld",  "XBCView.Error",                         "file %s, record %d:\n"                           "missing field %s",                     3 },  /* E_UNKNOWN -21 */  { "error", "unknown",   "XBCView.Error",                         "unknown error",                          0 }};/*----------------------------------------------------------------------  Global Variables----------------------------------------------------------------------*/static XtAppContext appctx;     /* X11 application context */static Display *display;        /* display connected to */static int     screen;          /* screen of the display */static Window  window;          /* main window */static Atom    wm_delwin;       /* delete window atom of window mgr. */static char    fmt[FMT_MAX];    /* format and buffer for messages */static char    buf[PATH_MAX +FMT_MAX];/* --- main widgets and menu --- */static Widget  w_top;           /* top level widget */static Widget  w_main;          /* main window widget */static Widget  w_view;          /* viewport widget */static MENU    *menu;           /* pull down menu */static GC      gc;              /* graphics context for drawing *//* --- property sheets --- */static PSHEET  *psh_fmt   = NULL;  /* data format */static PSHEET  *psh_color = NULL;  /* color settings */static PSHEET  *psh_marks = NULL;  /* marker settings *//* --- dialog box widgets --- */static Widget  db_atts  = NULL; /* 'Attributes...' dialog box */static Widget  di_h_att;        /* attribute list for horizontal */static Widget  di_h_min;        /* input gadgets for minimal */static Widget  di_h_max;        /* and maximal horizontal value */static Widget  di_v_att;        /* attribute list for vertical */static Widget  di_v_min;        /* input gadgets for minimal */static Widget  di_v_max;        /* and maximal vertical value *//* --- color and marker information --- */static PIXEL   black;           /* black, white, and grey */static PIXEL   white;           /* for markers on colored shades */static PIXEL   grey;static SHADES  *shades  = NULL; /* color shades for normal dists. */static SHADES  *datcols = NULL; /* colors for data points/markers */static int     mrkflgs  = 0x73; /* flags for markers */static int     mrksize  = 6;    /* size of data markers */static struct {                 /* --- color information --- */  int    dist;                  /* distribution type */  int    shdbase;               /* shade base */  int    shdcnt;                /* number of shades */  int    colcnt;                /* number of colors */  double coloff;                /* color offset (in degrees) */  double ndwgt;                 /* weight of normal distribution */  double cowgt;                 /* complement of this weight */} colinfo = { DT_PROB, SHD_WHITE, 32, 1, 0.0, 0.8, 0.2 };/*----------------------------------------------------------------------  Error Reporting Functions----------------------------------------------------------------------*/static void dcb_nop (Widget widget, XtPointer client, XtPointer call){                               /* --- close dialog box (callback) */  while (!XtIsTransientShell(widget))    widget = XtParent(widget);  /* find the shell widget */  XtPopdown(widget);            /* close dialog box */  mn_enable(menu, MN_MENU, 1);  /* and enable menu bar */}  /* dcb_nop() *//*--------------------------------------------------------------------*/static void error (int code, ...){                               /* --- print error message */  va_list      va;              /* list of variable arguments */  const ERRMSG *msg;            /* error message */  String       argv[8];         /* variable argument vector */  Cardinal     argc;            /* number of arguments */

⌨️ 快捷键说明

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