home *** CD-ROM | disk | FTP | other *** search
- #ifndef lint
- static char *SccsId = "@(#)VOdebug.c V1.19 3/13/95";
- #endif
-
- /*
- | file name -- VOdebug.c
- |===================================================================
- |
- | copyright (c) 1984, V. I. Corporation
- |
- | VOdebug - Checks object counts and statistics
- |
- | alan c morse 27 May 87 With much stuff from
- | C Goldensher's debug.c
- | chris hoffmann 16 mar 92 Add image/icon/pixmap stuff.
- |
- |===================================================================
- |
- | Module description/function:
- | General VO debug and statistics routines for use in testing
- | DV-Tools programs.
- |
- | ------------------------------------------------------------------
- | Module contents:
- | Function Name Description
- | ------------- -------------------------------
- | VOdbgCounts Prints the numbers of each type of object.
- | VOdbgObPts Prints control points of an object.
- | VOdbgOb Prints a description of the object
- | VOdbgDqList Prints contents of a deque
- | VOdbgAttr Prints contents of attributes structure
- |
- |====================================================================
- */
- #include "std.h"
- #include "dvstd.h"
- #include "VOstd.h"
- #include "GRfundecl.h"
- #include "VOfundecl.h"
- #include "VUfundecl.h"
-
- /***************** Begin Function Declarations *************/
- LOCAL void PrintCount V_P_ ((char *ObjectName, LONG count, LONG *oldcountp));
- /***************** End Function Declarations *************/
-
-
- /*===================================================================
- |
- | VOdbgCounts
- | Prints out the numbers of each kind of VO object.
- | For each object it also prints the change in the number for
- | that object from the last time it was called.
- */
- LONG arCount = 0, ciCount = 0, dqCount = 0, dgCount = 0, drCount = 0, elCount = 0,
- hpCount = 0, inCount = 0, itCount = 0, lnCount = 0, loCount = 0,
- ptCount = 0, pyCount = 0, reCount = 0, sdCount = 0, txCount = 0,
- ttCount = 0, vdCount = 0, vpCount = 0, xfCount = 0, vtCount = 0,
- stCount = 0, skCount = 0, ruCount = 0, acCount = 0, dyCount = 0,
- edCount = 0, noCount = 0, icCount = 0, imCount = 0, pmCount = 0,
- sfCount = 0;
-
- LOCAL void
- PrintCount (ObjectName, count, oldcountp)
- char *ObjectName;
- LONG count;
- LONG *oldcountp;
-
- /*------ Original comments: ----*/
- #if 0
- LOCAL VOID PrintCount (ObjectName, count, oldcountp)
- CHAR *ObjectName; /* Name of the object */
- LONG count; /* Current number of objects of this type */
- LONG *oldcountp; /* Address of where old count is stored */
- #endif
- /*---- Original comments ----*/
-
- {
- S_PRINTF (ObjectName);
- S_PRINTF (":%-5d", (int)count);
- if (*oldcountp > count)
- S_PRINTF ("-%-5d ", (INT) (*oldcountp - count));
- else if (*oldcountp == count)
- S_PRINTF ("+0 ");
- else /* *oldcountp < count ) */
- S_PRINTF ("+%-5d ", (INT) (count - *oldcountp));
- *oldcountp = count;
- }
-
- void
- VOdbgCounts ()
- {
- PrintCount ("ar", VOarStatistic (OBJECT_COUNT), &arCount);
- PrintCount ("ci", VOciStatistic (OBJECT_COUNT), &ciCount);
- PrintCount ("dg", VOdgStatistic (OBJECT_COUNT), &dgCount);
- PrintCount ("dq", VOdqStatistic (OBJECT_COUNT), &dqCount);
- PrintCount ("dr", VOdrStatistic (OBJECT_COUNT), &drCount);
- PrintCount ("dy", VOdyStatistic (OBJECT_COUNT), &dyCount);
- S_PUTCHAR ('\n');
- PrintCount ("ed", VOedStatistic (OBJECT_COUNT), &edCount);
- PrintCount ("el", VOelStatistic (OBJECT_COUNT), &elCount);
- PrintCount ("hp", VOhpStatistic (OBJECT_COUNT), &hpCount);
- PrintCount ("ic", VOicStatistic (OBJECT_COUNT), &icCount);
- PrintCount ("im", VOimStatistic (OBJECT_COUNT), &imCount);
- PrintCount ("in", VOinStatistic (OBJECT_COUNT), &inCount);
- PrintCount ("it", VOitStatistic (OBJECT_COUNT), &itCount);
- S_PUTCHAR ('\n');
- PrintCount ("ln", VOlnStatistic (OBJECT_COUNT), &lnCount);
- PrintCount ("lo", VOloStatistic (OBJECT_COUNT), &loCount);
- PrintCount ("no", VOnoStatistic (OBJECT_COUNT), &noCount);
- PrintCount ("pm", VOpmStatistic (OBJECT_COUNT), &pmCount);
- PrintCount ("pt", VOptStatistic (OBJECT_COUNT), &ptCount);
- PrintCount ("py", VOpyStatistic (OBJECT_COUNT), &pyCount);
- S_PUTCHAR ('\n');
- PrintCount ("re", VOreStatistic (OBJECT_COUNT), &reCount);
- PrintCount ("ru", VOruStatistic (OBJECT_COUNT), &ruCount);
- PrintCount ("sd", VOsdStatistic (OBJECT_COUNT), &sdCount);
- PrintCount ("sk", VOskStatistic (OBJECT_COUNT), &skCount);
- PrintCount ("st", VOstStatistic (OBJECT_COUNT), &stCount);
- PrintCount ("tt", VOttStatistic (OBJECT_COUNT), &ttCount);
- S_PUTCHAR ('\n');
- PrintCount ("tx", VOtxStatistic (OBJECT_COUNT), &txCount);
- PrintCount ("vd", VOvdStatistic (OBJECT_COUNT), &vdCount);
- PrintCount ("vp", VOvpStatistic (OBJECT_COUNT), &vpCount);
- PrintCount ("vt", VOvtStatistic (OBJECT_COUNT), &vtCount);
- PrintCount ("xf", VOxfStatistic (OBJECT_COUNT), &xfCount);
- PrintCount ("sf", VOsfStatistic (OBJECT_COUNT), &sfCount);
- S_PUTCHAR ('\n');
- /*PrintCount( "ac", VOacStatistic(OBJECT_COUNT), &acCount );*/
- }
-
- /*=============================================================
- |
- | VOdbgObPts:
- | Print the control points for the given object.
- | Returns the number of control points in the object.
- */
- int
- VOdbgObPts (obj)
- OBJECT obj;
- {
- INT numpts, i;
-
- (VOID) S_PRINTF ("object: 0x%x\n", (unsigned)obj);
-
- if (!VOobValid (obj))
- {
- (VOID) S_PRINTF ("\tinvalid object\n");
- return (0);
- }
- else
- {
- numpts = (INT) VOobPtGet (obj, 0);
- for (i = 1; i <= numpts; ++i)
- {
- OBJECT point;
- DV_POINT wcs_pt, offset;
-
- point = VOobPtGet (obj, i);
- VOptGet (point, &wcs_pt, &offset);
- (VOID) S_PRINTF ("\tpoint %d:", i);
- (VOID) S_PRINTF ("(%d,%d)", (int)wcs_pt.x, (int)wcs_pt.y);
- (VOID) S_PRINTF (" offset(%d,%d)\n", (int)offset.x, (int)offset.y);
- }
- return (numpts);
- }
- }
-
- /*=============================================================
- |
- | VOdbgDqList
- | List useful information about each object in the deque
- */
- int
- VOdbgDqList (deque)
- OBJECT deque;
- {
-
- if (VOdqValid (deque))
- {
- VOdqTraverse (deque, (VOOBTRAVERSEFUN) VOdbgOb, NULL);
- return (VOdqSize (deque));
- }
- else
- return (-1);
- }
-
- /*=============================================================
- |
- | VOdbgAttr
- | Prints Attributes data structure.
- */
- void
- VOdbgAttr (attr)
- ATTRIBUTES *attr;
- {
- if (attr->foreground_color != EMPTY_FIELD)
- (VOID) S_PRINTF ("\tforeground: 0x%lx",
- attr->foreground_color);
-
- if (attr->background_color != EMPTY_FIELD)
- (VOID) S_PRINTF ("\tbackground: 0x%lx",
- attr->background_color);
-
- if (attr->line_width != EMPTY_FIELD)
- (VOID) S_PRINTF ("\n\tline width: %d", attr->line_width);
-
- if (attr->line_type != EMPTY_FIELD)
- (VOID) S_PRINTF ("\ttype: %d\n", attr->line_type);
-
- if (attr->fill_status != EMPTY_FIELD)
- if (attr->fill_status == FILLED_OBJECT)
- (VOID) S_PRINTF ("\tfilled");
- else
- (VOID) S_PRINTF ("\tnot filled");
-
- if (attr->text_direction != EMPTY_FIELD)
- if (attr->text_direction == VERTICAL_TEXT)
- (VOID) S_PRINTF ("\n\tvertical");
- else
- (VOID) S_PRINTF ("\n\thorizontal");
-
- if (attr->text_position != EMPTY_FIELD)
- {
- DV_BOOL centered = NO;
-
- S_PUTCHAR ('\t');
-
- if (attr->text_position & AT_TOP_EDGE)
- (VOID) S_PRINTF ("Top ");
- else if (attr->text_position & AT_BOTTOM_EDGE)
- (VOID) S_PRINTF ("Bottom ");
- else
- centered = YES;
-
- if (attr->text_position & AT_LEFT_EDGE)
- (VOID) S_PRINTF ("Left ");
- else if (attr->text_position & AT_RIGHT_EDGE)
- (VOID) S_PRINTF ("Right ");
- else
- centered = YES;
-
- if (centered)
- (VOID) S_PRINTF ("Center justified");
- else
- (VOID) S_PRINTF ("justified");
- }
-
- if (attr->text_font != EMPTY_FIELD)
- (VOID) S_PRINTF ("\tfont: %d", attr->text_font);
-
- if (attr->text_size != EMPTY_FIELD)
- (VOID) S_PRINTF ("\tsize: %d", attr->text_size);
-
- if (attr->arc_direction != EMPTY_FIELD)
- if (attr->arc_direction == COUNTER_CLOCKWISE)
- (VOID) S_PRINTF ("\n\tcounter-clockwise");
- else
- (VOID) S_PRINTF ("\n\tclockwise");
-
- if (attr->curve_type != EMPTY_FIELD)
- if (attr->curve_type == CLOSED_ENDS)
- (VOID) S_PRINTF ("\n\tclosed end conditions");
- else if (attr->curve_type == OPEN_ENDS)
- (VOID) S_PRINTF ("\n\topen end conditions");
- else if (attr->curve_type == FLOATING_ENDS)
- (VOID) S_PRINTF ("\n\tfloating end conditions");
-
- S_PUTCHAR ('\n');
- }
-
- /*=============================================================
- |
- | VOdbgOb
- | Prints statistics about the specified object
- */
-
- #define S_UNKNOWN_TYPE "UNKNOWN TYPE"
- #define S_UNLISTED_TYPE "UNLISTED TYPE"
- #define S_HIGHEST_LISTED_TYPE 37
- LOCAL CHAR *obj_type[]=
- {
- "NOT_AN_OBJECT", /* 0 */
- "ARC", /* 1 */
- "PIXMAP", /* 2 */
- "CIRCLE", /* 3 */
- "COLOR", /* 4 */
- "IMAGE", /* 5 */
- "DATASOURCE", /* 6 */
- "DEQUE", /* 7 */
- "DG", /* 8 */
- "DRAWING", /* 9 */
- "HEAP", /* 10 */
- "LINE", /* 11 */
- "LOCATION", /* 12 */
- "ICON", /* 13 */
- "PARAMETER", /* 14 */
- "DV_POINT", /* 15 */
- "POLYGON", /* 16 */
- "RECTANGLE", /* 17 */
- "RGB", /* 18 */
- "SCREEN", /* 19 */
- "STREAM", /* 20 */
- "SUBDRAWING", /* 21 */
- "DV_TEXT", /* 22 */
- "THRESHTABLE", /* 23 */
- "VD", /* 24 */
- "VIEWPORT", /* 25 */
- "XFORM", /* 26 */
- "INPUT", /* 27 */
- "INPUT_TECHNIQUE", /* 28 */
- "VECTOR_TEXT", /* 29 */
- "EDGE", /* 30 */
- "NODE", /* 31 */
- "ELLIPSE", /* 32 */
- "SLOTKEY", /* 33 */
- "SLOTTABLE", /* 34 */
- "ACTION", /* 35 */
- "RULE", /* 36 */
- "DYNAMIC" /* 37 */
- };
-
-
- BOOLPARAM
- VOdbgOb (obj)
- OBJECT obj;
- {
- INT type; /* type of object */
- CHAR *s_type;
- LONG index; /* Color index */
- INT r, g, b; /* Color red, green, and blue components */
- INT n;
- FLOAT matrix[3][3];
-
- type = VOobType (obj);
- if (type < LOWEST_TYPE_CODE || type > S_HIGHEST_LISTED_TYPE)
- {
- if (type > HIGHEST_TYPE_CODE)
- s_type = S_UNLISTED_TYPE;
- else
- s_type = S_UNKNOWN_TYPE;
- }
- else
- s_type = obj_type[type];
-
- (VOID) S_PRINTF ("object: 0x%x", (unsigned)obj);
- if (VOobValid (obj))
- {
- ATTRIBUTES attr;
-
- (VOID) S_PRINTF ("\ttype: %s (%d)\n", s_type, type);
-
- /* print attributes */
- VOobAtGet (obj, &attr); /* get attributes of object */
- VOdbgAttr (&attr);
-
- /* processing specific to each type */
- switch (type)
- {
- case OT_ARC:
- case OT_CIRCLE:
- case OT_ELLIPSE:
- break;
-
- case OT_COLOR:
- case OT_RGB:
- index = VOcoIndex (obj);
- (VOID) S_PRINTF ("\tindex: %ld", index);
- GRindextorgb (index, &r, &g, &b);
- (VOID) S_PRINTF ("\tR:%d G:%d B:%d\n", r, g, b);
- break;
-
- case OT_DATASOURCE:
- break;
-
- case OT_DEQUE:
- (VOID) S_PRINTF ("\nDEQUE length: %d\n", VOdqSize (obj));
- break;
-
- case OT_DG:
- VUdbgDgp (VOdgAddress (obj));
- break;
-
- case OT_DRAWING:
- break;
-
- case OT_HEAP:
- break;
-
- case OT_ICON:
- {
- OBJECT pixmap, mask;
- INT h, w;
-
- VOicGet (obj, V_IC_PIXMAP, &pixmap,
- V_IC_MASK_PIXMAP, &mask,
- V_IC_HEIGHT, &h,
- V_IC_WIDTH, &w,
- V_IC_ATTR_ARGEND);
- (VOID) S_PRINTF ("\tpixmap: 0x%x", (unsigned)pixmap);
- if (mask)
- (VOID) S_PRINTF ("\tmask: 0x%x", (unsigned)mask);
- (VOID) S_PRINTF ("\t size: %dx%d", w, h);
- (VOID) S_PRINTF ("\n");
- }
- break;
-
- case OT_IMAGE:
- {
- OBJECT pixmap, mask;
-
- VOimGet (obj, V_IM_PIXMAP, &pixmap,
- V_IM_MASK_PIXMAP, &mask,
- V_IM_ATTR_ARGEND);
- (VOID) S_PRINTF ("\tpixmap: 0x%x", (unsigned)pixmap);
- if (mask)
- (VOID) S_PRINTF ("\tmask: 0x%x", (unsigned)mask);
- (VOID) S_PRINTF ("\n");
- }
- break;
-
- case OT_INPUT:
- break;
-
- case OT_INPUT_TECHNIQUE:
- break;
-
- case OT_LINE:
- break;
-
- case OT_LOCATION:
- {
- DV_POINT *pt;
-
- pt = VOloScpGet (obj); /* screen coordinates */
- if (pt)
- (VOID) S_PRINTF ("\tscreen coords: (%d,%d)",
- (int)pt->x, (int)pt->y);
- pt = VOloWcpGet (obj); /* world coordinates */
- if (pt)
- (VOID) S_PRINTF ("\tworld coords: (%d,%d)\n",
- (int)pt->x, (int)pt->y);
- else
- S_PRINTF ("\n");
- }
- break;
-
-
- case OT_PARAMETER:
- break;
-
- case OT_PIXMAP:
- {
- INT h, w;
- CHAR *fn;
- DV_BOOL included;
-
- VOpmGet (obj, V_PM_HEIGHT, &h,
- V_PM_WIDTH, &w,
- V_PM_FILENAME, &fn,
- V_PM_INCLUDE_PIXELS, &included,
- V_PM_ATTR_ARGEND);
- (VOID) S_PRINTF ("\tsize: %dx%d pixels", w, h);
- if (included)
- (VOID) S_PRINTF ("\t(included) ");
- else
- (VOID) S_PRINTF ("\t(referenced) ");
- if (fn)
- (VOID) S_PRINTF ("file: %s\n", fn);
-
- }
- break;
-
- case OT_POINT:
- {
- DV_POINT wcs_pt, pix_offset;
-
- VOptGet (obj, &wcs_pt, &pix_offset);
- (VOID) S_PRINTF ("\t(%d,%d)", (int)wcs_pt.x, (int)wcs_pt.y);
- (VOID) S_PRINTF ("\toffset (%d,%d)\n",
- (int)pix_offset.x, (int)pix_offset.y);
- }
- break;
-
- case OT_POLYGON:
- case OT_RECTANGLE:
- case OT_SCREEN:
- case OT_STREAM:
- case OT_SUBDRAWING:
- break;
-
- case OT_TEXT:
- (VOID) S_PRINTF ("\tstring: \"%s\"\n", VOtxGetString (obj));
- break;
-
- case OT_THRESHTABLE:
- break;
-
- case OT_VD:
- VUdbgVdp (VOvdAddress (obj));
- break;
-
- case OT_VIEWPORT:
- break;
-
- case OT_VTEXT:
- (VOID) S_PRINTF ("\tstring: \"%s\"\n", VOvtGetString (obj));
- break;
-
- case OT_SFTEXT:
- (VOID) S_PRINTF ("\tstring: \"%s\"\n", VOsfGetString (obj));
- break;
-
- case OT_XFORM:
- (VOID) S_PRINTF ("\tscale factor: %g\n", VOxfScale (obj));
- VOxfMatGet (obj, matrix);
- for (n = 0; n < 3; n++)
- S_PRINTF ("\tmatrix row%d: %-10g %-10g %-10g\n", n + 1,
- matrix[n][0], matrix[n][1], matrix[n][2]);
- break;
-
- case OT_SLOTTABLE:
- break;
-
- case OT_SLOTKEY:
- break;
-
- case OT_ACTION:
- break;
-
- case OT_RULE:
- break;
-
- case OT_DYNAMIC:
- break;
-
- case OT_NODE:
- break;
-
- case OT_EDGE:
- break;
-
- default:
- (VOID) S_PRINTF (
- "warning: valid object with unknown type\n");
- break;
- }
- }
- else
- (VOID) S_PRINTF ("\tinvalid object\n");
-
- return (NO);
- }
-