Annotation of researchv10no/cmd/dag/dag.h, revision 1.1.1.1

1.1       root        1: typedef int boolean;
                      2: const boolean true = 1;
                      3: const boolean false = 0;
                      4: 
                      5: struct dag_label_t {
                      6:        int                     type;   // STRING or DESC or 0 (no label)
                      7:        char*           value;  // macro name or drawing code
                      8: 
                      9:        dag_label_t(int intype,char *invalue) {
                     10:                type    =       intype;
                     11:                value   =       invalue;
                     12:        }
                     13:        dag_label_t()   {
                     14:                type    =       0;
                     15:                value   =       0;
                     16:        }
                     17: };
                     18: 
                     19: enum shape_id_t        {Box,Square,Diamond,Circle,Doublecircle,Ellipse,Plaintext,User_defined};
                     20: 
                     21: struct shape_t {
                     22:        int                     type;           // STRING or DESC
                     23:        char*           value;          // ascii name
                     24:        boolean         predefined;     // built-in type
                     25:        shape_id_t      shape_id;       // if predefined, else is clipping shape_id
                     26: 
                     27:        shape_t(int intype, char* invalue);
                     28:        boolean is_fixed_aspect_ratio();
                     29: };
                     30: 
                     31: enum   dag_ink_t       {solid_ink,dashed_ink,dotted_ink,invis_ink};
                     32: 
                     33: struct DAG_edge_t : public edge_t {
                     34:        char*           color;
                     35:        dag_label_t     label;          // label to put on the edge
                     36:        int                     pointsize;
                     37:        int                     flipped;        // true means backedge
                     38:        dag_ink_t       ink;            // solid_ink, ...
                     39: 
                     40:        DAG_edge_t();
                     41:        DAG_edge_t*     nextof() {return (DAG_edge_t*) next;}
                     42:        void            setlabel(int intype, char *invalue);
                     43:        void            setcolor(char* color);
                     44:        void            setweight(int inweight);
                     45:        void            setink(dag_ink_t inink);
                     46:        void            setpointsize(int inpointsize);
                     47: };
                     48: 
                     49: struct DAG_node_t : public node_t {
                     50:        int                     pointsize;
                     51:        dag_label_t     label;
                     52:        shape_t         shape;
                     53:        char*           color;
                     54:        int                     xsize;  // note: these do not depend on orientation,
                     55:        int                     ysize;  //  but the width and height in node_t do.
                     56: 
                     57:        void            autosize();
                     58:        void            sethw();
                     59: 
                     60:        DAG_node_t();
                     61:        void            setname(char *invalue);
                     62:        void            setshape(int intype, char* invalue);
                     63:        void            setcolor(char *incolor);
                     64:        void            setlabel(int intype, char* invalue);
                     65:        void            setxsize(int inxsize);
                     66:        void            setysize(int inysize);
                     67:        void            setpointsize(int inpointsize);
                     68: };
                     69: 
                     70: enum output_lang_t     {Pic,Postscript,Graphdraw,Cip};
                     71: 
                     72: struct user_info_t {
                     73:        double          height,width;
                     74:        boolean         rotated;
                     75: 
                     76:        user_info_t() {
                     77:                height = width = 0.0;
                     78:                rotated = false;
                     79:        }
                     80:        void set_rotate()       {rotated = true;}
                     81:        void set_size(double w, double h) {
                     82:                 width = w; height = h;
                     83:        }
                     84: };
                     85: 
                     86: struct Infile {
                     87:        FILE    *fp;
                     88:        int     line_number;
                     89:        char    *name;
                     90: 
                     91:        Infile() {
                     92:                name = strcpy(new char[2],"-");
                     93:                line_number = 0;
                     94:                fp = stdin;
                     95:        }
                     96:        Infile(char *p) {
                     97:                name = strcpy(new char[strlen(p)+1],p);
                     98:                line_number = 0;
                     99:                fp = fopen(name,"r");
                    100:        }
                    101:        char *gets(char*,int);
                    102: };
                    103: 
                    104: struct pair_t {
                    105:        int                     node;
                    106:        pair_t          *next;
                    107: 
                    108:        pair_t  (int in_node, pair_t *in_next) {
                    109:                        node = in_node;
                    110:                        next = in_next;
                    111:        }
                    112: };
                    113: 
                    114: /* --- front end --- */
                    115: extern const int Resolution;   // points per virtual inch
                    116: extern const double IPP;       // real inches per point of type (NOT Resolution!)
                    117: extern const double Pi;
                    118: 
                    119: class shared_string_t {
                    120:        shared_string_t *next;
                    121:        char data[1];   // dynamic
                    122:        friend char* newstring(char*);
                    123:        friend void freestrings();
                    124: };
                    125: extern shared_string_t *shared_string_pool;
                    126: 
                    127: extern Infile          Current_file;
                    128: extern boolean         Uselib;         // use standard DAG graphics library
                    129: extern char*           Lib_path;       // library directory
                    130: extern int                     N;
                    131: #define Init_extent    256
                    132: extern int                     Extent;
                    133: extern DAG_node_t      **Node;
                    134: extern DAG_edge_t      **Edge;
                    135: extern user_info_t     User;
                    136: extern options_t       Options;
                    137: extern char*           Cmd_name;
                    138: extern output_lang_t   Output_type;
                    139: extern int                     Xmax,Ymax;
                    140: extern Point           Page_size;
                    141: extern Point           Margin;
                    142: 
                    143: /* parser */
                    144: extern int                     Syntax_error;
                    145: extern DAG_node_t      Reset_node,Default_node;
                    146: extern DAG_edge_t      Reset_edge,Default_edge;
                    147: int                                    yyparse();
                    148: int                                    yylex();
                    149: void                           yyerror(char*s,char *s1="", char* s2="", char *s3="", char *s4="");
                    150: 
                    151: /* code generation */
                    152: void                           make_drawing();
                    153: void                           emit_pic();
                    154: void                           emit_ps();
                    155: void                           emit_graphdraw();
                    156: Point                          find_edge_midpoint(DAG_edge_t *e);
                    157: Point                          find_nodeport(int node, Point p0, Point p1);
                    158: void                           cat_libfile(char*);
                    159: void                           unsquirrel();
                    160: 
                    161: /* util */
                    162: Infile                         nextfile(char** &argv);
                    163: void                           reclaim_hashtable();
                    164: void                           set_output_type(char*);
                    165: void                           set_page_size(char*);
                    166: options_t                      reset_options();
                    167: void                           set_bounds(double,double);
                    168: int                                    node_lookup(char*);
                    169: 
                    170: void                           dumpgraph();
                    171: 
                    172: /* useful inline functions */
                    173: overload sign;
                    174: static inline int sign (int i) {return (i == 0? 0 : (i > 0 ? 1: - 1));}
                    175: static inline int sign (double i) {return (i == 0? 0 : (i > 0 ? 1: - 1));}
                    176: static inline double inchof(int i) { return (double)i / Resolution; }
                    177: static inline double distance(double x1, double y1, double x2, double y2)
                    178:        {return sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));}
                    179: static inline int between (int i1, int i2, int i3) {
                    180:        return ((i1 <= i2) && (i2 <= i3)) || ((i1 >= i2) && (i2 >= i3));
                    181: }
                    182: static inline int round(double d) { return( d > 0 ? (int)(d + .5) : (int)(d - .5)); }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.