fix connect by kissing undo function

This commit is contained in:
Stefan Frederik 2022-01-19 04:12:34 +01:00
parent 881b32a689
commit 0ab2a9631a
3 changed files with 19 additions and 10 deletions

View File

@ -652,17 +652,17 @@ void enable_layers(void)
}
}
void connect_by_kissing(void)
int connect_by_kissing(void)
{
xSymbol *symbol;
int npin, i, j;
double x0,y0, pinx0, piny0;
short flip, rot;
xRect *rct;
int k,ii, kissing;
int k,ii, kissing, done_undo = 0;
Wireentry *wptr;
Instpinentry *iptr;
int sqx, sqy;
int sqx, sqy, changed = 0;
rebuild_selected_array();
k = xctx->lastsel;
@ -713,13 +713,19 @@ void connect_by_kissing(void)
}
if(kissing) {
dbg(1, "connect_by_kissing(): adding wire in %g %g, wires before = %d\n", pinx0, piny0, xctx->wires);
dbg(0, "connect_by_kissing(): adding wire in %g %g, wires before = %d\n", pinx0, piny0, xctx->wires);
if(!done_undo) {
xctx->push_undo();
done_undo = 1;
}
storeobject(-1, pinx0, piny0, pinx0, piny0, WIRE, 0, SELECTED1, NULL);
changed = 1;
xctx->need_reb_sel_arr = 1;
}
}
}
rebuild_selected_array();
return changed;
}
void attach_labels_to_inst(int interactive) /* offloaded from callback.c 20171005 */

View File

@ -1039,7 +1039,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")) connect_by_kissing();
if(tclgetboolvar("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 &&
xctx->arc[c=xctx->sel_array[0].col][n=xctx->sel_array[0].n].sel!=SELECTED) {
@ -1085,8 +1086,8 @@ void move_objects(int what, int merge, double dx, double dy)
bbox(START, 0.0 , 0.0 , 0.0 , 0.0);
set_modify(1);
/* no undo push for MERGE ad PLACE, already done before */
if( !(xctx->ui_state & (STARTMERGE | PLACE_SYMBOL | PLACE_TEXT)) ) {
dbg(1, "move_objects(): push undo state\n");
if( !xctx->kissing && !(xctx->ui_state & (STARTMERGE | PLACE_SYMBOL | PLACE_TEXT)) ) {
dbg(0, "move_objects(): push undo state\n");
xctx->push_undo();
}
xctx->ui_state &= ~PLACE_SYMBOL;

View File

@ -802,14 +802,16 @@ typedef struct {
int mx_save, my_save, last_command;
char sel_or_clip[PATH_MAX];
int onetime;
/* move.c */
/* list of nodes, instances attached to these need redraw */
Int_hashentry **node_redraw_table;
/* list of instances, collected using previous table, that need redraw */
unsigned char *inst_redraw_table;
int inst_redraw_table_size;
/* move.c */
double rx1, rx2, ry1, ry2;
short move_rot;
/* a wire was created while separating a component frm a net or another component */
short kissing;
short move_flip;
int manhattan_lines;
double x1, y_1, x2, y_2, deltax, deltay;
@ -833,7 +835,7 @@ typedef struct {
double p_xx1,p_xx2,p_yy1,p_yy2;
/* set_modify */
int prev_set_modify;
/* pan2 */
/* pan */
int mx_s, my_s;
int mmx_s, mmy_s;
double xorig_save, yorig_save;
@ -1173,7 +1175,7 @@ extern int place_symbol(int pos, const char *symbol_name, double x, double y, sh
const char *inst_props, int draw_sym, int first_call, int to_push_undo);
extern void place_net_label(int type);
extern void attach_labels_to_inst(int interactive);
extern void connect_by_kissing(void);
extern int connect_by_kissing(void);
extern void delete_files(void);
extern int sym_vs_sch_pins(void);
extern int match_symbol(const char name[]);