Copyright (c) 1992 Mats Bergstr"om. TGIFCRTL a Run-Time Library in C to produce TGIF object files. Ver 1.1 AUTHOR: Mats Bergstr"om, University of Lund, Sweden. mats.bergstrom@kosufy.lu.se ABSTRACT: In many types of plots, machine created data is essential, yet the need for free hand editing is needed. TGIFCRTL is a small and simple run-time library written in ANSI-C to create plots readable by the TGIF programme. The programme TGIF is an interactive X-windows based drawing programme created by William Chia-Wei Cheng. CONTENTS: TGIFCRTL.h Header file for the library. TGIFCRTL.c Source code. TGIFCRTL.license License. *READ*IT*! TGIFCRTL.README This file. TGIFCRTL-TEST.c Simple test file. COMPILATION: Try Your favourite C-compiler: "cc -c TGIFCRTL.c" on Un*x like machines "CC TGIFCRTL" and "GCC TGIFCRTL" works on VMS. The library compiles successfully under the following circumstances: VAX/VMS V5.4-1 VAX C V3.0-031 (with \STANDARD=PORTABLE option) VAX/VMS V5.4-1 GNU GCC V2.2.2 (both with C an C++ options) ULTRIX V4.2 (Rev. 96) ULTRIX RISC C There should be no problem in compiling this library under UNIX. HISTORY: The TGIFCRTL was created after a number of frustrated and unsuccessful attempts to import claimed encapsulated PostScript files, created by various WYSIWYG PC tools, into LaTeX documents. As i had good experience with TGIF and the object files describing pictures used by TGIF are (fairly) simple ASCII text files, the TGIFCRTL was written as a solution to the problem. William Cheng answered may of my questions in a friendly, prompt and most enlightening way. I don't think i would have been able to finish it in twice the time without his help, *Thanks*!!! KNOWN PROBLEMS: Since TGIFCRTL does not involve any X-window routines, the text bounding boxes are faked. The same is true with a few other text attributes. This is no problem _as_long_as_the_file_is_read_by_TGIF_ since TGIF will recalculate these attributes. PRTGIF, however, *relies* on these values and may not perform correct. The solution is to read the file with TGIF, write it back immediately and then use PRTGIF (or even faster: print from within TGIF ;-). The page space upon which TGIFCRTL plots is restricted to the smallest common size of A4 and it's American cousin covers. TGIF seems to have a maximum number of 256 vertices in a polyline or polygon. Exceeding this number may cause trouble. If a polyline of polygon have vertices too close on a (supposed) smooth curve it may look crooked since the resolution is 5/mm (256/"), either recalculate with longer distances or delete points by hand. Please bare in mind that i wrote this in my spare time, THERE IS NO WARRANTY WHAT SO EVER (read the license!). If You find a bug, please drop me a note describing the problem. I'll try to correct it, if and when i can find time for a next verision. USAGE: The library supports all TGIF objects *except* arcs (will come in next version though). In addition to these a special MARKER object can be drawn. This is a composed object used for marking a position on a curve etc. Currently there are two types of markers available: CIRCLE and SQUARE. The graphical objects are divided into four classes: open (polyline), closed (box, oval, rcbox), text and marker. Each of these have a separate graphic state. The graphic state determines line width, line type, fill pattern, text font, marker type etc., for an object to be written on the output file. The header file "TGIFCRTL.h" defines macros for each of the possible parameter values in the "TRset_xxx" functions. If a parameter value is replace by the macro "IGNORE" the corresponding parameter is ignored and not set. The library sets no restriction in number of output files open simultaneously. The library functions may be divided into three types: i, Basic functions such as open and close an output file. ii, Control functions to set graphic states and transformation. iv, Drawing functions to draw objects. All function identifiers use the prefix "TR" (for TgifcRtl) and all but "TRopen" have "TR_FILE *tp" as first argument. Basic functions: TR_FILE * TRopen(char *fnam) Open a new output file. void TRclose(TR_FILE *tp) Close an output file. int TRerr(TR_FILE *tp) Report Error status (not fully implemented). Control functions: void TRset_default(TR_FILE *tp) Set default graphics states and transformation. void TRset_htrans(TR_FILE *tp, Set horizontal transformation. double pmin, min paper coordinate. double pmax, max paper coordinate. double cmin, min coordinate. double cmax) max coordinate. void TRset_vtrans(TR_FILE *tp, Set transformation vertically double pmin, min paper coordinate double pmax, max paper coordinate double cmin, min coordinate. double cmax) max coordinate. void TRset_lock(TR_FILE * tp) Objects are locked. void TRset_unlock(TR_FILE * tp) Objects are unlocked. void TRset_open_line(TR_FILE *tp, Set graphic state for open TRbp_t l_w, Line width TRbp_t l_s, Line style TRbp_t l_t ) Line type void TRset_open_fill(TR_FILE *tp, Set graphic state for open TRbp_t f_c, Fill colour TRbp_t f_p, Fill pattern TRbp_t f_l) Fill line-pattern void TRset_open_arrow(TR_FILE *tp, Set graphic state for open TRbp_t a_t, Arrow type TRbp_t a_s, Arrow style TRbp_t a_w, Arrow width TRbp_t a_h ) Arrow height void TRset_closed_line(TR_FILE *tp, Set Graphic state for closed TRbp_t l_w, Line width TRbp_t l_s, Line style TRbp_t l_t) Line type void TRset_closed_fill(TR_FILE *tp, Set Graphic state for closed TRbp_t f_c, Fill colour TRbp_t f_p, Fill pattern TRbp_t f_l) Fill line-pattern void TRset_closed_rc(TR_FILE *tp, Set Graphic state for closed TRbp_t c_r ) RC Box corner radius void TRset_text_text(TR_FILE *tp, Set graphic state for text. TRbp_t t_f, Text font TRbp_t t_s, Text Style TRbp_t t_a, Text Alignment TRbp_t t_p, Text Point Size TRbp_t t_r) Text Rotation. void TRset_text_fill(TR_FILE *tp, Set graphic state for text. TRbp_t f_c, Fill colour TRbp_t f_p, Fill pattern TRbp_t f_l ) Fill line-pattern void TRset_mark_mark(TR_FILE *tp, Set Graphic state for Markers. TRbp_t m_t, Marker Type TRbp_t m_s ) Marker Size void TRset_mark_line(TR_FILE *tp, Set Graphic state for Markers. TRbp_t l_w, Line width TRbp_t l_s, Line style TRbp_t l_t ) Line type void TRset_mark_fill(TR_FILE *tp, Set Graphic state for Markers. TRbp_t f_c, Fill colour TRbp_t f_p, Fill pattern TRbp_t f_l ) Fill line-pattern void TRset_mark_arrow(TR_FILE *tp, Set Graphic state for Markers. TRbp_t a_t, Arrow type TRbp_t a_s, Arrow style TRbp_t a_w, Arrow width TRbp_t a_h ) Arrow height void TRset_mark_text(TR_FILE *tp, Set Graphic state for Markers. TRbp_t t_f, Text font TRbp_t t_s, Text Style TRbp_t t_a, Text Alignment TRbp_t t_p, Text Point Size TRbp_t t_r ) Text Rotation. void TRpush(TR_FILE *tp) Push/Pop the current graphics void TRpop(TR_FILE *tp) on the graphics stack. TRpc_t TRhtrans(TR_FILE *tp, Return horiz. paper coordinate. double uc ) from user coordinate. TRpc_t TRvtrans(TR_FILE *tp, Return vert. paper coordinate. double uc ) from user coordinate. double TRhmm(TR_FILE *tp, Transform x to x horizonal mm's double x ) double TRvmm(TR_FILE *tp, Transform x to x vertical mm's double x ) double TRhdot(TR_FILE *tp, Transform x to horizonal dots double x ) double TRvdot(TR_FILE *tp, Transform x to vertical dots double x ) Drawing: void TRpolyline(TR_FILE *tp, Write a poly line. int n, No of points. double x[], horizontal points. double y[] ) vertical ponts. void TRpolygon(TR_FILE *tp, Write a polygon int n, No of points. double x[], horizontal points. double y[] ) vertical ponts. void TRoval(TR_FILE *tp, Write oval. double x0, one corner double y0, double x1, opposite corner. double y1 ) void TRbox(TR_FILE *tp, Write box. double x0, one corner double y0, double x1, opposite corner. double y1 ) void TRrcbox(TR_FILE *tp, Write rounded-corner box. double x0, one corner double y0, double x1, opposite corner. double y1 ) void TRtext(TR_FILE *tp, Write text. double x, position. double y, char *s ) The string. void TRgroup_begin(TR_FILE *tp) Begin a group object. void TRgroup_end(TR_FILE *tp) End a group object. void TRline(TR_FILE *tp, Draw a single line element double x0, start position. double y0, double x1, end position. double y1 ) void TRmark( TR_FILE *tp, Draw a marker at position. double x0, double y0 ) void TRpolymark(TR_FILE *tp, Mark may positions. int n, No of points. double x[], horizontal points. double y[] ) vertical ponts.