15b0d93edSopcode /*
2*7715c728Sopcode  * @(#)long1.c	1.2	01/03/85
35b0d93edSopcode  *
45b0d93edSopcode  * Routines to implement "long" commands in the SUN Gremlin picture editor.
55b0d93edSopcode  *
65b0d93edSopcode  * Mark Opperman (opcode@monet.BERKELEY)
75b0d93edSopcode  *
85b0d93edSopcode  */
95b0d93edSopcode 
105b0d93edSopcode /*
115b0d93edSopcode  * This file contains routines to implement the long text commands
125b0d93edSopcode  * of the gremlin PICTURE editor.
135b0d93edSopcode  */
145b0d93edSopcode 
155b0d93edSopcode #include <sunwindow/rect.h>
165b0d93edSopcode #include "gremlin.h"
175b0d93edSopcode #include <ctype.h>
185b0d93edSopcode 
195b0d93edSopcode /* imports from graphics files */
205b0d93edSopcode 
215b0d93edSopcode extern GRBlankPoints();
225b0d93edSopcode extern GRDisplayPoint();
235b0d93edSopcode extern GRErasePoint();
245b0d93edSopcode extern GRfontfound();
255b0d93edSopcode extern GROpenFont();
265b0d93edSopcode extern GRSetTextPos();
275b0d93edSopcode extern curve_set;		/* TRUE if spline points pre-computed */
285b0d93edSopcode 
295b0d93edSopcode /* imports from point.c */
305b0d93edSopcode 
315b0d93edSopcode extern POINT *PTMakeTextPoints();
325b0d93edSopcode 
335b0d93edSopcode /* imports from display.c */
345b0d93edSopcode 
355b0d93edSopcode extern DISClearSetDisplay();
365b0d93edSopcode extern DISScreenAdd();
375b0d93edSopcode extern DISScreenErase();
385b0d93edSopcode 
395b0d93edSopcode /* imports from database files */
405b0d93edSopcode 
415b0d93edSopcode extern ELT *DBCreateElt();
425b0d93edSopcode extern DBGravitate();
435b0d93edSopcode extern DBChangeBrush();
445b0d93edSopcode extern DBChangeFont();
455b0d93edSopcode extern DBChangeSize();
465b0d93edSopcode extern DBChangeStipple();
475b0d93edSopcode extern DBChangeText();
485b0d93edSopcode extern DBChangeJustify();
495b0d93edSopcode extern DBAddSet();
505b0d93edSopcode extern DBClearSet();
515b0d93edSopcode extern POINT *PTMakePoint();
525b0d93edSopcode extern PTDeletePoint();
535b0d93edSopcode 
545b0d93edSopcode /* imports from undodb.c */
555b0d93edSopcode 
565b0d93edSopcode extern UNRembMod();
575b0d93edSopcode 
585b0d93edSopcode /* imports from short.c */
595b0d93edSopcode 
605b0d93edSopcode extern SHUpdate();
615b0d93edSopcode 
625b0d93edSopcode /* imports from menu.c  */
635b0d93edSopcode 
645b0d93edSopcode extern HiArtMode;
655b0d93edSopcode extern HiLineStyle;
665b0d93edSopcode extern HiBrush[];
675b0d93edSopcode extern MNHighLt();
685b0d93edSopcode extern MNUnHighLt();
695b0d93edSopcode extern HiFont[];
705b0d93edSopcode extern HiSize[];
715b0d93edSopcode extern HiStipple[];
725b0d93edSopcode 
735b0d93edSopcode /* imports from text.c */
745b0d93edSopcode 
755b0d93edSopcode extern TxKillLine();
765b0d93edSopcode extern TxMsgOK();
775b0d93edSopcode extern text_getvalue();
785b0d93edSopcode 
795b0d93edSopcode /* imports from C */
805b0d93edSopcode 
815b0d93edSopcode extern char *malloc();
825b0d93edSopcode extern char *strcpy();
835b0d93edSopcode 
845b0d93edSopcode /* imports from main.c */
855b0d93edSopcode 
865b0d93edSopcode extern ELT *PICTURE;                /* current PICTURE database      */
875b0d93edSopcode extern ELT *cset;                   /* current set database          */
885b0d93edSopcode extern Artmode;			/* indication of point display size */
895b0d93edSopcode extern CBRUSH, CSIZE, CFONT;        /* current brush, size, font     */
905b0d93edSopcode extern CJUST;                       /* current text justification    */
915b0d93edSopcode extern CSTIPPLE;		    /* current stipple pattern	     */
925b0d93edSopcode extern Alignment;                   /* point alignment indicator     */
935b0d93edSopcode extern float PX, PY;                /* cursor coordinates            */
945b0d93edSopcode extern float Lastx, Lasty;          /* previous cursor coordinates   */
955b0d93edSopcode extern SEQ;                         /* point sequence number         */
965b0d93edSopcode extern POINT *POINTLIST, *BACKPOINT;/* accumulated point list        */
975b0d93edSopcode extern Adjustment;                  /* point adjustment mode         */
985b0d93edSopcode extern GravityOn;                   /* gravity mode flag             */
995b0d93edSopcode extern CHANGED;                     /* PICTURE changed flag          */
1005b0d93edSopcode extern SymbolicLines;
1015b0d93edSopcode extern Gridsize;
1025b0d93edSopcode 
1035b0d93edSopcode extern SUN_XORIGIN;
1045b0d93edSopcode extern SUN_YORIGIN;
1055b0d93edSopcode extern struct rect pix_size;
1065b0d93edSopcode 
1075b0d93edSopcode /* locals */
1085b0d93edSopcode 
1095b0d93edSopcode int SHOWPOINTS;			/* TRUE if current set reference points on */
1105b0d93edSopcode 
1115b0d93edSopcode static char badarg[] = "bad args";
1125b0d93edSopcode static char noset[] = "no current set";
1135b0d93edSopcode static char delmsg[] = "can't delete any more points";
1145b0d93edSopcode 
1155b0d93edSopcode #define BADNUM 0x7fffffff	/* largest positive 32-bit integer */
1165b0d93edSopcode 
1175b0d93edSopcode /*
1185b0d93edSopcode  * This routine trys to interpret the string starting at
1195b0d93edSopcode  * line+index as an integral numeric parameter.  The function
1205b0d93edSopcode  * returns the numeric equivalent or the largest possible
1215b0d93edSopcode  * integer if there is some error in interpreting the string.
1225b0d93edSopcode  */
GetNumParm(line,index)1235b0d93edSopcode GetNumParm(line, index)
1245b0d93edSopcode register char *line;
1255b0d93edSopcode register int *index;
1265b0d93edSopcode {
1275b0d93edSopcode     char num[20];
1285b0d93edSopcode     register sign = 1;
1295b0d93edSopcode     register i;
1305b0d93edSopcode     int result;
1315b0d93edSopcode 
1325b0d93edSopcode     for (i=0; (*(line + *index) == ' '); ++i)	/* skip blanks */
1335b0d93edSopcode 	++(*index);
1345b0d93edSopcode 
1355b0d93edSopcode     if (*(line + *index) == '-') {		/* negative number */
1365b0d93edSopcode 	sign = -1;
1375b0d93edSopcode 	++(*index);
1385b0d93edSopcode     }
1395b0d93edSopcode 
1405b0d93edSopcode     for (i=0; !Delimiter(*(line + *index)); ++i) {
1415b0d93edSopcode 	num[i] = *(line + *index);
1425b0d93edSopcode 	if (!isdigit(num[i]))
1435b0d93edSopcode 	    return(BADNUM);
1445b0d93edSopcode 	++(*index);
1455b0d93edSopcode     }
1465b0d93edSopcode 
1475b0d93edSopcode     if (i == 0)
1485b0d93edSopcode 	return(BADNUM);
1495b0d93edSopcode 
1505b0d93edSopcode     num[i] = '\0';
1515b0d93edSopcode     (void) sscanf(num, "%d", &result);
1525b0d93edSopcode     return(result * sign);
1535b0d93edSopcode }  /* end GetNumParm */
1545b0d93edSopcode 
1555b0d93edSopcode 
1565b0d93edSopcode /*
1575b0d93edSopcode  * This routine accepts coordinates from the text terminal
1585b0d93edSopcode  * and creates and displays a point from them by passing them
1595b0d93edSopcode  * along to LGPoint.
1605b0d93edSopcode  */
LGOPoint()1615b0d93edSopcode LGOPoint()
1625b0d93edSopcode {
1635b0d93edSopcode     int index, xcoord, ycoord;
1645b0d93edSopcode     char buf[TEXT_BUFMAX];
1655b0d93edSopcode 
1665b0d93edSopcode     text_getvalue(&buf[0]);
1675b0d93edSopcode     TxKillLine();
1685b0d93edSopcode     index = 0;
1695b0d93edSopcode     xcoord = GetNumParm(buf, &index);
1705b0d93edSopcode     if (xcoord == BADNUM) {
1715b0d93edSopcode 	error(badarg);
1725b0d93edSopcode 	return;
1735b0d93edSopcode     }
1745b0d93edSopcode 
1755b0d93edSopcode     ++index;
1765b0d93edSopcode     ycoord = GetNumParm(buf, &index);
1775b0d93edSopcode     if (ycoord == BADNUM) {
1785b0d93edSopcode 	error(badarg);
1795b0d93edSopcode 	return;
1805b0d93edSopcode     }
1815b0d93edSopcode 
1825b0d93edSopcode     PX = xcoord;
1835b0d93edSopcode     PY = ycoord;
1845b0d93edSopcode     LGPoint();
1855b0d93edSopcode }  /* end LGOPoint */
1865b0d93edSopcode 
1875b0d93edSopcode 
1885b0d93edSopcode /*
1895b0d93edSopcode  * This routine accepts cursor coordinates (global PX & PY) and then
1905b0d93edSopcode  * creates and displays points according to the current adjustment and
1915b0d93edSopcode  * alignment modes.  Note that alignment and gravity are mutually exclusive
1925b0d93edSopcode  * and adjustment takes precedence over either.
1935b0d93edSopcode  */
LGPoint()1945b0d93edSopcode LGPoint()
1955b0d93edSopcode {
1965b0d93edSopcode     ELT *temp;
1975b0d93edSopcode     POINT *p1;
1985b0d93edSopcode     float signx = 1.0;
1995b0d93edSopcode     float signy = 1.0;
2005b0d93edSopcode 
2015b0d93edSopcode     temp = DBInit();
2025b0d93edSopcode     if (GravityOn)
2035b0d93edSopcode 	DBGravitate (PX, PY, &PX, &PY, &p1, &temp, PICTURE, FALSE);
2045b0d93edSopcode 
2055b0d93edSopcode     if (DBNullelt(temp)) {   /* no gravity in effect */
2065b0d93edSopcode 	/* Round to nearest alignment boundary */
2075b0d93edSopcode 	if (PX < 0) {
2085b0d93edSopcode 	    signx = -1.0;
2095b0d93edSopcode 	    PX = -PX;
2105b0d93edSopcode 	}
2115b0d93edSopcode 	if (PY < 0) {
2125b0d93edSopcode 	    signy = -1.0;
2135b0d93edSopcode 	    PY = -PY;
2145b0d93edSopcode 	}
2155b0d93edSopcode 
2165b0d93edSopcode 	PX = (float) (((int) (PX / Alignment + 0.5)) * Alignment) * signx;
2175b0d93edSopcode 	PY = (float) (((int) (PY / Alignment + 0.5)) * Alignment) * signy;
2185b0d93edSopcode     }
2195b0d93edSopcode 
2205b0d93edSopcode     if (SEQ > 0) {    /* this isn't the first point */
2215b0d93edSopcode 	switch (Adjustment) {
2225b0d93edSopcode 	    case HORZ:
2235b0d93edSopcode 		PY = Lasty;
2245b0d93edSopcode 		break;
2255b0d93edSopcode 	    case VERT:
2265b0d93edSopcode 		PX = Lastx;
2275b0d93edSopcode 		break;
2285b0d93edSopcode 	    case MAN:
2295b0d93edSopcode 		if (fabs(PX - Lastx) > fabs(PY - Lasty))
2305b0d93edSopcode 		    PY = Lasty;
2315b0d93edSopcode 		else
2325b0d93edSopcode 		    PX = Lastx;
2335b0d93edSopcode 		break;
2345b0d93edSopcode 	}
2355b0d93edSopcode     }
2365b0d93edSopcode 
2375b0d93edSopcode     if (SEQ >= MAXPOINTS) {
2385b0d93edSopcode 	error("too many points");
2395b0d93edSopcode 	return;
2405b0d93edSopcode     }
2415b0d93edSopcode 
2425b0d93edSopcode     GRDisplayPoint(PX, PY, SEQ);
2435b0d93edSopcode     (void) PTMakePoint(PX, PY, &POINTLIST);
2445b0d93edSopcode     Lastx = PX;
2455b0d93edSopcode     Lasty = PY;
2465b0d93edSopcode 
2475b0d93edSopcode     ++SEQ;
2485b0d93edSopcode }  /* end LGPoint */
2495b0d93edSopcode 
2505b0d93edSopcode 
2515b0d93edSopcode /*
2525b0d93edSopcode  * Clear all points on from Showpoints command.
2535b0d93edSopcode  */
CSP()2545b0d93edSopcode CSP()
2555b0d93edSopcode {
2565b0d93edSopcode     if (SHOWPOINTS)
2575b0d93edSopcode 	LGShowPoints();
2585b0d93edSopcode }
2595b0d93edSopcode 
2605b0d93edSopcode 
2615b0d93edSopcode /*
2625b0d93edSopcode  * This routine deletes all points from the POINTLIST and
2635b0d93edSopcode  * clears them from the display also.
2645b0d93edSopcode  */
CP()2655b0d93edSopcode CP()
2665b0d93edSopcode {
2675b0d93edSopcode     POINT *temp;
2685b0d93edSopcode 
2695b0d93edSopcode     while (!Nullpoint(BACKPOINT)) {
2705b0d93edSopcode 	temp = PTNextPoint(BACKPOINT);
2715b0d93edSopcode 	free ((char *) BACKPOINT);
2725b0d93edSopcode 	BACKPOINT = temp;
2735b0d93edSopcode     }
2745b0d93edSopcode 
2755b0d93edSopcode     GRBlankPoints(POINTLIST);
2765b0d93edSopcode     BACKPOINT = POINTLIST;
2775b0d93edSopcode     POINTLIST = PTInit();
2785b0d93edSopcode     SEQ = 0;
2795b0d93edSopcode }  /* end CP */
2805b0d93edSopcode 
2815b0d93edSopcode 
2825b0d93edSopcode /*
2835b0d93edSopcode  * Clear all displayed points.
2845b0d93edSopcode  */
LGClearPoints()2855b0d93edSopcode LGClearPoints()
2865b0d93edSopcode {
2875b0d93edSopcode     CP();
2885b0d93edSopcode     CSP();
2895b0d93edSopcode }  /* end LGClearPoints */
2905b0d93edSopcode 
2915b0d93edSopcode 
2925b0d93edSopcode /*
2935b0d93edSopcode  * This routine removes the last point from the POINTLIST
2945b0d93edSopcode  * and erases it from the screen.
2955b0d93edSopcode  */
LGDeletePoint()2965b0d93edSopcode LGDeletePoint()
2975b0d93edSopcode {
2985b0d93edSopcode     POINT *pt1, *pt2, *pt3;
2995b0d93edSopcode 
3005b0d93edSopcode     if (SEQ == 0) {
3015b0d93edSopcode 	error("no point");
3025b0d93edSopcode 	return;
3035b0d93edSopcode     }
3045b0d93edSopcode 
3055b0d93edSopcode     pt2 = pt3 = POINTLIST;
3065b0d93edSopcode     while (!Nullpoint(pt3)) {	/* find last point and pointer to it */
3075b0d93edSopcode 	pt1 = pt2;
3085b0d93edSopcode 	pt2 = pt3;
3095b0d93edSopcode 	pt3 = PTNextPoint(pt3);
3105b0d93edSopcode     }
3115b0d93edSopcode 
3125b0d93edSopcode     SEQ--;
3135b0d93edSopcode     GRErasePoint(pt2->x, pt2->y, SEQ);
3145b0d93edSopcode     PTDeletePoint(pt2, &POINTLIST);
3155b0d93edSopcode     if (SEQ > 0) {	/* pt1 points to last one of them */
3165b0d93edSopcode 	Lastx = pt1->x;
3175b0d93edSopcode 	Lasty = pt1->y;
3185b0d93edSopcode     }
3195b0d93edSopcode }  /* end LGDeletePoint */
3205b0d93edSopcode 
3215b0d93edSopcode 
3225b0d93edSopcode /*
3235b0d93edSopcode  *  This routine causes the positioning points of the current set
3245b0d93edSopcode  *  to be displayed.
3255b0d93edSopcode  */
LGShowPoints()3265b0d93edSopcode LGShowPoints()
3275b0d93edSopcode {
3285b0d93edSopcode     register ELT *elt;
3295b0d93edSopcode     register POINT *p1;
3305b0d93edSopcode     register pno;
3315b0d93edSopcode 
3325b0d93edSopcode     if (DBNullelt(cset)) {
3335b0d93edSopcode 	error(noset);
3345b0d93edSopcode 	return;
3355b0d93edSopcode     }
3365b0d93edSopcode 
3375b0d93edSopcode     elt = cset;
3385b0d93edSopcode     while (!DBNullelt(elt)) {
3395b0d93edSopcode 	p1 = elt->ptlist;
3405b0d93edSopcode 	pno = 0;
3415b0d93edSopcode 
3425b0d93edSopcode 	while (!Nullpoint(p1)) {
3435b0d93edSopcode 	    GRDisplayPoint(p1->x, p1->y, pno);
3445b0d93edSopcode 	    p1 = PTNextPoint(p1);
3455b0d93edSopcode 	    pno++;
3465b0d93edSopcode 	}
3475b0d93edSopcode 
3485b0d93edSopcode 	elt = DBNextofSet(elt);
3495b0d93edSopcode     }
3505b0d93edSopcode     SHOWPOINTS = !SHOWPOINTS;
3515b0d93edSopcode } /* end LGShowPoints */
3525b0d93edSopcode 
3535b0d93edSopcode 
3545b0d93edSopcode /*
3555b0d93edSopcode  *  This routine handles the two forms of the TEXT command.
3565b0d93edSopcode  *  From the text subwindow, when a RETURN is pressed, the text
3575b0d93edSopcode  *  buffer is copied to the LAST point layed down, the text is
3585b0d93edSopcode  *  consumed, and that point is eaten.  This provides a convenient
3595b0d93edSopcode  *  method of entering several TEXT elements at many locations
3605b0d93edSopcode  *  in the picture.
3615b0d93edSopcode  *  From the menu subwindow, the traditional Gremlin TEXT command
3625b0d93edSopcode  *  is implemented.  One or two points may be specified, and all
3635b0d93edSopcode  *  points are consumed at the end of the command.
3645b0d93edSopcode  */
3655b0d93edSopcode static
LGTextDisplay(oldway)3665b0d93edSopcode LGTextDisplay(oldway)
3675b0d93edSopcode int oldway;
3685b0d93edSopcode {
3695b0d93edSopcode     register ELT *elt;
3705b0d93edSopcode     char buf[TEXT_BUFMAX];
3715b0d93edSopcode     POINT pos, ppnt, *p1;
3725b0d93edSopcode     char *text;
3735b0d93edSopcode 
3745b0d93edSopcode     if (SEQ == 0) {
3755b0d93edSopcode 	error("not enough points");
3765b0d93edSopcode 	return;
3775b0d93edSopcode     }
3785b0d93edSopcode 
3795b0d93edSopcode     text_getvalue(&buf[0]);
3805b0d93edSopcode 
3815b0d93edSopcode     if (*buf == '\0') {		/* no text */
3825b0d93edSopcode 	error("empty string");
3835b0d93edSopcode 	return;
3845b0d93edSopcode     }
3855b0d93edSopcode 
3865b0d93edSopcode     GROpenFont(CFONT, CSIZE);
3875b0d93edSopcode     if (!GRfontfound(CFONT, CSIZE)) {
3885b0d93edSopcode 	error("can't open font file");
3895b0d93edSopcode 	return;
3905b0d93edSopcode     }
3915b0d93edSopcode 
3925b0d93edSopcode     UNForget();
3935b0d93edSopcode     text = malloc((unsigned) strlen(buf) + 1);
3945b0d93edSopcode     (void) strcpy(text, buf);
3955b0d93edSopcode     DISClearSetDisplay();
3965b0d93edSopcode     DBClearSet();
3975b0d93edSopcode 
3985b0d93edSopcode     if (oldway == TRUE) {	/* one or two points OK */
3995b0d93edSopcode 	ppnt.x = POINTLIST->x;
4005b0d93edSopcode 	ppnt.y = POINTLIST->y;
4015b0d93edSopcode 	if (SEQ > 1) {
4025b0d93edSopcode 	    p1 = PTNextPoint(POINTLIST);
4035b0d93edSopcode 	    ppnt.x = (ppnt.x + p1->x) / 2;
4045b0d93edSopcode 	    ppnt.y = (ppnt.y + p1->y) / 2;
4055b0d93edSopcode 	}
4065b0d93edSopcode     }
4075b0d93edSopcode     else {			/* find last point */
4085b0d93edSopcode 	p1 = POINTLIST;
4095b0d93edSopcode 	while (!Nullpoint(PTNextPoint(p1)))
4105b0d93edSopcode 	    p1 = PTNextPoint(p1);
4115b0d93edSopcode 	ppnt.x = p1->x;
4125b0d93edSopcode 	ppnt.y = p1->y;
4135b0d93edSopcode     }
4145b0d93edSopcode 
4155b0d93edSopcode     GRSetTextPos(text, CJUST, CFONT, CSIZE, &ppnt, &pos);
4165b0d93edSopcode     p1 = PTMakeTextPoints(text, CFONT, CSIZE, &ppnt, &pos);
4175b0d93edSopcode     elt = DBCreateElt(CJUST, p1, CFONT, CSIZE, text, &PICTURE);
4185b0d93edSopcode 
4195b0d93edSopcode     DISScreenAdd(elt, pixmask | csetmask);
4205b0d93edSopcode     DBAddSet(elt);
4215b0d93edSopcode 
4225b0d93edSopcode     if (oldway == TRUE)
4235b0d93edSopcode 	CP();
4245b0d93edSopcode     else
4255b0d93edSopcode 	LGDeletePoint();
4265b0d93edSopcode 
4275b0d93edSopcode     TxKillLine();
4285b0d93edSopcode     CHANGED = TRUE;
4295b0d93edSopcode }  /* end LGTextDisplay */
4305b0d93edSopcode 
4315b0d93edSopcode 
4325b0d93edSopcode /*
4335b0d93edSopcode  *  This routine implements the TEXT command from the menu subwindow.
4345b0d93edSopcode  */
LGText()4355b0d93edSopcode LGText()
4365b0d93edSopcode {
4375b0d93edSopcode     LGTextDisplay(TRUE);		/* the old way of doing text entry */
4385b0d93edSopcode }  /* end LGText */
4395b0d93edSopcode 
4405b0d93edSopcode 
LGTextSW()4415b0d93edSopcode LGTextSW()
4425b0d93edSopcode {
4435b0d93edSopcode     LGTextDisplay(FALSE);		/* the new way of doing text entry */
4445b0d93edSopcode }  /* end LGTextSW */
4455b0d93edSopcode 
4465b0d93edSopcode 
4475b0d93edSopcode /*
4485b0d93edSopcode  * This routine sets the current brush to that specified in the parameter.
4495b0d93edSopcode  */
LGBrush(brush)4505b0d93edSopcode LGBrush(brush)
4515b0d93edSopcode {
4525b0d93edSopcode     MNUnHighLt(HiBrush[CBRUSH-1]);
4535b0d93edSopcode     CBRUSH = brush;
4545b0d93edSopcode     MNHighLt(HiBrush[CBRUSH-1]);
4555b0d93edSopcode }  /* end LGBrush */
4565b0d93edSopcode 
4575b0d93edSopcode 
LGBrush1()4585b0d93edSopcode LGBrush1()
4595b0d93edSopcode {
4605b0d93edSopcode     LGBrush(1);
4615b0d93edSopcode }
4625b0d93edSopcode 
4635b0d93edSopcode 
LGBrush2()4645b0d93edSopcode LGBrush2()
4655b0d93edSopcode {
4665b0d93edSopcode     LGBrush(2);
4675b0d93edSopcode }
4685b0d93edSopcode 
4695b0d93edSopcode 
LGBrush3()4705b0d93edSopcode LGBrush3()
4715b0d93edSopcode {
4725b0d93edSopcode     LGBrush(3);
4735b0d93edSopcode }
4745b0d93edSopcode 
4755b0d93edSopcode 
LGBrush4()4765b0d93edSopcode LGBrush4()
4775b0d93edSopcode {
4785b0d93edSopcode     LGBrush(4);
4795b0d93edSopcode }
4805b0d93edSopcode 
4815b0d93edSopcode 
LGBrush5()4825b0d93edSopcode LGBrush5()
4835b0d93edSopcode {
4845b0d93edSopcode     LGBrush(5);
4855b0d93edSopcode }
4865b0d93edSopcode 
4875b0d93edSopcode 
LGBrush6()4885b0d93edSopcode LGBrush6()
4895b0d93edSopcode {
4905b0d93edSopcode     LGBrush(6);
4915b0d93edSopcode }
4925b0d93edSopcode 
4935b0d93edSopcode 
4945b0d93edSopcode /*
4955b0d93edSopcode  * This routine causes the elements in the current set
4965b0d93edSopcode  * to be redrawn using the new brush.
4975b0d93edSopcode  */
LGMBrush(brush)4985b0d93edSopcode LGMBrush(brush)
4995b0d93edSopcode int brush;
5005b0d93edSopcode {
5015b0d93edSopcode     register ELT *elt;
5025b0d93edSopcode 
5035b0d93edSopcode     if (DBNullelt(cset)) {
5045b0d93edSopcode 	error(noset);
5055b0d93edSopcode 	return;
5065b0d93edSopcode     }
5075b0d93edSopcode 
5085b0d93edSopcode     UNForget();
5095b0d93edSopcode     CSP();
5105b0d93edSopcode 
5115b0d93edSopcode     elt = cset;
5125b0d93edSopcode     while (!DBNullelt(elt)) {
5135b0d93edSopcode 	if (!TEXT(elt->type)) {
5145b0d93edSopcode 	    DISScreenErase(elt, pixmask | csetmask);
5155b0d93edSopcode 	    DBChangeBrush(elt, brush, &PICTURE);
5165b0d93edSopcode 	    curve_set = TRUE;	/* no need to re-compute spline points */
5175b0d93edSopcode 	    DISScreenAdd(elt, pixmask | csetmask);
5185b0d93edSopcode 	}
5195b0d93edSopcode 	elt = DBNextofSet(elt);
5205b0d93edSopcode     }
5215b0d93edSopcode 
5225b0d93edSopcode     CP();
5235b0d93edSopcode     CHANGED = TRUE;
5245b0d93edSopcode } /* end LGMBrush */
5255b0d93edSopcode 
5265b0d93edSopcode 
LGMBrush1()5275b0d93edSopcode LGMBrush1()
5285b0d93edSopcode {
5295b0d93edSopcode     LGMBrush(1);
5305b0d93edSopcode }
5315b0d93edSopcode 
5325b0d93edSopcode 
LGMBrush2()5335b0d93edSopcode LGMBrush2()
5345b0d93edSopcode {
5355b0d93edSopcode     LGMBrush(2);
5365b0d93edSopcode }
5375b0d93edSopcode 
5385b0d93edSopcode 
LGMBrush3()5395b0d93edSopcode LGMBrush3()
5405b0d93edSopcode {
5415b0d93edSopcode     LGMBrush(3);
5425b0d93edSopcode }
5435b0d93edSopcode 
5445b0d93edSopcode 
LGMBrush4()5455b0d93edSopcode LGMBrush4()
5465b0d93edSopcode {
5475b0d93edSopcode     LGMBrush(4);
5485b0d93edSopcode }
5495b0d93edSopcode 
5505b0d93edSopcode 
LGMBrush5()5515b0d93edSopcode LGMBrush5()
5525b0d93edSopcode {
5535b0d93edSopcode     LGMBrush(5);
5545b0d93edSopcode }
5555b0d93edSopcode 
5565b0d93edSopcode 
LGMBrush6()5575b0d93edSopcode LGMBrush6()
5585b0d93edSopcode {
5595b0d93edSopcode     LGMBrush(6);
5605b0d93edSopcode }
5615b0d93edSopcode 
5625b0d93edSopcode 
5635b0d93edSopcode /*
5645b0d93edSopcode  * This routine causes text elements in the current set
5655b0d93edSopcode  * to be redrawn using the new justification mode.
5665b0d93edSopcode  * mode is 1 - 9 for tl, tc, tr, cl, cc, cl, bl, bc, br
5675b0d93edSopcode  */
LGMJustify(just)5685b0d93edSopcode LGMJustify(just)
5695b0d93edSopcode int just;
5705b0d93edSopcode {
5715b0d93edSopcode     register ELT *elt;
5725b0d93edSopcode 
5735b0d93edSopcode     if (DBNullelt(cset)) {
5745b0d93edSopcode 	error(noset);
5755b0d93edSopcode 	return;
5765b0d93edSopcode     }
5775b0d93edSopcode 
5785b0d93edSopcode     UNForget();
5795b0d93edSopcode     CSP();
5805b0d93edSopcode 
5815b0d93edSopcode     elt = cset;
5825b0d93edSopcode     while (!DBNullelt(elt)) {
5835b0d93edSopcode 	if (TEXT(elt->type)) {
5845b0d93edSopcode 	    DISScreenErase(elt, pixmask | csetmask);
5855b0d93edSopcode 	    DBChangeJustify(elt, just, &PICTURE);
5865b0d93edSopcode 	    DISScreenAdd(elt, pixmask | csetmask);
5875b0d93edSopcode 	}
5885b0d93edSopcode 	elt = DBNextofSet(elt);
5895b0d93edSopcode     }
5905b0d93edSopcode 
5915b0d93edSopcode     CP();
5925b0d93edSopcode     CHANGED = TRUE;
5935b0d93edSopcode } /* end LGMJustify */
5945b0d93edSopcode 
5955b0d93edSopcode 
5965b0d93edSopcode /*
5975b0d93edSopcode  * This routine causes the text elements in the current set
5985b0d93edSopcode  * to be redrawn using the new font.
5995b0d93edSopcode  */
LGMFont(font)6005b0d93edSopcode LGMFont(font)
6015b0d93edSopcode int font;
6025b0d93edSopcode {
6035b0d93edSopcode     register ELT *elt;
6045b0d93edSopcode 
6055b0d93edSopcode     if (DBNullelt(cset)) {
6065b0d93edSopcode 	error(noset);
6075b0d93edSopcode 	return;
6085b0d93edSopcode     }
6095b0d93edSopcode 
6105b0d93edSopcode     UNForget();
6115b0d93edSopcode     CSP();
6125b0d93edSopcode 
6135b0d93edSopcode     elt = cset;
6145b0d93edSopcode     while (!DBNullelt(elt)) {
6155b0d93edSopcode 	if (TEXT(elt->type)) {
6165b0d93edSopcode 	    GROpenFont(font, elt->size);
6175b0d93edSopcode 	    if (!GRfontfound(font, elt->size)) {
6185b0d93edSopcode 		error("can't open font file");
6195b0d93edSopcode 	    }
6205b0d93edSopcode 	    else {
6215b0d93edSopcode 		DISScreenErase(elt, pixmask | csetmask);
6225b0d93edSopcode 		TxMsgOK();
6235b0d93edSopcode 		DBChangeFont(elt, font, &PICTURE);
6245b0d93edSopcode 		DISScreenAdd(elt, pixmask | csetmask);
6255b0d93edSopcode 	    }
6265b0d93edSopcode 	}
6275b0d93edSopcode 	elt = DBNextofSet(elt);
6285b0d93edSopcode     }
6295b0d93edSopcode 
6305b0d93edSopcode     CP();
6315b0d93edSopcode     CHANGED = TRUE;
6325b0d93edSopcode }  /* end LGMFont */
6335b0d93edSopcode 
6345b0d93edSopcode 
LGMFont1()6355b0d93edSopcode LGMFont1()
6365b0d93edSopcode {
6375b0d93edSopcode     LGMFont(1);
6385b0d93edSopcode }
6395b0d93edSopcode 
6405b0d93edSopcode 
LGMFont2()6415b0d93edSopcode LGMFont2()
6425b0d93edSopcode {
6435b0d93edSopcode     LGMFont(2);
6445b0d93edSopcode }
6455b0d93edSopcode 
6465b0d93edSopcode 
LGMFont3()6475b0d93edSopcode LGMFont3()
6485b0d93edSopcode {
6495b0d93edSopcode     LGMFont(3);
6505b0d93edSopcode }
6515b0d93edSopcode 
6525b0d93edSopcode 
LGMFont4()6535b0d93edSopcode LGMFont4()
6545b0d93edSopcode {
6555b0d93edSopcode     LGMFont(4);
6565b0d93edSopcode }
6575b0d93edSopcode 
6585b0d93edSopcode 
6595b0d93edSopcode /*
6605b0d93edSopcode  * This routine causes the text elements in the current set
6615b0d93edSopcode  * to be redrawn using the new size.
6625b0d93edSopcode  */
LGMSize(size)6635b0d93edSopcode LGMSize(size)
6645b0d93edSopcode int size;
6655b0d93edSopcode {
6665b0d93edSopcode     register ELT *elt;
6675b0d93edSopcode 
6685b0d93edSopcode     if (DBNullelt(cset)) {
6695b0d93edSopcode 	error(noset);
6705b0d93edSopcode 	return;
6715b0d93edSopcode     }
6725b0d93edSopcode 
6735b0d93edSopcode     UNForget();
6745b0d93edSopcode     CSP();
6755b0d93edSopcode 
6765b0d93edSopcode     elt = cset;
6775b0d93edSopcode     while (!DBNullelt(elt)) {
6785b0d93edSopcode 	if (TEXT(elt->type)) {
6795b0d93edSopcode 	    GROpenFont(elt->brushf, size);
6805b0d93edSopcode 	    if (!GRfontfound(elt->brushf, size)) {
6815b0d93edSopcode 		error("can't open font file");
6825b0d93edSopcode 	    }
6835b0d93edSopcode 	    else {
6845b0d93edSopcode 		DISScreenErase(elt, pixmask | csetmask);
6855b0d93edSopcode 		TxMsgOK();
6865b0d93edSopcode 		DBChangeSize(elt, size, &PICTURE);
6875b0d93edSopcode 		DISScreenAdd(elt, pixmask | csetmask);
6885b0d93edSopcode 	    }
6895b0d93edSopcode 	}
6905b0d93edSopcode 	elt = DBNextofSet(elt);
6915b0d93edSopcode     }
6925b0d93edSopcode 
6935b0d93edSopcode     CP();
6945b0d93edSopcode     CHANGED = TRUE;
6955b0d93edSopcode }  /* end LGMFize */
6965b0d93edSopcode 
6975b0d93edSopcode 
LGMSize1()6985b0d93edSopcode LGMSize1()
6995b0d93edSopcode {
7005b0d93edSopcode     LGMSize(1);
7015b0d93edSopcode }
7025b0d93edSopcode 
7035b0d93edSopcode 
LGMSize2()7045b0d93edSopcode LGMSize2()
7055b0d93edSopcode {
7065b0d93edSopcode     LGMSize(2);
7075b0d93edSopcode }
7085b0d93edSopcode 
7095b0d93edSopcode 
LGMSize3()7105b0d93edSopcode LGMSize3()
7115b0d93edSopcode {
7125b0d93edSopcode     LGMSize(3);
7135b0d93edSopcode }
7145b0d93edSopcode 
7155b0d93edSopcode 
LGMSize4()7165b0d93edSopcode LGMSize4()
7175b0d93edSopcode {
7185b0d93edSopcode     LGMSize(4);
7195b0d93edSopcode }
7205b0d93edSopcode 
7215b0d93edSopcode 
7225b0d93edSopcode /*
7235b0d93edSopcode  * This routine causes the polygon elements in the current set
7245b0d93edSopcode  * to be redrawn using the new stipple.
7255b0d93edSopcode  */
LGMStipple(stipple)7265b0d93edSopcode LGMStipple(stipple)
7275b0d93edSopcode int stipple;
7285b0d93edSopcode {
7295b0d93edSopcode     register ELT *elt;
7305b0d93edSopcode 
7315b0d93edSopcode     if (DBNullelt(cset)) {
7325b0d93edSopcode 	error(noset);
7335b0d93edSopcode 	return;
7345b0d93edSopcode     }
7355b0d93edSopcode 
7365b0d93edSopcode     UNForget();
7375b0d93edSopcode     CSP();
7385b0d93edSopcode 
7395b0d93edSopcode     elt = cset;
7405b0d93edSopcode     while (!DBNullelt(elt)) {
7415b0d93edSopcode 	if (elt->type == POLYGON) {
7425b0d93edSopcode 	    DISScreenErase(elt, pixmask | csetmask);
7435b0d93edSopcode 	    TxMsgOK();
7445b0d93edSopcode 	    DBChangeStipple(elt, stipple, &PICTURE);
7455b0d93edSopcode 	    DISScreenAdd(elt, pixmask | csetmask);
7465b0d93edSopcode 	}
7475b0d93edSopcode 	elt = DBNextofSet(elt);
7485b0d93edSopcode     }
7495b0d93edSopcode 
7505b0d93edSopcode     CP();
7515b0d93edSopcode     CHANGED = TRUE;
7525b0d93edSopcode }  /* end LGMStipple */
7535b0d93edSopcode 
7545b0d93edSopcode 
LGMStipple1()7555b0d93edSopcode LGMStipple1()
7565b0d93edSopcode {
7575b0d93edSopcode     LGMStipple(1);
7585b0d93edSopcode }
7595b0d93edSopcode 
7605b0d93edSopcode 
LGMStipple2()7615b0d93edSopcode LGMStipple2()
7625b0d93edSopcode {
7635b0d93edSopcode     LGMStipple(2);
7645b0d93edSopcode }
7655b0d93edSopcode 
7665b0d93edSopcode 
LGMStipple3()7675b0d93edSopcode LGMStipple3()
7685b0d93edSopcode {
7695b0d93edSopcode     LGMStipple(3);
7705b0d93edSopcode }
7715b0d93edSopcode 
7725b0d93edSopcode 
LGMStipple4()7735b0d93edSopcode LGMStipple4()
7745b0d93edSopcode {
7755b0d93edSopcode     LGMStipple(4);
7765b0d93edSopcode }
7775b0d93edSopcode 
7785b0d93edSopcode 
LGMStipple5()7795b0d93edSopcode LGMStipple5()
7805b0d93edSopcode {
7815b0d93edSopcode     LGMStipple(5);
7825b0d93edSopcode }
7835b0d93edSopcode 
7845b0d93edSopcode 
LGMStipple6()7855b0d93edSopcode LGMStipple6()
7865b0d93edSopcode {
7875b0d93edSopcode     LGMStipple(6);
7885b0d93edSopcode }
7895b0d93edSopcode 
7905b0d93edSopcode 
LGMStipple7()7915b0d93edSopcode LGMStipple7()
7925b0d93edSopcode {
7935b0d93edSopcode     LGMStipple(7);
7945b0d93edSopcode }
7955b0d93edSopcode 
7965b0d93edSopcode 
LGMStipple8()7975b0d93edSopcode LGMStipple8()
7985b0d93edSopcode {
7995b0d93edSopcode     LGMStipple(8);
8005b0d93edSopcode }
8015b0d93edSopcode 
8025b0d93edSopcode 
8035b0d93edSopcode /*
8045b0d93edSopcode  * This routine allows modification of text by replacing
8055b0d93edSopcode  * an existing string with a new one, appropriately repositioned
8065b0d93edSopcode  */
LGMText()8075b0d93edSopcode LGMText()
8085b0d93edSopcode {
8095b0d93edSopcode     register ELT *elt;
8105b0d93edSopcode     char buf[TEXT_BUFMAX];
8115b0d93edSopcode 
8125b0d93edSopcode     if (DBNullelt(cset)) {
8135b0d93edSopcode 	error(noset);
8145b0d93edSopcode 	return;
8155b0d93edSopcode     }
8165b0d93edSopcode 
8175b0d93edSopcode     text_getvalue(&buf[0]);
8185b0d93edSopcode     if (*buf == '\0') {		/* no text */
8195b0d93edSopcode 	error("empty string");
8205b0d93edSopcode 	return;
8215b0d93edSopcode     }
8225b0d93edSopcode 
8235b0d93edSopcode     UNForget();
8245b0d93edSopcode     CSP();
8255b0d93edSopcode 
8265b0d93edSopcode     elt = cset;
8275b0d93edSopcode     while (!DBNullelt(elt)) {
8285b0d93edSopcode         if (TEXT(elt->type)) {
8295b0d93edSopcode             DISScreenErase(elt, pixmask | csetmask);
8305b0d93edSopcode             TxMsgOK();
8315b0d93edSopcode 	    DBChangeText(elt, buf, &PICTURE);
8325b0d93edSopcode             DISScreenAdd(elt, pixmask | csetmask);
8335b0d93edSopcode         }
8345b0d93edSopcode         elt = DBNextofSet(elt);
8355b0d93edSopcode     }
8365b0d93edSopcode 
8375b0d93edSopcode     CP();
8385b0d93edSopcode     TxKillLine();
8395b0d93edSopcode     CHANGED = TRUE;
8405b0d93edSopcode }  /* end LGMText */
8415b0d93edSopcode 
8425b0d93edSopcode 
8435b0d93edSopcode /*
8445b0d93edSopcode  * This routine modifies the element which contains the point
8455b0d93edSopcode  * closest to the first of two specified points so that that point
8465b0d93edSopcode  * coincides with the second of the points (if specified).
8475b0d93edSopcode  *
8485b0d93edSopcode  * Note: it implies knowledge of the database representation by modifying
8495b0d93edSopcode  *       the element directly.
8505b0d93edSopcode  */
LGMPoint()8515b0d93edSopcode LGMPoint()
8525b0d93edSopcode {
8535b0d93edSopcode     ELT *elt;
8545b0d93edSopcode     POINT *p1, *p2, *p3, *p4;
8555b0d93edSopcode     float x1, y1;
8565b0d93edSopcode     int length;
8575b0d93edSopcode 
8585b0d93edSopcode     if (SEQ < 1) {
8595b0d93edSopcode 	error("no point specified");
8605b0d93edSopcode 	return;
8615b0d93edSopcode     }
8625b0d93edSopcode 
8635b0d93edSopcode     /* find point */
8645b0d93edSopcode     DBGravitate(POINTLIST->x, POINTLIST->y, &x1, &y1, &p1, &elt, cset, TRUE);
8655b0d93edSopcode 
8665b0d93edSopcode     if (DBNullelt(elt) || TEXT(elt->type)) {
8675b0d93edSopcode 	error("can't find a good element");
8685b0d93edSopcode 	return;
8695b0d93edSopcode     }
8705b0d93edSopcode 
8715b0d93edSopcode     if (SEQ == 1) {		/* wants to delete a point */
8725b0d93edSopcode 	length = PTListLength(elt);
8735b0d93edSopcode 	if (((elt->type == POLYGON) && (length == 3)) || (length == 2)) {
8745b0d93edSopcode 	    error(delmsg);
8755b0d93edSopcode 	    return;
8765b0d93edSopcode 	}
8775b0d93edSopcode     }
8785b0d93edSopcode 
8795b0d93edSopcode     /* now OK to do whatever */
8805b0d93edSopcode     UNForget();
8815b0d93edSopcode     CSP();
8825b0d93edSopcode 
8835b0d93edSopcode     DBClearSet();
8845b0d93edSopcode     GRClear(csetmask);
8855b0d93edSopcode     DISScreenErase(elt, pixmask);
8865b0d93edSopcode     UNRembMod(elt, &PICTURE);
8875b0d93edSopcode     if (SEQ > 1) {		/* move a point, not delete */
8885b0d93edSopcode 	p2 = PTNextPoint(POINTLIST);
8895b0d93edSopcode 	p1->x = p2->x;
8905b0d93edSopcode 	p1->y = p2->y;
8915b0d93edSopcode 	p2 = PTNextPoint(p2);
8925b0d93edSopcode 	if (!Nullpoint(p2)) {
8935b0d93edSopcode 	    p3 = PTInit();
8945b0d93edSopcode 	    while (!Nullpoint(p2)) {
8955b0d93edSopcode 		p4 = PTMakePoint(p2->x, p2->y, &p3);
8965b0d93edSopcode 		p2 = PTNextPoint(p2);
8975b0d93edSopcode 	    }
8985b0d93edSopcode 	    p4->nextpt = p1->nextpt;
8995b0d93edSopcode 	    p1->nextpt = p3;
9005b0d93edSopcode 	}
9015b0d93edSopcode     }
9025b0d93edSopcode     else {
9035b0d93edSopcode 	PTDeletePoint(p1, &(elt->ptlist));
9045b0d93edSopcode     }
9055b0d93edSopcode 
9065b0d93edSopcode     DISScreenAdd(elt, pixmask | csetmask);
9075b0d93edSopcode     DBAddSet(elt);
9085b0d93edSopcode 
9095b0d93edSopcode     CP();
9105b0d93edSopcode     CHANGED = TRUE;
9115b0d93edSopcode }  /* end LGMPoint */
9125b0d93edSopcode 
9135b0d93edSopcode 
9145b0d93edSopcode /*
9155b0d93edSopcode  * This routine allows users to leave gripe messages or report
9165b0d93edSopcode  * bugs to the maintainer.  Mail is invoked via the defined constant GRIPE.
9175b0d93edSopcode  */
LGGripe()9185b0d93edSopcode LGGripe()
9195b0d93edSopcode {
9205b0d93edSopcode     TxPutMsg("mail gripes to opcode@monet");
9215b0d93edSopcode }  /* end LGGripe */
9225b0d93edSopcode 
9235b0d93edSopcode 
9245b0d93edSopcode /*
9255b0d93edSopcode  * This routine controls the size of the point that is displayed.
9265b0d93edSopcode  * The sizes available are Artmode in which a small (3 x 3) point is displayed
9275b0d93edSopcode  * with no number and regular (non-Artmode).
9285b0d93edSopcode  */
LGLittlePoint()9295b0d93edSopcode LGLittlePoint()
9305b0d93edSopcode {
9315b0d93edSopcode     register POINT *plist;
9325b0d93edSopcode     register sp;
9335b0d93edSopcode     register i = 0;
9345b0d93edSopcode 
9355b0d93edSopcode     GRBlankPoints(POINTLIST);
9365b0d93edSopcode     if ((sp = SHOWPOINTS) != 0)		/* turn off show points */
9375b0d93edSopcode 	CSP();
9385b0d93edSopcode     Artmode = !Artmode;
9395b0d93edSopcode 
9405b0d93edSopcode     plist = POINTLIST;
9415b0d93edSopcode     while (!Nullpoint(plist)) {
9425b0d93edSopcode 	GRDisplayPoint(plist->x, plist->y, i++);
9435b0d93edSopcode 	plist = PTNextPoint(plist);
9445b0d93edSopcode     }
9455b0d93edSopcode 
9465b0d93edSopcode     if (sp != 0)			/* turn on show points */
9475b0d93edSopcode 	LGShowPoints();
9485b0d93edSopcode 
9495b0d93edSopcode     if (Artmode)
9505b0d93edSopcode 	MNUnHighLt(HiArtMode);
9515b0d93edSopcode     else
9525b0d93edSopcode 	MNHighLt(HiArtMode);
9535b0d93edSopcode }  /* end LGLittlePoint */
9545b0d93edSopcode 
9555b0d93edSopcode 
9565b0d93edSopcode /*
9575b0d93edSopcode  * This routine looks at the command line for parameters to set
9585b0d93edSopcode  * the current Font.
9595b0d93edSopcode  */
LGFont(font)9605b0d93edSopcode LGFont(font)
9615b0d93edSopcode int font;
9625b0d93edSopcode {
9635b0d93edSopcode     MNUnHighLt(HiFont[CFONT-1]);
9645b0d93edSopcode     CFONT = font;
9655b0d93edSopcode     MNHighLt(HiFont[CFONT-1]);
9665b0d93edSopcode }  /* end LGFont */
9675b0d93edSopcode 
9685b0d93edSopcode 
LGFont1()9695b0d93edSopcode LGFont1()
9705b0d93edSopcode {
9715b0d93edSopcode     LGFont(1);
9725b0d93edSopcode }
9735b0d93edSopcode 
9745b0d93edSopcode 
LGFont2()9755b0d93edSopcode LGFont2()
9765b0d93edSopcode {
9775b0d93edSopcode     LGFont(2);
9785b0d93edSopcode }
9795b0d93edSopcode 
9805b0d93edSopcode 
LGFont3()9815b0d93edSopcode LGFont3()
9825b0d93edSopcode {
9835b0d93edSopcode     LGFont(3);
9845b0d93edSopcode }
9855b0d93edSopcode 
9865b0d93edSopcode 
LGFont4()9875b0d93edSopcode LGFont4()
9885b0d93edSopcode {
9895b0d93edSopcode     LGFont(4);
9905b0d93edSopcode }
9915b0d93edSopcode 
9925b0d93edSopcode 
9935b0d93edSopcode /*
9945b0d93edSopcode  * This routine changes the current character size.
9955b0d93edSopcode  */
LGSize(size)9965b0d93edSopcode LGSize(size)
9975b0d93edSopcode int size;
9985b0d93edSopcode {
9995b0d93edSopcode     MNUnHighLt(HiSize[CSIZE-1]);
10005b0d93edSopcode     CSIZE = size;
10015b0d93edSopcode     MNHighLt(HiSize[CSIZE-1]);
10025b0d93edSopcode }  /* end LGSize */
10035b0d93edSopcode 
10045b0d93edSopcode 
LGSize1()10055b0d93edSopcode LGSize1()
10065b0d93edSopcode {
10075b0d93edSopcode     LGSize(1);
10085b0d93edSopcode }
10095b0d93edSopcode 
10105b0d93edSopcode 
LGSize2()10115b0d93edSopcode LGSize2()
10125b0d93edSopcode {
10135b0d93edSopcode     LGSize(2);
10145b0d93edSopcode }
10155b0d93edSopcode 
10165b0d93edSopcode 
LGSize3()10175b0d93edSopcode LGSize3()
10185b0d93edSopcode {
10195b0d93edSopcode     LGSize(3);
10205b0d93edSopcode }
10215b0d93edSopcode 
10225b0d93edSopcode 
LGSize4()10235b0d93edSopcode LGSize4()
10245b0d93edSopcode {
10255b0d93edSopcode     LGSize(4);
10265b0d93edSopcode }
10275b0d93edSopcode 
10285b0d93edSopcode 
10295b0d93edSopcode /*
10305b0d93edSopcode  * This routine changes the current stipple pattern.
10315b0d93edSopcode  */
LGStipple(stipple)10325b0d93edSopcode LGStipple(stipple)
10335b0d93edSopcode int stipple;
10345b0d93edSopcode {
10355b0d93edSopcode     MNUnHighLt(HiStipple[CSTIPPLE-1]);
10365b0d93edSopcode     CSTIPPLE = stipple;
10375b0d93edSopcode     MNHighLt(HiStipple[CSTIPPLE-1]);
10385b0d93edSopcode }  /* end LGStipple */
10395b0d93edSopcode 
10405b0d93edSopcode 
LGStipple1()10415b0d93edSopcode LGStipple1()
10425b0d93edSopcode {
10435b0d93edSopcode     LGStipple(1);
10445b0d93edSopcode }
10455b0d93edSopcode 
10465b0d93edSopcode 
LGStipple2()10475b0d93edSopcode LGStipple2()
10485b0d93edSopcode {
10495b0d93edSopcode     LGStipple(2);
10505b0d93edSopcode }
10515b0d93edSopcode 
10525b0d93edSopcode 
LGStipple3()10535b0d93edSopcode LGStipple3()
10545b0d93edSopcode {
10555b0d93edSopcode     LGStipple(3);
10565b0d93edSopcode }
10575b0d93edSopcode 
10585b0d93edSopcode 
LGStipple4()10595b0d93edSopcode LGStipple4()
10605b0d93edSopcode {
10615b0d93edSopcode     LGStipple(4);
10625b0d93edSopcode }
10635b0d93edSopcode 
10645b0d93edSopcode 
LGStipple5()10655b0d93edSopcode LGStipple5()
10665b0d93edSopcode {
10675b0d93edSopcode     LGStipple(5);
10685b0d93edSopcode }
10695b0d93edSopcode 
10705b0d93edSopcode 
LGStipple6()10715b0d93edSopcode LGStipple6()
10725b0d93edSopcode {
10735b0d93edSopcode     LGStipple(6);
10745b0d93edSopcode }
10755b0d93edSopcode 
10765b0d93edSopcode 
LGStipple7()10775b0d93edSopcode LGStipple7()
10785b0d93edSopcode {
10795b0d93edSopcode     LGStipple(7);
10805b0d93edSopcode }
10815b0d93edSopcode 
10825b0d93edSopcode 
LGStipple8()10835b0d93edSopcode LGStipple8()
10845b0d93edSopcode {
10855b0d93edSopcode     LGStipple(8);
10865b0d93edSopcode }
10875b0d93edSopcode 
10885b0d93edSopcode 
10895b0d93edSopcode /*
10905b0d93edSopcode  * Toggle line style
10915b0d93edSopcode  */
LGLineStyle()10925b0d93edSopcode LGLineStyle()
10935b0d93edSopcode {
10945b0d93edSopcode     if (SymbolicLines = !SymbolicLines)
10955b0d93edSopcode 	MNUnHighLt(HiLineStyle);
10965b0d93edSopcode     else
10975b0d93edSopcode 	MNHighLt(HiLineStyle);
10985b0d93edSopcode 
10995b0d93edSopcode     SHUpdate();
11005b0d93edSopcode }  /* end LGLineStyle */
11015b0d93edSopcode 
11025b0d93edSopcode 
LGPan()11035b0d93edSopcode LGPan()
11045b0d93edSopcode {
11055b0d93edSopcode     if (SEQ < 1) {
11065b0d93edSopcode 	error("need one point");
11075b0d93edSopcode 	return;
11085b0d93edSopcode     }
11095b0d93edSopcode 
11105b0d93edSopcode     LGdopan(POINTLIST->x, POINTLIST->y);
11115b0d93edSopcode }
11125b0d93edSopcode 
11135b0d93edSopcode 
11145b0d93edSopcode /*
11155b0d93edSopcode  * Make (wx, wy) center of Gremlin window.
11165b0d93edSopcode  */
LGdopan(wx,wy)11175b0d93edSopcode LGdopan(wx, wy)
11185b0d93edSopcode float wx, wy;
11195b0d93edSopcode {
11205b0d93edSopcode     float cx, cy;
11215b0d93edSopcode     register tx, ty;
11225b0d93edSopcode 
11235b0d93edSopcode     CP();						/* eat points first */
11245b0d93edSopcode 
11255b0d93edSopcode     cx = SUN_XORIGIN + (pix_size.r_width >> 1);		/* window x center */
11265b0d93edSopcode     cy = SUN_YORIGIN - (pix_size.r_height >> 1);	/* window y center */
11275b0d93edSopcode 
11285b0d93edSopcode     tx = (int) (wx - cx);				/* x translation */
11295b0d93edSopcode     ty = (int) (wy - cy);				/* y translation */
11305b0d93edSopcode 
11315b0d93edSopcode     tx += (tx < 0) ? -1 : 1;				/* fudge factor */
11325b0d93edSopcode     ty += (ty < 0) ? -1 : 1;
11335b0d93edSopcode 
11345b0d93edSopcode     SUN_XORIGIN += (tx / Gridsize) * Gridsize;
11355b0d93edSopcode     SUN_YORIGIN += (ty / Gridsize) * Gridsize;
11365b0d93edSopcode 
11375b0d93edSopcode     SHUpdate();
11385b0d93edSopcode }  /* end LGPan */
11395b0d93edSopcode 
11405b0d93edSopcode 
11415b0d93edSopcode /*
11425b0d93edSopcode  * Pan to absolute center of picture.
11435b0d93edSopcode  * Invoked by the middle button on the PAN icon.
11445b0d93edSopcode  */
LGMPan()11455b0d93edSopcode LGMPan()
11465b0d93edSopcode {
11475b0d93edSopcode     register ELT *elt;
11485b0d93edSopcode     register POINT *point;
11495b0d93edSopcode     float minx, miny, maxx, maxy;
11505b0d93edSopcode 
11515b0d93edSopcode     if (DBNullelt(PICTURE)) {
11525b0d93edSopcode 	error("empty picture");
11535b0d93edSopcode 	return;
11545b0d93edSopcode     }
11555b0d93edSopcode 
11565b0d93edSopcode     elt = PICTURE;
11575b0d93edSopcode     minx = maxx = elt->ptlist->x;
11585b0d93edSopcode     miny = maxy = elt->ptlist->y;
11595b0d93edSopcode 
11605b0d93edSopcode     while (!DBNullelt(elt)) {
11615b0d93edSopcode 	point = elt->ptlist;
11625b0d93edSopcode 
11635b0d93edSopcode 	while (!Nullpoint(point)) {
11645b0d93edSopcode 	    MINMAX(minx, maxx, point->x);
11655b0d93edSopcode 	    MINMAX(miny, maxy, point->y);
11665b0d93edSopcode 	    point = PTNextPoint(point);
11675b0d93edSopcode 	}
11685b0d93edSopcode 
11695b0d93edSopcode 	elt = DBNextElt(elt);
11705b0d93edSopcode     }
11715b0d93edSopcode 
11725b0d93edSopcode     LGdopan(maxx - ((maxx - minx) / 2.0), maxy - ((maxy - miny) / 2.0));
11735b0d93edSopcode }
1174