home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-29 | 60.9 KB | 2,805 lines |
- head 1.11;
- access;
- symbols
- stage1:1.8;
- locks; strict;
- comment @ * @;
-
-
- 1.11
- date 94.04.30.00.12.07; author peteric; state Exp;
- branches;
- next 1.10;
-
- 1.10
- date 94.04.27.11.37.54; author peteric; state Exp;
- branches;
- next 1.9;
-
- 1.9
- date 94.03.26.11.28.03; author peteric; state Exp;
- branches;
- next 1.8;
-
- 1.8
- date 94.03.10.21.28.26; author peteric; state Exp;
- branches;
- next 1.7;
-
- 1.7
- date 94.03.07.12.44.14; author peteric; state Exp;
- branches;
- next 1.6;
-
- 1.6
- date 94.03.01.23.19.50; author peteric; state Exp;
- branches;
- next 1.5;
-
- 1.5
- date 94.02.27.19.37.21; author peteric; state Exp;
- branches;
- next 1.4;
-
- 1.4
- date 94.02.13.16.44.05; author peteric; state Exp;
- branches;
- next 1.3;
-
- 1.3
- date 94.02.12.20.33.26; author peteric; state Exp;
- branches;
- next 1.2;
-
- 1.2
- date 94.02.12.20.00.23; author peteric; state Exp;
- branches;
- next 1.1;
-
- 1.1
- date 94.02.12.19.52.00; author peteric; state Exp;
- branches;
- next ;
-
-
- desc
- @print routine for ftree family tree formatter.
- @
-
-
- 1.11
- log
- @Fixed a problem with the inter-marriage lines not being printed
- correctly - now uses the 'datewidth' member to join points approx
- next to the date of each marriage linked; also includes a 'stroke'
- command which was missing.
- Also moved the initial placement of the title up a bit so it doesn't
- overlap the first marriage(s) on the tree.
- @
- text
- @/*************************************************************************
- *
- * $RCSfile: print.c,v $
- *
- * $Author: peteric $
- *
- * $Date: 1994/04/27 11:37:54 $
- *
- * $State: Exp $
- *
- * $Revision: 1.10 $
- *
- * Purpose: Print routines for ftree.
- *
- * $Log: print.c,v $
- * Revision 1.10 1994/04/27 11:37:54 peteric
- * Moved widthof code here from layout.c; added new routines
- * setpersonwidths and setmarriagewidths to run through the person
- * and marriage lists & set up the widths.
- * Adjusted the structure member 'width' to be h.width in accordance with
- * the structure changes.
- * Fixed (a) bug in the 'printtitle' code. Removed the quoting aroung
- * the brackets in PS strings - we know they will match properly.
- *
- * Revision 1.9 1994/03/26 11:28:03 peteric
- * Included multiple-marriage print routines.
- * [Not working correctly yet!] and modified title print
- * code with PS support.
- *
- * Revision 1.8 1994/03/10 21:28:26 peteric
- * Multiple pages working!
- *
- * Revision 1.7 1994/03/07 12:44:14 peteric
- * Passed on as first Version.
- *
- * Revision 1.6 1994/03/01 23:19:50 peteric
- * fixed handling of tickmarks & postitioning of
- * printed lines. Improved compliance of DSC comments. Final?
- * mods to the landscape code
- *
- * Revision 1.5 1994/02/27 19:37:21 peteric
- * improved comments; new prolog stuff, fixed landscape mode
- * code, moved some functions to layout.c
- *
- *
- *************************************************************************/
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <sys/time.h>
- #include <math.h>
- #include <assert.h>
-
- #include "ftree.h"
-
- #define MAX_CHART_PEOPLE 15
- #define EOS '\0'
-
- int numpeople = 0;
- int numchartprocs = 1;
-
- /*(
- *************************************************************
- *
- * Function: print_tree
- *
- *
- * Inputs:
- * outf - the output file to write PostScript to.
- * opts - current option set
- * id - the ID of the person to start at, who should be
- * married.
- *
- * Outputs:
- * (file)
- *
- * Error Handling:
- * None.
- *
- * Description:
- *
- *
- *
- *************************************************************
- )*/
-
- void print_tree(FILE *outf, options_t *opts, marriage_t *marriage)
- {
- person_t *child;
-
- while(marriage)
- {
- dbprintf(( "\nprint_tree: marriage at: %d,%d\n", marriage->h.xpos, marriage->h.ypos));
-
- /*
- * print this marriage.
- */
- printmarriage(outf, opts, marriage, marriage->h.xpos, marriage->h.ypos);
-
- if (marriage->children > 0)
- {
- int gap;
- int x1, x2;
- int y;
-
- dbprintf(( "print_tree: writing %d children ...\n", marriage->children));
-
- fprintf(outf, "1 setlinewidth\n");
-
- /*
- * gap allowed for the parents info.
- */
- gap = (opts->personfont.linespc * opts->marrlines);
-
- /*
- * draw a line 'connecting' the parents
- * to the children's line.
- */
- y = marriage->firstchild->h.ypos;
- fprintf(outf, "%d %d moveto %d %d lineto\n",
- XOF(opts, marriage->h.xpos), YOF(opts, marriage->h.ypos + gap),
- XOF(opts, marriage->h.xpos), YOF(opts, y - opts->ticklen));
-
- /*
- * draw the horizontal line connecting
- * the children together.
- */
- if (marriage->firstchild->married)
- x1 = marriage->firstchild->firstmarriage->h.xpos;
- else
- x1 = marriage->firstchild->h.xpos;
-
- if (marriage->lastchild->married)
- x2 = marriage->lastchild->firstmarriage->h.xpos;
- else
- x2 = marriage->lastchild->h.xpos;
-
- fprintf(outf, "%d %d %d xrln %% draw connecting bar for family\n",
- DXOF(opts, x2 - x1), XOF(opts, x1), YOF(opts, y - opts->ticklen));
-
- /*
- * draw the tickmarks for each child
- */
- child = marriage->firstchild;
- while(child != NULL)
- {
- if (child->married)
- {
- fprintf(outf, "%d %d %d yrln %% draw tick for %s %s\n",
- DYOF(opts, -opts->ticklen),
- XOF(opts, child->firstmarriage->h.xpos), YOF(opts, child->firstmarriage->h.ypos),
- child->firstname, child->family);
- }
- else
- {
- fprintf(outf, "%d %d %d yrln %% draw tick for %s %s\n",
- DYOF(opts, -opts->ticklen), XOF(opts, child->h.xpos), YOF(opts, child->h.ypos),
- child->firstname, child->family);
- }
- child = child->nextchild;
- }
- fprintf(outf, "stroke\n");
-
- /*
- * draw each child
- */
- child = marriage->firstchild;
- while(child != NULL)
- {
- if (child->married)
- print_tree(outf, opts, child->firstmarriage);
- else
- printperson(outf, opts, child, child->h.xpos, child->h.ypos);
- child = child->nextchild;
- }
- }
- marriage = marriage->next;
- }
-
- dbprintf(( "print_tree: finished writing marriage.\n"));
- }
-
- /*(
- *************************************************************
- *
- * Function: printperson
- *
- *
- * Inputs:
- * outf - output file to write PostScript to.
- * opts - global options
- * person - person to write
- * x, y - PostScript coordinates to write person at.
- *
- * Outputs:
- * none.
- *
- * Description:
- *
- * Print an unmarried person centred at the position
- * (x,y). The y coordinate is at the top of the area used for
- * printing. Notice is taken of the 'fullname' variable.
- *
- *************************************************************
- )*/
-
- void printperson(FILE *outf, options_t *opts, person_t *person, int x, int y)
- {
- char dbuf[64], nbuf[128];
- int linepos, lines[3];
-
- if (opts->multipage && (++numpeople > MAX_CHART_PEOPLE))
- {
- numpeople = 0;
- numchartprocs++;
- fprintf(outf, "} def\n\n/chartproc%02d {\n", numchartprocs);
- }
-
- linepos = y;
-
- /*
- * print out id, if wanted.
- */
- if (opts->printids)
- {
- linepos += opts->identfont.linespc;
- lines[0] = YOF(opts, linepos);
- }
- else
- linepos += opts->personfont.linespc;
-
- /*
- * print out name.
- */
- lines[1] = YOF(opts, linepos);
- if (person->fullname)
- {
- strcpy(nbuf, person->firstname);
- strcat(nbuf, " ");
- strcat(nbuf, person->family);
- }
- else
- strcpy(nbuf, person->firstname);
-
- /*
- * print out the date of birth & death
- * SORT OUT: d.o.baptism
- */
- linepos += opts->datefont.linespc;
- lines[2] = YOF(opts, linepos);
- datefmt(dbuf, &person->born, &person->died);
-
- if (opts->printids)
- fprintf(outf, "(%s) %d (%s) %d (ID: %lX) %d %d printperson\n",
- dbuf, lines[2], nbuf, lines[1], person->id, lines[0],
- XOF(opts, x));
- else
- fprintf(outf, "(%s) %d (%s) %d %d printperson\n",
- dbuf, lines[2], nbuf, lines[1], XOF(opts, x));
- }
-
- /*(
- *************************************************************
- *
- * Function: printmarriage
- *
- *
- * Inputs:
- *
- *
- * Outputs:
- * (file)
- *
- * Error Handling:
- * none.
- *
- * Description:
- *
- * print two married people centred at the position
- * (x,y)
- *
- *************************************************************
- )*/
-
- void printmarriage(FILE *outf, options_t *opts, marriage_t *marriage,
- int x, int y)
- {
- int linepos, lines[7];
- person_t *husb, *wife;
- char hdtbuf[64], wdtbuf[64], hidbuf[12], widbuf[12];
-
- if (marriage == NULL)
- {
- dbprintf(("printmarriage: no marriage!!.\n"));
- return;
- }
-
- if (opts->multipage && (++numpeople > MAX_CHART_PEOPLE))
- {
- numpeople = 0;
- numchartprocs++;
- fprintf(outf, "} def\n\n/chartproc%02d {\n", numchartprocs);
- }
-
- husb = marriage->husband;
- wife = marriage->wife;
-
- if (marriage->backlink != NULL)
- {
- person_t *p;
-
- /*
- * First find out which parent is the child of the marriage given.
- */
- p = marriage->backlink->firstchild;
- while(p != NULL && p != marriage->husband && p != marriage->wife)
- {
- p = p->nextchild;
- }
- if (p != husb)
- {
- husb = marriage->wife;
- wife = marriage->husband;
- }
- }
- else
- dbprintf(("printmarriage: no backlink.\n"));
-
- linepos = y;
-
- /*
- * calculate the details for the first person.
- */
- linepos += opts->personfont.linespc;
- lines[0] = YOF(opts,linepos);
-
- if (opts->printids)
- {
- linepos += opts->identfont.linespc;
- lines[1] = YOF(opts,linepos);
- sprintf(hidbuf, "(ID: %lX) true\n", husb->id);
- }
- else
- hidbuf[0] = EOS;
-
- datefmt(hdtbuf, &husb->born, &husb->died);
- linepos += opts->datefont.linespc;
- lines[2] = YOF(opts,linepos);
-
- /*
- * line for 'x' between the people
- */
- linepos += opts->symfont.linespc;
- lines[3] = YOF(opts,linepos);
-
- /*
- * calculate the details for the second person.
- */
- linepos += opts->personfont.linespc;
- lines[4] = YOF(opts,linepos);
-
- if (opts->printids)
- {
- linepos += opts->identfont.linespc;
- lines[5] = YOF(opts, linepos);
- sprintf(widbuf, "(ID: %lX)", wife->id);
- }
-
- datefmt(wdtbuf, &wife->born, &wife->died);
- linepos += opts->datefont.linespc;
- lines[6] = YOF(opts,linepos);
-
- if (marriage->when.known)
- fprintf(outf, "(%s) %d (%s %s) %d ( %s) true %d (%s) %d (%s %s) %d %d printmarriage\n",
- wdtbuf, lines[6], wife->firstname, wife->family, lines[4],
- date2string(&marriage->when), lines[3],
- hdtbuf, lines[2], husb->firstname, husb->family, lines[0],
- XOF(opts, x));
- else
- fprintf(outf, "(%s) %d (%s %s) %d false %d (%s) %d (%s %s) %d %d printmarriage\n",
- wdtbuf, lines[6], wife->firstname, wife->family, lines[4], lines[3],
- hdtbuf, lines[2], husb->firstname, husb->family, lines[0],
- XOF(opts, x));
-
- if (marriage->children == 0)
- {
- linepos += opts->personfont.linespc;
- fprintf(outf, "personfont setfont %d %d moveto ([no issue]) showcentred\n", XOF(opts, x), YOF(opts, linepos));
- }
-
- if (marriage->prev)
- {
- int axs, axe, ay;
-
- ay = lines[3] + (opts->symfont.linespc / 3);
- axs = marriage->prev->h.xpos + (marriage->prev->datewidth / 2) + 2;
- axe = marriage->h.xpos - 2 - (marriage->datewidth / 2);
- dbprintf(("printmarriage: inter-marriage line: %d %d to %d %d\n", axs, ay, axe, ay));
- axs = XOF(opts, axs);
- axe = XOF(opts, axe);
- fprintf(outf, "%d %d %d xrln stroke\n", (axe - axs) + 1, axs, ay);
- }
- }
-
- /*(
- *************************************************************
- *
- * Function: do_title
- *
- *
- * Inputs:
- * outf - file to write PostScript to
- * opts - option settings, including the title etc.
- *
- * Outputs:
- * (file)
- *
- * Error Handling:
- * none.
- *
- * Description:
- *
- * To print the title string of the tree. Optionally, to
- * place it in a grey box.
- *
- *************************************************************
- )*/
-
- void do_title(FILE *outf, options_t *opts, marriage_t *marriage)
- {
- fprintf(outf, "%%\n%% Draw the page title\n%%\n");
- if (opts->multipage)
- {
- fprintf(outf, "titlefont setfont\n");
- fprintf(outf, "%d %d moveto %.3f %d (%s) printtitle\n",
- XOF(opts, marriage->h.xpos), YOF(opts, opts->titlefont.linespc) + 2,
- opts->titlegreylevel, opts->titlefont.linespc, opts->titlestr);
- }
- else
- {
- fprintf(outf, "titlefont setfont\n");
- fprintf(outf, "%d %d moveto %.3f %d (%s) printtitle\n",
- XOF(opts, opts->pagewidth/2), YOF(opts, opts->titlefont.linespc) + 2,
- opts->titlegreylevel, opts->titlefont.linespc, opts->titlestr);
- }
- }
-
- /*(
- *************************************************************
- *
- * Function: do_prolog
- *
- *
- * Inputs:
- * outf - the file to write to
- * opts - the current options set
- *
- * Outputs:
- * None.
- *
- * Error Handling:
- * None.
- *
- * Description:
- *
- * To output the appropriate DSC comments for the output
- * file and generate definitions of private procedures.
- *
- *************************************************************
- )*/
-
- static char default_procs[] =
- {
- "/showcentred { % str =>\n"
- " dup stringwidth pop 2 div neg 0 rmoveto show\n"
- "} def\n"
- "/show2centred { % fdict str1 fdict str2 =>\n"
- " 4 dict begin /s2 exch def /f2 exch def /s1 exch def /f1 exch def\n"
- " f1 setfont s1 stringwidth pop\n"
- " f2 setfont s2 stringwidth pop\n"
- " add 2 div neg 0 rmoveto\n"
- " f1 setfont s1 show f2 setfont s2 show\n"
- "end } def\n"
- "/showright { % str => \n"
- " dup stringwidth pop neg 0 rmoveto show\n"
- "} def\n"
- "/yrln { % dy x y =>\n"
- " moveto 0 exch rlineto\n"
- "} bind def\n"
- "/xrln { % dx x y =>\n"
- " moveto 0 rlineto\n"
- "} bind def\n"
- "/fsf { % name size font-id =>\n"
- " findfont exch scalefont def\n"
- "} bind def\n"
- "/printtitle { % grlev ptsiz ttl =>\n"
- " /ttl exch def /yd exch 10 add def /grlev exch def\n"
- " 0 5 rmoveto currentpoint\n"
- " /xd ttl stringwidth pop 2 div 10 add def\n"
- " xd neg 0 rlineto 0 yd neg rlineto xd 2 mul 0 rlineto 0 yd rlineto\n"
- " closepath gsave grlev setgray fill grestore stroke\n"
- " moveto 0 yd 10 sub neg rmoveto ttl showcentred\n"
- "} def\n"
- "/printmarriage { % wdt wdt-y wife wf-y { mdt } show2? mdt-y bool hdt hdt-y husb-nm husb-y xpos =>\n"
- " /xpos exch def\n"
- " personfont setfont\n"
- " xpos exch moveto showcentred\n"
- " datefont setfont\n"
- " xpos exch moveto showcentred\n"
- " xpos exch moveto\n"
- " { symfont (x) datefont 4 -1 roll show2centred }\n"
- " { symfont setfont (x) showcentred } ifelse\n"
- " personfont setfont\n"
- " xpos exch moveto showcentred\n"
- " datefont setfont\n"
- " xpos exch moveto showcentred\n"
- "} def\n"
- "/printperson { % dt-str dt-y nm-str nm-y { id-str id-y } pr-id xpos =>\n"
- " /xpos exch def\n"
- " printids { identfont setfont\n"
- " xpos exch moveto showcentred\n"
- " } if\n"
- " personfont setfont\n"
- " xpos exch moveto showcentred\n"
- " datefont setfont\n"
- " xpos exch moveto showcentred\n"
- "} def\n"
- "/cross { % dxby2 dyby2 =>\n"
- " /dby2 exch def\n"
- " dby2 0 rmoveto dby2 neg 2 mul 0 rlineto\n"
- " dby2 dy rmoveto 0 dby2 2 mul rlineto\n"
- " 0 dby2 neg rmoveto \n"
- "} def\n"
- "/cross { % dby2 =>\n"
- " /dby2 exch def\n"
- " dby2 0 rmoveto dby2 -2 mul 0 rlineto\n"
- " dby2 dby2 rmoveto 0 dby2 -2 mul rlineto\n"
- " 0 dby2 rmoveto \n"
- "} def\n"
- "/pmargins {\n"
- " 0 setlinewidth\n"
- " newpath\n"
- " 0 0 moveto 5 cross\n"
- " 0 pageheight rmoveto 5 cross\n"
- " pagewidth 0 rmoveto 5 cross\n"
- " 0 pageheight neg rmoveto 5 cross\n"
- " stroke\n"
- "} def\n"
- "/printmultiple { % x-pages y-pages =>\n"
- " /rows exch def\n"
- " /cols exch def\n"
- " /pictproc exch def\n"
- " newpath\n"
- " leftmargin botmargin moveto\n"
- " 0 pageheight rlineto\n"
- " pagewidth 0 rlineto\n"
- " 0 pageheight neg rlineto\n"
- " closepath clip\n"
- " newpath % clip doesn't do this\n"
- " leftmargin botmargin translate\n"
- " 0 1 rows 1 sub {\n"
- " /rowcount exch def\n"
- " 0 1 cols 1 sub {\n"
- " /colcount exch def\n"
- " gsave initclip pmargins grestore\n"
- " gsave\n"
- " pagewidth colcount mul neg\n"
- " pageheight rowcount mul neg\n"
- " translate\n"
- " pictproc\n"
- " gsave showpage grestore\n"
- " grestore\n"
- " } for\n"
- " } for\n"
- "} def\n"
- };
-
-
- void do_prolog(FILE *outf, options_t *opts)
- {
- time_t now;
- FILE *fp;
- int pagew, pageh;
-
- /*
- * the page size in terms of drawable area.
- */
- pagew = opts->pagewidth - (opts->lmargin + opts->rmargin);
- pageh = opts->pageheight - (opts->tmargin + opts->bmargin);
-
- time(&now);
- fprintf(outf, "%%!PS-Adobe-3.0\n");
- fprintf(outf, "%%%%BoundingBox: (atend)\n");
- fprintf(outf, "%%%%Title: (%s)\n", opts->titlestr);
- fprintf(outf, "%%%%Creator: Ftree version " VERSION " (" __DATE__ ")\n");
- fprintf(outf, "%%%%Copyright: Copyright (c) 1994 P. Ivimey-Cook\n");
- fprintf(outf, "%%%%CreationDate: %s", ctime(&now));
- fprintf(outf, "%%%%DocumentMedia: Plain %d %d 0 white ()\n", opts->pagewidth, opts->pageheight);
- fprintf(outf, "%%%%DocumentNeededResources: font %s\n", opts->titlefont.font);
- if (opts->printids)
- fprintf(outf, "%%+ font %s\n", opts->identfont.font);
- fprintf(outf, "%%%%+ font %s\n", opts->symfont.font);
- fprintf(outf, "%%%%+ font %s\n", opts->datefont.font);
- fprintf(outf, "%%%%+ font %s\n", opts->personfont.font);
- fprintf(outf, "%%%%DocumentSuppliedResources: file %s\n", PROCSET_FILENAME);
- if (opts->multipage)
- {
- int xp, yp;
- xp = (opts->bbux + (pagew - 1)) / pagew;
- yp = (opts->bbly + (pageh - 1)) / pageh;
- fprintf(outf, "%%%%Pages: %d\n", xp * yp);
- }
- else
- fprintf(outf, "%%%%Pages: 1\n");
- fprintf(outf, "%%%%EndComments\n");
- fprintf(outf, "%%%%BeginProlog\n");
- fprintf(outf, "%%%%EndProlog\n");
- fprintf(outf, "\n");
- fprintf(outf, "%%%%Page: 1 1\n");
- fprintf(outf, "%%%%BeginPageSetup\n");
- if (!streq(opts->papertype, "special"))
- {
- fprintf(outf, "%%%%BeginFeature: *PageSize %s\n", opts->papertype);
- fprintf(outf, "systemdict /%s known { %s } if\n", opts->papertype, opts->papertype);
- fprintf(outf, "%%%%EndFeature\n");
- }
- fprintf(outf, "50 dict begin\n");
- fprintf(outf, "%%%%BeginResource: file %s\n", PROCSET_FILENAME);
-
- fp = fopen(PROCSET_FILENAME, "r");
- if (fp == NULL)
- {
- fputs(default_procs, outf);
- dbprintf(("do_prolog: default procset loaded\n"));
- }
- else
- {
- static char buf[1024];
- unsigned int l;
- dbprintf(("do_prolog: procset %s loaded\n", PROCSET_FILENAME));
- while((l = fread(buf, 1, sizeof(buf), fp)) > 0)
- fwrite(buf, 1, l, outf);
- fclose(fp);
- }
- fprintf(outf, "%%%%EndResource: file %s\n", PROCSET_FILENAME);
-
- fprintf(outf, "/personfont %.1f /%s fsf\n", opts->personfont.size, opts->personfont.font);
- fprintf(outf, "/titlefont %.1f /%s fsf\n", opts->titlefont.size, opts->titlefont.font);
- fprintf(outf, "/datefont %.1f /%s fsf\n", opts->datefont.size, opts->datefont.font);
- fprintf(outf, "/symfont %.1f /%s fsf\n", opts->symfont.size, opts->symfont.font);
- if (opts->printids)
- {
- fprintf(outf, "/identfont %.1f /%s fsf\n", opts->identfont.size, opts->identfont.font);
- fprintf(outf, "/printids true def\n");
- }
- else
- fprintf(outf, "/printids false def\n");
- if (opts->landscape)
- {
- fprintf(outf, "%%%%PageOrientation: Landscape\n");
- fprintf(outf, "clippath pathbbox exch pop exch pop exch pop \n");
- fprintf(outf, "0 0 moveto -90 rotate neg dup == 0 translate\n");
- }
- else
- fprintf(outf, "%%%%PageOrientation: Portrait\n");
-
- if (opts->multipage)
- {
- fprintf(outf, "/pagewidth %d def\n", pagew);
- fprintf(outf, "/pageheight %d def\n", pageh);
- fprintf(outf, "/leftmargin %d def\n", opts->lmargin);
- fprintf(outf, "/botmargin %d def\n", opts->bmargin);
- fprintf(outf, "%%%%EndPageSetup\n");
- fprintf(outf, "\n/chartproc01 {\n");
- numchartprocs = 1;
- }
- else
- fprintf(outf, "%%%%EndPageSetup\n");
-
- }
-
- /*(
- *************************************************************
- *
- * Function: do_epilog
- *
- *
- * Inputs:
- * outf - the file to write to
- * opts - the current options set
- *
- * Outputs:
- * none.
- *
- * Error Handling:
- * none.
- *
- * Description:
- *
- * To close off the postscript program with showpage and
- * appropriate DSC comments.
- *
- *************************************************************
- )*/
-
- void do_epilog(FILE *outf, options_t *opts)
- {
- int i;
- if (opts->multipage)
- {
- fprintf(outf, "} def\n");
- fprintf(outf, "{ ");
- for (i = 1; i <= numchartprocs; i++)
- fprintf(outf, "chartproc%02d ", i);
- fprintf(outf, "}\n");
- fprintf(outf, "%d pagewidth 1 sub add pagewidth idiv\n", opts->bbux);
- fprintf(outf, "%d pageheight 1 sub add pageheight idiv\n", opts->bbly);
- fprintf(outf, "printmultiple\n");
- }
- else
- fprintf(outf, "showpage\n");
- fprintf(outf, "end %% of dict begin\n");
- fprintf(outf, "%%%%PageTrailer\n");
- fprintf(outf, "%%%%Trailer\n");
- fprintf(outf, "%%%%BoundingBox: %d %d %d %d\n",
- opts->bblx, opts->bbly, opts->bbux, opts->bbuy);
- fprintf(outf, "%%%%EOF\n");
- }
-
- /*(
- *************************************************************
- *
- * Function: date2string
- *
- *
- * Inputs:
- * d - pointer to a struct date
- *
- * Outputs:
- * char * - pointer to a statically allocated buffer
- *
- * Error Handling:
- * Copes with various forms of unknown date by placing
- * '?' characters in the returned string. Copes with 'd'
- * being NULL by returning "".
- *
- * Description:
- *
- * Formats a date into a string, accounting for the
- * values of some of the fields being unknown. The date format
- * is predefined and unchangeable.
- *
- *************************************************************
- )*/
-
- static char *months[] =
- {
- "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
- };
-
- char *date2string(struct date *d)
- {
- static char buf[32];
- char tbuf[12];
-
- buf[0] = EOS;
- if (d == NULL || d->known == 0)
- return buf;
-
- if (d->dvalid)
- sprintf(buf, "%d-", d->day);
-
- if (d->mvalid && d->month >= 1 && d->month <= 12)
- {
- sprintf(tbuf, "%s-", months[d->month-1]);
- strcat(buf, tbuf);
- }
- else if (buf[0] != EOS)
- strcat(buf, "?-");
-
- if (d->yvalid)
- {
- sprintf(tbuf, "%d", d->year);
- strcat(buf, tbuf);
- }
- else
- strcat(buf, "?");
-
- dbprintf(( "date2string: buf : %s\n", buf));
- return buf;
- }
-
- /*(
- ***********************************************************************
- *
- * Function: datefmt
- *
- *
- * Inputs:
- * born & died - dates which to be written
- *
- * Outputs:
- * buf contains formatted date
- *
- * Description:
- *
- * Formats a date for inclusion in a chart - the standard format is:
- * (<born> - <died>)
- * where <born> and <died> are the dates formatted by date2string above.
- *
- ***********************************************************************
- )*/
-
- void datefmt(char *buf, struct date *born, struct date *died)
- {
- strcpy(buf, "(");
- strcat(buf, date2string(born));
- strcat(buf, " - ");
- strcat(buf, date2string(died));
- strcat(buf, ")");
-
- return;
- }
-
- void setmarriagewidths(options_t *opts, marriage_t *mroot)
- {
- register marriage_t *m = mroot;
- while(m)
- {
- m->h.width = widthofmarriage(opts, m);
- m = m->nextmarriage;
- }
- }
-
- void setpersonwidths(options_t *opts, person_t *proot)
- {
- register person_t *p = proot;
- while(p)
- {
- p->h.width = widthof(opts, p);
- p = p->nextperson;
- }
- }
-
- /*(
- **********************************************************************************
- *
- * Function: widthof
- *
- *
- * Inputs:
- * opts - global options
- * pers - pointer to a person record.
- *
- * Outputs:
- * int - width in PS units (points) of the printed
- * version of the person.
- *
- * Description:
- *
- * return the width required to print 'person'
- *
- **********************************************************************************
- )*/
-
- int widthof(options_t *opts, person_t *pers)
- {
- int w, namew, datew;
- char bufn[128], bufd[128];
-
- if (pers->fullname)
- {
- strcpy(bufn, pers->firstname);
- strcat(bufn, " ");
- strcat(bufn, pers->family);
- }
- else
- strcpy(bufn, pers->firstname);
-
- namew = ceil(stringwidth(&opts->personfont, opts->afmconst, bufn));
-
- datefmt(bufd, &pers->born, &pers->died);
- datew = ceil(stringwidth(&opts->datefont, opts->afmconst, bufd));
-
- if (namew > datew)
- w = namew + opts->tree_gap;
- else
- w = datew + opts->tree_gap;
-
- dbprintf(("widthof: person %s / %s returns %d / %d --> result %d\n",
- bufn, bufd, namew, datew, w));
- return w;
- }
-
- /*(
- **********************************************************************************
- *
- * Function: widthofmarriage
- *
- *
- * Inputs:
- * opts - global options.
- * marriage - the marriage defintion record.
- *
- * Outputs:
- * int - the required width
- *
- * Description:
- *
- * Determines the width required to print a marriage in the standard form. The
- * person widths are used for the name lengths, and the additional dates etc are
- * then added into the calculations.
- *
- *********************************************************************************
- )*/
-
- int widthofmarriage(options_t *opts, marriage_t *marriage)
- {
- int w1, w2, w3;
-
- assert(marriage->husband->married);
- assert(marriage->wife->married);
-
- w1 = marriage->husband->h.width;
- w2 = marriage->wife->h.width;
-
- w3 = ceil(stringwidth(&opts->symfont, opts->afmconst, "x"));
- if (marriage->when.known)
- {
- char *buf = date2string(&marriage->when);
- w3 += ceil(stringwidth(&opts->datefont, opts->afmconst, buf));
- }
- marriage->datewidth = w3;
-
- if (w1 < w2)
- w1 = w2;
- if (w1 < w3)
- w1 = w3;
-
- dbprintf(("widthofmarriage: return %d for marriage width\n", w1));
-
- return w1;
- }
-
- @
-
-
- 1.10
- log
- @Moved widthof code here from layout.c; added new routines
- setpersonwidths and setmarriagewidths to run through the person
- and marriage lists & set up the widths.
- Adjusted the structure member 'width' to be h.width in accordance with
- the structure changes.
- Fixed (a) bug in the 'printtitle' code. Removed the quoting aroung
- the brackets in PS strings - we know they will match properly.
- @
- text
- @d7 1
- a7 1
- * $Date: 1994/03/26 11:28:03 $
- d11 1
- a11 1
- * $Revision: 1.9 $
- d16 9
- d396 3
- a398 3
- ay = lines[3];
- axs = marriage->prev->h.xpos + (marriage->prev->h.width / 2) - 1;
- axe = marriage->h.xpos - (marriage->h.width / 2) + 1;
- d402 1
- a402 1
- fprintf(outf, "2 setlinewidth %d %d %d xrln\n", axe - axs, axs, ay);
- d437 1
- a437 1
- XOF(opts, marriage->h.xpos), YOF(opts, opts->titlefont.linespc),
- d444 1
- a444 1
- XOF(opts, opts->pagewidth/2), YOF(opts, opts->titlefont.linespc),
- d935 1
- @
-
-
- 1.9
- log
- @Included multiple-marriage print routines.
- [Not working correctly yet!] and modified title print
- code with PS support.
- @
- text
- @d7 1
- a7 1
- * $Date: 1994/03/10 21:28:26 $
- d11 1
- a11 1
- * $Revision: 1.8 $
- d16 5
- d43 2
- d85 1
- a85 1
- dbprintf(( "\nprint_tree: marriage at: %d,%d\n", marriage->xpos, marriage->ypos));
- d90 1
- a90 1
- printmarriage(outf, opts, marriage, marriage->xpos, marriage->ypos);
- d111 1
- a111 1
- y = marriage->firstchild->ypos;
- d113 2
- a114 2
- XOF(opts, marriage->xpos), YOF(opts, marriage->ypos + gap),
- XOF(opts, marriage->xpos), YOF(opts, y - opts->ticklen));
- d121 1
- a121 1
- x1 = marriage->firstchild->firstmarriage->xpos;
- d123 1
- a123 1
- x1 = marriage->firstchild->xpos;
- d126 1
- a126 1
- x2 = marriage->lastchild->firstmarriage->xpos;
- d128 1
- a128 1
- x2 = marriage->lastchild->xpos;
- d143 1
- a143 1
- XOF(opts, child->firstmarriage->xpos), YOF(opts, child->firstmarriage->ypos),
- d149 1
- a149 1
- DYOF(opts, -opts->ticklen), XOF(opts, child->xpos), YOF(opts, child->ypos),
- d165 1
- a165 1
- printperson(outf, opts, child, child->xpos, child->ypos);
- d361 1
- a361 1
- datefmt(hdtbuf, &wife->born, &wife->died);
- d388 2
- a389 2
- axs = marriage->prev->xpos + (marriage->prev->width / 2) - 1;
- axe = marriage->xpos - (marriage->width / 2) + 1;
- d428 1
- a428 1
- XOF(opts, marriage->xpos), YOF(opts, opts->titlefont.linespc),
- d489 3
- a491 3
- " /ttl exch def /yd exch 1.2 mul def /grlev exch def\n"
- " currentpoint\n"
- " /xd ttl stringwidth pop 2 div 1.2 mul def\n"
- d494 1
- a494 1
- " moveto yd 1.1 div 0 rmoveto ttl showcentred\n"
- d584 1
- a584 1
- fprintf(outf, "%%%%!PS-Adobe-3.0\n");
- d653 2
- a654 3
- fprintf(outf, "-90 rotate -%d %d translate\n",
- opts->pageheight - opts->tmargin,
- - ((opts->pageheight - opts->pagewidth) - opts->rmargin));
- d809 1
- a809 1
- strcpy(buf, "\\(");
- d813 1
- a813 1
- strcat(buf, "\\)");
- d816 121
- a936 1
- }@
-
-
- 1.8
- log
- @Multiple pages working!
- @
- text
- @d7 1
- a7 1
- * $Date: 1994/03/07 12:44:14 $
- d11 1
- a11 1
- * $Revision: 1.7 $
- d16 3
- d42 1
- d72 1
- a72 1
- void print_tree(FILE *outf, options_t *opts, id_t id)
- a74 1
- marriage_t *marriage;
- a75 1
- marriage = findmarriage1(id);
- d156 1
- a156 1
- print_tree(outf, opts, child->id);
- d162 1
- a162 1
- marriage = nextmarriage(marriage, id);
- d175 4
- a178 1
- *
- d181 1
- a181 4
- *
- *
- * Error Handling:
- *
- d185 3
- a187 2
- * print an unmarried person centred at the position
- * (x,y)
- d197 1
- a197 1
- if (++numpeople > MAX_CHART_PEOPLE)
- d236 1
- a236 5
- strcpy(dbuf, "(");
- strcat(dbuf, date2string(&person->born));
- strcat(dbuf, " - ");
- strcat(dbuf, date2string(&person->died));
- strcat(dbuf, ")");
- d283 1
- a283 1
- if (++numpeople > MAX_CHART_PEOPLE)
- d316 3
- d329 1
- a329 1
- hidbuf[0] = '\0';
- d331 1
- a331 5
- strcpy(hdtbuf, "(");
- strcat(hdtbuf, date2string(&husb->born));
- strcat(hdtbuf, " - ");
- strcat(hdtbuf, date2string(&husb->died));
- strcat(hdtbuf, ")");
- d342 1
- a342 1
- * deal with the wife.
- d354 1
- a354 5
- strcpy(wdtbuf, "(");
- strcat(wdtbuf, date2string(&wife->born));
- strcat(wdtbuf, " - ");
- strcat(wdtbuf, date2string(&wife->died));
- strcat(wdtbuf, ")");
- d375 13
- d414 1
- a414 1
- void do_title(FILE *outf, options_t *opts)
- a415 2
- int lx, ty, rx, by;
-
- d417 8
- a424 1
- if (opts->titlegreylevel < 1.0)
- d426 5
- a430 14
- fprintf(outf, "%.3f setgray\n", opts->titlegreylevel);
- lx = 0;
- ty = 0;
- rx = opts->pagewidth - opts->rmargin;
- by = opts->titlefont.size * 1.7;
- fprintf(outf, "%d %d moveto %d %d lineto %d %d lineto %d %d lineto\n",
- XOF(opts, lx), YOF(opts, ty), XOF(opts, rx), YOF(opts, ty),
- XOF(opts, rx), YOF(opts, by), XOF(opts, lx), YOF(opts, by));
- fprintf(outf, "closepath gsave fill grestore 0 setgray stroke\n");
- }
- fprintf(outf, "titlefont setfont\n");
- fprintf(outf, "%d %d moveto (%s) showcentred\n",
- XOF(opts, opts->pagewidth/2), YOF(opts, opts->titlefont.linespc),
- opts->titlestr);
- d481 8
- d568 1
- d570 6
- d591 9
- a599 1
- fprintf(outf, "%%%%Pages: 1\n");
- d606 6
- a611 3
- fprintf(outf, "%%%%BeginFeature: *PageSize %s\n", opts->papertype);
- fprintf(outf, "systemdict /%s known { %s } if\n", opts->papertype, opts->papertype);
- fprintf(outf, "%%%%EndFeature\n");
- d652 1
- d655 2
- a656 2
- fprintf(outf, "/pagewidth %d def\n", opts->pagewidth - (opts->lmargin + opts->rmargin));
- fprintf(outf, "/pageheight %d def\n", opts->pageheight - (opts->tmargin + opts->bmargin));
- d659 3
- d665 1
- a665 2
- fprintf(outf, "/chartproc01 {\n");
- numchartprocs = 1;
- d753 1
- a753 1
- buf[0] = '\0';
- a758 2
- else
- strcpy(buf, "?-");
- d765 1
- a765 1
- else
- d780 20
- d801 10
- @
-
-
- 1.7
- log
- @Passed on as first Version.
- @
- text
- @d7 1
- a7 1
- * $Date: 1994/03/01 23:19:50 $
- d11 1
- a11 1
- * $Revision: 1.6 $
- d16 3
- d38 5
- d103 1
- a103 1
- fprintf(outf, "%d %d moveto %d %d lineto stroke\n",
- d121 2
- a122 3
- fprintf(outf, "%% draw connecting bar for family\n");
- fprintf(outf, "%d %d moveto %d 0 rlineto stroke\n",
- XOF(opts, x1), YOF(opts, y - opts->ticklen), DXOF(opts, x2 - x1));
- d132 2
- a133 2
- fprintf(outf, "%% draw tick for %s %s\n", child->firstname, child->family);
- fprintf(outf, "%d %d moveto 0 %d rlineto stroke\n",
- d135 1
- a135 3
- DYOF(opts, -opts->ticklen));
-
- print_tree(outf, opts, child->id);
- d139 17
- a155 4
- fprintf(outf, "%% draw tick for %s %s\n", child->firstname, child->family);
- fprintf(outf, "%d %d moveto 0 %d rlineto stroke\n",
- XOF(opts, child->xpos), YOF(opts, child->ypos), DYOF(opts, -opts->ticklen));
-
- a156 1
- }
- d183 1
- a183 1
- * print an unmarried person centered at the position
- d191 2
- a192 2
- char buf[64];
- int linepos;
- d194 7
- d202 1
- a202 1
- fprintf(outf, "%%\n%% print an unmarried person\n%%\n");
- d209 1
- a209 3
- fprintf(outf, "identfont setfont\n");
- fprintf(outf, "%d %d moveto (ID: %lX) show\n",
- XOF(opts, x), YOF(opts, linepos), person->id);
- d217 1
- a217 2
- fprintf(outf, "personfont setfont\n");
- fprintf(outf, "%d %d moveto\n", XOF(opts, x), YOF(opts, linepos));
- d219 5
- a223 1
- fprintf(outf, "(%s %s) showcentered\n", person->firstname, person->family);
- d225 1
- a225 1
- fprintf(outf, "(%s) showcentered\n", person->firstname);
- d232 14
- a245 8
- fprintf(outf, "datefont setfont\n");
- strcpy(buf, "(");
- strcat(buf, date2string(&person->born));
- strcat(buf, " - ");
- strcat(buf, date2string(&person->died));
- strcat(buf, ")");
- fprintf(outf, "%d %d moveto (%s) showcentered\n",
- XOF(opts, x), YOF(opts, linepos), buf);
- d265 1
- a265 1
- * print two married people centered at the position
- d274 1
- a274 2
- char buf[64];
- int linepos;
- d276 1
- d283 8
- d318 1
- a318 4
- fprintf(outf, "%%\n%% print a marriage\n%%\n");
- fprintf(outf, "personfont setfont\n");
- fprintf(outf, "%d %d moveto\n", XOF(opts, x), YOF(opts, linepos));
- fprintf(outf, "(%s %s) showcentered\n", husb->firstname, husb->family);
- d323 2
- a324 3
- fprintf(outf, "identfont setfont\n");
- fprintf(outf, "%d %d moveto\n", XOF(opts, x), YOF(opts, linepos));
- fprintf(outf, "(ID: %lx) show\n", husb->id);
- d326 2
- d329 5
- a333 6
- strcpy(buf, "(");
- strcat(buf, date2string(&husb->born));
- strcat(buf, " - ");
- strcat(buf, date2string(&husb->died));
- strcat(buf, ")");
- fprintf(outf, "datefont setfont\n");
- d335 1
- a335 2
- fprintf(outf, "%d %d moveto (%s) showcentered\n",
- XOF(opts, x), YOF(opts, linepos), buf);
- d338 1
- a338 1
- * put an 'x' between the people
- d341 1
- a341 13
- fprintf(outf, "symfont setfont %d %d moveto\n",
- XOF(opts, x), YOF(opts, linepos));
- #ifdef GLYPH
- fprintf(outf, "/multiply glyphstring showcentered\n");
- #else
- if (marriage->when.known)
- {
- fprintf(outf, "symfont (x) datefont ( %s) show2centered\n",
- date2string(&marriage->when));
- }
- else
- fprintf(outf, "(x) showcentered\n");
- #endif
- a345 1
- fprintf(outf, "personfont setfont\n");
- d347 1
- a347 2
- fprintf(outf, "%d %d moveto\n", XOF(opts, x), YOF(opts, linepos));
- fprintf(outf, "(%s %s) showcentered\n", wife->firstname, wife->family);
- d352 2
- a353 3
- fprintf(outf, "identfont setfont\n");
- fprintf(outf, "%d %d moveto\n", XOF(opts, x), YOF(opts, linepos));
- fprintf(outf, "(ID: %lx) showcentered\n", wife->id);
- d356 5
- a360 6
- strcpy(buf, "(");
- strcat(buf, date2string(&wife->born));
- strcat(buf, " - ");
- strcat(buf, date2string(&wife->died));
- strcat(buf, ")");
- fprintf(outf, "datefont setfont\n");
- d362 1
- a362 1
- fprintf(outf, "%d %d moveto (%s) showcentered\n", XOF(opts, x), YOF(opts, linepos), buf);
- d364 12
- a377 1
- fprintf(outf, "personfont setfont\n");
- d379 1
- a379 1
- fprintf(outf, "%d %d moveto ([no issue]) showcentered\n", XOF(opts, x), YOF(opts, linepos));
- d425 1
- a425 1
- fprintf(outf, "%d %d moveto (%s) showcentered\n",
- d454 99
- d556 1
- d559 1
- a559 1
- fprintf(outf, "%%!PS-Adobe-3.0\n");
- d568 5
- a572 4
- fprintf(outf, "%%+ %s\n", opts->identfont.font);
- fprintf(outf, "%%%%+ %s\n", opts->symfont.font);
- fprintf(outf, "%%%%+ %s\n", opts->datefont.font);
- fprintf(outf, "%%%%+ %s\n", opts->personfont.font);
- d583 20
- a602 31
- fprintf(outf, "10 dict begin\n");
- fprintf(outf, "/showcentered { %% str showcentered -- \n");
- fprintf(outf, "dup stringwidth pop 2 div neg 0 rmoveto show\n");
- fprintf(outf, "} def\n");
- fprintf(outf, "/show2centered { %% fdict str1 fdict str2 showcentered -- \n");
- fprintf(outf, "4 dict begin /s2 exch def /f2 exch def /s1 exch def /f1 exch def\n");
- fprintf(outf, "f1 setfont s1 stringwidth pop\n");
- fprintf(outf, "f2 setfont s2 stringwidth pop\n");
- fprintf(outf, "add 2 div neg 0 rmoveto\n");
- fprintf(outf, "f1 setfont s1 show f2 setfont s2 show\n");
- fprintf(outf, "end } def\n");
- fprintf(outf, "/showright { %% str showright -- \n");
- fprintf(outf, "dup stringwidth pop neg 0 rmoveto show\n");
- fprintf(outf, "} def\n");
- fprintf(outf, "/fsf {findfont exch scalefont def} bind def\n");
- #ifdef GLYPH
- fprintf(outf, "/glyphstring %% symname glyhstring string\n");
- fprintf(outf, "{ 4 dict begin\n");
- fprintf(outf, " /glyph exch def %% get parameter\n");
- fprintf(outf, " /res 1 string def\n");
- fprintf(outf, " /encoding currentfont /Encoding get def\n");
- fprintf(outf, " 0 1 encoding length 1 sub\n");
- fprintf(outf, " { dup encoding exch get glyph eq\n");
- fprintf(outf, " { res exch 0 exch put exit }\n");
- fprintf(outf, " { pop } ifelse\n");
- fprintf(outf, " } for\n");
- fprintf(outf, " res end\n");
- fprintf(outf, "} def\n");
- #endif
- if (opts->printids)
- fprintf(outf, "/identfont %.1f /%s fsf\n", opts->identfont.size, opts->identfont.font);
- d607 7
- d623 11
- a633 1
- fprintf(outf, "%%%%EndPageSetup\n");
- d662 14
- a675 1
- fprintf(outf, "showpage\n");
- @
-
-
- 1.6
- log
- @fixed handling of tickmarks & postitioning of
- printed lines. Improved compliance of DSC comments. Final?
- mods to the landscape code
- @
- text
- @d7 1
- a7 1
- * $Date: 1994/02/27 19:37:21 $
- d11 1
- a11 1
- * $Revision: 1.5 $
- d16 5
- d209 1
- a209 4
- if (person->born.known)
- {
- strcat(buf, date2string(&person->born));
- }
- d211 1
- a211 4
- if (person->died.known)
- {
- strcat(buf, date2string(&person->died));
- }
- a242 1
- #if 0
- d245 1
- d247 1
- a247 3
- linepos = y;
- fprintf(outf, "%%\n%% print a marriage\n%%\n");
- if (opts->printids)
- d249 2
- a250 4
- linepos += opts->identfont.linespc;
- fprintf(outf, "identfont setfont\n");
- fprintf(outf, "%d %d moveto\n", XOF(opts, x), YOF(opts, linepos));
- fprintf(outf, "(ID: %lx) show\n", marriage->husband->id);
- d252 4
- a255 13
- else
- linepos += opts->personfont.linespc;
-
- fprintf(outf, "personfont setfont\n");
- fprintf(outf, "%d %d moveto\n", XOF(opts, x), YOF(opts, linepos));
- fprintf(outf, "( %s) show\n", marriage->husband->firstname);
- linepos += opts->personfont.linespc;
-
- fprintf(outf, "%d %d moveto\n", XOF(opts, x), YOF(opts, linepos));
- fprintf(outf, "( %s) show\n", marriage->husband->family);
- linepos += opts->personfont.linespc;
- strcpy(buf, "(");
- if (marriage->husband->born.known)
- d257 15
- a271 21
- strcat(buf, date2string(&marriage->husband->born));
- }
- strcat(buf, " - ");
- if (marriage->husband->died.known)
- {
- strcat(buf, date2string(&marriage->husband->died));
- }
- strcat(buf, ")");
- fprintf(outf, "datefont setfont\n");
- fprintf(outf, "%d %d moveto (%s) show\n", XOF(opts, x+1), YOF(opts, linepos), buf);
-
- /*
- * deal with the wife.
- */
- linepos = y;
- if (opts->printids)
- {
- linepos += opts->identfont.linespc;
- fprintf(outf, "identfont setfont\n");
- fprintf(outf, "%d %d moveto\n", XOF(opts, x), YOF(opts, linepos));
- fprintf(outf, "(ID: %lx) showright\n", marriage->wife->id);
- d274 2
- a275 26
- linepos += opts->personfont.linespc;
- fprintf(outf, "personfont setfont\n");
- fprintf(outf, "%d %d moveto\n", XOF(opts, x), YOF(opts, linepos));
- fprintf(outf, "(%s ) showright\n", marriage->wife->firstname);
- linepos += opts->personfont.linespc;
- fprintf(outf, "%d %d moveto\n", XOF(opts, x), YOF(opts, linepos));
- fprintf(outf, "(%s ) showright\n", marriage->wife->family);
- linepos += opts->personfont.linespc;
-
- strcpy(buf, "(");
- if (marriage->wife->born.known)
- {
- strcat(buf, date2string(&marriage->wife->born));
- }
- strcat(buf, " - ");
- if (marriage->wife->died.known)
- {
- strcat(buf, date2string(&marriage->wife->died));
- }
- strcat(buf, ")");
- fprintf(outf, "datefont setfont\n");
- fprintf(outf, "%d %d moveto (%s) showright\n", XOF(opts, x-1), YOF(opts, linepos), buf);
- #else
- char buf[64];
- int linepos;
-
- d277 1
- d282 1
- a282 1
- fprintf(outf, "(%s %s) showcentered\n", marriage->husband->firstname, marriage->husband->family);
- d289 1
- a289 1
- fprintf(outf, "(ID: %lx) show\n", marriage->husband->id);
- d293 1
- a293 4
- if (marriage->husband->born.known)
- {
- strcat(buf, date2string(&marriage->husband->born));
- }
- d295 1
- a295 4
- if (marriage->husband->died.known)
- {
- strcat(buf, date2string(&marriage->husband->died));
- }
- d299 2
- a300 1
- fprintf(outf, "%d %d moveto (%s) showcentered\n", XOF(opts, x), YOF(opts, linepos), buf);
- d306 2
- a307 1
- fprintf(outf, "symfont setfont %d %d moveto\n", XOF(opts, x), YOF(opts, linepos));
- d313 2
- a314 1
- fprintf(outf, "symfont (x) datefont ( %s) show2centered\n", date2string(&marriage->when));
- d326 1
- a326 1
- fprintf(outf, "(%s %s) showcentered\n", marriage->wife->firstname, marriage->wife->family);
- d333 1
- a333 1
- fprintf(outf, "(ID: %lx) showcentered\n", marriage->wife->id);
- d337 1
- a337 4
- if (marriage->wife->born.known)
- {
- strcat(buf, date2string(&marriage->wife->born));
- }
- d339 1
- a339 4
- if (marriage->wife->died.known)
- {
- strcat(buf, date2string(&marriage->wife->died));
- }
- d344 7
- a350 1
- #endif
- d560 6
- d572 1
- a572 1
- if (d == NULL)
- d576 1
- a576 1
- sprintf(buf, "%d/", d->day);
- d578 1
- a578 1
- strcpy(buf, "?/");
- d580 1
- a580 1
- if (d->mvalid)
- d582 1
- a582 1
- sprintf(tbuf, "%d/", d->month);
- d586 1
- a586 1
- strcat(buf, "?/");
- @
-
-
- 1.5
- log
- @improved comments; new prolog stuff, fixed landscape mode
- code, moved some functions to layout.c
- @
- text
- @d3 1
- a3 1
- * $RCSfile$
- d5 1
- a5 1
- * $Author$
- d7 1
- a7 1
- * $Date$
- d9 1
- a9 1
- * $State$
- d11 1
- a11 1
- * $Revision$
- d15 4
- a18 1
- * $Log$
- d20 1
- d73 2
- d83 1
- a83 1
- gap = (opts->personfont.linespc * opts->marrlines) - (opts->ticklen);
- d89 1
- d92 1
- a92 1
- XOF(opts, marriage->xpos), YOF(opts, marriage->firstchild->ypos - opts->ticklen));
- d98 11
- d110 1
- a110 2
- XOF(opts, marriage->firstchild->xpos), YOF(opts, marriage->firstchild->ypos - opts->ticklen),
- DXOF(opts, marriage->lastchild->xpos - marriage->firstchild->xpos));
- d112 3
- a117 3
- fprintf(outf, "%d %d moveto 0 %d rlineto stroke\n",
- XOF(opts, child->xpos), YOF(opts, child->ypos), DYOF(opts, -opts->ticklen));
-
- d120 5
- d129 5
- a133 1
- printperson(outf, opts, child, child->xpos, child->ypos+opts->ticklen+1);
- d174 3
- a176 1
- fprintf(outf, "personfont setfont\n");
- d180 2
- a181 1
- fprintf(outf, "%d %d moveto (ID: %lx) show\n",
- d184 7
- d196 6
- d215 1
- a215 1
- XOF(opts, x), YOF(opts, y+opts->personfont.linespc), buf);
- d252 1
- a255 1
- linepos += opts->identfont.linespc;
- d257 2
- d288 1
- a291 1
- linepos += opts->identfont.linespc;
- d293 2
- d321 1
- a325 1
- linepos += opts->personfont.linespc;
- d329 1
- a332 1
- linepos += opts->identfont.linespc;
- d347 1
- a348 1
- linepos += opts->personfont.linespc;
- d353 1
- a364 1
- linepos += opts->symfont.linespc;
- d370 1
- a372 1
- linepos += opts->personfont.linespc;
- d376 1
- a379 1
- linepos += opts->identfont.linespc;
- d394 1
- d477 3
- a479 1
- fprintf(outf, "%%%%CreatorTitle: Ftree version " VERSION " (" __DATE__ ")\n");
- d481 1
- d484 4
- a487 4
- fprintf(outf, "%%+ %s\n", opts->identfont.font);
- fprintf(outf, "%%+ %s\n", opts->symfont.font);
- fprintf(outf, "%%+ %s\n", opts->datefont.font);
- fprintf(outf, "%%+ %s\n", opts->personfont.font);
- d489 3
- d495 3
- a498 1
- fprintf(outf, "systemdict /%s known { %s } if\n", opts->papertype, opts->papertype);
- d528 1
- a528 1
- fprintf(outf, "/identfont %.1f /%s fsf\n", opts->identfont.size, opts->identfont.font);
- d536 3
- a538 2
- fprintf(outf, "-90 rotate -%d %d translate\n", opts->pageheight - opts->tmargin, opts->rmargin);
- fprintf(outf, "0.66 dup scale\n");
- d573 2
- a574 2
- fprintf(outf, "%%%%EndPage: 1 1\n");
- fprintf(outf, "%%%%Trailer:\n");
- @
-
-
- 1.4
- log
- @started to implement multiple marriages; they overprint at the
- moment! Made the DSC comments treat the tree as a page & fixed
- some minor errors. Added new code to print marriage people on
- a line.
- @
- text
- @d5 1
- a5 1
- * $Author: peteric $
- d7 1
- a7 1
- * $Date: 1994/02/12 20:33:26 $
- d11 1
- a11 1
- * $Revision: 1.3 $
- d15 1
- a15 3
- * $Log: print.c,v $
- * Revision 1.3 1994/02/12 20:33:26 peteric
- * changed interface to marriages to allow multiple marriages per id
- a16 5
- * Revision 1.2 94/02/12 20:00:23 20:00:23 peteric (Peter Ivimey-Cook)
- * added in comments etc.
- *
- *
- *
- a18 1
-
- d21 1
- a25 2
- #define TREE_GAP 12
-
- d29 1
- a29 1
- * Function: print
- a32 318
- * opts
- *
- * Outputs:
- * (file)
- *
- * Error Handling:
- * none.
- *
- * Description:
- *
- * Calls the routines to format and output PostScript
- * statements which will draw the family tree described in the
- * opts array, using data from the mroot/proot lists.
- *
- * The tree is assumed to be a true tree - i.e. one root
- * node branching out to n leaf nodes.
- *
- * If the named 'outputfile' is 'con' this is taken as
- * a signal to write output to the standard output stream
- * instead of opening a new file.
- *
- *************************************************************
- )*/
-
- void print(options_t *opts)
- {
- FILE *outf;
- person_t *pers;
- marriage_t *marr;;
-
- if (strcmp(opts->outputfile, "con"))
- {
- outf = fopen(opts->outputfile, "w");
- if (outf == NULL)
- {
- fprintf(stderr, "ftree: cannot write file '%s'\n", opts->outputfile);
- exit(1);
- }
- }
- else
- outf = stdout;
-
- /*
- * print out the prolog stuff
- */
- do_prolog(outf, opts);
-
- /*
- * put a title on the page
- */
- do_title(outf, opts);
-
- /*
- * print our tree
- */
- do_simple_layout(opts, opts->startperson, (opts->pagewidth - opts->rmargin)/2, opts->title.linespc + 3*opts->person.linespc, 0);
- adjust_layout(opts, opts->startperson);
- print_tree(outf, opts, opts->startperson);
-
- /*
- * finish it off
- */
- do_epilog(outf, opts);
-
- /*
- * close the file.
- */
- if (outf != stdout)
- fclose(outf);
- }
-
- /*(
- *************************************************************
- *
- * Function:
- *
- *
- * Inputs:
- *
- *
- * Outputs:
- *
- *
- * Error Handling:
- *
- *
- * Description:
- *
- *
- *
- *************************************************************
- )*/
-
- void do_simple_layout(options_t *opts, char *id, int x, int y, int level)
- {
- int i, children;
- int ptwidth, startx, endx, childy;
- person_t *child;
- marriage_t *marriage, *m;
-
- dbprintf(( "\ndo_simple_layout: do layout for ID %s at: %d,%d\n", id, x,y));
-
- marriage = findmarriage(id);
- while(marriage)
- {
- dbprintf(( "do_simple_layout: found marriage.\n"));
- marriage->xpos = x;
- marriage->ypos = y;
-
- /*
- * work out how many children there are
- */
- children = 0;
- ptwidth = 0;
- child = marriage->firstchild;
- while(child != NULL)
- {
- children++;
- child->married = (findmarriage(child->id) != NULL);
- child->fullname = !streq(child->family, marriage->husband->family) || child->married;
- child->width = widthof(opts, child);
- ptwidth += child->width;
- dbprintf(( "do_simple_layout: adding width for child %d\n", children));
- child = child->nextchild;
- }
- marriage->children = children;
- marriage->level = level;
-
- /*
- * ptwidth is only the width of the connecting line ... it doesn't
- * include the space at each end.
- */
- if (marriage->children >= 1)
- ptwidth -= (marriage->firstchild->width + marriage->lastchild->width) / 2;
-
- dbprintf(( "do_simple_layout: ptwidth: %d children %d\n", ptwidth, marriage->children));
-
- if (marriage->children > 0)
- {
- childy = y + opts->vspace;
- startx = x - (ptwidth / 2);
- dbprintf(( "do_simple_layout: startx: %d (= %d - (%d/2)), children: %d\n", startx, x, ptwidth,marriage->children));
- /*
- * have a go at placing the children.
- */
- child = marriage->firstchild;
- while(child != NULL)
- {
- child->xpos = startx;
- child->ypos = childy;
- dbprintf(( "do_simple_layout: child %s @@ %dx%d\n", child->firstname, startx, childy));
- startx += (child->width + child->nextchild->width) / 2;
- child = child->nextchild;
- }
-
- dbprintf(( "do_simple_layout: searching for marriages \n"));
-
- child = marriage->firstchild;
- while(child != NULL)
- {
- if (child->married)
- {
- if (level <= opts->maxlevel)
- {
- do_simple_layout(opts, child->id, child->xpos, child->ypos + opts->ticklen+1, level+1);
- }
- else
- {
- dbprintf(("do_simple_layout: marriage of %s %s skipped - too many levels.\n", child->firstname, child->family));
- }
- }
- child = child->nextchild;
- }
- }
- dbprintf(( "do_simple_layout: finished marriage.\n"));
- marriage = nextmarriage(marriage, id);
- }
-
- dbprintf(( "do_simple_layout: finished simple layout for ID %s.\n", id));
- }
-
- /*(
- *************************************************************
- *
- * Function: adjust_layout
- *
- *
- * Inputs:
- * opts - current option set
- * id - the ID of the person to start at, who should be
- * married.
- *
- * Outputs:
- * (file)
- *
- * Error Handling:
- * None.
- *
- * Description:
- *
- * This routine takes the initial positions assigned by
- * the routine do_simple_layout and adjusts the positions
- * such that people do not overlap.
- *
- *************************************************************
- )*/
-
- void adjust_layout(options_t *opts, char *id)
- {
- person_t *child, *lastchild = NULL;
- marriage_t *m, *marriage;
- int newpos, dx;
-
- dbprintf(( "adjust_layout: examining tree for ID %s....\n", id));
-
- marriage = findmarriage(id);
- while(marriage)
- {
- child = marriage->firstchild;
- while(child != NULL)
- {
- if (child->married)
- {
- adjust_layout(opts, child->id);
- m = findmarriage(child->id);
- }
- if (child->married && m->children > 0)
- {
- if (lastchild)
- {
- newpos = m->firstchild->xpos;
- dx = lastchild->xpos - newpos;
- dbprintf(("adjust_layout: does child %s overlap %s (%d vs %d) ?",
- m->firstchild->firstname, lastchild->firstname, newpos, lastchild->xpos));
- if (dx > 0)
- {
- dbprintf((" ... yes\n"));
- dx += ((lastchild->width + m->firstchild->width) / 2 );
- dbprintf(("adjust_layout: dx += (%d + %d)/2 => %d\n", lastchild->width, m->firstchild->width, dx));
- move_tree(m, dx);
- child->xpos += dx;
- }
- else
- {
- dbprintf((" ... no\n"));
- }
- }
- lastchild = m->lastchild;
- }
- child = child->nextchild;
- }
- marriage = nextmarriage(marriage, id);
- }
-
- dbprintf(( "adjust_layout: finished examining tree for ID %s...\n", id));
- }
-
- /*(
- *************************************************************
- *
- * Function: move_tree
- *
- *
- * Inputs:
- * marriage - the base of the tree to move
- * dx - the ammount by which to move the tree
- *
- * Outputs:
- * none.
- *
- * Error Handling:
- * none.
- *
- * Description:
- *
- * Moves the tree based at 'marriage' by an ammount 'dx'
- * in the X direction. No effect in the Y direction.
- *
- *************************************************************
- )*/
-
- void move_tree(marriage_t *marriage, int dx)
- {
- person_t *child;
- marriage_t *m;
-
- dbprintf(( "move_tree: move marriage %s %s by %d\n",
- marriage->husband->firstname, marriage->wife->family, dx));
-
- marriage->xpos += dx;
-
- if (marriage->children > 0)
- {
- child = marriage->firstchild;
- while(child != NULL)
- {
- child->xpos += dx;
-
- dbprintf(( "move_tree: move child %s %s by %d\n",
- child->firstname, child->family, dx));
-
- if (child->married)
- {
- m = findmarriage(child->id);
- move_tree(m, dx);
- }
- child = child->nextchild;
- }
- }
- }
-
- /*(
- *************************************************************
- *
- * Function:
- *
- *
- * Inputs:
- d51 1
- a51 1
- void print_tree(FILE *outf, options_t *opts, char *id)
- d54 1
- a54 1
- marriage_t *m, *marriage;
- d56 1
- a56 1
- marriage = findmarriage(id);
- d77 1
- a77 1
- gap = (opts->person.linespc * opts->marrlines) - (opts->ticklen);
- a120 47
- * Function: widthof
- *
- *
- * Inputs:
- *
- *
- * Outputs:
- *
- *
- * Error Handling:
- *
- *
- * Description:
- *
- * return the width required to print 'person'
- *
- *************************************************************
- )*/
-
- int widthof(options_t *opts, person_t *pers)
- {
- int w;
- person_t *child;
- int l;
-
- if (pers->fullname)
- {
- l = strlen(pers->family);
- l += strlen(pers->firstname);
- }
- else
- {
- l = strlen(pers->firstname);
- }
-
- w = (opts->person.size * l) / 1.5;
- w = w + TREE_GAP;
-
- dbprintf(( "widthof: %s width of \"%s\" is \t%d (%dc).\n",
- (pers->fullname)?"full":"short", pers->firstname, w, l));
- return w;
- }
-
-
- /*(
- *************************************************************
- *
- d151 2
- a152 2
- linepos += opts->ident.linespc;
- fprintf(outf, "%d %d moveto (ID: %s) show\n",
- d173 1
- a173 1
- XOF(opts, x), YOF(opts, y+opts->person.linespc), buf);
- d212 2
- a213 2
- fprintf(outf, "(ID: %s) show\n", marriage->husband->id);
- linepos += opts->ident.linespc;
- d219 1
- a219 1
- linepos += opts->person.linespc;
- d223 1
- a223 1
- linepos += opts->person.linespc;
- d246 2
- a247 2
- fprintf(outf, "(ID: %s) showright\n", marriage->wife->id);
- linepos += opts->ident.linespc;
- d252 1
- a252 1
- linepos += opts->person.linespc;
- d255 1
- a255 1
- linepos += opts->person.linespc;
- d279 1
- a279 1
- linepos += opts->person.linespc;
- d285 2
- a286 2
- fprintf(outf, "(ID: %s) show\n", marriage->husband->id);
- linepos += opts->ident.linespc;
- d302 1
- a302 1
- linepos += opts->person.linespc;
- d305 1
- a305 1
- * put an '=' between the people
- d307 12
- a318 3
- fprintf(outf, "%d %d moveto\n", XOF(opts, x), YOF(opts, linepos));
- fprintf(outf, "(=) showcentered\n");
- linepos += opts->person.linespc;
- d326 1
- a326 1
- linepos += opts->person.linespc;
- d332 2
- a333 2
- fprintf(outf, "(ID: %s) showcentered\n", marriage->wife->id);
- linepos += opts->ident.linespc;
- a377 1
- int h;
- a378 1
- float ptsz = opts->title.size;
- d387 1
- a387 1
- by = opts->title.size * 1.7;
- d395 2
- a396 1
- XOF(opts, opts->pagewidth/2), YOF(opts, opts->title.linespc), opts->titlestr);
- d422 1
- d432 6
- a437 2
- fprintf(outf, "%%%%DocumentSuppliedResources: font %s %s %s\n",
- opts->title.font, opts->ident.font, opts->person.font);
- d444 1
- a444 1
- fprintf(outf, "/showcentered { %% str showc -- \n");
- d447 8
- a454 1
- fprintf(outf, "/showright { %% str showc -- \n");
- d458 20
- a477 4
- fprintf(outf, "/identfont %.1f /%s fsf\n", opts->ident.size, opts->ident.font);
- fprintf(outf, "/personfont %.1f /%s fsf\n", opts->person.size, opts->person.font);
- fprintf(outf, "/titlefont %.1f /%s fsf\n", opts->title.size, opts->title.font);
- fprintf(outf, "/datefont %.1f /%s fsf\n", opts->person.size-2, opts->person.font);
- d481 2
- a482 4
- fprintf(outf, "gsave clippath pathbbox grestore\n");
- fprintf(outf, "4 dict begin /ury exch def /urx exch def /lly exch def /llx exch def\n");
- fprintf(outf, "-90 rotate urx neg lly neg translate\n");
- fprintf(outf, "end\n");
- d557 1
- a557 1
- return;
- @
-
-
- 1.3
- log
- @changed interface to marriages to allow multiple marriages per id
- @
- text
- @d3 1
- a3 1
- * $Name$
- d7 1
- a7 1
- * $Date: 94/02/12 20:00:23 $
- d9 1
- a9 1
- * $Revision: 1.2 $
- d11 2
- d15 4
- a18 1
- * $Log: print.c,v $
- d38 1
- a38 1
- * Function:
- d42 1
- a42 1
- *
- d45 1
- a45 1
- *
- d48 1
- a48 1
- *
- d52 10
- a61 1
- *
- d142 1
- a142 1
- dbprintf(( "\ndo_simple_layout: marriage at: %d,%d\n", x,y));
- d147 1
- a180 2
- int gap;
-
- d210 1
- a210 1
- dbprintf(("do_simple_layout: marriage skipped - too many levels.\n"));
- d220 1
- a220 1
- dbprintf(( "do_simple_layout: finished simple layout.\n"));
- d226 1
- a226 1
- * Function:
- d230 3
- a232 1
- *
- d235 1
- a235 1
- *
- d238 1
- a238 1
- *
- d242 3
- a244 1
- *
- a252 1
- int lastpos = 0;
- d255 1
- a255 1
- dbprintf(( "adjust_layout: examining tree....\n"));
- d263 6
- a268 1
- if (child->married && (m = findmarriage(child->id)) && m->children > 0)
- d273 1
- a273 2
- dx = (lastpos - newpos);
- dbprintf(("adjust_layout: dx = (%d - %d) => %d\n", lastpos, newpos, dx));
- d275 1
- a275 1
- m->firstchild->firstname, lastchild->firstname, newpos, lastpos));
- a289 1
- lastpos = lastchild->xpos;
- d296 1
- a296 1
- dbprintf(( "adjust_layout: finished examining tree...\n"));
- d302 1
- a302 1
- * Function:
- d306 2
- a307 1
- *
- d310 1
- a310 1
- *
- d313 1
- a313 1
- *
- d317 2
- a318 1
- *
- d322 1
- a322 3
- /*
- * move a tree rooted at marriage by an ammount dx.
- */
- d360 4
- a363 1
- *
- d366 1
- a366 1
- *
- d369 1
- a369 1
- *
- d377 1
- d404 1
- a404 1
- gap = (opts->person.linespc * 5) - (opts->ticklen);
- d448 1
- a448 1
- * Function:
- d462 1
- a462 1
- *
- d466 1
- a466 3
- /*
- * return the width required to print 'person'
- */
- d483 1
- a483 1
- w = (opts->person.size * l) / 1.6;
- d495 1
- a495 1
- * Function:
- d509 2
- a510 1
- *
- d514 1
- a514 3
- /*
- * print an unmarried person centered at the position (x,y)
- */
- d553 1
- a553 1
- * Function:
- d560 1
- a560 1
- *
- d563 1
- a563 1
- *
- d567 2
- a568 1
- *
- d572 1
- a572 3
- /*
- * print two married people centered at the position (x,y)
- */
- d720 1
- a720 1
- * Function:
- d724 2
- a725 1
- *
- d728 1
- a728 1
- *
- d731 1
- a731 1
- *
- d735 2
- a736 1
- *
- d740 1
- a740 3
- /*
- * print out our title string
- */
- d748 13
- a760 10
- fprintf(outf, "0.75 setgray\n");
- lx = 0;
- ty = 0;
- rx = opts->pagewidth - opts->rmargin;
- by = opts->title.size * 1.7;
- fprintf(outf, "%d %d moveto %d %d lineto %d %d lineto %d %d lineto ",
- XOF(opts, lx), YOF(opts, ty), XOF(opts, rx), YOF(opts, ty),
- XOF(opts, rx), YOF(opts, by), XOF(opts, lx), YOF(opts, by));
- fprintf(outf, " closepath fill\n");
- fprintf(outf, "titlefont setfont 0 setgray\n");
- d768 1
- a768 1
- * Function:
- d772 2
- a773 1
- *
- d776 1
- a776 1
- *
- d779 1
- a779 1
- *
- d783 2
- a784 1
- *
- d795 1
- a795 1
- fprintf(outf, "%%%%CreatorTitle: %s\n", opts->title);
- d797 2
- a798 1
- fprintf(outf, "%%%%DocumentFonts: %s\n", opts->title.font);
- d800 4
- a803 1
- fprintf(outf, "%%%%BeginProlog\n");
- d817 10
- a826 5
- fprintf(outf, "-90 rotate %d 0 translate\n", -opts->pagewidth);
- fprintf(outf, "%d %d translate\n", opts->lmargin, opts->bmargin);
- fprintf(outf, "%%%%EndProlog\n");
- fprintf(outf, "\n");
- fprintf(outf, "%%%%Page: 1 1\n");
- d832 1
- a832 1
- * Function:
- d836 2
- a837 1
- *
- d840 1
- a840 1
- *
- d843 1
- a843 1
- *
- d847 2
- a848 1
- *
- d852 1
- d856 1
- d861 1
- d867 1
- a867 1
- * Function:
- d871 1
- a871 1
- *
- d874 1
- a874 1
- *
- d877 3
- a879 1
- *
- d883 3
- a885 1
- *
- d889 1
- d896 3
- @
-
-
- 1.2
- log
- @added in comments etc.
- @
- text
- @d5 1
- a5 1
- * $Author$
- d7 1
- a7 1
- * $Date$
- d9 1
- a9 1
- * $Revision$
- d13 4
- a16 1
- * $Log$
- d30 22
- a57 7
- marr = findmarriage(opts->startperson);
- if (marr == NULL)
- {
- fprintf(stderr, "ftree: start person %s not found in a marriage.\n", opts->startperson);
- exit(1);
- }
-
- d83 3
- a85 3
- do_simple_layout(opts, marr, (opts->pagewidth - opts->rmargin)/2, opts->title.linespc + 3*opts->person.linespc, 0);
- adjust_layout(opts, marr);
- print_tree(outf, opts, marr);
- d99 23
- a121 1
- void do_simple_layout(options_t *opts, marriage_t *marriage, int x, int y, int level)
- d126 1
- a126 1
- marriage_t *m;
- a128 3
-
- marriage->xpos = x;
- marriage->ypos = y;
- d130 2
- a131 7
- /*
- * work out how many children there are
- */
- children = 0;
- ptwidth = 0;
- child = marriage->firstchild;
- while(child != NULL)
- d133 2
- a134 10
- children++;
- child->married = (findmarriage(child->id) != NULL);
- child->fullname = !streq(child->family, marriage->husband->family) || child->married;
- child->width = widthof(opts, child);
- ptwidth += child->width;
- dbprintf(( "do_simple_layout: adding width for child %d\n", children));
- child = child->nextchild;
- }
- marriage->children = children;
- marriage->level = level;
- a135 16
- /*
- * ptwidth is only the width of the connecting line ... it doesn't
- * include the space at each end.
- */
- if (marriage->children >= 1)
- ptwidth -= (marriage->firstchild->width + marriage->lastchild->width) / 2;
-
- dbprintf(( "do_simple_layout: ptwidth: %d children %d\n", ptwidth, marriage->children));
-
- if (marriage->children > 0)
- {
- int gap;
-
- childy = y + opts->vspace;
- startx = x - (ptwidth / 2);
- dbprintf(( "do_simple_layout: startx: %d (= %d - (%d/2)), children: %d\n", startx, x, ptwidth,marriage->children));
- d137 1
- a137 1
- * have a go at placing the children.
- d139 2
- d144 6
- a149 4
- child->xpos = startx;
- child->ypos = childy;
- dbprintf(( "do_simple_layout: child %s @@ %dx%d\n", child->firstname, startx, childy));
- startx += (child->width + child->nextchild->width) / 2;
- d152 2
- d155 6
- a160 1
- dbprintf(( "do_simple_layout: searching for marriages \n"));
- d162 3
- a164 2
- child = marriage->firstchild;
- while(child != NULL)
- d166 10
- a175 1
- if (child->married && (m = findmarriage(child->id)) != NULL && (level <= opts->maxlevel))
- d177 5
- a181 3
- dbprintf(("do_simple_layout: calling do_simple_layout...\n"));
- do_simple_layout(opts, m, child->xpos, child->ypos + opts->ticklen+1, level+1);
- dbprintf(("do_simple_layout: returning from do_simple_layout...\n"));
- d183 19
- a201 1
- child = child->nextchild;
- d203 2
- d206 2
- a207 1
- dbprintf(( "do_simple_layout: finished writing marriage.\n"));
- d210 21
- d232 1
- a232 1
- void adjust_layout(options_t *opts, marriage_t *marriage)
- d235 1
- a235 1
- marriage_t *m;
- d241 2
- a242 2
- child = marriage->firstchild;
- while(child != NULL)
- d244 2
- a245 1
- if (child->married && (m = findmarriage(child->id)) && m->children > 0)
- d247 1
- a247 1
- if (lastchild)
- d249 1
- a249 6
- newpos = m->firstchild->xpos;
- dx = (lastpos - newpos);
- dbprintf(("adjust_layout: dx = (%d - %d) => %d\n", lastpos, newpos, dx));
- dbprintf(("adjust_layout: does child %s overlap %s (%d vs %d) ?",
- m->firstchild->firstname, lastchild->firstname, newpos, lastpos));
- if (dx > 0)
- d251 17
- a267 5
- dbprintf((" ... yes\n"));
- dx += ((lastchild->width + m->firstchild->width) / 2 );
- dbprintf(("adjust_layout: dx += (%d + %d)/2 => %d\n", lastchild->width, m->firstchild->width, dx));
- move_tree(m, dx);
- child->xpos += dx;
- d269 2
- a270 4
- else
- {
- dbprintf((" ... no\n"));
- }
- d272 1
- a272 2
- lastchild = m->lastchild;
- lastpos = lastchild->xpos;
- d274 1
- a274 1
- child = child->nextchild;
- d280 21
- d334 22
- a355 1
- void print_tree(FILE *outf, options_t *opts, marriage_t *marriage)
- d358 1
- a358 1
- marriage_t *m;
- d360 2
- a361 7
- dbprintf(( "\nprint_tree: marriage at: %d,%d\n", marriage->xpos, marriage->ypos));
- /*
- * print this marriage.
- */
- printmarriage(outf, opts, marriage, marriage->xpos, marriage->ypos);
-
- if (marriage->children > 0)
- d363 1
- a363 1
- int gap;
- a364 4
- dbprintf(( "print_tree: writing %d children ...\n", marriage->children));
-
- fprintf(outf, "1 setlinewidth\n");
-
- d366 1
- a366 1
- * gap allowed for the parents info.
- d368 5
- a372 1
- gap = (opts->person.linespc * 5) - (opts->ticklen);
- d374 1
- a374 7
- /*
- * draw a line 'connecting' the parents
- * to the children's line.
- */
- fprintf(outf, "%d %d moveto %d %d lineto stroke\n",
- XOF(opts, marriage->xpos), YOF(opts, marriage->ypos + gap),
- XOF(opts, marriage->xpos), YOF(opts, marriage->firstchild->ypos - opts->ticklen));
- d376 1
- a376 7
- /*
- * draw the horizontal line connecting
- * the children together.
- */
- fprintf(outf, "%d %d moveto %d 0 rlineto stroke\n",
- XOF(opts, marriage->firstchild->xpos), YOF(opts, marriage->firstchild->ypos - opts->ticklen),
- DXOF(opts, marriage->lastchild->xpos - marriage->firstchild->xpos));
- d378 23
- a400 7
- child = marriage->firstchild;
- while(child != NULL)
- {
- fprintf(outf, "%d %d moveto 0 %d rlineto stroke\n",
- XOF(opts, child->xpos), YOF(opts, child->ypos), DYOF(opts, -opts->ticklen));
-
- if (child->married)
- d402 12
- a413 2
- m = findmarriage(child->id);
- print_tree(outf, opts, m);
- a414 5
- else
- {
- printperson(outf, opts, child, child->xpos, child->ypos+opts->ticklen+1);
- }
- child = child->nextchild;
- d416 3
- a418 1
- }
- d422 21
- d471 21
- d530 21
- a553 1
- #if 0
- d557 1
- a624 1
- }
- a625 3
- void printmarriage(FILE *outf, options_t *opts, marriage_t *marriage,
- int x, int y)
- {
- d695 1
- a696 1
- #endif
- d698 21
- d743 21
- d796 21
- d826 21
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d1 17
- @
-