home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume19 / xfig / part07 / object.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-27  |  8.7 KB  |  350 lines

  1. /*
  2.  * FIG : Facility for Interactive Generation of figures
  3.  * Copyright (c) 1985 by Supoj Sutanthavibul
  4.  *
  5.  * "Permission to use, copy, modify, distribute, and sell this software and its
  6.  * documentation for any purpose is hereby granted without fee, provided that
  7.  * the above copyright notice appear in all copies and that both the copyright
  8.  * notice and this permission notice appear in supporting documentation. 
  9.  * No representations are made about the suitability of this software for 
  10.  * any purpose.  It is provided "as is" without express or implied warranty."
  11.  */
  12.  
  13. #define        DEFAULT              (-1)
  14. #define        SOLID_LINE        0
  15. #define        DASH_LINE        1
  16. #define        DOTTED_LINE        2
  17. #define        RUBBER_LINE        3
  18. #define        PANEL_LINE        4
  19.  
  20. #define        Color            int
  21.  
  22. #define        BLACK            0
  23. #define        WHITE            7
  24.  
  25. typedef struct f_pattern {
  26.     int            w, h;
  27.     int           *p;
  28. }
  29.         F_pattern;
  30.  
  31. typedef struct f_point {
  32.     int            x, y;
  33.     struct f_point *next;
  34. }
  35.         F_point;
  36.  
  37. typedef struct f_pos {
  38.     int            x, y;
  39. }
  40.         F_pos;
  41.  
  42. typedef struct f_arrow {
  43.     int            type;
  44.     int            style;
  45.     float        thickness;
  46.     float        wid;
  47.     float        ht;
  48. }
  49.         F_arrow;
  50.  
  51. typedef struct f_ellipse {
  52.     int            tagged;
  53.     int            type;
  54. #define                    T_ELLIPSE_BY_RAD    1
  55. #define                    T_ELLIPSE_BY_DIA    2
  56. #define                    T_CIRCLE_BY_RAD        3
  57. #define                    T_CIRCLE_BY_DIA        4
  58.     int            style;
  59.     int            thickness;
  60.     Color        color;
  61.     int            depth;
  62.     int            direction;
  63.     float        style_val;
  64.     float        angle;
  65.     int            pen;
  66.     int            fill_style;
  67. #define                    UNFILLED    0
  68. #define                    WHITE_FILL    1
  69. #define                    BLACK_FILL    21
  70.     struct f_pos    center;
  71.     struct f_pos    radiuses;
  72.     struct f_pos    start;
  73.     struct f_pos    end;
  74.     struct f_ellipse *next;
  75. }
  76.         F_ellipse;
  77.  
  78. typedef struct f_arc {
  79.     int            tagged;
  80.     int            type;
  81. #define                    T_3_POINTS_ARC        1
  82.     int            style;
  83.     int            thickness;
  84.     Color        color;
  85.     int            depth;
  86.     int            pen;
  87.     int            fill_style;
  88.     float        style_val;
  89.     int            direction;
  90.     struct f_arrow *for_arrow;
  91.     struct f_arrow *back_arrow;
  92.     struct {
  93.     float        x, y;
  94.     }            center;
  95.     struct f_pos    point[3];
  96.     struct f_arc   *next;
  97. }
  98.         F_arc;
  99.  
  100. #define        CLOSED_PATH        0
  101. #define        OPEN_PATH        1
  102. #define        DEF_BOXRADIUS        7
  103. #define        DEF_DASHLENGTH        4
  104. #define        DEF_DOTGAP        3
  105.  
  106. typedef struct f_eps {
  107.     char        file[PATH_MAX];
  108.     int            flipped;
  109.     unsigned char  *bitmap;
  110.     float        hw_ratio;
  111.     int            size_x, size_y;
  112.     struct f_pos    bit_size;
  113.     Pixmap        pixmap;
  114.     int            pix_rotation, pix_width, pix_height, pix_flipped;
  115. }
  116.         F_eps;
  117.  
  118. extern char    EMPTY_EPS[];
  119.  
  120. typedef struct f_line {
  121.     int            tagged;
  122.     int            type;
  123. #define                    T_POLYLINE    1
  124. #define                    T_BOX        2
  125. #define                    T_POLYGON    3
  126. #define                    T_ARC_BOX    4
  127. #define                    T_EPS_BOX    5
  128.     int            style;
  129.     int            thickness;
  130.     Color        color;
  131.     int            depth;
  132.     float        style_val;
  133.     int            pen;
  134.     int            fill_style;
  135.     int            radius;    /* corner radius for T_ARC_BOX */
  136.     struct f_arrow *for_arrow;
  137.     struct f_arrow *back_arrow;
  138.     struct f_point *points;
  139.     struct f_eps   *eps;
  140.     struct f_line  *next;
  141. }
  142.         F_line;
  143.  
  144. typedef struct f_text {
  145.     int            tagged;
  146.     int            type;
  147. #define                    T_LEFT_JUSTIFIED    0
  148. #define                    T_CENTER_JUSTIFIED    1
  149. #define                    T_RIGHT_JUSTIFIED    2
  150.     int            font;
  151.     PIX_ROT_FONT    fontstruct;
  152.     int            size;    /* point size */
  153.     Color        color;
  154.     int            depth;
  155.     float        angle;    /* in radian */
  156.  
  157.     int            flags;
  158. #define                    RIGID_TEXT        1
  159. #define                    SPECIAL_TEXT        2
  160. #define                    PSFONT_TEXT        4
  161. #define                    HIDDEN_TEXT        8
  162.  
  163.     int            height;    /* pixels */
  164.     int            length;    /* pixels */
  165.     int            base_x;
  166.     int            base_y;
  167.     int            pen;
  168.     char       *cstring;
  169.     struct f_text  *next;
  170. }
  171.         F_text;
  172.  
  173. #define MAXFONT(T) (psfont_text(T) ? NUM_PS_FONTS : NUM_LATEX_FONTS)
  174.  
  175. #define        rigid_text(t) \
  176.             (t->flags == DEFAULT \
  177.                 || (t->flags & RIGID_TEXT))
  178.  
  179. #define        special_text(t) \
  180.             ((t->flags != DEFAULT \
  181.                 && (t->flags & SPECIAL_TEXT)))
  182.  
  183. #define        psfont_text(t) \
  184.             (t->flags != DEFAULT \
  185.                 && (t->flags & PSFONT_TEXT))
  186.  
  187. #define        hidden_text(t) \
  188.             (t->flags != DEFAULT \
  189.                 && (t->flags & HIDDEN_TEXT))
  190.  
  191. #define        text_length(t) \
  192.             (hidden_text(t) ? hidden_text_length : t->length)
  193.  
  194. #define        using_ps    (cur_textflags & PSFONT_TEXT)
  195.  
  196. typedef struct f_control {
  197.     float        lx, ly, rx, ry;
  198.     struct f_control *next;
  199. }
  200.         F_control;
  201.  
  202. #define        int_spline(s)        (s->type & 0x2)
  203. #define        normal_spline(s)    (!(s->type & 0x2))
  204. #define        closed_spline(s)    (s->type & 0x1)
  205. #define        open_spline(s)        (!(s->type & 0x1))
  206.  
  207. typedef struct f_spline {
  208.     int            tagged;
  209.     int            type;
  210. #define                    T_OPEN_NORMAL    0
  211. #define                    T_CLOSED_NORMAL 1
  212. #define                    T_OPEN_INTERP    2
  213. #define                    T_CLOSED_INTERP 3
  214.     int            style;
  215.     int            thickness;
  216.     Color        color;
  217.     int            depth;
  218.     float        style_val;
  219.     int            pen;
  220.     int            fill_style;
  221.     struct f_arrow *for_arrow;
  222.     struct f_arrow *back_arrow;
  223.     /*
  224.      * For T_OPEN_NORMAL and T_CLOSED_NORMAL points are control points while
  225.      * they are knots for T_OPEN_INTERP and T_CLOSED_INTERP whose control
  226.      * points are stored in controls.
  227.      */
  228.     struct f_point *points;
  229.     struct f_control *controls;
  230.     struct f_spline *next;
  231. }
  232.         F_spline;
  233.  
  234. typedef struct f_compound {
  235.     int            tagged;
  236.     struct f_pos    nwcorner;
  237.     struct f_pos    secorner;
  238.     struct f_line  *lines;
  239.     struct f_ellipse *ellipses;
  240.     struct f_spline *splines;
  241.     struct f_text  *texts;
  242.     struct f_arc   *arcs;
  243.     struct f_compound *compounds;
  244.     struct f_compound *next;
  245. }
  246.         F_compound;
  247.  
  248. typedef struct f_linkinfo {
  249.     struct f_line  *line;
  250.     struct f_point *endpt;
  251.     struct f_point *prevpt;
  252.     int            two_pts;
  253.     struct f_linkinfo *next;
  254. }
  255.         F_linkinfo;
  256.  
  257. #define        ARROW_SIZE        sizeof(struct f_arrow)
  258. #define        POINT_SIZE        sizeof(struct f_point)
  259. #define        CONTROL_SIZE        sizeof(struct f_control)
  260. #define        ELLOBJ_SIZE        sizeof(struct f_ellipse)
  261. #define        ARCOBJ_SIZE        sizeof(struct f_arc)
  262. #define        LINOBJ_SIZE        sizeof(struct f_line)
  263. #define        TEXOBJ_SIZE        sizeof(struct f_text)
  264. #define        SPLOBJ_SIZE        sizeof(struct f_spline)
  265. #define        COMOBJ_SIZE        sizeof(struct f_compound)
  266. #define        EPS_SIZE        sizeof(struct f_eps)
  267. #define        LINKINFO_SIZE        sizeof(struct f_linkinfo)
  268.  
  269. /**********************  object codes  **********************/
  270.  
  271. #define        O_ELLIPSE        1
  272. #define        O_POLYLINE        2
  273. #define        O_SPLINE        3
  274. #define        O_TEXT            4
  275. #define        O_ARC            5
  276. #define        O_COMPOUND        6
  277. #define        O_END_COMPOUND        -O_COMPOUND
  278. #define        O_ALL_OBJECT        99
  279.  
  280. /********************* object masks for update  ************************/
  281.  
  282. #define M_NONE            0x000
  283. #define M_POLYLINE_POLYGON    0x001
  284. #define M_POLYLINE_LINE        0x002
  285. #define M_POLYLINE_BOX        0x004    /* includes ARCBOX */
  286. #define M_SPLINE_O_NORMAL    0x008
  287. #define M_SPLINE_C_NORMAL    0x010
  288. #define M_SPLINE_O_INTERP    0x020
  289. #define M_SPLINE_C_INTERP    0x040
  290. #define M_TEXT_NORMAL        0x080
  291. #define M_TEXT_HIDDEN        0x100
  292. #define M_ARC            0x200
  293. #define M_ELLIPSE        0x400
  294. #define M_COMPOUND        0x800
  295.  
  296. #define M_TEXT        (M_TEXT_HIDDEN | M_TEXT_NORMAL)
  297. #define M_SPLINE_O    (M_SPLINE_O_NORMAL | M_SPLINE_O_INTERP)
  298. #define M_SPLINE_C    (M_SPLINE_C_NORMAL | M_SPLINE_C_INTERP)
  299. #define M_SPLINE_NORMAL (M_SPLINE_O_NORMAL | M_SPLINE_C_NORMAL)
  300. #define M_SPLINE_INTERP (M_SPLINE_O_INTERP | M_SPLINE_C_INTERP)
  301. #define M_SPLINE    (M_SPLINE_NORMAL | M_SPLINE_INTERP)
  302. #define M_POLYLINE    (M_POLYLINE_LINE | M_POLYLINE_POLYGON | M_POLYLINE_BOX)
  303. #define M_VARPTS_OBJECT (M_POLYLINE_LINE | M_POLYLINE_POLYGON | M_SPLINE)
  304. #define M_OPEN_OBJECT    (M_POLYLINE_LINE | M_SPLINE_O | M_ARC)
  305. #define M_ROTATE_ANGLE    (M_VARPTS_OBJECT | M_ARC | M_TEXT | M_COMPOUND | M_ELLIPSE)
  306. #define M_ELLTEXTANGLE    (M_ELLIPSE | M_TEXT)
  307. #define M_OBJECT    (M_ELLIPSE | M_POLYLINE | M_SPLINE | M_TEXT | M_ARC)
  308. #define M_NO_TEXT    (M_ELLIPSE | M_POLYLINE | M_SPLINE | M_COMPOUND | M_ARC)
  309. #define M_ALL        (M_OBJECT | M_COMPOUND)
  310.  
  311. /************************  Objects  **********************/
  312.  
  313. extern F_compound objects;
  314.  
  315. /************  global working pointers ************/
  316.  
  317. extern F_line  *cur_l, *new_l, *old_l;
  318. extern F_arc   *cur_a, *new_a, *old_a;
  319. extern F_ellipse *cur_e, *new_e, *old_e;
  320. extern F_text  *cur_t, *new_t, *old_t;
  321. extern F_spline *cur_s, *new_s, *old_s;
  322. extern F_compound *cur_c, *new_c, *old_c;
  323. extern F_point *first_point, *cur_point;
  324. extern F_linkinfo *cur_links;
  325.  
  326. /*************** object attribute settings ***********/
  327.  
  328. /*  Lines  */
  329. extern int    cur_linewidth;
  330. extern int    cur_linestyle;
  331. extern float    cur_dashlength;
  332. extern float    cur_dotgap;
  333. extern float    cur_styleval;
  334. extern int    pen_size;
  335. extern int    pen_type;
  336. extern Color    cur_color;
  337. extern int    cur_boxradius;
  338. extern int    cur_fillstyle;
  339. extern int    cur_arrowmode;
  340.  
  341. /* Text */
  342. extern int    cur_fontsize;    /* font size */
  343. extern int    cur_latex_font;
  344. extern int    cur_ps_font;
  345. extern int    cur_textjust;
  346. extern int    cur_textflags;
  347.  
  348. /* Misc */
  349. extern float    cur_elltextangle;
  350.