Completed the small set of command extensions to make sure all

commands that make use of the pointer position have an equivalent
command that operates solely on layout coordinates, or otherwise
avoids needing a pointer position.  Added the command option
"down <instance>" to avoid using the pointer to disambiguate
selections.  Added the command option "select ... at x y" to
do paint or cell selections at a specific coordinate instead of
the pointer position.
This commit is contained in:
Tim Edwards 2023-07-08 13:59:00 -04:00
parent d3b314d877
commit 3890181ebe
4 changed files with 94 additions and 27 deletions

View File

@ -3773,7 +3773,7 @@ CmdDelete(w, cmd)
* new edit cell into the window containing the point tool.
*
* Usage:
* down
* down [<instname>]
*
* Results:
* None.
@ -3795,11 +3795,23 @@ CmdDown(w, cmd)
MagWindow *w;
TxCommand *cmd;
{
CellUse *use = NULL;
Rect area, pointArea;
int cmdEditRedisplayFunc(); /* External declaration. */
int cmdDownEnumFunc(); /* Forward declaration. */
if (cmd->tx_argc > 1)
if ((w != NULL) && (cmd->tx_argc == 2))
{
CellUse *rootUse;
SearchContext scx;
rootUse = (CellUse *)w->w_surfaceID;
bzero(&scx, sizeof(SearchContext));
DBTreeFindUse(cmd->tx_argv[1], rootUse, &scx);
use = scx.scx_use;
}
if ((use == NULL) && (cmd->tx_argc > 1))
{
TxError("Usage: edit\nMaybe you want the \"load\" command\n");
return;
@ -3822,8 +3834,18 @@ CmdDown(w, cmd)
(void) ToolGetPoint((Point *) NULL, &pointArea);
cmdFoundNewDown = FALSE;
(void) SelEnumCells(FALSE, (bool *) NULL, (SearchContext *) NULL,
cmdDownEnumFunc, (ClientData) &pointArea);
if (use == NULL)
{
SelEnumCells(FALSE, (bool *) NULL, (SearchContext *) NULL,
cmdDownEnumFunc, (ClientData) &pointArea);
}
else
{
EditCellUse = use;
EditRootDef = use->cu_def;
cmdFoundNewDown = TRUE;
}
if (!cmdFoundNewDown)
TxError("You haven't selected a new cell to edit.\n");

View File

@ -786,7 +786,7 @@ CmdSelect(w, cmd)
};
static char *cmdSelectMsg[] =
{
"[more | less | nocycle] [layers]\n"
"[more | less | nocycle] [layers] [at x y]\n"
" [de]select paint chunk/region/net under\n"
" cursor, or [de]select subcell if cursor\n"
" over space",
@ -845,13 +845,14 @@ CmdSelect(w, cmd)
CellUse *use;
CellDef *rootBoxDef;
Transform trans, rootTrans, tmp1;
Point p, rootPoint;
Point p, rootPoint, atPoint;
Rect r, selarea;
ExtRectList *rlist;
int option;
int feedstyle;
bool layerspec;
bool degenerate;
bool doat = FALSE;
bool more = FALSE, less = FALSE, samePlace = TRUE;
unsigned char labelpolicy = SEL_DO_LABELS;
#ifdef MAGIC_WRAPPER
@ -939,6 +940,20 @@ CmdSelect(w, cmd)
"cell", strlen(cmd->tx_argv[2])))
optionArgs = &cmd->tx_argv[2];
}
doat = FALSE;
if ((cmd->tx_argc > 3) && !strcmp(cmd->tx_argv[cmd->tx_argc - 3], "at"))
{
Point editPoint;
doat = TRUE;
editPoint.p_x = cmdParseCoord(w, cmd->tx_argv[cmd->tx_argc - 2],
FALSE, TRUE);
editPoint.p_y = cmdParseCoord(w, cmd->tx_argv[cmd->tx_argc - 1],
FALSE, FALSE);
GeoTransPoint(&EditToRootTransform, &editPoint, &atPoint);
cmd->tx_argc -= 3;
}
}
/* Check the option for validity. */
@ -1247,11 +1262,12 @@ CmdSelect(w, cmd)
*/
case SEL_DEFAULT:
if (cmd->tx_argc > 2) goto usageError;
if (cmd->tx_argc == 2)
layerspec = TRUE;
else
layerspec = FALSE;
goto Okay;
case SEL_CELL:
layerspec = FALSE;
@ -1284,6 +1300,15 @@ Okay:
scx.scx_area.r_ytop = scx.scx_area.r_ybot + 1;
degenerate = TRUE;
}
else if (doat)
{
scx.scx_area.r_xbot = atPoint.p_x;
scx.scx_area.r_ybot = atPoint.p_y;
scx.scx_area.r_xtop = atPoint.p_x + 1;
scx.scx_area.r_ytop = atPoint.p_y + 1;
windCheckOnlyWindow(&w, DBWclientID);
window = w;
}
else
{
window = CmdGetRootPoint((Point *) NULL, &scx.scx_area);
@ -1305,17 +1330,34 @@ Okay:
* same space WILL cause a crash).
*/
if (!GEO_ENCLOSE(&cmd->tx_p, &lastArea)
|| ((lastCommand + 1) != TxCommandNumber))
if (doat)
{
samePlace = FALSE;
lastUse = NULL;
}
if (!GEO_ENCLOSE(&scx.scx_area.r_ll, &lastArea)
|| ((lastCommand + 1) != TxCommandNumber))
{
samePlace = FALSE;
lastUse = NULL;
}
lastArea.r_xbot = cmd->tx_p.p_x - MARGIN;
lastArea.r_ybot = cmd->tx_p.p_y - MARGIN;
lastArea.r_xtop = cmd->tx_p.p_x + MARGIN;
lastArea.r_ytop = cmd->tx_p.p_y + MARGIN;
lastArea.r_xbot = scx.scx_area.r_xbot - MARGIN;
lastArea.r_ybot = scx.scx_area.r_ybot - MARGIN;
lastArea.r_xtop = scx.scx_area.r_xbot + MARGIN;
lastArea.r_ytop = scx.scx_area.r_ybot + MARGIN;
}
else
{
if (!GEO_ENCLOSE(&cmd->tx_p, &lastArea)
|| ((lastCommand + 1) != TxCommandNumber))
{
samePlace = FALSE;
lastUse = NULL;
}
lastArea.r_xbot = cmd->tx_p.p_x - MARGIN;
lastArea.r_ybot = cmd->tx_p.p_y - MARGIN;
lastArea.r_xtop = cmd->tx_p.p_x + MARGIN;
lastArea.r_ytop = cmd->tx_p.p_y + MARGIN;
}
lastCommand = TxCommandNumber;
/* If there's material under the cursor, select some paint.

View File

@ -20,20 +20,22 @@
<H2>down</H2>
<HR>
Load selected cell into a window
Load selected or indicated cell into a window
<HR>
<H3>Usage:</H3>
<BLOCKQUOTE>
<B>down</B>
<B>down</B> [<I>instance</I>]
</BLOCKQUOTE>
<H3>Summary:</H3>
<BLOCKQUOTE>
The <B>down</B> command loads the currently selected cell into the
window. If more than one cell is selected, the one closest to the
cursor (pointer) position will be used, or at worst, one will be
selected arbitrarily.
With no arguments, the <B>down</B> command loads the currently
selected cell into the window. If more than one cell is selected,
the one closest to the cursor (pointer) position will be used, or at
worst, one will be selected arbitrarily. <BR><BR>
With one argument <I>instance</I>, the cell of the instance named
<I>instance</I> will be loaded into the window.
</BLOCKQUOTE>
<H3>Implementation Notes:</H3>

View File

@ -47,13 +47,14 @@ create a new cell definition from a selection.
<BLOCKQUOTE>
where <I>option</I> may be one of the following:
<DL>
<DT> [<B>more</B> | <B>less</B>] [<I>layers</I>]
<DD> [De]select material under cursor, or
[de]select a subcell if the cursor is over space.
<DT> <B>nocycle</B> [<I>layers</I>]
<DT> [<B>more</B> | <B>less</B>] [<I>layers</I>] [<B>at</B> <I>x y</I>]
<DD> [De]select material under cursor or indicated position, or
[de]select a subcell if the cursor or indicated position is over
space.
<DT> <B>nocycle</B> [<I>layers</I>] [<B>at</B> <I>x y</I>]
<DD> Select material without cycling through different tile
types when "select" is called from the same cursor position
more than once.
or indicated coordinate more than once.
<DT> [<B>do</B> | <B>no</B> | <B>simple</B>] <B>labels</B>
<DD> Set policy for copying labels during a network selection.
<DT> [<B>more</B> | <B>less</B>] <B>area</B> [<I>layers</I>] [<I>pattern</I>]