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
|
/*
* CmdAB.c --
*
* Commands with names beginning with the letters A through B.
*
* *********************************************************************
* * 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-7.5/commands/CmdAB.c,v 1.2 2006/04/14 06:51:24 anonymous Exp $";
#endif /* not lint */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "tcltk/tclmagic.h"
#include "utils/magic.h"
#include "utils/geometry.h"
#include "tiles/tile.h"
#include "utils/hash.h"
#include "database/database.h"
#include "windows/windows.h"
#include "dbwind/dbwind.h"
#include "utils/main.h"
#include "commands/commands.h"
#include "utils/utils.h"
#include "textio/textio.h"
#include "drc/drc.h"
#include "cif/cif.h"
#include "graphics/graphics.h"
#include "textio/txcommands.h"
#include "utils/malloc.h"
#include "utils/netlist.h"
#include "select/select.h"
/* ---------------------------------------------------------------------------
*
* CmdAddPath --
*
* Implement the "addpath" command: append to the global cell search path.
* (Usage superceded by extended "path" command; retained for compatibility)
*
* Usage:
* addpath path
*
* Results:
* None.
*
* Side effects:
* The search path used to find cells is appended to with the first
* command line argument. See CmdLQ.CmdPath for more information.
*
* History:
* Contributed by Doug Pan and Prof. Mark Linton at Stanford.
*
* ---------------------------------------------------------------------------
*/
/*ARGSUSED*/
void
CmdAddPath( w, cmd )
MagWindow *w;
TxCommand *cmd;
{
if (cmd->tx_argc != 2) {
TxError("Usage: %s appended_search_path\n", cmd->tx_argv[0]);
return;
}
PaAppend(&Path, cmd->tx_argv[1]);
}
/* Linked-list structure for returning information about arrayed cells */
typedef struct LA1
{
CellUse *cellUse;
ArrayInfo arrayInfo;
struct LA1 *ar_next;
} LinkedArray;
/*
* ----------------------------------------------------------------------------
*
* CmdArray --
*
* Implement the "array" command. Make everything in the selection
* into an array. For paint and labels, just copy. For subcells,
* make each use into an arrayed use.
*
* Usage:
* array xlo xhi ylo yhi | xsize ysize
*
* array count [xlo xhi ylo yhi | xsize ysize]
* array width [value]
* array height [value]
* array pitch [x y]
* array position [x y]
* array help
*
* Results:
* None.
*
* Side effects:
* Changes the edit cell.
*
* ----------------------------------------------------------------------------
*/
#define ARRAY_COUNT 0
#define ARRAY_WIDTH 1
#define ARRAY_HEIGHT 2
#define ARRAY_PITCH 3
#define ARRAY_POSITION 4
#define ARRAY_HELP 5
#define ARRAY_DEFAULT 6
void
CmdArray(w, cmd)
MagWindow *w;
TxCommand *cmd;
{
static char *cmdArrayOption[] = {
"count [[xlo] xhi [ylo] yhi] array subcells",
"width [value] set or return array x-spacing",
"height [value] set or return array y-spacing",
"pitch [x y] set or return array spacing",
"position [x y] set or return array origin",
"help print help information",
NULL
};
char **msg;
int option;
ArrayInfo a;
Rect toolRect;
LinkedArray *lahead = NULL, *la;
int xval, yval;
extern int selGetArrayFunc();
if (cmd->tx_argc == 1)
goto badusage;
else
{
option = Lookup(cmd->tx_argv[1], cmdArrayOption);
if (option < 0) {
if (cmd->tx_argc == 3 || cmd->tx_argc == 5)
option = ARRAY_DEFAULT;
else
goto badusage;
}
}
if (!ToolGetEditBox((Rect *)NULL)) return;
/* Get all information about cell uses in the current selection */
(void) SelEnumCells(FALSE, (bool *) NULL, (SearchContext *) NULL,
selGetArrayFunc, (ClientData) &lahead);
/* Note: All "unimplemented functions" below will require a routine
* similar to "SelectArray", but which only operates on cells, and
* only changes specific parameters; i.e., the arrayInfo structure
* is generated separately for each selected cell, the values filled
* in with the current values for that cell, and then the requested
* parameter changed.
*/
switch (option)
{
case ARRAY_COUNT:
if (cmd->tx_argc == 2)
{
for (la = lahead; la != NULL; la = la->ar_next)
{
if (la->cellUse->cu_id != NULL)
TxPrintf("Cell use \"%s\":", la->cellUse->cu_id);
else
TxPrintf("Cell \"%s\":", la->cellUse->cu_def->cd_name);
TxPrintf("x index %d to %d, y index %d to %d\n",
la->arrayInfo.ar_xlo,
la->arrayInfo.ar_xhi,
la->arrayInfo.ar_ylo,
la->arrayInfo.ar_yhi);
}
break;
}
else if ((cmd->tx_argc != 4) && (cmd->tx_argc != 6))
goto badusage;
if (!StrIsInt(cmd->tx_argv[2]) || !StrIsInt(cmd->tx_argv[3]))
goto badusage;
if (cmd->tx_argc == 4)
{
a.ar_xlo = 0;
a.ar_ylo = 0;
a.ar_xhi = atoi(cmd->tx_argv[2]) - 1;
a.ar_yhi = atoi(cmd->tx_argv[3]) - 1;
if ( (a.ar_xhi < 0) || (a.ar_yhi < 0) ) goto badusage;
}
else if (cmd->tx_argc == 6)
{
if (!StrIsInt(cmd->tx_argv[4]) ||
!StrIsInt(cmd->tx_argv[5])) goto badusage;
a.ar_xlo = atoi(cmd->tx_argv[2]);
a.ar_xhi = atoi(cmd->tx_argv[3]);
a.ar_ylo = atoi(cmd->tx_argv[4]);
a.ar_yhi = atoi(cmd->tx_argv[5]);
}
if (!ToolGetBox((CellDef **) NULL, &toolRect))
{
TxError("Position the box to indicate the array spacing.\n");
return;
}
a.ar_xsep = toolRect.r_xtop - toolRect.r_xbot;
a.ar_ysep = toolRect.r_ytop - toolRect.r_ybot;
SelectArray(&a);
break;
case ARRAY_WIDTH:
if (cmd->tx_argc == 2)
{
for (la = lahead; la != NULL; la = la->ar_next)
{
if (la->cellUse->cu_id != NULL)
TxPrintf("Cell use \"%s\":", la->cellUse->cu_id);
else
TxPrintf("Cell \"%s\":", la->cellUse->cu_def->cd_name);
TxPrintf("x separation %d\n", la->arrayInfo.ar_xsep);
}
break;
}
if ((cmd->tx_argc != 3) || (!StrIsInt(cmd->tx_argv[2])))
goto badusage;
xval = atoi(cmd->tx_argv[2]);
yval = atoi(cmd->tx_argv[3]);
TxPrintf("Unimplemented function.\n");
break;
case ARRAY_HEIGHT:
if (cmd->tx_argc == 2)
{
for (la = lahead; la != NULL; la = la->ar_next)
{
if (la->cellUse->cu_id != NULL)
TxPrintf("Cell use \"%s\":", la->cellUse->cu_id);
else
TxPrintf("Cell \"%s\":", la->cellUse->cu_def->cd_name);
TxPrintf("y separation %d\n", la->arrayInfo.ar_ysep);
}
break;
}
if ((cmd->tx_argc != 3) || (!StrIsInt(cmd->tx_argv[2])))
goto badusage;
xval = atoi(cmd->tx_argv[2]);
yval = atoi(cmd->tx_argv[3]);
TxPrintf("Unimplemented function.\n");
break;
case ARRAY_PITCH:
if (cmd->tx_argc == 2)
{
for (la = lahead; la != NULL; la = la->ar_next)
{
if (la->cellUse->cu_id != NULL)
TxPrintf("Cell use \"%s\":", la->cellUse->cu_id);
else
TxPrintf("Cell \"%s\":", la->cellUse->cu_def->cd_name);
TxPrintf("x separation %d ", la->arrayInfo.ar_xsep);
TxPrintf("y separation %d\n", la->arrayInfo.ar_ysep);
}
break;
}
if ((cmd->tx_argc != 4) || (!StrIsInt(cmd->tx_argv[2])) ||
(!StrIsInt(cmd->tx_argv[3])))
goto badusage;
xval = atoi(cmd->tx_argv[2]);
yval = atoi(cmd->tx_argv[3]);
TxPrintf("Unimplemented function.\n");
break;
case ARRAY_POSITION:
if (cmd->tx_argc == 2)
{
for (la = lahead; la != NULL; la = la->ar_next)
{
if (la->cellUse->cu_id != NULL)
TxPrintf("Cell use \"%s\":", la->cellUse->cu_id);
else
TxPrintf("Cell \"%s\":", la->cellUse->cu_def->cd_name);
TxPrintf("x=%d ", la->cellUse->cu_bbox.r_xbot);
TxPrintf("y=%d\n", la->cellUse->cu_bbox.r_ybot);
}
break;
}
if ((cmd->tx_argc != 4) || (!StrIsInt(cmd->tx_argv[2])) ||
(!StrIsInt(cmd->tx_argv[3])))
goto badusage;
xval = atoi(cmd->tx_argv[2]);
yval = atoi(cmd->tx_argv[3]);
TxPrintf("Unimplemented function.\n");
break;
case ARRAY_DEFAULT:
if (!StrIsInt(cmd->tx_argv[1]) || !StrIsInt(cmd->tx_argv[2]))
goto badusage;
if (cmd->tx_argc == 3)
{
a.ar_xlo = 0;
a.ar_ylo = 0;
a.ar_xhi = atoi(cmd->tx_argv[1]) - 1;
a.ar_yhi = atoi(cmd->tx_argv[2]) - 1;
if ( (a.ar_xhi < 0) || (a.ar_yhi < 0) ) goto badusage;
}
else
{
if (!StrIsInt(cmd->tx_argv[3]) ||
!StrIsInt(cmd->tx_argv[4])) goto badusage;
a.ar_xlo = atoi(cmd->tx_argv[1]);
a.ar_xhi = atoi(cmd->tx_argv[2]);
a.ar_ylo = atoi(cmd->tx_argv[3]);
a.ar_yhi = atoi(cmd->tx_argv[4]);
}
if (!ToolGetBox((CellDef **) NULL, &toolRect))
{
TxError("Position the box to indicate the array spacing.\n");
return;
}
a.ar_xsep = toolRect.r_xtop - toolRect.r_xbot;
a.ar_ysep = toolRect.r_ytop - toolRect.r_ybot;
SelectArray(&a);
break;
case ARRAY_HELP:
badusage:
for (msg = &(cmdArrayOption[0]); *msg != NULL; msg++)
{
TxPrintf(" %s\n", *msg);
}
break;
}
freelist:
la = lahead;
while (la != NULL)
{
freeMagic((char *)la);
la = la->ar_next;
}
return;
}
/* ----------------------------------------------------------------------------
* Procedure returning information on arrayed selection
*/
int
selGetArrayFunc(selUse, use, trans, arg)
CellUse *selUse;
CellUse *use;
Transform *trans;
LinkedArray **arg;
{
/* Check "use" for array information and pass this to arrayInfo */
LinkedArray *la;
int xlo, xhi, ylo, yhi, xsep, ysep, t;
la = (LinkedArray *)mallocMagic(sizeof(LinkedArray));
xlo = use->cu_xlo;
ylo = use->cu_ylo;
xhi = use->cu_xhi;
yhi = use->cu_yhi;
/* preserve x and y relative to root */
if (trans->t_a == 0)
{
t = xlo; xlo = ylo; ylo = t;
t = xhi; xhi = yhi; yhi = t;
}
la->arrayInfo.ar_xlo = xlo;
la->arrayInfo.ar_xhi = xhi;
la->arrayInfo.ar_ylo = ylo;
la->arrayInfo.ar_yhi = yhi;
/* Reverse the transformation in DBMakeArray */
ysep = (trans->t_d * use->cu_xsep - trans->t_a * use->cu_ysep);
ysep /= (trans->t_d * trans->t_b - trans->t_a * trans->t_e);
if (trans->t_a == 0)
xsep = (use->cu_ysep - trans->t_e * ysep) / trans->t_d;
else
xsep = (use->cu_xsep - trans->t_b * ysep) / trans->t_a;
la->arrayInfo.ar_xsep = xsep;
la->arrayInfo.ar_ysep = ysep;
la->cellUse = use;
la->ar_next = (*arg);
(*arg) = la;
return 0;
}
/*
* ----------------------------------------------------------------------------
*
* CmdBox --
*
* Box command.
*
* Usage:
* box width [num]
* box height [num]
* box size [width height]
* box position [llx lly] [-edit]
* box values [llx lly urx ury] [-edit]
*
* box <direction> <distance> | cursor
*
* box move <direction> <distance> | cursor
* box grow <direction> <distance>
* box shrink <direction> <distance>
*
* box [llx lly urx ury] [-edit]
*
* Coordinates and sizes may be specified in any of the following
* units: none (internal), "i" (internal), "l" (lambda), or any
* metric units (e.g., "um"). Coordinates may be integer or
* floating-point (e.g., "20i" or "1.5mm"). There should be no
* space between the value and the unit specifier (i.e., "20l",
* not "20 l").
*
* Coordinates are usually reported relative to the root cell of
* the window, unless the "-edit" switch is given.
*
* Results:
* Box values are printed to the console.
* Tcl version returns values for the first five cases above when
* the optional value or values are not present.
*
* Side effects:
* May modify the location of the box tool.
*
* ----------------------------------------------------------------------------
*/
#define BOX_WIDTH 0
#define BOX_HEIGHT 1
#define BOX_SIZE 2
#define BOX_POSITION 3
#define BOX_VALUES 4
#define BOX_MOVE 5
#define BOX_GROW 6
#define BOX_SHRINK 7
#define BOX_CORNER 8
#define BOX_EXISTS 9
#define BOX_HELP 10
#define BOX_DEFAULT 11
void
CmdBox(w, cmd)
MagWindow *w;
TxCommand *cmd;
{
static char *cmdBoxOption[] = {
"width [value] set or return box width",
"height [value] set or return box height",
"size [width height] set or return box size",
"position [llx lly] [-edit] set or return box position",
"values [llx lly urx ury] [-edit] set or return box coordinates",
"move <direction> <distance> move box position",
"grow <direction> <distance> expand box size",
"shrink <direction> <distance> shrink box size",
"corner <direction> <distance> set box corner",
"exists is the cursor box present?",
"help print help information",
NULL
};
CellDef *rootBoxDef;
Rect rootBox, editbox, *boxptr;
Point ll;
int option, direction, distancex, distancey;
int width, height, area;
int argc;
int tcorner;
float iscale, oscale;
bool needBox = TRUE; /* require that box be defined */
bool refEdit = FALSE; /* referenced to edit cell coordinates */
bool cursorRef = FALSE; /* reference position is the cursor */
char **msg;
argc = cmd->tx_argc;
if (argc > 7) goto badusage;
/*----------------------------------------------------------*/
/* Check for the request to report in edit cell coordinates */
/*----------------------------------------------------------*/
if (!strncmp(cmd->tx_argv[argc - 1], "-edit", 5))
{
refEdit = TRUE;
argc--;
}
/*----------------------------------------------------------*/
/* Parse command for options */
/*----------------------------------------------------------*/
if (argc == 1)
option = BOX_DEFAULT;
else
{
option = Lookup(cmd->tx_argv[1], cmdBoxOption);
/* This hack allows 'h' to be used as a synonym for "height" */
/* 'w' already works for width because no other options begin */
/* with "w". But the addition of option "help" presents an */
/* ambiguity. */
if (option == -1 && cmd->tx_argv[1][0] == 'h')
option = BOX_HEIGHT;
else if (option < 0)
option = BOX_DEFAULT;
}
windCheckOnlyWindow(&w, DBWclientID);
/*----------------------------------------------------------*/
/* Check for the command options which do not require a box */
/* to be present. */
/*----------------------------------------------------------*/
switch (option)
{
case BOX_MOVE:
case BOX_GROW:
case BOX_SHRINK:
case BOX_CORNER:
if (!strncmp(cmd->tx_argv[argc - 1], "cursor", 6))
{
needBox = FALSE;
cursorRef = TRUE;
}
break;
case BOX_DEFAULT:
if (argc == 5) needBox = FALSE;
break;
case BOX_VALUES:
if (argc == 6) needBox = FALSE;
break;
case BOX_EXISTS:
#ifdef MAGIC_WRAPPER
Tcl_SetResult(magicinterp, ToolGetBox(NULL, NULL) ? "1" : "0",
NULL);
#else
TxPrintf("%s\n", ToolGetBox(NULL, NULL) ? "True" : "False");
#endif
return;
}
if (needBox)
{
if (refEdit)
{
if (!ToolGetEditBox(&editbox)) return;
}
else
{
if (!ToolGetBox(&rootBoxDef, &rootBox))
{
TxError("Box tool must be present\n");
return;
}
}
}
else if (w == NULL)
{
TxError("Cursor not in a window.\n");
return;
}
else
{
Rect r;
if (argc >= 5)
{
r.r_xbot = cmdParseCoord(w, cmd->tx_argv[argc - 4], FALSE, TRUE);
r.r_ybot = cmdParseCoord(w, cmd->tx_argv[argc - 3], FALSE, FALSE);
r.r_xtop = cmdParseCoord(w, cmd->tx_argv[argc - 2], FALSE, TRUE);
r.r_ytop = cmdParseCoord(w, cmd->tx_argv[argc - 1], FALSE, FALSE);
}
else
{
/* If we got here, then we requested a box or corner move
* to the cursor position, but there was no box present.
* To keep users from becoming bewildered at this point,
* we generate a zero-size box at the origin and work from
* there.
*/
r.r_xbot = r.r_ybot = r.r_xtop = r.r_ytop = 0;
}
rootBoxDef = ((CellUse *) w->w_surfaceID)->cu_def;
if (refEdit)
{
GeoTransRect(&EditToRootTransform, &r, &rootBox);
refEdit = FALSE;
}
else rootBox = r;
}
/*----------------------------------------------------------*/
/* Edit cell or Root cell? */
/*----------------------------------------------------------*/
boxptr = (refEdit) ? &editbox : &rootBox;
/*----------------------------------------------------------*/
/* Parse arguments according to class */
/*----------------------------------------------------------*/
switch (option)
{
case BOX_MOVE:
case BOX_GROW:
case BOX_SHRINK:
case BOX_CORNER:
if (argc != 4) goto badusage;
direction = GeoNameToPos(cmd->tx_argv[2], FALSE, TRUE);
if (direction < 0) return;
else if (cursorRef)
{
switch (direction)
{
case GEO_SOUTHWEST:
tcorner = TOOL_BL;
break;
case GEO_NORTHEAST:
tcorner = TOOL_TR;
break;
case GEO_NORTHWEST:
tcorner = TOOL_TL;
break;
case GEO_SOUTHEAST:
tcorner = TOOL_BR;
break;
}
switch(option)
{
case BOX_MOVE:
ToolMoveBox(tcorner, &cmd->tx_p, TRUE, rootBoxDef);
break;
case BOX_CORNER:
ToolMoveCorner(tcorner, &cmd->tx_p, TRUE, rootBoxDef);
break;
}
return;
}
else if (DBWSnapToGrid != DBW_SNAP_USER)
{
distancex = cmdParseCoord(w, cmd->tx_argv[3], TRUE, FALSE);
distancey = distancex;
}
else
{
switch (direction)
{
case GEO_EAST: case GEO_WEST:
distancex = cmdParseCoord(w, cmd->tx_argv[3], TRUE, TRUE);
distancey = distancex;
break;
case GEO_NORTH: case GEO_SOUTH:
distancey = cmdParseCoord(w, cmd->tx_argv[3], TRUE, FALSE);
distancex = distancey;
break;
default:
distancex = cmdParseCoord(w, cmd->tx_argv[3], TRUE, TRUE);
distancey = cmdParseCoord(w, cmd->tx_argv[3], TRUE, FALSE);
break;
}
}
if ((distancex == 0) && (distancey == 0)) return;
break;
}
/*----------------------------------------------------------*/
switch (option)
{
case BOX_WIDTH:
if (argc == 2)
{
#ifdef MAGIC_WRAPPER
char *boxvalues = (char *)Tcl_Alloc(50);
sprintf(boxvalues, "%d",
boxptr->r_xtop - boxptr->r_xbot);
Tcl_SetResult(magicinterp, boxvalues, TCL_DYNAMIC);
#else
TxPrintf("%s box width is %d\n",
(refEdit) ? "Edit" : "Root",
boxptr->r_xtop - boxptr->r_xbot);
#endif
return;
}
else if (argc != 3) goto badusage;
width = cmdParseCoord(w, cmd->tx_argv[2], TRUE, TRUE);
rootBox.r_xtop = rootBox.r_xbot + width;
break;
case BOX_HEIGHT:
if (argc == 2)
{
#ifdef MAGIC_WRAPPER
char *boxvalues = (char *)Tcl_Alloc(50);
sprintf(boxvalues, "%d",
boxptr->r_ytop - boxptr->r_ybot);
Tcl_SetResult(magicinterp, boxvalues, TCL_DYNAMIC);
#else
TxPrintf("%s box height is %d\n",
(refEdit) ? "Edit" : "Root",
boxptr->r_ytop - boxptr->r_ybot);
#endif
return;
}
else if (argc != 3) goto badusage;
height = cmdParseCoord(w, cmd->tx_argv[2], TRUE, FALSE);
rootBox.r_ytop = rootBox.r_ybot + height;
break;
case BOX_SIZE:
if (argc == 2)
{
#ifdef MAGIC_WRAPPER
char *boxvalues = (char *)Tcl_Alloc(50);
sprintf(boxvalues, "%d %d",
boxptr->r_xtop - boxptr->r_xbot,
boxptr->r_ytop - boxptr->r_ybot);
Tcl_SetResult(magicinterp, boxvalues, TCL_DYNAMIC);
#else
TxPrintf("%s box size is %d x %d\n",
(refEdit) ? "Edit" : "Root",
boxptr->r_xtop - boxptr->r_xbot,
boxptr->r_ytop - boxptr->r_ybot);
#endif
return;
}
else if (argc != 4) goto badusage;
width = cmdParseCoord(w, cmd->tx_argv[2], TRUE, TRUE);
height = cmdParseCoord(w, cmd->tx_argv[3], TRUE, FALSE);
rootBox.r_xtop = rootBox.r_xbot + width;
rootBox.r_ytop = rootBox.r_ybot + height;
break;
case BOX_POSITION:
if (argc == 2)
{
#ifdef MAGIC_WRAPPER
char *boxvalues = (char *)Tcl_Alloc(50);
sprintf(boxvalues, "%d %d",
boxptr->r_xbot, boxptr->r_ybot);
Tcl_SetResult(magicinterp, boxvalues, TCL_DYNAMIC);
#else
TxPrintf("%s box lower-left corner at (%d, %d)\n",
(refEdit) ? "Edit" : "Root",
boxptr->r_xbot, boxptr->r_ybot);
#endif
return;
}
else if (argc != 4) goto badusage;
width = rootBox.r_xtop - rootBox.r_xbot;
height = rootBox.r_ytop - rootBox.r_ybot;
ll.p_x = cmdParseCoord(w, cmd->tx_argv[2], FALSE, TRUE);
ll.p_y = cmdParseCoord(w, cmd->tx_argv[3], FALSE, FALSE);
boxptr->r_xbot = ll.p_x;
boxptr->r_ybot = ll.p_y;
boxptr->r_xtop = boxptr->r_xbot + width;
boxptr->r_ytop = boxptr->r_ybot + height;
break;
case BOX_VALUES:
if (argc == 2)
{
#ifdef MAGIC_WRAPPER
char *boxvalues = (char *)Tcl_Alloc(50);
sprintf(boxvalues, "%d %d %d %d",
boxptr->r_xbot, boxptr->r_ybot,
boxptr->r_xtop, boxptr->r_ytop);
Tcl_SetResult(magicinterp, boxvalues, TCL_DYNAMIC);
#else
TxPrintf("%s box coordinates (%d, %d) to (%d, %d)\n",
(refEdit) ? "Edit" : "Root",
boxptr->r_xbot, boxptr->r_ybot,
boxptr->r_xtop, boxptr->r_ytop);
#endif
return;
}
else if (argc != 6) goto badusage;
break;
case BOX_MOVE:
switch (direction)
{
case GEO_NORTH:
rootBox.r_ybot += distancey;
rootBox.r_ytop += distancey;
break;
case GEO_SOUTH:
rootBox.r_ybot -= distancey;
rootBox.r_ytop -= distancey;
break;
case GEO_EAST:
rootBox.r_xbot += distancex;
rootBox.r_xtop += distancex;
break;
case GEO_WEST:
rootBox.r_xbot -= distancex;
rootBox.r_xtop -= distancex;
break;
case GEO_NORTHEAST:
rootBox.r_ybot += distancey;
rootBox.r_ytop += distancey;
rootBox.r_xbot += distancex;
rootBox.r_xtop += distancex;
break;
case GEO_NORTHWEST:
rootBox.r_ybot += distancey;
rootBox.r_ytop += distancey;
rootBox.r_xbot -= distancex;
rootBox.r_xtop -= distancex;
break;
case GEO_SOUTHEAST:
rootBox.r_ybot -= distancey;
rootBox.r_ytop -= distancey;
rootBox.r_xbot += distancex;
rootBox.r_xtop += distancex;
break;
case GEO_SOUTHWEST:
rootBox.r_ybot -= distancey;
rootBox.r_ytop -= distancey;
rootBox.r_xbot -= distancex;
rootBox.r_xtop -= distancex;
break;
}
break;
case BOX_GROW:
switch (direction)
{
case GEO_NORTH:
rootBox.r_ytop += distancey;
break;
case GEO_SOUTH:
rootBox.r_ybot -= distancey;
break;
case GEO_EAST:
rootBox.r_xtop += distancex;
break;
case GEO_WEST:
rootBox.r_xbot -= distancex;
break;
case GEO_NORTHEAST:
rootBox.r_ytop += distancey;
rootBox.r_xtop += distancex;
break;
case GEO_NORTHWEST:
rootBox.r_ytop += distancey;
rootBox.r_xbot -= distancex;
break;
case GEO_SOUTHEAST:
rootBox.r_ybot -= distancey;
rootBox.r_xtop += distancex;
break;
case GEO_SOUTHWEST:
rootBox.r_ybot -= distancey;
rootBox.r_xbot -= distancex;
break;
case GEO_CENTER:
rootBox.r_ytop += distancey;
rootBox.r_ybot -= distancey;
rootBox.r_xtop += distancex;
rootBox.r_xbot -= distancex;
break;
}
break;
case BOX_CORNER:
ll.p_x = cmdParseCoord(w, cmd->tx_argv[2], FALSE, TRUE);
ll.p_y = cmdParseCoord(w, cmd->tx_argv[3], FALSE, FALSE);
switch (direction)
{
case GEO_SOUTHWEST:
tcorner = TOOL_BL;
break;
case GEO_NORTHEAST:
tcorner = TOOL_TR;
break;
case GEO_NORTHWEST:
tcorner = TOOL_TL;
break;
case GEO_SOUTHEAST:
tcorner = TOOL_BR;
break;
}
ToolMoveCorner(tcorner, &ll, FALSE, rootBoxDef);
return;
case BOX_SHRINK:
switch (direction)
{
case GEO_NORTH:
rootBox.r_ytop -= distancey;
break;
case GEO_SOUTH:
rootBox.r_ybot += distancey;
break;
case GEO_EAST:
rootBox.r_xtop -= distancex;
break;
case GEO_WEST:
rootBox.r_xbot += distancex;
break;
case GEO_NORTHEAST:
rootBox.r_ytop -= distancey;
rootBox.r_xtop -= distancex;
break;
case GEO_NORTHWEST:
rootBox.r_ytop -= distancey;
rootBox.r_xbot += distancex;
break;
case GEO_SOUTHEAST:
rootBox.r_ybot += distancey;
rootBox.r_xtop -= distancex;
break;
case GEO_SOUTHWEST:
rootBox.r_ybot += distancey;
rootBox.r_xbot += distancex;
break;
case GEO_CENTER:
rootBox.r_ytop -= distancey;
rootBox.r_xtop -= distancex;
rootBox.r_ybot += distancey;
rootBox.r_xbot += distancex;
break;
}
break;
case BOX_DEFAULT:
/*----------------------------------------------------------*/
/* Print box values to the screen ("box" w/no options only) */
/*----------------------------------------------------------*/
width = boxptr->r_xtop - boxptr->r_xbot;
height = boxptr->r_ytop - boxptr->r_ybot;
area = width * height;
TxPrintf("%s cell box:\n", (refEdit) ? "Edit" : "Root");
iscale = (float)DBLambda[0] / (float)DBLambda[1];
oscale = CIFGetOutputScale(1000); /* 1000 for conversion to um */
TxPrintf(" width x height ( llx, lly ), ( urx, ury )");
if (area > 0)
TxPrintf(" area (units^2)");
TxPrintf("\n\nmicrons: %6.2f x %-6.2f (% 6.2f, % -6.2f), "
"(% 6.2f, % -6.2f)",
(float)width *oscale, (float)height * oscale,
(float)boxptr->r_xbot * oscale, (float)boxptr->r_ybot * oscale,
(float)boxptr->r_xtop * oscale, (float)boxptr->r_ytop * oscale);
if (area > 0)
TxPrintf(" %-10.2f", (float)area * oscale * oscale);
TxPrintf("\nlambda:");
if (DBLambda[0] != DBLambda[1])
{
TxPrintf(" %6.2f x %-6.2f (% 6.2f, % -6.2f), (% 6.2f, % -6.2f)",
(float)width * iscale, (float)height * iscale,
(float)boxptr->r_xbot * iscale,
(float)boxptr->r_ybot * iscale,
(float)boxptr->r_xtop * iscale,
(float)boxptr->r_ytop * iscale);
if (area > 0)
TxPrintf(" %-10.2f", (float)area * iscale * iscale);
TxPrintf("\ninternal:");
}
else
TxPrintf(" ");
TxPrintf(" %6d x %-6d (% 6d, % -6d), (% 6d, % -6d)",
width, height,
boxptr->r_xbot, boxptr->r_ybot,
boxptr->r_xtop, boxptr->r_ytop);
if (area > 0)
TxPrintf(" %-10d", area);
TxPrintf("\n");
break;
case BOX_HELP:
badusage:
for (msg = &(cmdBoxOption[0]); *msg != NULL; msg++)
{
TxPrintf(" %s\n", *msg);
}
return;
}
/*----------------------------------------------------------*/
/* Change the position of the box in the layout window */
/*----------------------------------------------------------*/
if (argc != 1) /* Don't bother to move if only reporting */
{
ToolMoveBox(TOOL_BL, &rootBox.r_ll, FALSE, rootBoxDef);
ToolMoveCorner(TOOL_TR, &rootBox.r_ur, FALSE, rootBoxDef);
}
return;
}
/*----------------------------------------------------------*/
|