From 076ee09e2eeb8242a60cc68d89363d727e14bcb4 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Wed, 7 Oct 2020 15:37:31 -0400 Subject: [PATCH] Added two new command options: "select bbox", which returns the bounding box of the selection (somewhat unuseful, especially as the result gets absorbed by the tag callback), and "box select", which sets the cursor box to the bounding box of the selection (much more useful). Also corrected the "port" command so that the command "port make" will search only for non-port labels. --- VERSION | 2 +- commands/CmdAB.c | 30 +++++++++++++++++++++++------- commands/CmdLQ.c | 8 ++++++-- commands/CmdRS.c | 42 ++++++++++++++++++++++++++++++++++++------ 4 files changed, 66 insertions(+), 16 deletions(-) diff --git a/VERSION b/VERSION index 4eb423f5..4d445a44 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.3.62 +8.3.63 diff --git a/commands/CmdAB.c b/commands/CmdAB.c index fa919ceb..8878b8cc 100644 --- a/commands/CmdAB.c +++ b/commands/CmdAB.c @@ -545,6 +545,7 @@ selGetArrayFunc(selUse, use, trans, arg) * box size [width height] * box position [llx lly] [-edit] * box values [llx lly urx ury] [-edit] + * box select * * box | cursor * @@ -580,13 +581,14 @@ selGetArrayFunc(selUse, use, trans, arg) #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 +#define BOX_SELECT 5 +#define BOX_MOVE 6 +#define BOX_GROW 7 +#define BOX_SHRINK 8 +#define BOX_CORNER 9 +#define BOX_EXISTS 10 +#define BOX_HELP 11 +#define BOX_DEFAULT 12 void CmdBox(w, cmd) @@ -599,6 +601,7 @@ CmdBox(w, cmd) "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", + "select set box to selection bounding box", "move move box position", "grow expand box size", "shrink shrink box size", @@ -907,6 +910,19 @@ CmdBox(w, cmd) boxptr->r_ytop = boxptr->r_ybot + height; break; + case BOX_SELECT: + if (argc == 2) + { + Rect selarea; + GeoTransRect(&SelectUse->cu_transform, &SelectDef->cd_bbox, &selarea); + boxptr->r_xbot = selarea.r_xbot; + boxptr->r_ybot = selarea.r_ybot; + boxptr->r_xtop = selarea.r_xtop; + boxptr->r_ytop = selarea.r_ytop; + } + else goto badusage; + break; + case BOX_VALUES: if (argc == 2) { diff --git a/commands/CmdLQ.c b/commands/CmdLQ.c index 1c008a1c..3f1b25ae 100644 --- a/commands/CmdLQ.c +++ b/commands/CmdLQ.c @@ -1449,7 +1449,12 @@ CmdPort(w, cmd) if (option != PORT_LAST && option != PORT_FIRST) { if (lab == NULL) - lab = portFindLabel(editDef, TRUE, TRUE, &nonEdit); + { + if (option == PORT_MAKE) + lab = portFindLabel(editDef, FALSE, TRUE, &nonEdit); + else + lab = portFindLabel(editDef, TRUE, TRUE, &nonEdit); + } if (option == PORT_EXISTS) { @@ -1467,7 +1472,6 @@ CmdPort(w, cmd) #endif return; } - } if ((option != PORT_LAST) && (option != PORT_FIRST) && (option != PORT_MAKEALL) && (option != PORT_RENUMBER) diff --git a/commands/CmdRS.c b/commands/CmdRS.c index 5535b7be..95178efa 100644 --- a/commands/CmdRS.c +++ b/commands/CmdRS.c @@ -680,12 +680,13 @@ CmdSelect(w, cmd) #define SEL_PICK 8 #define SEL_SAVE 9 #define SEL_FEEDBACK 10 -#define SEL_BOX 11 -#define SEL_CHUNK 12 -#define SEL_REGION 13 -#define SEL_NET 14 -#define SEL_SHORT 15 -#define SEL_DEFAULT 16 +#define SEL_BBOX 11 +#define SEL_BOX 12 +#define SEL_CHUNK 13 +#define SEL_REGION 14 +#define SEL_NET 15 +#define SEL_SHORT 16 +#define SEL_DEFAULT 17 static char *cmdSelectOption[] = { @@ -700,6 +701,7 @@ CmdSelect(w, cmd) "pick", "save", "feedback", + "bbox", "box", "chunk", "region", @@ -724,6 +726,7 @@ CmdSelect(w, cmd) "pick delete selection from layout", "save file save selection on disk in file.mag", "feedback [style] copy selection to feedback", + "bbox return the bounding box of the selection", "[more | less] box | chunk | region | net [layers]\n" " [de]select chunk/region/net specified by\n" " the lower left corner of the current box", @@ -775,6 +778,7 @@ CmdSelect(w, cmd) bool more = FALSE, less = FALSE, samePlace = TRUE; #ifdef MAGIC_WRAPPER char *tclstr; + Tcl_Obj *lobj; #endif /* How close two clicks must be to be considered the same point: */ @@ -933,6 +937,32 @@ CmdSelect(w, cmd) TxPrintf(" select %s\n", *msg); return; + /*-------------------------------------------------------------------- + * Print or return the bounding box of the selection + *-------------------------------------------------------------------- + */ + + case SEL_BBOX: + GeoTransRect(&SelectUse->cu_transform, &SelectDef->cd_bbox, &selarea); + +#ifdef MAGIC_WRAPPER + lobj = Tcl_NewListObj(0, NULL); + Tcl_ListObjAppendElement(magicinterp, lobj, + Tcl_NewIntObj(selarea.r_xbot)); + Tcl_ListObjAppendElement(magicinterp, lobj, + Tcl_NewIntObj(selarea.r_ybot)); + Tcl_ListObjAppendElement(magicinterp, lobj, + Tcl_NewIntObj(selarea.r_xtop)); + Tcl_ListObjAppendElement(magicinterp, lobj, + Tcl_NewIntObj(selarea.r_ytop)); + Tcl_SetObjResult(magicinterp, lobj); +#else + TxPrintf("Select bounding box: %d %d %d %d\n", + selarea.r_xbot, selarea.r_ybot, + selarea.r_xtop, selarea.r_ytop); +#endif + return; + /*-------------------------------------------------------------------- * Make a copy of the selection at its present loction but do not * clear the selection.