add no-infix (set infix_interface 0) operation to move and copy operations

This commit is contained in:
stefan schippers 2025-01-18 21:59:04 +01:00
parent c96d5be7cd
commit ca1035eca1
4 changed files with 92 additions and 40 deletions

View File

@ -642,8 +642,10 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
<li><kbd> copy_hierarchy to from</kbd></li><pre>
Copy hierarchy info from tab/window "from" to tab/window "to"
Example: xschem copy_hierarchy .drw .x1.drw </pre>
<li><kbd> copy_objects [deltax deltay [rot flip]]</kbd></li><pre>
if deltax and deltay (and optionally rot and flip) are given copy selection
<li><kbd> copy_objects [dx dy] [kissing] [stretch]</kbd></li><pre>
if kissing is given add nets to pins that touch other instances or nets
if stretch is given stretch connected nets to follow instace pins
if dx and dy are given copy selection
to specified offset, otherwise start a GUI copy operation </pre>
<li><kbd> count_items string separator quoting_chars</kbd></li><pre>
Debug command </pre>

View File

@ -1459,7 +1459,7 @@ static int end_place_move_copy_zoom()
static int check_menu_start_commands(double c_snap)
{
dbg(1, "check_menu_start_commands(): ui_state=%d, ui_state2=%d last_command=%d\n",
dbg(1, "check_menu_start_commands(): ui_state=%x, ui_state2=%x last_command=%d\n",
xctx->ui_state, xctx->ui_state2, xctx->last_command);
if((xctx->ui_state & MENUSTART) && (xctx->ui_state2 & MENUSTARTWIRECUT)) {
@ -1481,6 +1481,13 @@ static int check_menu_start_commands(double c_snap)
xctx->ui_state &=~MENUSTART;
return 1;
}
else if((xctx->ui_state & MENUSTART) && (xctx->ui_state2 & MENUSTARTCOPY)) {
xctx->mx_double_save=xctx->mousex_snap;
xctx->my_double_save=xctx->mousey_snap;
copy_objects(START);
xctx->ui_state &=~MENUSTART;
return 1;
}
else if((xctx->ui_state & MENUSTART) && (xctx->ui_state2 & MENUSTARTWIRE)) {
int prev_state = xctx->ui_state;
if(xctx->semaphore >= 2) return 0;
@ -3589,64 +3596,93 @@ int rstate; /* (reduced state, without ShiftMask) */
}
break;
}
if(key=='m' && rstate==0 && !(xctx->ui_state & (STARTMOVE | STARTCOPY))) /* move selection */
/* Move selection */
if(key=='m' && rstate==0 && !(xctx->ui_state & (STARTMOVE | STARTCOPY)))
{
if(waves_selected(event, key, state, button)) {
waves_callback(event, mx, my, key, button, aux, state);
break;
}
xctx->mx_double_save=xctx->mousex_snap;
xctx->my_double_save=xctx->mousey_snap;
if(tclgetboolvar("enable_stretch"))
select_attached_nets(); /* stretch nets that land on selected instance pins */
move_objects(START,0,0,0);
if(infix_interface) {
xctx->mx_double_save=xctx->mousex_snap;
xctx->my_double_save=xctx->mousey_snap;
move_objects(START,0,0,0);
} else {
xctx->ui_state |= MENUSTART;
xctx->ui_state2 = MENUSTARTMOVE;
}
break;
}
/* Move selection adding wires to moved pins */
if(((key == 'M' && rstate == 0) || (key == 'm' && EQUAL_MODMASK)) &&
!(xctx->ui_state & (STARTMOVE | STARTCOPY))) /* move selection */
!(xctx->ui_state & (STARTMOVE | STARTCOPY)))
{
xctx->mx_double_save=xctx->mousex_snap;
xctx->my_double_save=xctx->mousey_snap;
xctx->connect_by_kissing = 2; /* 2 will be used to reset var to 0 at end of move */
/* select_attached_nets(); */ /* stretch nets that land on selected instance pins */
move_objects(START,0,0,0);
if(infix_interface) {
xctx->mx_double_save=xctx->mousex_snap;
xctx->my_double_save=xctx->mousey_snap;
/* select_attached_nets(); */ /* stretch nets that land on selected instance pins */
move_objects(START,0,0,0);
} else {
xctx->ui_state |= MENUSTART;
xctx->ui_state2 = MENUSTARTMOVE;
}
break;
}
/* move selection stretching attached nets */
if(key=='m' && rstate == ControlMask &&
!(xctx->ui_state & (STARTMOVE | STARTCOPY))) /* move selection */
!(xctx->ui_state & (STARTMOVE | STARTCOPY)))
{
if(waves_selected(event, key, state, button)) {
waves_callback(event, mx, my, key, button, aux, state);
break;
}
xctx->mx_double_save=xctx->mousex_snap;
xctx->my_double_save=xctx->mousey_snap;
if(!tclgetboolvar("enable_stretch"))
select_attached_nets(); /* stretch nets that land on selected instance pins */
move_objects(START,0,0,0);
if(infix_interface) {
xctx->mx_double_save=xctx->mousex_snap;
xctx->my_double_save=xctx->mousey_snap;
move_objects(START,0,0,0);
} else {
xctx->ui_state |= MENUSTART;
xctx->ui_state2 = MENUSTARTMOVE;
}
break;
}
}
/* move selection, stretch attached nets, create new wires on pin-to-moved-pin connections */
if(key=='M' && state == (ControlMask | ShiftMask) &&
!(xctx->ui_state & (STARTMOVE | STARTCOPY))) /* move selection */
!(xctx->ui_state & (STARTMOVE | STARTCOPY)))
{
xctx->mx_double_save=xctx->mousex_snap;
xctx->my_double_save=xctx->mousey_snap;
if(!tclgetboolvar("enable_stretch"))
select_attached_nets(); /* stretch nets that land on selected instance pins */
xctx->connect_by_kissing = 2; /* 2 will be used to reset var to 0 at end of move */
move_objects(START,0,0,0);
if(infix_interface) {
xctx->mx_double_save=xctx->mousex_snap;
xctx->my_double_save=xctx->mousey_snap;
move_objects(START,0,0,0);
} else {
xctx->ui_state |= MENUSTART;
xctx->ui_state2 = MENUSTARTMOVE;
}
break;
}
if(key=='c' && EQUAL_MODMASK && /* duplicate selection */
!(xctx->ui_state & (STARTMOVE | STARTCOPY)))
{
if(xctx->semaphore >= 2) break;
xctx->connect_by_kissing = 2; /* 2 will be used to reset var to 0 at end of move */
xctx->mx_double_save=xctx->mousex_snap;
xctx->my_double_save=xctx->mousey_snap;
copy_objects(START);
if(infix_interface) {
xctx->mx_double_save=xctx->mousex_snap;
xctx->my_double_save=xctx->mousey_snap;
copy_objects(START);
} else {
xctx->ui_state |= MENUSTART;
xctx->ui_state2 = MENUSTARTCOPY;
}
break;
}
@ -3654,9 +3690,14 @@ int rstate; /* (reduced state, without ShiftMask) */
!(xctx->ui_state & (STARTMOVE | STARTCOPY)))
{
if(xctx->semaphore >= 2) break;
xctx->mx_double_save=xctx->mousex_snap;
xctx->my_double_save=xctx->mousey_snap;
copy_objects(START);
if(infix_interface) {
xctx->mx_double_save=xctx->mousex_snap;
xctx->my_double_save=xctx->mousey_snap;
copy_objects(START);
} else {
xctx->ui_state |= MENUSTART;
xctx->ui_state2 = MENUSTARTCOPY;
}
break;
}
if(key=='n' && rstate == ControlMask) /* clear schematic */
@ -4003,7 +4044,7 @@ int rstate; /* (reduced state, without ShiftMask) */
if(xctx->last_command == STARTWIRE) start_wire(xctx->mousex_snap, xctx->mousey_snap);
break;
}
/* handle all object insertions started from Tools menu */
/* handle all object insertions started from Tools/Edit menu */
if(check_menu_start_commands(c_snap)) break;
/* complete the STARTWIRE, STARTRECT, STARTZOOM, STARTCOPY ... operations */
if(end_place_move_copy_zoom()) break;

View File

@ -683,29 +683,37 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
Tcl_SetResult(interp, my_itoa(ret), TCL_VOLATILE);
}
/* copy_objects [deltax deltay [rot flip]]
* if deltax and deltay (and optionally rot and flip) are given copy selection
/* copy_objects [dx dy] [kissing] [stretch]
* if kissing is given add nets to pins that touch other instances or nets
* if stretch is given stretch connected nets to follow instace pins
* if dx and dy are given copy selection
* to specified offset, otherwise start a GUI copy operation */
else if(!strcmp(argv[1], "copy_objects"))
{
int nparam = 0;
int kissing= 0;
int stretch = 0;
if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
if(argc > 3) {
if(argc > 2) {
int i;
for(i = 2; i < argc; i++) {
if(!strcmp(argv[i], "kissing")) {kissing = 1; nparam++;}
if(!strcmp(argv[i], "stretch")) {stretch = 1; nparam++;}
}
}
if(stretch) select_attached_nets();
if(kissing) xctx->connect_by_kissing = 2;
if(argc > 3 + nparam) {
copy_objects(START);
xctx->deltax = atof(argv[2]);
xctx->deltay = atof(argv[3]);
if(argc > 4) {
xctx->move_rot = (short int)atoi(argv[4]);
}
if(argc > 5) {
xctx->move_flip = (short int)atoi(argv[5]);
}
copy_objects(END);
} else {
copy_objects(START);
xctx->ui_state |= MENUSTART;
xctx->ui_state2 = MENUSTARTCOPY;
}
Tcl_ResetResult(interp);
}
/* count_items string separator quoting_chars
Debug command */
else if(!strcmp(argv[1], "count_items"))

View File

@ -249,6 +249,7 @@ extern char win_temp_dir[PATH_MAX];
#define MENUSTARTMOVE 256U
#define MENUSTARTWIRECUT 512U
#define MENUSTARTWIRECUT2 1024U /* do not align cut point to snap */
#define MENUSTARTCOPY 2048U
#define WIRE 1 /* types of defined objects */
#define xRECT 2