1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476
|
/*
* plotVers.c --
*
* This file contains the procedures that generate plots on
* Versatec-style black-and-white printers.
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*/
#ifndef lint
static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/plot/plotVers.c,v 1.3 2010/06/24 12:37:25 tim Exp $";
#endif /* not lint */
#include <stdio.h>
#include <string.h>
#include "utils/magic.h"
#include "utils/geometry.h"
#include "utils/geofast.h"
#include "tiles/tile.h"
#include "utils/hash.h"
#include "database/database.h"
#include "utils/malloc.h"
#include "plot/plotInt.h"
#include "windows/windows.h"
#include "commands/commands.h"
#include "textio/textio.h"
#include "utils/utils.h"
#include "utils/tech.h"
#include "utils/signals.h"
#include "dbwind/dbwind.h"
#include "cif/cif.h" /* for CIFGetOutputScale() */
#ifdef VERSATEC
/* Library imports: */
extern int rasFileByteCount;
/* Records of the following type are used to describe how to generate
* output for the mask layers. Each style describes a particular
* stipple pattern.
*/
typedef struct versatecstyle
{
TileTypeBitMask vs_layers; /* Layers to plot in this style. */
Stipple vs_stipple; /* Stipple pattern to use. */
int vs_flags; /* Flag bits, see below. */
struct versatecstyle *vs_next; /* Pointer to next style in list. */
/* If the color flag is false, all stipples will be black */
VersatecColor vs_color; /* Stipple color */
} VersatecStyle;
/* Flag values for VersatecStyles:
*
* VS_CROSS - if this bit is set, then generate an outline with an
* X through the middle, like for contacts, instead of
* stippling. The stipple pattern is ignored in this
* case.
* VS_BORDER - if this bit is set, generate an outline with no X
* through the middle and no stipple. The stipple
* pattern is ignored in this case.
*/
#define VS_CROSS 1
#define VS_BORDER 2
static VersatecStyle *plotVersStyles;
static VersatecStyle *plotColorVersStyles;
char *plotVersatecColorNames[] = {
"Black",
"Cyan",
"Magenta",
"Yellow"
};
/*
* ----------------------------------------------------------------------------
* The parameters below control various aspects of the plotting
* process. The initial values are defaults for the versatec
* printer. However, many of them can be modified by users
* with the "plot option" command.
* ----------------------------------------------------------------------------
*/
/* Supported format. Default is "hprtl". */
unsigned char PlotVersPlotType = HPRTL;
int PlotVersWidth = 2400; /* Number of dots across Versatec page.
* Should be a multiple of 32.
*/
int PlotVersDotsPerInch = 300; /* Dots per inch. */
int PlotVersSwathHeight = 64; /* Width of swath to generate at one time,
* in dots.
*/
/* Name of printer to use for output: */
static char *defaultPrinter = "versatec";
char *PlotVersPrinter = NULL;
/* Command to use to actually print rasterized file. Contains two %s'es,
* which are supplied with the printer name and the name of the raster file.
*/
static char *defaultCommand = "lp -d %s %s";
char *PlotVersCommand = NULL;
/* Directory in which to create temporary file to hold raster: */
static char *defaultDirectory = "/tmp";
char *PlotTempDirectory = NULL;
/* Name of fonts to use: */
static char *defaultIdFont = "vfont.I.12";
char *PlotVersIdFont = NULL;
static char *defaultNameFont = "vfont.B.12";
char *PlotVersNameFont = NULL;
static char *defaultLabelFont = "vfont.R.8";
char *PlotVersLabelFont = NULL;
/*
* ----------------------------------------------------------------------------
* The variables below are shared between the top-level Versatec
* plotting procedure and the lower-level search functions. They
* contain specific information about how to generate the current
* plot. There area three coordinate systems of interest here:
*
* 1. Magic root coordinates.
* 2. Raster coordinates: based on printer pixels, one unit per pixel,
* where (0,0) corresponds to the lower-leftmost dot that will be
* printed.
* 3. Swath coordinates: the raster will be much too large to keep in
* memory all at once, so it's generated in a series of horizontal
* swaths. The stippling routines all work in swath-relative
* coordinates, which are the same as raster coordinates except for
* a y-displacement (swathY below).
* ----------------------------------------------------------------------------
*/
Point plotLL; /* Point in root Magic coords that corresponds
* to (0,0) in raster coordinates.
*/
int swathY; /* The y-coordinate in raster coordinates that
* corresponds to (0,0) in swath coords. It's
* always >= 0.
*/
static int scale; /* How many (2**scaleShift)-ths of a pixel
* correspond to one Magic unit.
*/
int scaleShift; /* The idea is that one Magic unit is equal
* to scale/(2**scaleShift) pixels.
*/
static Rect rootClip; /* Total root area of the plot. Used for
* clipping.
*/
static Rect swathClip; /* Rectangle used for clipping to the area of
* the current swath. This is in swath
* coordinates.
*/
static VersatecStyle *curStyle; /* Current style being processed. */
static TileTypeBitMask curMask; /* Mask of layers currently being stippled.
* This is the AND of the mask from curStyle
* and the layers that the user wants plotted.
*/
static int crossSize; /* Length of each arm of the crosses used
* to draw labels, in pixel units.
*/
static RasterFont *labelFont; /* Font to use when rendering labels. */
static RasterFont *cellNameFont; /* Font to use when rendering cell names. */
static RasterFont *cellIdFont; /* Font to use when rendering cell ids. */
#endif /* VERSATEC */
/*
* ----------------------------------------------------------------------------
* PlotVersTechInit --
*
* Called once at beginning of technology file read-in to initialize
* data structures.
*
* Results:
* None.
*
* Side effects:
* Clears out the list of things to plot.
* ----------------------------------------------------------------------------
*/
#ifdef VERSATEC
void
PlotVersTechInit()
{
VersatecStyle *style;
for (style = plotVersStyles; style != NULL; style = style->vs_next)
{
freeMagic((char *) style);
}
plotVersStyles = NULL;
if (PlotVersPrinter == NULL)
StrDup(&PlotVersPrinter, defaultPrinter);
if (PlotVersCommand == NULL)
StrDup(&PlotVersCommand, defaultCommand);
if (PlotTempDirectory == NULL)
StrDup(&PlotTempDirectory, defaultDirectory);
if (PlotVersIdFont == NULL)
StrDup(&PlotVersIdFont, defaultIdFont);
if (PlotVersNameFont == NULL)
StrDup(&PlotVersNameFont, defaultNameFont);
if (PlotVersLabelFont == NULL)
StrDup(&PlotVersLabelFont, defaultLabelFont);
}
#else
void
PlotVersTechInit()
{}
#endif /* VERSATEC */
/*
* ----------------------------------------------------------------------------
* PlotColorVersTechInit --
*
* Called once at beginning of technology file read-in to initialize
* data structures.
*
* Results:
* None.
*
* Side effects:
* Clears out the list of things to plot.
* ----------------------------------------------------------------------------
*/
#ifdef VERSATEC
void
PlotColorVersTechInit()
{
VersatecStyle *style;
for (style = plotColorVersStyles; style != NULL; style = style->vs_next)
{
freeMagic((char *) style);
}
plotColorVersStyles = NULL;
if (PlotVersPrinter == NULL)
StrDup(&PlotVersPrinter, defaultPrinter);
if (PlotVersCommand == NULL)
StrDup(&PlotVersCommand, defaultCommand);
if (PlotTempDirectory == NULL)
StrDup(&PlotTempDirectory, defaultDirectory);
if (PlotVersIdFont == NULL)
StrDup(&PlotVersIdFont, defaultIdFont);
if (PlotVersNameFont == NULL)
StrDup(&PlotVersNameFont, defaultNameFont);
if (PlotVersLabelFont == NULL)
StrDup(&PlotVersLabelFont, defaultLabelFont);
}
#else
void
PlotColorVersTechInit()
{}
#endif /* VERSATEC */
/*
* ----------------------------------------------------------------------------
* PlotVersTechLine --
*
* This procedure is invoked by the technology module once for
* each line in the "versatec" subsection of the "plot" section
* of the technology file.
*
* Results:
* Always returns TRUE (otherwise the technology module would
* abort Magic with a fatal error).
*
* Side effects:
* Builds up the table of Versatec styles.
* ----------------------------------------------------------------------------
*/
#ifdef VERSATEC
bool
PlotVersTechLine(sectionName, argc, argv)
char *sectionName; /* Name of this section (unused). */
int argc; /* Number of arguments on line. */
char *argv[]; /* Pointers to fields of line. */
{
VersatecStyle *new;
int i;
new = (VersatecStyle *) mallocMagic(sizeof(VersatecStyle));
DBTechNoisyNameMask(argv[0], &new->vs_layers);
if (argc == 2)
{
if (strcmp(argv[1], "X") == 0)
new->vs_flags = VS_CROSS;
else if (strcmp(argv[1], "B") == 0)
new->vs_flags = VS_BORDER;
else
{
TechError("Second field must be \"X\" or \"B\"\n");
freeMagic((char *) new);
return TRUE;
}
}
else
{
int i, value;
if (argc != 17)
{
TechError("\"versatec\" lines must have either 2 or 17 fields.\n");
freeMagic((char *)new);
return TRUE;
}
new->vs_color = 0;
new->vs_flags = 0;
for (i = 0; i < 16; i++)
{
(void) sscanf(argv[i+1], "%x", &value);
new->vs_stipple[i] = (value<<16) | (value & 0xffff);
#ifndef WORDS_BIGENDIAN
new->vs_stipple[i] = PlotSwapBytes(new->vs_stipple[i]);
#endif /* WORDS_BIGENDIAN */
}
}
new->vs_next = plotVersStyles;
plotVersStyles = new;
return TRUE;
}
#else
bool
PlotVersTechLine(sectionName, argc, argv)
char *sectionName; /* Name of this section (unused). */
int argc; /* Number of arguments on line. */
char *argv[]; /* Pointers to fields of line. */
{
return TRUE;
}
#endif /* VERSATEC */
/*
* ----------------------------------------------------------------------------
* PlotColorVersTechLine --
*
* This procedure is invoked by the technology module once for
* each line in the "colorversatec" subsection of the "plot" section
* of the technology file.
*
* Results:
* Always returns TRUE (otherwise the technology module would
* abort Magic with a fatal error).
*
* Side effects:
* Builds up the table of ColorVersatec styles.
* ----------------------------------------------------------------------------
*/
#ifdef VERSATEC
bool
PlotColorVersTechLine(sectionName, argc, argv)
char *sectionName; /* Name of this section (unused). */
int argc; /* Number of arguments on line. */
char *argv[]; /* Pointers to fields of line. */
{
VersatecStyle *new;
static struct { char *l_str; int l_color; } colors[] = {
"black", BLACK,
"cyan", CYAN,
"magenta", MAGENTA,
"yellow", YELLOW,
"K", BLACK,
"C", CYAN,
"M", MAGENTA,
"Y", YELLOW,
0
};
int i;
new = (VersatecStyle *)mallocMagic(sizeof(VersatecStyle));
DBTechNoisyNameMask(argv[0], &new->vs_layers);
if (argc == 2)
{
new->vs_color = BLACK;
if (strcmp(argv[1], "X") == 0)
new->vs_flags = VS_CROSS;
else if (strcmp(argv[1], "B") == 0)
new->vs_flags = VS_BORDER;
else
{
TechError("Second field must be \"X\" or \"B\"\n");
freeMagic((char *) new);
return TRUE;
}
}
else
{
int i, j, value;
if (argc != 3 && argc != 4 && argc != 6 && argc != 10 && argc != 18)
{
TechError("\"colorversatec\" lines must have 2 fields + 1, 2, 4, 8,"
" or 16 stipple word values.\n");
freeMagic((char *)new);
return TRUE;
}
i = LookupStruct(argv[1], (LookupTable *) colors, sizeof colors[0]);
if (i < 0)
{
TechError("First field must be BLACK, CYAN, MAGENTA or YELLOW.\n");
freeMagic((char *)new);
return TRUE;
}
new->vs_color = colors[i].l_color;
new->vs_flags = 0;
for (j = 0; j < 16; j += (argc - 2))
{
for (i = 0; i < (argc - 2); i++)
{
sscanf(argv[i + 2], "%x", &value);
new->vs_stipple[j + i] = (value << 16) | (value & 0xffff);
#ifndef WORDS_BIGENDIAN
new->vs_stipple[j + i] = PlotSwapBytes(new->vs_stipple[i]);
#endif /* WORDS_BIGENDIAN */
}
}
}
new->vs_next = plotColorVersStyles;
plotColorVersStyles = new;
return TRUE;
}
#else
bool
PlotColorVersTechLine(sectionName, argc, argv)
char *sectionName; /* Name of this section (unused). */
int argc; /* Number of arguments on line. */
char *argv[]; /* Pointers to fields of line. */
{
return TRUE;
}
#endif /* VERSATEC */
#ifdef VERSATEC
/*
* ----------------------------------------------------------------------------
*
* plotTransToSwath --
*
* Transforms a rectangle from Magic root coordinates to the
* coordinates of the current swath.
*
* Results:
* None.
*
* Side effects:
* Dst is modified to hold a rectangle that has been transformed
* to swath coordinates.
*
* ----------------------------------------------------------------------------
*/
void
plotTransToSwath(src, dst)
Rect *src; /* Rectangle in Magic root coords. */
Rect *dst; /* Rectangle to be filled in with swath
* corresponding to src.
*/
{
dst->r_xbot = ((src->r_xbot - plotLL.p_x)*scale) >> scaleShift;
dst->r_xtop = ((src->r_xtop - plotLL.p_x)*scale) >> scaleShift;
dst->r_ybot = (((src->r_ybot - plotLL.p_y)*scale) >> scaleShift) - swathY;
dst->r_ytop = (((src->r_ytop - plotLL.p_y)*scale) >> scaleShift) - swathY;
}
/*
* ----------------------------------------------------------------------------
*
* plotVersLine --
*
* This procedure plots a line of a given thickness.
*
* Results:
* None.
*
* Side effects:
* The current raster is modified.
*
* ----------------------------------------------------------------------------
*/
void
plotVersLine(area, widen, raster)
Rect *area; /* The "corner" points of this rectangle
* give the endpoints of the line, in
* Magic root coordinates.
*/
int widen; /* Amount by which to widen line. 0 means
* line is drawn one pixel wide, 1 means 3
* pixels wide, etc.
*/
Raster *raster; /* Raster to write to */
{
Rect swathArea;
plotTransToSwath(area, &swathArea);
/* Handle Manhattan lines using rectangle-drawing, since it's faster. */
if ((swathArea.r_xbot == swathArea.r_xtop) ||
(swathArea.r_ybot == swathArea.r_ytop))
{
GEO_EXPAND(&swathArea, widen, &swathArea);
GEOCLIP(&swathArea, &swathClip);
if ((swathArea.r_xbot <= swathArea.r_xtop) &&
(swathArea.r_ybot <= swathArea.r_ytop))
PlotFillRaster(raster, &swathArea, PlotBlackStipple);
}
else
PlotRastFatLine(raster, &swathArea.r_ll, &swathArea.r_ur, widen);
}
/*
* ----------------------------------------------------------------------------
*
* plotVersRect --
*
* This procedure takes a rectangular area, given in Magic root
* coordinates, translates it to swath coordinates, and draws
* it as an outline of a given thickness.
*
* Results:
* None.
*
* Side effects:
* Modifies raster.
*
* ----------------------------------------------------------------------------
*/
void
plotVersRect(area, widen, raster)
Rect *area; /* Rectangular area to draw, in root
* coordinates.
*/
int widen; /* If zero, rectangular outline is drawn
* one pixel wide. If non-zero, the outline
* is widened by this many units on each
* side.
*/
Raster *raster; /* Raster to plot to */
{
Rect side;
/* First, the bottom side. */
if (area->r_xbot != area->r_xtop)
{
side = *area;
side.r_ytop = side.r_ybot;
plotVersLine(&side, widen, raster);
/* Now the top side, if it doesn't coincide with the bottom. */
if (area->r_ybot != area->r_ytop)
{
side = *area;
side.r_ybot = side.r_ytop;
plotVersLine(&side, widen, raster);
}
}
/* Now do the left side. */
if (area->r_ybot != area->r_ytop)
{
side = *area;
side.r_xtop = side.r_xbot;
plotVersLine(&side, widen, raster);
/* Now the right side, if it doesn't coincide with the left. */
if (area->r_xbot != area->r_xtop)
{
side = *area;
side.r_xbot = side.r_xtop;
plotVersLine(&side, widen, raster);
}
}
}
/*
* ----------------------------------------------------------------------------
*
* plotVersTile --
*
* This procedure is called for paint tiles. It renders each tile
* in the current style, in the current swath.
*
* Results:
* Always returns 0 to keep the search alive.
*
* Side effects:
* Modifies the raster area.
*
* ----------------------------------------------------------------------------
*/
int
plotVersTile(tile, cxp)
Tile *tile; /* Tile that's of type to be output. */
TreeContext *cxp; /* Describes search in progress. */
{
Rect tileArea, rootArea, swathArea, edge;
TileType ntype;
Tile *neighbor;
Transform *trans = &cxp->tc_scx->scx_trans;
Raster *raster = (Raster *)cxp->tc_filter->tf_arg;
/* Transform tile coords to root coords and then to swath coords. */
TITORECT(tile, &tileArea);
GEOTRANSRECT(trans, &tileArea, &rootArea);
plotTransToSwath(&rootArea, &swathArea);
/* Handle X'ed things specially. */
if (curStyle->vs_flags & VS_CROSS)
{
if (!IsSplit(tile))
if (((swathArea.r_xtop - swathArea.r_xbot) > 6)
&& ((swathArea.r_ytop - swathArea.r_ybot) > 6))
{
Rect r2;
plotVersLine(&rootArea, 0, raster);
r2.r_xtop = rootArea.r_xbot;
r2.r_ybot = rootArea.r_ybot;
r2.r_xbot = rootArea.r_xtop;
r2.r_ytop = rootArea.r_ytop;
plotVersLine(&r2, 0, raster);
}
}
if (IsSplit(tile))
{
int i, j;
TileType dinfo;
Rect r;
dinfo = DBTransformDiagonal(TiGetTypeExact(tile), &cxp->tc_scx->scx_trans);
if (!(curStyle->vs_flags & VS_BORDER) && !(curStyle->vs_flags & VS_CROSS))
PlotPolyRaster(raster, &swathArea, &swathClip, dinfo,
curStyle->vs_stipple);
/* Diagonal is always drawn (clipping handled in plotVersLine) */
r = rootArea;
if (dinfo & TT_DIRECTION)
{
/* swap X to make diagonal go the other way */
r.r_xbot = r.r_xtop;
r.r_xtop = rootArea.r_xbot;
}
plotVersLine(&r, 0, raster);
}
else
{
/* Clip and then stipple. */
GEOCLIP(&swathArea, &swathClip);
if (swathArea.r_xbot > swathArea.r_xtop) return 0;
if (swathArea.r_ybot > swathArea.r_ytop) return 0;
if (!(curStyle->vs_flags & VS_BORDER) && !(curStyle->vs_flags & VS_CROSS))
PlotFillRaster(raster, &swathArea, curStyle->vs_stipple);
}
/* Now output lines for any edges between material of the type
* currently being drawn and material of other types. This is
* done by searching along the tile's borders for neighbors that
* have the wrong types. First, search the tile's bottom border
* (unless it is at infinity).
*/
if (IsSplit(tile) && (!(SplitSide(tile) ^ SplitDirection(tile))))
goto searchleft; /* nothing on bottom of split */
if (tileArea.r_ybot > TiPlaneRect.r_ybot)
{
edge.r_ybot = edge.r_ytop = tileArea.r_ybot;
for (neighbor = LB(tile); LEFT(neighbor) < tileArea.r_xtop;
neighbor = TR(neighbor))
{
ntype = TiGetTopType(neighbor);
if (TTMaskHasType(&curMask, ntype)) continue;
edge.r_xbot = LEFT(neighbor);
edge.r_xtop = RIGHT(neighbor);
if (edge.r_xbot < tileArea.r_xbot) edge.r_xbot = tileArea.r_xbot;
if (edge.r_xtop > tileArea.r_xtop) edge.r_xtop = tileArea.r_xtop;
GEOTRANSRECT(trans, &edge, &rootArea);
plotVersLine(&rootArea, 0, raster);
}
}
searchleft:
if (IsSplit(tile) && (SplitSide(tile)))
goto searchtop; /* Nothing on left side of split */
/* Now go along the tile's left border, doing the same thing. Ignore
* edges that are at infinity.
*/
if (tileArea.r_xbot > TiPlaneRect.r_xbot)
{
edge.r_xbot = edge.r_xtop = tileArea.r_xbot;
for (neighbor = BL(tile); BOTTOM(neighbor) < tileArea.r_ytop;
neighbor = RT(neighbor))
{
ntype = TiGetRightType(neighbor);
if (TTMaskHasType(&curMask, ntype)) continue;
edge.r_ybot = BOTTOM(neighbor);
edge.r_ytop = TOP(neighbor);
if (edge.r_ybot < tileArea.r_ybot) edge.r_ybot = tileArea.r_ybot;
if (edge.r_ytop > tileArea.r_ytop) edge.r_ytop = tileArea.r_ytop;
GEOTRANSRECT(trans, &edge, &rootArea);
plotVersLine(&rootArea, 0, raster);
}
}
/* Same thing for the tile's top border. */
searchtop:
if (IsSplit(tile) && (SplitSide(tile) ^ SplitDirection(tile)))
goto searchright; /* Nothing on top side of tile */
if (tileArea.r_ytop < TiPlaneRect.r_ytop)
{
edge.r_ybot = edge.r_ytop = tileArea.r_ytop;
for (neighbor = RT(tile); RIGHT(neighbor) > tileArea.r_xbot;
neighbor = BL(neighbor))
{
ntype = TiGetBottomType(neighbor);
if (TTMaskHasType(&curMask, ntype)) continue;
edge.r_xbot = LEFT(neighbor);
edge.r_xtop = RIGHT(neighbor);
if (edge.r_xbot < tileArea.r_xbot) edge.r_xbot = tileArea.r_xbot;
if (edge.r_xtop > tileArea.r_xtop) edge.r_xtop = tileArea.r_xtop;
GEOTRANSRECT(trans, &edge, &rootArea);
plotVersLine(&rootArea, 0, raster);
}
}
/* Finally, the right border. */
searchright:
if (IsSplit(tile) && !(SplitSide(tile)))
return 0; /* Nothing on right side of tile */
if (tileArea.r_xtop < TiPlaneRect.r_xtop)
{
edge.r_xbot = edge.r_xtop = tileArea.r_xtop;
for (neighbor = TR(tile); TOP(neighbor) > tileArea.r_ybot;
neighbor = LB(neighbor))
{
ntype = TiGetLeftType(neighbor);
if (TTMaskHasType(&curMask, ntype)) continue;
edge.r_ybot = BOTTOM(neighbor);
edge.r_ytop = TOP(neighbor);
if (edge.r_ybot < tileArea.r_ybot) edge.r_ybot = tileArea.r_ybot;
if (edge.r_ytop > tileArea.r_ytop) edge.r_ytop = tileArea.r_ytop;
GEOTRANSRECT(trans, &edge, &rootArea);
plotVersLine(&rootArea, 0, raster);
}
}
return 0;
}
/*
* ----------------------------------------------------------------------------
*
* plotVersLabel --
*
* This procedure is invoked for labels. It generates bits to
* display the label in the current raster swath.
*
* Results:
* Always returns 0 to keep the search from aborting.
*
* Side effects:
* Modifies the raster.
*
* ----------------------------------------------------------------------------
*/
int
plotVersLabel(scx, label, tpath, raster)
SearchContext *scx; /* Describes state of search when label
* was found.
*/
Label *label; /* Label that was found. */
TerminalPath *tpath; /* Ignored. */
Raster *raster; /* Raster to write to */
{
Rect rootArea, swathArea, labelSize;
Point point;
int pos;
/* Translate the label's area and relative position to root
* coordinates and then to swath coordinates. Figure out
* the point relative to which the label is to be positioned.
*/
GeoTransRect(&scx->scx_trans, &label->lab_rect, &rootArea);
plotTransToSwath(&rootArea, &swathArea);
pos = GeoTransPos(&scx->scx_trans, label->lab_just);
PlotTextSize(labelFont, label->lab_text, &labelSize);
switch (pos)
{
case GEO_NORTH:
case GEO_NORTHEAST:
case GEO_NORTHWEST:
point.p_y = swathArea.r_ytop + crossSize + 2 - labelSize.r_ybot;
break;
case GEO_CENTER:
case GEO_WEST:
case GEO_EAST:
point.p_y = (swathArea.r_ytop + swathArea.r_ybot)/2;
point.p_y -= (labelSize.r_ytop + labelSize.r_ybot)/2;
break;
case GEO_SOUTH:
case GEO_SOUTHEAST:
case GEO_SOUTHWEST:
point.p_y = swathArea.r_ybot - crossSize - 2 - labelSize.r_ytop;
break;
}
switch (pos)
{
case GEO_WEST:
case GEO_NORTHWEST:
case GEO_SOUTHWEST:
point.p_x = swathArea.r_xbot - crossSize - 2 - labelSize.r_xtop;
break;
case GEO_CENTER:
case GEO_NORTH:
case GEO_SOUTH:
point.p_x = (swathArea.r_xtop + swathArea.r_xbot)/2;
point.p_x -= (labelSize.r_xtop + labelSize.r_xbot)/2;
break;
case GEO_EAST:
case GEO_NORTHEAST:
case GEO_SOUTHEAST:
point.p_x = swathArea.r_xtop + crossSize + 2 - labelSize.r_xbot;
break;
}
/* Output lines marking the label's area. Different things are
* done depending on whether the label is a point, a line, or an
* area.
*/
if ((rootArea.r_xbot == rootArea.r_xtop) &&
(rootArea.r_ybot == rootArea.r_ytop))
{
Rect tmp;
/* Point label. Output a cross. */
tmp = swathArea;
tmp.r_ytop += crossSize;
tmp.r_ybot -= crossSize;
GEO_EXPAND(&tmp, 1, &tmp);
GEOCLIP(&tmp, &swathClip);
if ((tmp.r_xbot <= tmp.r_xtop) &&
(tmp.r_ybot <= tmp.r_ytop))
PlotFillRaster(raster, &tmp, PlotBlackStipple);
tmp = swathArea;
tmp.r_xtop += crossSize;
tmp.r_xbot -= crossSize;
GEO_EXPAND(&tmp, 1, &tmp);
GEOCLIP(&tmp, &swathClip);
if ((tmp.r_xbot <= tmp.r_xtop) &&
(tmp.r_ybot <= tmp.r_ytop))
PlotFillRaster(raster, &tmp, PlotBlackStipple);
}
else
{
/* Line or rectangle. Draw outline. */
plotVersRect(&rootArea, 1, raster);
}
/* Output the text for the label. Before outputting the label,
* erase the area where the label will appear in order to make
* the label more visible.
*/
labelSize.r_xbot += point.p_x - 1;
labelSize.r_xtop += point.p_x + 1;
labelSize.r_ybot += point.p_y - 1;
labelSize.r_ytop += point.p_y + 1;
GEOCLIP(&labelSize, &swathClip);
PlotClearRaster(raster, &labelSize);
PlotRasterText(raster, &swathClip, labelFont, label->lab_text, &point);
return 0;
}
/*
* ----------------------------------------------------------------------------
*
* plotVersCell --
*
* This procedure is invoked for unexpanded cells.
*
* Results:
* Always returns 0 to keep the search from aborting.
*
* Side effects:
* The raster is modified to depict the cell's boundary,
* name, and instance id.
*
* ----------------------------------------------------------------------------
*/
int
plotVersCell(scx, raster)
SearchContext *scx; /* Describes cell whose bbox is to
* be plotted.
*/
Raster *raster; /* Raster to write to */
{
char idName[100];
Rect rootArea, swathArea, textSize;
Point point;
CellDef *def;
/* Convert the cell's bounding box to root coordinates and then
* draw as a thick outline.
*/
def = scx->scx_use->cu_def;
GeoTransRect(&scx->scx_trans, &def->cd_bbox, &rootArea);
plotVersRect(&rootArea, 2, raster);
if (!PlotShowCellNames)
return (0);
/* Output the cell's name and id text. */
if (cellNameFont != NULL)
{
plotTransToSwath(&rootArea, &swathArea);
PlotTextSize(cellNameFont, def->cd_name, &textSize);
point.p_x = (swathArea.r_xtop + swathArea.r_xbot)/2;
point.p_x -= (textSize.r_xtop + textSize.r_xbot)/2;
point.p_y = (2*swathArea.r_ytop + swathArea.r_ybot)/3;
point.p_y -= (textSize.r_ytop + textSize.r_ybot)/2;
PlotRasterText(raster, &swathClip, cellNameFont, def->cd_name, &point);
}
if (cellIdFont != NULL)
{
DBPrintUseId(scx, idName, 100, TRUE);
PlotTextSize(cellIdFont, idName, &textSize);
point.p_x = (swathArea.r_xtop + swathArea.r_xbot)/2;
point.p_x -= (textSize.r_xtop + textSize.r_xbot)/2;
point.p_y = (swathArea.r_ytop + 2*swathArea.r_ybot)/3;
point.p_y -= (textSize.r_ytop + textSize.r_ybot)/2;
PlotRasterText(raster, &swathClip, cellIdFont, idName, &point);
}
return 0;
}
/*
* ----------------------------------------------------------------------------
*
* PlotVersatec --
*
* This procedure generates a raster file suitable for driving
* printers like the Versatec black-and-white family, and runs
* a spooling program to print the file.
*
* If PlotVersPlotType is VERSATEC_COLOR, it will generate a
* versatec color plot file in straight color raster format.
*
* If PlotVersPlotType is HPGL2 or HPRTL, it will generate
* an HPRTL file for the supported HP plotters.
*
* Results:
* None.
*
* Side effects:
* Lots of disk space is chewed up by the file.
*
* ----------------------------------------------------------------------------
*/
void
PlotVersatec(scx, layers, xMask, user_scale)
SearchContext *scx; /* The use and area and transformation
* in this describe what to plot.
*/
TileTypeBitMask *layers; /* Tells what layers to plot. Only
* paint layers in this mask, and also
* expanded according to xMask, are
* plotted. If L_LABELS is set, then
* labels on the layers are also
* plotted, if expanded according to
* xMask. If L_CELL is set, then
* subcells that are unexpanded
* according to xMask are plotted as
* bounding boxes.
*/
int xMask; /* An expansion mask, used to indicate
* the window whose expansion status
* will be used to determine
* visibility. Zero means treat
* everything as expanded.
*/
int user_scale; /* Scalefactor of output */
{
static char *yesNo[] = {"no", "yes", NULL};
int dotsAcross, dotsDown, swathsDown, scaleDown;
int mag_width; /* lambda */
float width; /* inches */
char fileName[200], command[300], answer[32];
float length, mBytes;
Transform tinv;
int action, result;
FILE *file;
VersatecColor color;
bool haveColorMessage;
int usedScale, maxScale;
float oscale;
Raster *raster = NULL;
/* CMYK color separated raster buffers. */
Raster *kRaster = NULL, *cRaster = NULL, *mRaster = NULL, *yRaster = NULL;
haveColorMessage = FALSE;
GeoTransRect(&scx->scx_trans, &scx->scx_area, &rootClip);
GEO_EXPAND(&rootClip, 1, &rootClip);
/* Get conversion factor (internal units to inches) */
oscale = CIFGetOutputScale(1000); /* convert to microns */
oscale *= 3.937e-5; /* convert to inches */
/* Compute plot width from scalefactor */
mag_width = rootClip.r_xtop - rootClip.r_xbot;
maxScale = ((float)PlotVersWidth / (float)PlotVersDotsPerInch)
/ (oscale * (float)mag_width);
width = (float)user_scale * oscale * (float)mag_width;
dotsAcross = (int)(width * (float)PlotVersDotsPerInch);
if (dotsAcross <= 0 || dotsAcross > PlotVersWidth)
{
dotsAcross = PlotVersWidth;
usedScale = maxScale;
}
else
usedScale = user_scale;
/* Recompute width based on the actual scale used */
width = (float)usedScale * oscale * (float)mag_width;
/*
* Compute the number of pixels per magic unit.
* This number will be the fraction: scale / (1 << scaleShift).
* In order to be reasonably sure that we have enough precision
* in the numerator of the fraction, require that scale have at
* least three bits (i.e., be greater than or equal to 4).
*/
for (scale = 0, scaleShift = 4; ; scaleShift++)
{
scaleDown = 1 << scaleShift;
scale = (scaleDown * dotsAcross) / mag_width;
if (scaleShift >= 8 * sizeof (int))
{
TxError("The area selected is too many lambda wide to plot.\n");
TxError("(There are numerical problems with rasterizing it).\n");
TxError("Try selecting a smaller area, or else asking for ");
TxError("a wider plot.\n");
return;
}
if (scale >= 8)
break;
}
/*
* Compute scaling information, and tell the user how big the
* plot will be.
*/
dotsDown = ((rootClip.r_ytop - rootClip.r_ybot)*scale) >> scaleShift;
swathsDown = (dotsDown + PlotVersSwathHeight - 1)/PlotVersSwathHeight;
dotsDown = swathsDown * PlotVersSwathHeight;
mBytes = ((PlotVersWidth/8)*dotsDown)/1000000.0;
length = dotsDown;
length /= PlotVersDotsPerInch;
TxPrintf("Plot will be %.1f inches wide by %.1f inches long.\n", width, length);
TxPrintf("It will take %.2f Megabytes in \"%s\".\n",
(PlotVersPlotType == HPRTL || PlotVersPlotType == HPGL2)
? 4.0 * mBytes : mBytes, PlotTempDirectory);
TxPrintf("Lambda: %.3f (um) Requested scale: %dX Actual scale: %dX "
"[Full scale: %dX].\n", CIFGetOutputScale(1000),
user_scale, usedScale, maxScale);
do
{
TxPrintf("Do you still want the plot? [yes] ");
if (TxGetLine(answer, sizeof answer) == NULL || answer[0] == '\0')
{
action = 1;
break;
}
} while ((action = Lookup(answer, yesNo)) < 0);
if (action == 0) return;
/* The plot has been "approved". Now obtain a swath raster if
* we don't already have one. If the swath size has changed,
* recycle the raster for a new one.
*/
if ((raster != NULL) && ((raster->ras_width != PlotVersWidth)
|| (raster->ras_height != PlotVersSwathHeight)))
{
if (PlotVersPlotType == HPGL2 || PlotVersPlotType == HPRTL)
{
PlotFreeRaster(cRaster);
PlotFreeRaster(mRaster);
PlotFreeRaster(yRaster);
}
PlotFreeRaster(kRaster);
raster = NULL;
}
if (raster == NULL)
{
if (PlotVersPlotType == HPGL2 || PlotVersPlotType == HPRTL)
{
cRaster = PlotNewRaster(PlotVersSwathHeight, PlotVersWidth);
mRaster = PlotNewRaster(PlotVersSwathHeight, PlotVersWidth);
yRaster = PlotNewRaster(PlotVersSwathHeight, PlotVersWidth);
}
kRaster = PlotNewRaster(PlotVersSwathHeight, PlotVersWidth);
raster = kRaster;
}
/* Load font information for the plot, if it isn't already
* loaded.
*/
labelFont = PlotLoadFont(PlotVersLabelFont);
cellNameFont = PlotLoadFont(PlotVersNameFont);
cellIdFont = PlotLoadFont(PlotVersIdFont);
/* Compute the name of the file to use for output, and open it. */
sprintf(fileName, "%s/magicPlotXXXXXX", PlotTempDirectory);
result = mkstemp(fileName);
if (result == -1)
{
TxError("Failed to create temporary filename for %s\n", fileName);
return;
}
file = PaOpen(fileName, "w", (char *) NULL, (char *) NULL, (char *) NULL,
(char **) NULL);
if (file == NULL)
{
TxError("Couldn't open file \"%s\" to write plot.\n", fileName);
return;
}
/* Set up the rest of the transformation variables.
* Arrange for the plot to be centered on the page.
*/
plotLL.p_y = rootClip.r_ybot;
plotLL.p_x = (rootClip.r_xtop+rootClip.r_xbot)/2 - (PlotVersWidth*8)/scale;
if (plotLL.p_x > rootClip.r_xbot)
plotLL.p_x = rootClip.r_xbot;
/* Compute a distance equal to 1/8th the size of a typical wire
* (max of thicknesses of routing layers). This is used to offset
* text from labels and to compute cross size for point labels.
*/
if (RtrMetalWidth > RtrPolyWidth)
crossSize = (RtrMetalWidth*scale)/(scaleDown*8);
else crossSize = (RtrPolyWidth*scale)/(scaleDown*8);
if (crossSize < 2) crossSize = 2;
/* Step down the page one swath at a time, rasterizing everything
* that overlaps the current swath, then outputting the swath.
*/
GeoInvertTrans(&scx->scx_trans, &tinv);
for (color = BLACK; color <= YELLOW; color++)
{
int swathsDownThisColor;
swathsDownThisColor = swathsDown;
rasFileByteCount = 0;
/* issue preamble for this color's raster. if we are doing colors */
switch (PlotVersPlotType)
{
case HPRTL:
PlotHPRTLHeader(PlotVersWidth, dotsDown, PlotVersDotsPerInch, file);
break;
case HPGL2:
PlotHPGL2Header(PlotVersWidth, dotsDown, PlotVersDotsPerInch,
usedScale, file);
break;
case VERSATEC_COLOR:
if (PlotDumpColorPreamble(color, file, dotsDown, PlotVersWidth) != 0)
goto error;
if (SigInterruptPending)
goto error;
TxPrintf("\nDumping %s Raster:", plotVersatecColorNames[color]);
TxFlush();
break;
}
for (swathsDownThisColor -= 1;
swathsDownThisColor >= 0;
swathsDownThisColor -= 1)
{
SearchContext scx2;
Rect root, labelArea;
int labelHeight;
swathY = swathsDownThisColor * PlotVersSwathHeight;
if (PlotVersPlotType == HPGL2 || PlotVersPlotType == HPRTL)
{
PlotClearRaster(cRaster, (Rect *) NULL);
PlotClearRaster(mRaster, (Rect *) NULL);
PlotClearRaster(yRaster, (Rect *) NULL);
}
PlotClearRaster(kRaster, (Rect *) NULL);
/* Compute the area of the swath that overlaps the portion of
* the layout we're plotting.
*/
plotTransToSwath(&rootClip, &swathClip);
if (swathClip.r_xbot < 0) swathClip.r_xbot = 0;
if (swathClip.r_ybot < 0) swathClip.r_ybot = 0;
if (swathClip.r_xtop >= PlotVersWidth)
swathClip.r_xtop = PlotVersWidth - 1;
if (swathClip.r_ytop >= PlotVersSwathHeight)
swathClip.r_ytop = PlotVersSwathHeight - 1;
/* Compute the area of layout that overlaps this swath. This is
* done twice, once for mask material and once for labels. The
* separate computation for labels is because labels stick out
* from their positioning points. We may have to search a larger
* area than just the swath in order to find all the labels that
* must be drawn in this swath. Only the y-direction needs to
* be expanded this way, since we're only swathing in y. Even
* non-label stuff has to be expanded slightly, because lines
* are drawn more than 1 pixel thick.
*/
scx2 = *scx;
root.r_xbot = (scaleDown*swathClip.r_xbot)/scale + plotLL.p_x;
root.r_xtop = (scaleDown*swathClip.r_xtop)/scale + plotLL.p_x;
root.r_ybot = (scaleDown*(swathY-4))/scale + plotLL.p_y;
root.r_ytop = (scaleDown*(swathY+swathClip.r_ytop+4))/scale+plotLL.p_y;
GEO_EXPAND(&root, 1, &root);
GeoTransRect(&tinv, &root, &scx2.scx_area);
labelArea.r_xbot = root.r_xbot;
labelArea.r_xtop = root.r_xtop;
if (labelFont != NULL)
{
labelHeight = (labelFont->fo_bbox.r_ytop
- labelFont->fo_bbox.r_ybot) + 2;
labelArea.r_ybot = (scaleDown * (swathY - crossSize
- labelHeight)) / scale + plotLL.p_y;
labelArea.r_ytop = (scaleDown * (swathY + swathClip.r_ytop
+ crossSize + labelHeight)) / scale + plotLL.p_y;
GEO_EXPAND(&labelArea, 1, &labelArea);
}
/* For each Versatec style, output stippled areas for all
* the tiles requested by the style.
*/
switch (PlotVersPlotType)
{
case VERSATEC_BW:
curStyle = plotVersStyles;
break;
case HPGL2: case HPRTL:
curStyle = plotColorVersStyles;
if (curStyle == NULL)
{
TxError("Warning: No color versatec styles are defined"
" in the technology file!\nPlotting aborted.\n");
return;
}
break;
default:
curStyle = plotColorVersStyles;
if (!haveColorMessage)
{
TxError("Warning: No color versatec styles are defined"
" in the technology file!\nPlot will be"
" monochrome.\n");
haveColorMessage = TRUE;
curStyle = plotVersStyles;
}
}
if (curStyle == NULL)
{
TxError("Warning: No monochrome versatec styles are"
" defined in the technology file!\nPlotting"
" aborted.\n");
return;
}
for ( ; curStyle != NULL; curStyle = curStyle->vs_next)
{
/* if we are plotting in B&W, then visit all the tiles in this
* swath, otherwise only visit them if they should be
* plotted in the current style's color.
*/
if (PlotVersPlotType == HPGL2 || PlotVersPlotType == HPRTL)
{
switch (curStyle->vs_color)
{
case CYAN:
raster = cRaster;
break;
case MAGENTA:
raster = mRaster;
break;
case YELLOW:
raster = yRaster;
break;
default:
raster = kRaster;
break;
}
}
if ((PlotVersPlotType != VERSATEC_COLOR) || (curStyle->vs_color == color))
{
TTMaskAndMask3(&curMask, layers, &curStyle->vs_layers);
(void) DBTreeSrTiles(&scx2, &curMask, xMask, plotVersTile,
(ClientData) raster);
}
}
raster = kRaster;
/* Output labels, if they are wanted. */
if (TTMaskHasType(layers, L_LABEL) && (color == BLACK) &&
(labelFont != NULL))
{
curMask = *layers;
TTMaskSetType(&curMask, TT_SPACE);
GeoTransRect(&tinv, &labelArea, &scx2.scx_area);
(void) DBTreeSrLabels(&scx2, &curMask, xMask,
(TerminalPath *) NULL, TF_LABEL_ATTACH,
plotVersLabel, (ClientData) raster);
}
/* Output subcell bounding boxes, if they are wanted. */
if (TTMaskHasType(layers, L_CELL) && color == BLACK)
{
(void) DBTreeSrCells(&scx2, xMask, plotVersCell, (ClientData) raster);
}
TxPrintf("#");
TxFlush();
switch (PlotVersPlotType)
{
case HPGL2: case HPRTL:
PlotDumpHPRTL(file, kRaster, cRaster, mRaster, yRaster);
break;
case VERSATEC_COLOR: case VERSATEC_BW:
if (PlotDumpRaster(raster, file) != 0)
goto error;
if (SigInterruptPending)
goto error;
break;
}
}
/* Only the VERSATEC_COLOR type runs colors separately */
if (PlotVersPlotType != VERSATEC_COLOR) break;
TxPrintf ("\nWrote %d bytes of data.\n", rasFileByteCount);
}
/* Write trailers */
switch (PlotVersPlotType)
{
case HPGL2:
PlotHPGL2Trailer(file);
break;
case HPRTL:
PlotHPRTLTrailer(file);
break;
}
/* Close the file and issue the command to plot it. */
TxPrintf("\n");
fclose(file);
sprintf(command, PlotVersCommand, PlotVersPrinter, fileName);
if (system(command) != 0)
{
TxError("Couldn't execute spooler command to print \"%s\"\n",
fileName);
}
return;
error:
TxError("\nVersatec plot aborted.\n");
fclose(file);
unlink(fileName);
}
#endif /* VERSATEC */
|