add tanh() function in wave expression evaluator

This commit is contained in:
stefan schippers 2023-10-27 10:48:53 +02:00
parent 9f1b447c16
commit 6362ebb214
5 changed files with 78 additions and 13 deletions

View File

@ -3393,6 +3393,31 @@ void pan(int what, int mx, int my)
}
}
/* instead of doing a drawtemprect(xctx->gctiled, NOW, ....) do 4
* XCopy Area operations */
void fix_restore_rect(double x1, double y1, double x2, double y2)
{
dbg(0, "---\n");
/* horizontal lines */
MyXCopyAreaDouble(display, xctx->save_pixmap, xctx->window, xctx->gc[0],
x1, y1, x2, y1, x1, y1,
xctx->lw);
MyXCopyAreaDouble(display, xctx->save_pixmap, xctx->window, xctx->gc[0],
x1, y2, x2, y2, x1, y2,
xctx->lw);
/* vertical lines */
MyXCopyAreaDouble(display, xctx->save_pixmap, xctx->window, xctx->gc[0],
x1, y1, x1, y2, x1, y1,
xctx->lw);
MyXCopyAreaDouble(display, xctx->save_pixmap, xctx->window, xctx->gc[0],
x2, y1, x2, y2, x2, y1,
xctx->lw);
}
/* 20150927 select=1: select objects, select=0: unselect objects */
void select_rect(int what, int select)
{

View File

@ -2139,9 +2139,38 @@ int rstate; /* (reduced state, without ShiftMask) */
draw();
break;
}
if(0 && (key=='u') && rstate==ControlMask) /* testmode */
if( 0 && (key=='u') && rstate==ControlMask) /* testmode */
{
dbg(0, "%d\n", sizeof(Xschem_ctx));
int x = 1;
if(x == 0) {
XFillRectangle(display, xctx->window, xctx->gctiled,
xctx->xrect[0].x, xctx->xrect[0].y, xctx->xrect[0].width, xctx->xrect[0].height);
} else if(x == 1) {
int i;
for(i = 0; i < xctx->xrect[0].height; i++) {
XDrawLine(display, xctx->window, xctx->gctiled,
xctx->xrect[0].x, i, xctx->xrect[0].width, i);
}
} else if(x == 2) {
int i, j;
for(i = 0; i < xctx->xrect[0].width; i++) {
for(j = 0; j < xctx->xrect[0].height; j++) {
XDrawLine(display, xctx->window, xctx->gctiled,
i, xctx->xrect[0].y, xctx->xrect[0].width - i, j);
XDrawLine(display, xctx->window, xctx->gctiled,
xctx->xrect[0].width - i, xctx->xrect[0].y, i, j);
XDrawLine(display, xctx->window, xctx->gctiled,
i, xctx->xrect[0].height, xctx->xrect[0].width - i, j);
XDrawLine(display, xctx->window, xctx->gctiled,
xctx->xrect[0].width - i, xctx->xrect[0].height, i, j);
}
}
}
x++;
break;
}
if(key=='u' && rstate==0) /* undo */

View File

@ -4087,7 +4087,7 @@ int XSetTile(Display* display, GC gc, Pixmap s_pixmap)
void MyXCopyArea(Display* display, Drawable src, Drawable dest, GC gc, int src_x, int src_y,
unsigned int width, unsigned int height, int dest_x, int dest_y)
{
dbg(1, "MyXCopyArea()\n");
dbg(1, "MyXCopyArea(%d, %d, %u, %u)\n", src_x, src_y, width, height);
#if !defined(__unix__)
XCopyArea(display, src, dest, gc, src_x, src_y, width, height, dest_x, dest_y);
#if HAS_CAIRO==1
@ -4110,6 +4110,7 @@ void MyXCopyAreaDouble(Display* display, Drawable src, Drawable dest, GC gc,
double isx1, isy1, isx2, isy2, idx1, idy1;
unsigned int width, height;
dbg(1, "MyXCopyAreaDouble(%g, %g, %g, %g)\n", sx1, sy1, sx2, sy2);
isx1=X_TO_SCREEN(sx1) - 2 * INT_WIDTH(lw);
isy1=Y_TO_SCREEN(sy1) - 2 * INT_WIDTH(lw);
isx2=X_TO_SCREEN(sx2) + 2 * INT_WIDTH(lw);

View File

@ -1185,16 +1185,17 @@ static double ravg_store(int what , int i, int p, int last, double value)
#define SGN 14
#define SQRT 15
#define TAN 16
#define INTEG 17
#define AVG 18
#define DERIV 19
#define EXCH 20
#define DUP 21
#define RAVG 22 /* running average */
#define DB20 23
#define DERIV0 24 /* derivative to first sweep variable, regardless of specified sweep_idx */
#define PREV 25 /* previous point */
#define DEL 26 /* delay by an anount of sweep axis distance */
#define TANH 17
#define INTEG 18
#define AVG 19
#define DERIV 20
#define EXCH 21
#define DUP 22
#define RAVG 23 /* running average */
#define DB20 24
#define DERIV0 25 /* derivative to first sweep variable, regardless of specified sweep_idx */
#define PREV 26 /* previous point */
#define DEL 27 /* delay by an anount of sweep axis distance */
#define ORDER_DERIV 1 /* 1 or 2: 1st order or 2nd order differentiation. 1st order is faster */
@ -1242,6 +1243,7 @@ int plot_raw_custom_data(int sweep_idx, int first, int last, const char *expr)
else if(!strcmp(n, "sgn()")) stack1[stackptr1++].i = SGN;
else if(!strcmp(n, "sqrt()")) stack1[stackptr1++].i = SQRT;
else if(!strcmp(n, "tan()")) stack1[stackptr1++].i = TAN;
else if(!strcmp(n, "tanh()")) stack1[stackptr1++].i = TANH;
else if(!strcmp(n, "exp()")) stack1[stackptr1++].i = EXP;
else if(!strcmp(n, "ln()")) stack1[stackptr1++].i = LN;
else if(!strcmp(n, "log10()")) stack1[stackptr1++].i = LOG10;
@ -1529,6 +1531,9 @@ int plot_raw_custom_data(int sweep_idx, int first, int last, const char *expr)
case TAN:
stack2[stackptr2 - 1] = tan(stack2[stackptr2 - 1]);
break;
case TANH:
stack2[stackptr2 - 1] = tanh(stack2[stackptr2 - 1]);
break;
case SIN:
stack2[stackptr2 - 1] = sin(stack2[stackptr2 - 1]);
break;

View File

@ -1337,6 +1337,11 @@ extern void filledrect(int c, int what, double rectx1,double recty1,
extern void drawtempline(GC gc, int what, double x1,double y1,double x2,double y2);
/* instead of doing a drawtemprect(xctx->gctiled, NOW, ....) do 4
* XCopy Area operations. Used if fix_broken_tiled_fill is set */
extern void fix_restore_rect(double x1, double y1, double x2, double y2);
extern void drawtemprect(GC gc, int what, double rectx1,double recty1,
double rectx2,double recty2);
extern void drawtemparc(GC gc, int what, double x, double y, double r, double a, double b);