some fixes on numerical cursor adjustments (for log X scales)

This commit is contained in:
stefan schippers 2024-01-05 03:13:51 +01:00
parent 90ce40da2c
commit 1fa490b066
1 changed files with 10 additions and 6 deletions

View File

@ -418,10 +418,12 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
/* Numerically set cursor position */
if( (xctx->graph_flags & 2) && fabs(xctx->mousex - W_X(xctx->graph_cursor1_x)) < 10) {
if(gr->logx) {
double pos = pow(xctx->graph_cursor1_x, 10);
double pos = pow(10., xctx->graph_cursor1_x);
tclvareval("input_line {Pos:} {} ", dtoa_eng(pos), NULL);
pos = mylog10(atof_eng(tclresult()));
tclvareval("xschem set cursor1_x ", dtoa(pos), NULL);
if(tclresult()[0]) {
pos = mylog10(atof_eng(tclresult()));
tclvareval("xschem set cursor1_x ", dtoa(pos), NULL);
}
} else {
tclvareval("input_line {Pos:} {xschem set cursor1_x} ", dtoa_eng(xctx->graph_cursor1_x), NULL);
}
@ -430,10 +432,12 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
}
if( (xctx->graph_flags & 4) && fabs(xctx->mousex - W_X(xctx->graph_cursor2_x)) < 10) {
if(gr->logx) {
double pos = pow(xctx->graph_cursor2_x, 10);
double pos = pow(10., xctx->graph_cursor2_x);
tclvareval("input_line {Pos:} {} ", dtoa_eng(pos), NULL);
pos = mylog10(atof_eng(tclresult()));
tclvareval("xschem set cursor2_x ", dtoa(pos), NULL);
if(tclresult()[0]) {
pos = mylog10(atof_eng(tclresult()));
tclvareval("xschem set cursor2_x ", dtoa(pos), NULL);
}
} else {
tclvareval("input_line {Pos:} {xschem set cursor2_x} ", dtoa_eng(xctx->graph_cursor2_x), NULL);
}