add new command `Shift-M`, move selected instances adding wires when separating overlapping instance pins (Connect by kissing)

This commit is contained in:
Stefan Schippers 2023-06-10 18:57:32 +02:00
parent 43befd4e3e
commit 3b3e723f8f
5 changed files with 24 additions and 8 deletions

View File

@ -167,6 +167,7 @@ alt 'l' add lab_pin.sym to schematic
ctrl+shift 'o' Load most recent schematic
ctrl 'o' Load schematic
- 'm' Move selected obj.
shift 'M' Move selected obj, insert wire when separating touching instance pins.
shift 'N' Top level only netlist
- 'n' Hierarchical Netlist
ctrl 'n' Clear schematic

View File

@ -2183,7 +2183,14 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
move_objects(START,0,0,0);
break;
}
if(key=='M' && state==ShiftMask && !(xctx->ui_state & (STARTMOVE | STARTCOPY))) /* move selection */
{
xctx->mx_double_save=xctx->mousex_snap;
xctx->my_double_save=xctx->mousey_snap;
tclsetintvar("connect_by_kissing", 2); /* 2 will be used to reset var to 0 at end of move */
move_objects(START,0,0,0);
break;
}
if(key=='c' && state==0 && /* duplicate selection */
!(xctx->ui_state & (STARTMOVE | STARTCOPY)))
{

View File

@ -394,7 +394,7 @@ static int touches_inst_pin(double x, double y, int inst)
}
}
}
dbg(0, "touches_inst_pin(): %g %g : touches =%d on inst %d\n", x, y, touches, inst);
dbg(1, "touches_inst_pin(): %g %g : touches =%d on inst %d\n", x, y, touches, inst);
return touches;
}
@ -440,7 +440,7 @@ void break_wires_at_pins(int remove)
xctx->wire[xctx->wires].end2 = 0;
xctx->wire[xctx->wires].x2=x0;
xctx->wire[xctx->wires].y2=y0;
xctx->wire[xctx->wires].sel=0;
xctx->wire[xctx->wires].sel=SELECTED;
xctx->wire[xctx->wires].prop_ptr=NULL;
my_strdup(_ALLOC_ID_, &xctx->wire[xctx->wires].prop_ptr, xctx->wire[i].prop_ptr);
if(!strcmp(get_tok_value(xctx->wire[xctx->wires].prop_ptr,"bus",0), "true"))
@ -456,7 +456,7 @@ void break_wires_at_pins(int remove)
xctx->need_reb_sel_arr=1;
xctx->wires++;
} else {
dbg(0, "break_wires_at_pins(): skipping wire creation on wire %d, end1=%d\n",
dbg(1, "break_wires_at_pins(): skipping wire creation on wire %d, end1=%d\n",
i, xctx->wire[xctx->wires].end1);
deleted_wire = 1;
}
@ -471,7 +471,7 @@ void break_wires_at_pins(int remove)
/* mark for deletion only if no other nets attached */
xctx->wire[i].sel = SELECTED4; /* use a special flag to later delete these wires
* only and not other seleted wires */
dbg(0, "break_wires_at_pins(): mark wire %d for deletion: end2=%d\n", i, xctx->wire[i].end2);
dbg(1, "break_wires_at_pins(): mark wire %d for deletion: end2=%d\n", i, xctx->wire[i].end2);
}
}
}
@ -521,7 +521,7 @@ void break_wires_at_pins(int remove)
xctx->wire[xctx->wires].y1=xctx->wire[i].y1;
xctx->wire[xctx->wires].x2=x0;
xctx->wire[xctx->wires].y2=y0;
xctx->wire[xctx->wires].sel=0;
xctx->wire[xctx->wires].sel=SELECTED;
xctx->wire[xctx->wires].prop_ptr=NULL;
my_strdup(_ALLOC_ID_, &xctx->wire[xctx->wires].prop_ptr, xctx->wire[i].prop_ptr);
if(!strcmp(get_tok_value(xctx->wire[xctx->wires].prop_ptr,"bus",0), "true"))

View File

@ -127,6 +127,7 @@ alt 'l' add lab_pin.sym to schematic
ctrl+shift 'o' Load most recent schematic
ctrl 'o' Load schematic
- 'm' Move selected obj.
shift 'M' Move selected obj, insert wire when separating touching instance pins.
shift 'N' Top level only netlist
- 'n' Hierarchical Netlist
ctrl 'n' Clear schematic

View File

@ -1073,7 +1073,8 @@ void move_objects(int what, int merge, double dx, double dy)
xctx->rotatelocal=0;
xctx->deltax = xctx->deltay = 0.0;
rebuild_selected_array();
if(tclgetboolvar("connect_by_kissing")) xctx->kissing = connect_by_kissing();
/* if connect_by_kissing==2 it was set in callback.c ('M' command) */
if(tclgetintvar("connect_by_kissing")) xctx->kissing = connect_by_kissing();
else xctx->kissing = 0;
xctx->movelastsel = xctx->lastsel;
if(xctx->lastsel==1 && xctx->sel_array[0].type==ARC &&
@ -1086,7 +1087,10 @@ void move_objects(int what, int merge, double dx, double dy)
}
if(what & ABORT) /* draw objects while moving */
{
if(xctx->kissing) pop_undo(0, 0);
if(xctx->kissing) {
pop_undo(0, 0);
if(tclgetintvar("connect_by_kissing") == 2) tclsetintvar("connect_by_kissing", 0);
}
draw_selection(xctx->gctiled,0);
xctx->move_rot=xctx->move_flip=0;
xctx->deltax=xctx->deltay=0.;
@ -1119,6 +1123,9 @@ void move_objects(int what, int merge, double dx, double dy)
int firsti, firstw;
int floaters = there_are_floaters();
if(tclgetintvar("connect_by_kissing") == 2) {
tclsetintvar("connect_by_kissing", 0);
}
if(!floaters) bbox(START, 0.0 , 0.0 , 0.0 , 0.0);
/* no undo push for MERGE ad PLACE, already done before */
if( !xctx->kissing && !(xctx->ui_state & (STARTMERGE | PLACE_SYMBOL | PLACE_TEXT)) ) {