william@CS.UCLA.EDU (William Cheng) (02/13/91)
Submitted-by: william@CS.UCLA.EDU (William Cheng) Posting-number: Volume 11, Issue 66 Archive-name: tgif/patch6.04 Patch-To: tgif: Volume 7, Issue 56-76 (original: tgif-1.2) Patch-To: tgif: Volume 8, Issue 46-48 (Patch1: tgif-1.2 => tgif-1.9) Patch-To: tgif: Volume 8, Issue 58-60 (Patch2: tgif-1.9 => tgif-1.12) Patch-To: tgif: Volume 8, Issue 87-89 (Patch3: tgif-1.12 => tgif-1.13) Patch-To: tgif: Volume 8, Issue 94 (Patch4: tgif-1.13 => tgif-1.14) Patch-To: tgif: Volume 8, Issue 95 (Patch5: tgif-1.14 => tgif-1.15) ---------------------------------> cut here <--------------------------------- *** oval.c.orig Wed Dec 12 14:36:17 1990 --- oval.c Wed Dec 12 14:36:19 1990 *************** *** 6,10 **** #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/oval.c,v 1.7 90/08/13 09:23:35 william Exp $"; #endif --- 6,10 ---- #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/oval.c,v 1.11 90/11/10 13:51:00 william Exp $"; #endif *************** *** 93,97 **** struct ObjRec * ObjPtr; { ! int ltx, lty, rbx, rby, xc, yc, a, b, fill, width, pen; ltx = ObjPtr->obbox.ltx; lty = ObjPtr->obbox.lty; --- 93,98 ---- struct ObjRec * ObjPtr; { ! int ltx, lty, rbx, rby, xc, yc, a, b, i; ! int fill, width, pen, dash, color_index; ltx = ObjPtr->obbox.ltx; lty = ObjPtr->obbox.lty; *************** *** 103,109 **** --- 104,120 ---- width = ObjPtr->detail.o->width; pen = ObjPtr->detail.o->pen; + dash = ObjPtr->detail.o->dash; if (fill == NONEPAT && pen == NONEPAT) return; + if (colorDump) + { + color_index = ObjPtr->color; + fprintf (FP, "%.3f %.3f %.3f setrgbcolor\n", + ((float)tgifColors[color_index].red/maxRGB), + ((float)tgifColors[color_index].green/maxRGB), + ((float)tgifColors[color_index].blue/maxRGB)); + } + switch (fill) { *************** *** 128,131 **** --- 139,150 ---- fprintf (FP, "%1d setlinewidth\n", widthOfLine[width]); + if (dash != 0) + { + fprintf (FP, "["); + for (i = 0; i < dashListLength[dash]-1; i++) + fprintf (FP, "%1d ", (int)(dashList[dash][i])); + fprintf (FP, "%1d] 0 setdash\n", + (int)(dashList[dash][dashListLength[dash]-1])); + } switch (pen) *************** *** 147,150 **** --- 166,170 ---- break; } + if (dash != 0) fprintf (FP, "[] 0 setdash\n"); fprintf (FP, "1 setlinewidth\n\n"); } *************** *** 156,160 **** { struct OvalRec * oval_ptr = ObjPtr->detail.o; ! int fill, width, pen, pixel, real_x_off, real_y_off; char s[80]; struct BBRec bbox; --- 176,180 ---- { struct OvalRec * oval_ptr = ObjPtr->detail.o; ! int fill, width, pen, dash, pixel, real_x_off, real_y_off; char s[80]; struct BBRec bbox; *************** *** 171,174 **** --- 191,195 ---- width = ObjPtr->detail.o->width; pen = ObjPtr->detail.o->pen; + dash = ObjPtr->detail.o->dash; pixel = colorPixels[ObjPtr->color]; *************** *** 191,197 **** values.stipple = patPixmap[pen]; values.line_width = widthOfLine[width] >> zoomScale; XChangeGC (mainDisplay, drawGC, ! GCForeground | GCFunction | GCFillStyle | GCStipple | GCLineWidth, ! &values); XDrawArc (mainDisplay, window, drawGC, bbox.ltx, bbox.lty, bbox.rbx-bbox.ltx, bbox.rby-bbox.lty, 0, 360*64); --- 212,226 ---- values.stipple = patPixmap[pen]; values.line_width = widthOfLine[width] >> zoomScale; + if (dash != 0) + { + XSetDashes (mainDisplay, drawGC, 0, dashList[dash], + dashListLength[dash]); + values.line_style = LineOnOffDash; + } + else + values.line_style = LineSolid; XChangeGC (mainDisplay, drawGC, ! GCForeground | GCFunction | GCFillStyle | GCStipple | GCLineWidth | ! GCLineStyle, &values); XDrawArc (mainDisplay, window, drawGC, bbox.ltx, bbox.lty, bbox.rbx-bbox.ltx, bbox.rby-bbox.lty, 0, 360*64); *************** *** 211,214 **** --- 240,244 ---- oval_ptr->width = lineWidth; oval_ptr->pen = penPat; + oval_ptr->dash = curDash; obj_ptr = (struct ObjRec *) calloc (1, sizeof(struct ObjRec)); *************** *** 257,262 **** values.fill_style = FillSolid; values.line_width = 0; XChangeGC (mainDisplay, drawGC, ! GCForeground | GCFunction | GCFillStyle | GCLineWidth, &values); grid_x = end_x = OrigX; --- 287,294 ---- values.fill_style = FillSolid; values.line_width = 0; + values.line_style = LineSolid; XChangeGC (mainDisplay, drawGC, ! GCForeground | GCFunction | GCFillStyle | GCLineWidth | GCLineStyle, ! &values); grid_x = end_x = OrigX; *************** *** 333,341 **** struct ObjRec * ObjPtr; { ! fprintf (FP, "oval(%s,", colorMenuItems[ObjPtr->color]); ! fprintf (FP, "%1d,%1d,%1d,%1d,%1d,%1d,%1d,%1d,", ObjPtr->obbox.ltx, ObjPtr->obbox.lty, ObjPtr->obbox.rbx, ObjPtr->obbox.rby, ObjPtr->detail.o->fill, ObjPtr->detail.o->width, ! ObjPtr->detail.o->pen, ObjPtr->id); SaveAttrs (FP, ObjPtr->lattr); fprintf (FP, ")"); --- 365,373 ---- struct ObjRec * ObjPtr; { ! fprintf (FP, "oval('%s',", colorMenuItems[ObjPtr->color]); ! fprintf (FP, "%1d,%1d,%1d,%1d,%1d,%1d,%1d,%1d,%1d,", ObjPtr->obbox.ltx, ObjPtr->obbox.lty, ObjPtr->obbox.rbx, ObjPtr->obbox.rby, ObjPtr->detail.o->fill, ObjPtr->detail.o->width, ! ObjPtr->detail.o->pen, ObjPtr->id, ObjPtr->detail.o->dash); SaveAttrs (FP, ObjPtr->lattr); fprintf (FP, ")"); *************** *** 348,352 **** struct OvalRec * oval_ptr; char color_str[20], * s; ! int ltx, lty, rbx, rby, fill, width, pen, w; * ObjPtr = (struct ObjRec *) calloc (1, sizeof(struct ObjRec)); --- 380,384 ---- struct OvalRec * oval_ptr; char color_str[20], * s; ! int ltx, lty, rbx, rby, fill, width, pen, dash, w; * ObjPtr = (struct ObjRec *) calloc (1, sizeof(struct ObjRec)); *************** *** 365,368 **** --- 397,401 ---- } (*ObjPtr)->id = objId++; + dash = 0; } else if (fileVersion <= 7) *************** *** 371,376 **** <x, <y, &rbx, &rby, &fill, &width, &pen); (*ObjPtr)->id = objId++; } ! else { sscanf (s, "%d , %d, %d , %d , %d , %d , %d , %d", --- 404,410 ---- <x, <y, &rbx, &rby, &fill, &width, &pen); (*ObjPtr)->id = objId++; + dash = 0; } ! else if (fileVersion <= 8) { sscanf (s, "%d , %d, %d , %d , %d , %d , %d , %d", *************** *** 377,381 **** --- 411,423 ---- <x, <y, &rbx, &rby, &fill, &width, &pen, &((*ObjPtr)->id)); if ((*ObjPtr)->id >= objId) objId = (*ObjPtr)->id + 1; + dash = 0; } + else + { + sscanf (s, "%d , %d, %d , %d , %d , %d , %d , %d , %d", + <x, <y, &rbx, &rby, &fill, &width, &pen, &((*ObjPtr)->id), + &dash); + if ((*ObjPtr)->id >= objId) objId = (*ObjPtr)->id + 1; + } oval_ptr->fill = fill; *************** *** 382,385 **** --- 424,428 ---- oval_ptr->width = width; oval_ptr->pen = pen; + oval_ptr->dash = dash; (*ObjPtr)->x = ltx; (*ObjPtr)->y = lty; *** pattern.c.orig Wed Dec 12 14:36:26 1990 --- pattern.c Wed Dec 12 14:36:29 1990 *************** *** 6,10 **** #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/pattern.c,v 1.3 90/07/11 21:30:41 william Exp $"; #endif --- 6,10 ---- #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/pattern.c,v 1.5 90/10/31 11:37:19 william Exp $"; #endif *************** *** 30,33 **** --- 30,34 ---- int penPat = SOLIDPAT; int curSpline = LT_STRAIGHT; + int curDash = 0; void ModeMenu (X, Y) *************** *** 505,508 **** --- 506,624 ---- } + static + int ChangeObjDashes (ObjPtr, DashIndex) + struct ObjRec * ObjPtr; + int DashIndex; + { + register struct ObjRec * obj_ptr; + int changed = FALSE; + + for (obj_ptr = ObjPtr; obj_ptr != NULL; obj_ptr = obj_ptr->prev) + switch (obj_ptr->type) + { + case OBJ_POLY: + if (obj_ptr->detail.p->dash != DashIndex) + { + obj_ptr->detail.p->dash = DashIndex; + changed = TRUE; + } + break; + case OBJ_BOX: + if (obj_ptr->detail.b->dash != DashIndex) + { + obj_ptr->detail.b->dash = DashIndex; + changed = TRUE; + } + break; + case OBJ_OVAL: + if (obj_ptr->detail.o->dash != DashIndex) + { + obj_ptr->detail.o->dash = DashIndex; + changed = TRUE; + } + break; + case OBJ_POLYGON: + if (obj_ptr->detail.g->dash != DashIndex) + { + obj_ptr->detail.g->dash = DashIndex; + changed = TRUE; + } + break; + + case OBJ_GROUP: + case OBJ_SYM: + if (ChangeObjLineWidth (obj_ptr->detail.r->last, DashIndex)) + changed = TRUE; + break; + } + return (changed); + } + + void ChangeAllSelDashes (DashIndex) + int DashIndex; + { + register struct SelRec * sel_ptr; + register struct ObjRec * obj_ptr; + int changed = FALSE; + + if (topSel == NULL) + { + curDash = DashIndex; + ShowLineWidth (); + return; + } + + for (sel_ptr = botSel; sel_ptr != NULL; sel_ptr = sel_ptr->prev) + { + obj_ptr = sel_ptr->obj; + switch (obj_ptr->type) + { + case OBJ_POLY: + if (obj_ptr->detail.p->dash != DashIndex) + { + obj_ptr->detail.p->dash = DashIndex; + changed = TRUE; + } + break; + case OBJ_BOX: + if (obj_ptr->detail.b->dash != DashIndex) + { + obj_ptr->detail.b->dash = DashIndex; + changed = TRUE; + } + break; + case OBJ_OVAL: + if (obj_ptr->detail.o->dash != DashIndex) + { + obj_ptr->detail.o->dash = DashIndex; + changed = TRUE; + } + break; + case OBJ_POLYGON: + if (obj_ptr->detail.g->dash != DashIndex) + { + obj_ptr->detail.g->dash = DashIndex; + changed = TRUE; + } + break; + + case OBJ_GROUP: + case OBJ_SYM: + if (ChangeObjDashes (obj_ptr->detail.r->last, DashIndex)) + changed = TRUE; + break; + } + } + + if (changed) + { + SetFileModified (TRUE); + HighLightReverse (); + RedrawAnArea (botObj, selLtX-(1<<zoomScale), selLtY-(1<<zoomScale), + selRbX+(1<<zoomScale), selRbY+(1<<zoomScale)); + HighLightForward (); + } + } + void LineStyleMenu (X, Y) int X, Y; *************** *** 510,519 **** int index, ltx, lty, rbx, rby, * fore_colors, * valid; ! DefaultColorArrays (MAXLINEWIDTHS+MAXLINETYPES+MAXLINESTYLES, &fore_colors, ! &valid); cfree (valid); index = PxMpMenuLoop (X, Y, menuImageW, menuImageH, ! MAXLINEWIDTHS+MAXLINETYPES+MAXLINESTYLES, 1, ! MAXLINEWIDTHS+MAXLINETYPES+MAXLINESTYLES, fore_colors, lineStylePixmap, SINGLECOLOR); if (index == INVALID) return; --- 626,644 ---- int index, ltx, lty, rbx, rby, * fore_colors, * valid; ! /* DefaultColorArrays (MAXLINEWIDTHS+MAXLINETYPES+MAXLINESTYLES, &fore_colors, */ ! /* &valid); */ ! /* cfree (valid); */ ! /* index = PxMpMenuLoop (X, Y, menuImageW, menuImageH, */ ! /* MAXLINEWIDTHS+MAXLINETYPES+MAXLINESTYLES, 1, */ ! /* MAXLINEWIDTHS+MAXLINETYPES+MAXLINESTYLES, */ ! /* fore_colors, lineStylePixmap, SINGLECOLOR); */ ! /* if (index == INVALID) return; */ ! ! DefaultColorArrays (MAXLINEWIDTHS+MAXLINETYPES+MAXDASHES+MAXLINESTYLES, ! &fore_colors, &valid); cfree (valid); index = PxMpMenuLoop (X, Y, menuImageW, menuImageH, ! MAXLINEWIDTHS+MAXLINETYPES+MAXDASHES+MAXLINESTYLES, 1, ! MAXLINEWIDTHS+MAXLINETYPES+MAXDASHES+MAXLINESTYLES, fore_colors, lineStylePixmap, SINGLECOLOR); if (index == INVALID) return; *************** *** 523,528 **** else if (index < MAXLINEWIDTHS+MAXLINETYPES) ChangeAllSelLineType (index - MAXLINEWIDTHS); else ! ChangeAllSelLineStyle (index - MAXLINEWIDTHS - MAXLINETYPES); } --- 648,655 ---- else if (index < MAXLINEWIDTHS+MAXLINETYPES) ChangeAllSelLineType (index - MAXLINEWIDTHS); + else if (index < MAXLINEWIDTHS+MAXLINETYPES+MAXDASHES) + ChangeAllSelDashes (index - MAXLINEWIDTHS - MAXLINETYPES); else ! ChangeAllSelLineStyle (index - MAXLINEWIDTHS - MAXLINETYPES - MAXDASHES); } *** poly.c.orig Wed Dec 12 14:36:51 1990 --- poly.c Wed Dec 12 14:36:54 1990 *************** *** 6,10 **** #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/poly.c,v 1.6 90/08/13 09:23:49 william Exp $"; #endif --- 6,10 ---- #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/poly.c,v 1.10 90/11/10 13:51:04 william Exp $"; #endif *************** *** 117,120 **** --- 117,121 ---- poly_ptr->curved = curSpline; poly_ptr->fill = objFill; + poly_ptr->dash = curDash; obj_ptr = (struct ObjRec *) calloc (1, sizeof(struct ObjRec)); obj_ptr->color = colorIndex; *************** *** 175,181 **** */ ! void MyLine (Win,Cont,Rb,N,StartX,StartY,EndX,EndY,W,S,P,Pix) Window Win; ! int Cont, Rb, N, StartX, StartY, EndX, EndY, W, S, P, Pix; /* 'Cont' means continue */ /* 'Rb' means rubber-band */ --- 176,182 ---- */ ! void MyLine (Win,Cont,Rb,N,StartX,StartY,EndX,EndY,W,S,P,Pix,Dash) Window Win; ! int Cont, Rb, N, StartX, StartY, EndX, EndY, W, S, P, Pix, Dash; /* 'Cont' means continue */ /* 'Rb' means rubber-band */ *************** *** 245,250 **** values.fill_style = FillSolid; values.line_width = 0; XChangeGC (mainDisplay, drawGC, ! GCForeground | GCFunction | GCFillStyle | GCLineWidth, &values); } else if (P != 0) --- 246,253 ---- values.fill_style = FillSolid; values.line_width = 0; + values.line_style = LineSolid; XChangeGC (mainDisplay, drawGC, ! GCForeground | GCFunction | GCFillStyle | GCLineWidth | GCLineStyle, ! &values); } else if (P != 0) *************** *** 255,261 **** values.stipple = patPixmap[P]; values.line_width = widthOfLine[W] >> zoomScale; XChangeGC (mainDisplay, drawGC, ! GCForeground | GCFunction | GCFillStyle | GCStipple | GCLineWidth, ! &values); } else --- 258,272 ---- values.stipple = patPixmap[P]; values.line_width = widthOfLine[W] >> zoomScale; + if (Dash != 0) + { + XSetDashes (mainDisplay, drawGC, 0, dashList[Dash], + dashListLength[Dash]); + values.line_style = LineOnOffDash; + } + else + values.line_style = LineSolid; XChangeGC (mainDisplay, drawGC, ! GCForeground | GCFunction | GCFillStyle | GCStipple | GCLineWidth | ! GCLineStyle, &values); } else *************** *** 344,350 **** values.fill_style = FillSolid; values.line_width = 0; XChangeGC (mainDisplay, drawGC, ! GCForeground | GCFunction | GCFillStyle | GCLineWidth, &values); --- 355,362 ---- values.fill_style = FillSolid; values.line_width = 0; + values.line_style = LineSolid; XChangeGC (mainDisplay, drawGC, ! GCForeground | GCFunction | GCFillStyle | GCLineWidth | GCLineStyle, &values); *************** *** 362,366 **** motion_ev = &(input.xmotion); MyLine (drawWindow, CONT, RB, num_pts, OrigX, OrigY, grid_x, ! grid_y, lineWidth, lineStyle, penPat, xor_pixel); end_x = motion_ev->x; --- 374,378 ---- motion_ev = &(input.xmotion); MyLine (drawWindow, CONT, RB, num_pts, OrigX, OrigY, grid_x, ! grid_y, lineWidth, lineStyle, penPat, xor_pixel,0); end_x = motion_ev->x; *************** *** 369,373 **** MarkRulers (grid_x, grid_y); MyLine (drawWindow, CONT, RB, num_pts, OrigX, OrigY, grid_x, ! grid_y, lineWidth, lineStyle, penPat, xor_pixel); while (XCheckMaskEvent (mainDisplay, PointerMotionMask, &ev)) ; } --- 381,385 ---- MarkRulers (grid_x, grid_y); MyLine (drawWindow, CONT, RB, num_pts, OrigX, OrigY, grid_x, ! grid_y, lineWidth, lineStyle, penPat, xor_pixel,0); while (XCheckMaskEvent (mainDisplay, PointerMotionMask, &ev)) ; } *************** *** 376,380 **** button_ev = &(input.xbutton); MyLine (drawWindow, CONT, RB, num_pts, OrigX, OrigY, grid_x, ! grid_y, lineWidth, lineStyle, penPat, xor_pixel); GridXY (end_x, end_y, &grid_x, &grid_y); --- 388,392 ---- button_ev = &(input.xbutton); MyLine (drawWindow, CONT, RB, num_pts, OrigX, OrigY, grid_x, ! grid_y, lineWidth, lineStyle, penPat, xor_pixel,0); GridXY (end_x, end_y, &grid_x, &grid_y); *************** *** 394,398 **** MyLine (drawWindow, CONT, NORB, num_pts-1, OrigX, OrigY, grid_x, grid_y, lineWidth, lineStyle, penPat, ! pixel); OrigX = grid_x; OrigY = grid_y; --- 406,410 ---- MyLine (drawWindow, CONT, NORB, num_pts-1, OrigX, OrigY, grid_x, grid_y, lineWidth, lineStyle, penPat, ! pixel,0); OrigX = grid_x; OrigY = grid_y; *************** *** 404,408 **** MyLine (drawWindow, NOCONT, NORB, num_pts-1, OrigX, OrigY, grid_x, grid_y, lineWidth, lineStyle, ! penPat, pixel); done = TRUE; --- 416,420 ---- MyLine (drawWindow, NOCONT, NORB, num_pts-1, OrigX, OrigY, grid_x, grid_y, lineWidth, lineStyle, ! penPat, pixel,0); done = TRUE; *************** *** 416,424 **** { CreatePolyObj (num_pts); ! if (topObj->detail.p->curved == LT_SPLINE || ! topObj->detail.p->fill != NONEPAT) ! RedrawAnArea (botObj, topObj->bbox.ltx-(1<<zoomScale), ! topObj->bbox.lty-(1<<zoomScale), topObj->bbox.rbx+(1<<zoomScale), ! topObj->bbox.rby+(1<<zoomScale)); polyDrawn = TRUE; SetFileModified (TRUE); --- 428,434 ---- { CreatePolyObj (num_pts); ! RedrawAnArea (botObj, topObj->bbox.ltx-(1<<zoomScale), ! topObj->bbox.lty-(1<<zoomScale), topObj->bbox.rbx+(1<<zoomScale), ! topObj->bbox.rby+(1<<zoomScale)); polyDrawn = TRUE; SetFileModified (TRUE); *************** *** 473,477 **** { XPoint * v; ! int num_pts, fill, pen, width, curved, w, aw, ah, dy, dx; fill = ObjPtr->detail.p->fill; --- 483,488 ---- { XPoint * v; ! int i, num_pts, fill, pen, width, curved, dash, color_index; ! int w, aw, ah, dy, dx; fill = ObjPtr->detail.p->fill; *************** *** 479,485 **** --- 490,508 ---- pen = ObjPtr->detail.p->pen; curved = ObjPtr->detail.p->curved; + dash = ObjPtr->detail.p->dash; v = ObjPtr->detail.p->vlist; num_pts = ObjPtr->detail.p->n; + if (fill == NONEPAT && pen == NONEPAT) return; + + if (colorDump) + { + color_index = ObjPtr->color; + fprintf (FP, "%.3f %.3f %.3f setrgbcolor\n", + ((float)tgifColors[color_index].red/maxRGB), + ((float)tgifColors[color_index].green/maxRGB), + ((float)tgifColors[color_index].blue/maxRGB)); + } + if (fill != NONEPAT && num_pts > 2) { *************** *** 545,549 **** } ! if (pen == NONEPAT) return; fprintf (FP, "gsave\n"); --- 568,573 ---- } ! if (pen == NONEPAT) { fprintf (FP, "\n"); return; } ! fprintf (FP, "gsave\n"); *************** *** 562,565 **** --- 586,597 ---- fprintf (FP, " %1d setlinewidth\n", w); + if (dash != 0) + { + fprintf (FP, " ["); + for (i = 0; i < dashListLength[dash]-1; i++) + fprintf (FP, "%1d ", (int)(dashList[dash][i])); + fprintf (FP, "%1d] 0 setdash\n", + (int)(dashList[dash][dashListLength[dash]-1])); + } fprintf (FP, "newpath\n %1d %1d moveto\n", v[0].x, v[0].y); *************** *** 622,626 **** register struct PolyRec * poly_ptr = ObjPtr->detail.p; XPoint * pv = poly_ptr->vlist, * v; ! int pen, width, pixel, fill, curved, n; int x1, y1, x2, y2, ah, real_x_off, real_y_off; Pixmap tile; --- 654,658 ---- register struct PolyRec * poly_ptr = ObjPtr->detail.p; XPoint * pv = poly_ptr->vlist, * v; ! int pen, width, pixel, fill, curved, n, dash; int x1, y1, x2, y2, ah, real_x_off, real_y_off; Pixmap tile; *************** *** 632,639 **** pen = poly_ptr->pen; curved = poly_ptr->curved; pixel = colorPixels[ObjPtr->color]; if (curved == LT_SPLINE) ! DrawSplinePolyObj (Win, XOff, YOff, fill, width, pen, pixel, poly_ptr); else { --- 664,673 ---- pen = poly_ptr->pen; curved = poly_ptr->curved; + dash = poly_ptr->dash; pixel = colorPixels[ObjPtr->color]; if (curved == LT_SPLINE) ! DrawSplinePolyObj (Win, XOff, YOff, fill, width, pen, dash, pixel, ! poly_ptr); else { *************** *** 671,675 **** MyLine (Win, CONT, NORB, i+1, x1, y1, x2, y2, poly_ptr->width, ! poly_ptr->style, pen, pixel); } x1 = (pv[i].x-real_x_off)>>zoomScale; --- 705,709 ---- MyLine (Win, CONT, NORB, i+1, x1, y1, x2, y2, poly_ptr->width, ! poly_ptr->style, pen, pixel, dash); } x1 = (pv[i].x-real_x_off)>>zoomScale; *************** *** 679,683 **** MyLine (Win, NOCONT, NORB, i+1, x1, y1, x2, y2, poly_ptr->width, ! poly_ptr->style, pen, pixel); } } --- 713,717 ---- MyLine (Win, NOCONT, NORB, i+1, x1, y1, x2, y2, poly_ptr->width, ! poly_ptr->style, pen, pixel, dash); } } *************** *** 691,695 **** n = poly_ptr->n; ! fprintf (FP, "poly(%s,%1d,[", colorMenuItems[ObjPtr->color], poly_ptr->n); for (i = 0; i < n-1; i++) { --- 725,729 ---- n = poly_ptr->n; ! fprintf (FP, "poly('%s',%1d,[", colorMenuItems[ObjPtr->color], poly_ptr->n); for (i = 0; i < n-1; i++) { *************** *** 697,702 **** } fprintf (FP, "%1d,%1d", poly_ptr->vlist[n-1].x, poly_ptr->vlist[n-1].y); ! fprintf (FP, "],%1d,%1d,%1d,%1d,%1d,%1d,", poly_ptr->style, poly_ptr->width, ! poly_ptr->pen, ObjPtr->id, poly_ptr->curved, poly_ptr->fill); SaveAttrs (FP, ObjPtr->lattr); fprintf (FP, ")"); --- 731,736 ---- } fprintf (FP, "%1d,%1d", poly_ptr->vlist[n-1].x, poly_ptr->vlist[n-1].y); ! fprintf (FP, "],%1d,%1d,%1d,%1d,%1d,%1d,%1d,", poly_ptr->style, poly_ptr->width, ! poly_ptr->pen, ObjPtr->id, poly_ptr->curved, poly_ptr->fill, poly_ptr->dash); SaveAttrs (FP, ObjPtr->lattr); fprintf (FP, ")"); *************** *** 754,757 **** --- 788,792 ---- case 2: poly_ptr->width = 6; break; } + poly_ptr->dash = 0; } else if (fileVersion <= 3) *************** *** 773,776 **** --- 808,812 ---- case 2: poly_ptr->width = 6; break; } + poly_ptr->dash = 0; } else if (fileVersion <= 4) *************** *** 786,789 **** --- 822,826 ---- case 2: poly_ptr->width = 6; break; } + poly_ptr->dash = 0; } else if (fileVersion <= 5) *************** *** 798,803 **** case 2: poly_ptr->width = 6; break; } } ! else { sscanf (s, "%d , %d , %d , %d, %d, %d", &(poly_ptr->style), --- 835,841 ---- case 2: poly_ptr->width = 6; break; } + poly_ptr->dash = 0; } ! else if (fileVersion <= 8) { sscanf (s, "%d , %d , %d , %d, %d, %d", &(poly_ptr->style), *************** *** 804,807 **** --- 842,853 ---- &(poly_ptr->width), &(poly_ptr->pen), &((*ObjPtr)->id), &(poly_ptr->curved), &(poly_ptr->fill)); + if ((*ObjPtr)->id >= objId) objId = (*ObjPtr)->id + 1; + poly_ptr->dash = 0; + } + else + { + sscanf (s, "%d , %d , %d , %d , %d , %d , %d", &(poly_ptr->style), + &(poly_ptr->width), &(poly_ptr->pen), &((*ObjPtr)->id), + &(poly_ptr->curved), &(poly_ptr->fill), &(poly_ptr->dash)); if ((*ObjPtr)->id >= objId) objId = (*ObjPtr)->id + 1; } *** polygon.c.orig Wed Dec 12 14:37:07 1990 --- polygon.c Wed Dec 12 14:37:09 1990 *************** *** 6,10 **** #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/polygon.c,v 1.5 90/08/13 09:23:36 william Exp $"; #endif --- 6,10 ---- #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/polygon.c,v 1.9 90/11/10 13:51:09 william Exp $"; #endif *************** *** 52,56 **** { XPoint * v = ObjPtr->detail.g->vlist; ! int num_pts = ObjPtr->detail.g->n, fill, width, pen, curved; fill = ObjPtr->detail.g->fill; --- 52,57 ---- { XPoint * v = ObjPtr->detail.g->vlist; ! int num_pts = ObjPtr->detail.g->n, i; ! int fill, width, pen, curved, dash, color_index; fill = ObjPtr->detail.g->fill; *************** *** 58,62 **** --- 59,75 ---- pen = ObjPtr->detail.g->pen; curved = ObjPtr->detail.g->curved; + dash = ObjPtr->detail.g->dash; + if (fill == NONEPAT && pen == NONEPAT) return; + + if (colorDump) + { + color_index = ObjPtr->color; + fprintf (FP, "%.3f %.3f %.3f setrgbcolor\n", + ((float)tgifColors[color_index].red/maxRGB), + ((float)tgifColors[color_index].green/maxRGB), + ((float)tgifColors[color_index].blue/maxRGB)); + } + if (fill != NONEPAT) { *************** *** 115,177 **** } ! if (pen != NONEPAT) { ! fprintf (FP, "%1d setlinewidth\n", widthOfLine[width]); ! switch (curved) ! { ! case LT_STRAIGHT: ! switch (pen) ! { ! case SOLIDPAT: ! fprintf (FP, "newpath\n %1d %1d moveto\n", v[0].x, v[0].y); ! DumpPoints (FP, num_pts-1, v, 3); ! fprintf (FP, "closepath stroke\n"); ! break; ! case BACKPAT: ! fprintf (FP, "newpath\n %1d %1d moveto\n", v[0].x, v[0].y); ! DumpPoints (FP, num_pts-1, v, 3); ! fprintf (FP, "closepath 1 setgray stroke 0 setgray\n"); ! break; ! default: ! fprintf (FP, "gsave\n"); ! fprintf (FP, " pat%1d 8 1 0 72 300 32 div div setpattern\n", ! pen); ! fprintf (FP, " newpath\n"); ! fprintf (FP, " %1d %1d moveto\n", v[0].x, v[0].y); ! DumpPoints (FP, num_pts-1, v, 6); ! fprintf (FP, " closepath stroke\n"); ! fprintf (FP, "grestore\n"); ! break; ! } ! break; ! case LT_SPLINE: ! switch (pen) ! { ! case SOLIDPAT: ! fprintf (FP, "newpath\n"); ! DumpCurvedPolygonPoints (FP, num_pts, v, 3); ! fprintf (FP, "closepath stroke\n"); ! break; ! case BACKPAT: ! fprintf (FP, "newpath\n"); ! DumpCurvedPolygonPoints (FP, num_pts, v, 3); ! fprintf (FP, "closepath 1 setgray stroke 0 setgray\n"); ! break; ! default: ! fprintf (FP, "gsave\n"); ! fprintf (FP, " pat%1d 8 1 0 72 300 32 div div setpattern\n", ! pen); ! fprintf (FP, " newpath\n"); ! DumpCurvedPolygonPoints (FP, num_pts, v, 6); ! fprintf (FP, " closepath stroke\n"); ! fprintf (FP, "grestore\n"); ! break; ! } ! break; ! } ! fprintf (FP, "1 setlinewidth\n"); } ! fprintf (FP, "\n"); } --- 128,197 ---- } ! if (pen == NONEPAT) { fprintf (FP, "\n"); return; } ! ! fprintf (FP, "%1d setlinewidth\n", widthOfLine[width]); ! if (dash != 0) { ! fprintf (FP, "["); ! for (i = 0; i < dashListLength[dash]-1; i++) ! fprintf (FP, "%1d ", (int)(dashList[dash][i])); ! fprintf (FP, "%1d] 0 setdash\n", ! (int)(dashList[dash][dashListLength[dash]-1])); ! } ! switch (curved) ! { ! case LT_STRAIGHT: ! switch (pen) ! { ! case SOLIDPAT: ! fprintf (FP, "newpath\n %1d %1d moveto\n", v[0].x, v[0].y); ! DumpPoints (FP, num_pts-1, v, 3); ! fprintf (FP, "closepath stroke\n"); ! break; ! case BACKPAT: ! fprintf (FP, "newpath\n %1d %1d moveto\n", v[0].x, v[0].y); ! DumpPoints (FP, num_pts-1, v, 3); ! fprintf (FP, "closepath 1 setgray stroke 0 setgray\n"); ! break; ! default: ! fprintf (FP, "gsave\n"); ! fprintf (FP, " pat%1d 8 1 0 72 300 32 div div setpattern\n", ! pen); ! fprintf (FP, " newpath\n"); ! fprintf (FP, " %1d %1d moveto\n", v[0].x, v[0].y); ! DumpPoints (FP, num_pts-1, v, 6); ! fprintf (FP, " closepath stroke\n"); ! fprintf (FP, "grestore\n"); ! break; ! } ! break; ! case LT_SPLINE: ! switch (pen) ! { ! case SOLIDPAT: ! fprintf (FP, "newpath\n"); ! DumpCurvedPolygonPoints (FP, num_pts, v, 3); ! fprintf (FP, "closepath stroke\n"); ! break; ! case BACKPAT: ! fprintf (FP, "newpath\n"); ! DumpCurvedPolygonPoints (FP, num_pts, v, 3); ! fprintf (FP, "closepath 1 setgray stroke 0 setgray\n"); ! break; ! default: ! fprintf (FP, "gsave\n"); ! fprintf (FP, " pat%1d 8 1 0 72 300 32 div div setpattern\n", ! pen); ! fprintf (FP, " newpath\n"); ! DumpCurvedPolygonPoints (FP, num_pts, v, 6); ! fprintf (FP, " closepath stroke\n"); ! fprintf (FP, "grestore\n"); ! break; ! } ! break; } ! if (dash != 0) fprintf (FP, "[] 0 setdash\n"); ! fprintf (FP, "1 setlinewidth\n\n"); } *************** *** 184,188 **** XPoint * v; struct PolygonRec * polygon_ptr = ObjPtr->detail.g; ! int fill, width, pen, curved, pixel; int real_x_off, real_y_off; XGCValues values; --- 204,208 ---- XPoint * v; struct PolygonRec * polygon_ptr = ObjPtr->detail.g; ! int fill, width, pen, curved, dash, pixel; int real_x_off, real_y_off; XGCValues values; *************** *** 192,199 **** pen = polygon_ptr->pen; curved = polygon_ptr->curved; pixel = colorPixels[ObjPtr->color]; if (curved == LT_SPLINE) ! DrawSplinePolygonObj (Win, XOff, YOff, fill, width, pen, pixel, polygon_ptr); else --- 212,220 ---- pen = polygon_ptr->pen; curved = polygon_ptr->curved; + dash = polygon_ptr->dash; pixel = colorPixels[ObjPtr->color]; if (curved == LT_SPLINE) ! DrawSplinePolygonObj (Win, XOff, YOff, fill, width, pen, dash, pixel, polygon_ptr); else *************** *** 228,234 **** values.stipple = patPixmap[pen]; values.line_width = widthOfLine[width] >> zoomScale; XChangeGC (mainDisplay, drawGC, GCForeground | GCFunction | GCFillStyle | GCStipple | ! GCLineWidth, &values); XDrawLines (mainDisplay, Win, drawGC, v, polygon_ptr->n, --- 249,263 ---- values.stipple = patPixmap[pen]; values.line_width = widthOfLine[width] >> zoomScale; + if (dash != 0) + { + XSetDashes (mainDisplay, drawGC, 0, dashList[dash], + dashListLength[dash]); + values.line_style = LineOnOffDash; + } + else + values.line_style = LineSolid; XChangeGC (mainDisplay, drawGC, GCForeground | GCFunction | GCFillStyle | GCStipple | ! GCLineWidth | GCLineStyle, &values); XDrawLines (mainDisplay, Win, drawGC, v, polygon_ptr->n, *************** *** 274,277 **** --- 303,307 ---- polygon_ptr->pen = penPat; polygon_ptr->curved = curSpline; + polygon_ptr->dash = curDash; obj_ptr = (struct ObjRec *) calloc (1, sizeof(struct ObjRec)); obj_ptr->color = colorIndex; *************** *** 320,326 **** values.fill_style = FillSolid; values.line_width = 0; XChangeGC (mainDisplay, drawGC, ! GCForeground | GCFunction | GCFillStyle | GCLineWidth, &values); --- 350,357 ---- values.fill_style = FillSolid; values.line_width = 0; + values.line_style = LineSolid; XChangeGC (mainDisplay, drawGC, ! GCForeground | GCFunction | GCFillStyle | GCLineWidth | GCLineStyle, &values); *************** *** 450,461 **** default: CreatePolygonObj (num_pts); ! if (topObj->detail.g->curved == LT_SPLINE) ! RedrawAnArea (botObj, topObj->bbox.ltx-(1<<zoomScale), ! topObj->bbox.lty-(1<<zoomScale), ! topObj->bbox.rbx+(1<<zoomScale), ! topObj->bbox.rby+(1<<zoomScale)); ! else if (objFill != 0) ! DrawPolygonObj (drawWindow, drawOrigX, drawOrigY, topObj); ! polygonDrawn = TRUE; SetFileModified (TRUE); --- 481,488 ---- default: CreatePolygonObj (num_pts); ! RedrawAnArea (botObj, topObj->bbox.ltx-(1<<zoomScale), ! topObj->bbox.lty-(1<<zoomScale), ! topObj->bbox.rbx+(1<<zoomScale), ! topObj->bbox.rby+(1<<zoomScale)); polygonDrawn = TRUE; SetFileModified (TRUE); *************** *** 497,501 **** n = polygon_ptr->n; ! fprintf (FP, "polygon(%s,%1d,[", colorMenuItems[ObjPtr->color], polygon_ptr->n); for (i = 0; i < n-1; i++) --- 524,528 ---- n = polygon_ptr->n; ! fprintf (FP, "polygon('%s',%1d,[", colorMenuItems[ObjPtr->color], polygon_ptr->n); for (i = 0; i < n-1; i++) *************** *** 502,508 **** fprintf (FP, "%1d,%1d,", polygon_ptr->vlist[i].x, polygon_ptr->vlist[i].y); ! fprintf (FP, "%1d,%1d],%1d,%1d,%1d,%1d,%1d,", polygon_ptr->vlist[n-1].x, polygon_ptr->vlist[n-1].y, polygon_ptr->fill, polygon_ptr->width, ! polygon_ptr->pen, polygon_ptr->curved, ObjPtr->id); SaveAttrs (FP, ObjPtr->lattr); fprintf (FP, ")"); --- 529,535 ---- fprintf (FP, "%1d,%1d,", polygon_ptr->vlist[i].x, polygon_ptr->vlist[i].y); ! fprintf (FP, "%1d,%1d],%1d,%1d,%1d,%1d,%1d,%1d,", polygon_ptr->vlist[n-1].x, polygon_ptr->vlist[n-1].y, polygon_ptr->fill, polygon_ptr->width, ! polygon_ptr->pen, polygon_ptr->curved, ObjPtr->id, polygon_ptr->dash); SaveAttrs (FP, ObjPtr->lattr); fprintf (FP, ")"); *************** *** 518,522 **** char color_str[20], * s; int num_pts, ltx, lty, rbx, rby, x, y, fill, width, pen, w; ! int curved; * ObjPtr = (struct ObjRec *) calloc (1, sizeof(struct ObjRec)); --- 545,549 ---- char color_str[20], * s; int num_pts, ltx, lty, rbx, rby, x, y, fill, width, pen, w; ! int curved, dash; * ObjPtr = (struct ObjRec *) calloc (1, sizeof(struct ObjRec)); *************** *** 559,562 **** --- 586,590 ---- } (*ObjPtr)->id = objId++; + dash = 0; } else if (fileVersion <= 5) *************** *** 569,572 **** --- 597,601 ---- } (*ObjPtr)->id = objId++; + dash = 0; } else if (fileVersion <= 7) *************** *** 574,579 **** sscanf (s, "%d , %d , %d , %d", &fill, &width, &pen, &curved); (*ObjPtr)->id = objId++; } ! else { sscanf (s, "%d , %d , %d , %d , %d", &fill, &width, &pen, &curved, --- 603,609 ---- sscanf (s, "%d , %d , %d , %d", &fill, &width, &pen, &curved); (*ObjPtr)->id = objId++; + dash = 0; } ! else if (fileVersion <= 8) { sscanf (s, "%d , %d , %d , %d , %d", &fill, &width, &pen, &curved, *************** *** 580,584 **** --- 610,621 ---- &((*ObjPtr)->id)); if ((*ObjPtr)->id >= objId) objId = (*ObjPtr)->id + 1; + dash = 0; } + else + { + sscanf (s, "%d , %d , %d , %d , %d , %d", &fill, &width, &pen, &curved, + &((*ObjPtr)->id), &dash); + if ((*ObjPtr)->id >= objId) objId = (*ObjPtr)->id + 1; + } polygon_ptr->vlist = v; *************** *** 590,593 **** --- 627,631 ---- polygon_ptr->pen = pen; polygon_ptr->curved = curved; + polygon_ptr->dash = dash; (*ObjPtr)->x = ltx; (*ObjPtr)->y = lty; *** prtgif.c.orig Wed Dec 12 14:37:17 1990 --- prtgif.c Wed Dec 12 14:37:19 1990 *************** *** 6,10 **** #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/prtgif.c,v 1.16 90/08/16 15:28:30 william Exp $"; #endif --- 6,10 ---- #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/prtgif.c,v 1.17 90/11/01 13:49:48 william Exp $"; #endif *************** *** 108,119 **** struct ObjRec * obj_ptr; char full_name[MAXPATHLENGTH]; FILE * fp; ! strcpy (full_name, FileName); ! strcat (full_name, ".obj"); if ((fp = fopen (full_name, "r")) == NULL) { ! printf ("Can not open '%s'.", full_name); return (FALSE); } --- 108,123 ---- struct ObjRec * obj_ptr; char full_name[MAXPATHLENGTH]; + int len; FILE * fp; ! len = strlen (FileName); ! if (len >= 4 && strcmp (&FileName[len-4], ".obj") == 0) ! strcpy (full_name, FileName); ! else ! sprintf (full_name, "%s.obj", FileName); if ((fp = fopen (full_name, "r")) == NULL) { ! printf ("Can not open '%s'.\n", full_name); return (FALSE); } ---------------------------------> cut here <--------------------------------- -- Bill Cheng // UCLA Computer Science Department // (213) 206-7135 3277 Boelter Hall // Los Angeles, California 90024 // USA william@CS.UCLA.EDU ...!{uunet|ucbvax}!cs.ucla.edu!william -- Dan Heller ------------------------------------------------ O'Reilly && Associates Zyrcom Inc Senior Writer President argv@ora.com argv@zipcode.com