avoid doing a move_objects(RUBBER,...) if doing an "xschem paste xoffs yoffs" from script, to avoid graphical artifacts

This commit is contained in:
stefan schippers 2023-09-12 09:21:54 +02:00
parent c5420f4f07
commit 55fcf5d28e
2 changed files with 17 additions and 9 deletions

View File

@ -282,12 +282,16 @@ static void merge_inst(int k,FILE *fd)
xctx->instances++;
}
/* merge selection if selection_load=1, otherwise ask for filename */
/* selection_load: */
/* 0: ask filename to merge */
/* if ext=="" else use ext as name ... 20071215 */
/* 1: merge selection */
/* 2: merge clipboard */
/* merge selection if selection_load=1, otherwise ask for filename
* selection_load:
* 0: ask filename to merge
* if ext=="" else use ext as name
* 1: merge selection
* 2: merge clipboard
* if bit 3 is set do not start a move_objects(RUBBER,0,0,0)
* to avoid graphical artifacts if doing a xschem paste with x and y offsets
* from script
*/
void merge_file(int selection_load, const char ext[])
{
FILE *fd;
@ -298,8 +302,10 @@ void merge_file(int selection_load, const char ext[])
char tmp[256]; /* 20161122 overflow safe */
char *aux_ptr=NULL;
int got_mouse, generator = 0;
int rubber = 1;
rubber = !(selection_load & 8);
selection_load &= 7;
if(selection_load==0)
{
if(!strcmp(ext,"")) {
@ -425,7 +431,7 @@ void merge_file(int selection_load, const char ext[])
move_objects(START,0,0,0);
xctx->mousex_snap = xctx->mx_double_save;
xctx->mousey_snap = xctx->my_double_save;
move_objects(RUBBER,0,0,0);
if(rubber) move_objects(RUBBER,0,0,0);
} else {
dbg(0, "merge_file(): can not open %s\n", name);
}

View File

@ -2464,11 +2464,13 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
* Paste clipboard. If 'x y' not given user should complete placement in the GUI */
else if(!strcmp(argv[1], "paste"))
{
merge_file(2, ".sch");
if(argc > 3) {
merge_file(10, ".sch"); /* set bit 3 to avoid doing move_objects(RUBBER,...) */
xctx->deltax = atof(argv[2]);
xctx->deltay = atof(argv[3]);
move_objects(END, 0, 0.0, 0.0);
} else {
merge_file(2, ".sch");
}
Tcl_ResetResult(interp);
}