better instance selection min-distance calculation

This commit is contained in:
Stefan Schippers 2020-09-17 09:05:08 +02:00
parent b51ce34b1c
commit c08613608d
4 changed files with 7 additions and 6 deletions

View File

@ -198,7 +198,7 @@ ctrl '+' Test mode: change line width
'+' brite colors
- '_' Toggle change line width
- '%' Toggle draw grid
- '=' Toggle fill rectangles
ctrl '=' Toggle fill rectangles
- '$' Toggle pixmap saving
ctrl '$' Toggle use XCopyArea vs drawing primitives for drawing the screen
- ':' Toggle flat netlist

View File

@ -391,7 +391,7 @@ int callback(int event, int mx, int my, KeySym key,
print_hilight_net(3);
break;
}
if(key == 'J' && state==ShiftMask) { /* testmode */
if(key == 'J' && state==ShiftMask) {
create_plot_cmd(NGSPICE);
break;
}

View File

@ -254,10 +254,11 @@ void find_closest_element(double mx,double my)
if( POINTINSIDE(mx,my,inst_ptr[i].x1,inst_ptr[i].y1,inst_ptr[i].x2,inst_ptr[i].y2) )
{
/* tmp=pow(mx-inst_ptr[i].x0, 2)+pow(my-inst_ptr[i].y0, 2); */
tmp=pow(mx-(inst_ptr[i].x1 + inst_ptr[i].x2)/2, 2)+pow(my-(inst_ptr[i].y1 + inst_ptr[i].y2)/2, 2);
if(tmp*.1 < distance)
tmp=pow(mx-(inst_ptr[i].xx1 + inst_ptr[i].xx2)/2, 2)+pow(my-(inst_ptr[i].yy1 + inst_ptr[i].yy2)/2, 2);
dbg(0, "i=%d, xx1=%g, yy1=%g, xx2=%g, yy2=%g\n", i, inst_ptr[i].xx1, inst_ptr[i].yy1, inst_ptr[i].xx2, inst_ptr[i].yy2);
if(tmp*0.1 < distance)
{
r = i; distance = tmp;
r = i; distance = tmp*0.1;
}
dbg(2, "find_closest_element(): finding closest element, lastinst=%d, dist=%.16g\n",i,tmp);
}

View File

@ -158,7 +158,7 @@ ctrl '+' Test mode: change line width
'+' brite colors
- '_' Toggle change line width
- '%' Toggle draw grid
- '=' Toggle fill rectangles
ctrl '=' Toggle fill rectangles
- '$' Toggle pixmap saving
ctrl '$' Toggle use XCopyArea vs drawing primitives for drawing the screen
- ':' Toggle flat netlist