📄 sutwig.c
字号:
/* Wiggle plot subroutine for vertical plotting */void wigplot( float *dataptr, int nt, int ntr, string title, string label1, string label2, float tmin, float dt, float xmin, float dx){ char tval[8]; /* time value string */ char xval[8]; /* x value string */ string tfmt; /* format string for time tic labels */ string xfmt; /* format string for x tic labels */ float ltic; /* length of tic marks (inches) */ float margint; /* top/bot gap between box and traces */ float marginx; /* side gap between box and traces */ float mt; /* margint/scalet */ float mx; /* marginx/scalex */ float overlap; /* maximum trace overlap */ float scalet; /* time axis scale */ float scalex; /* trace axis scale */ float sizet; /* length of t-axis (inches) */ float sizex; /* length of x-axis (inches) */ float tpos; /* temp for time position */ float xpos; /* temp for trace position */ float zerot; /* base of plot to bot. of screen */ float zerox; /* left of plot to left of screen */ float tmax; /* maximum t value on section */ float xmax; /* maximum x value on section */ float tnum; /* next t value to label */ float xnum; /* next x value to label */ float tzero; /* largest t value to round to zero */ float xzero; /* largest x value to round to zero */ float dtict; /* delta for time tics (0.0 automatic) */ float dticx; /* delta for x tics (0.0 automatic) */ float ftict; /* first time tic (dtict != 0.0) */ float fticx; /* first x tic (dticx != 0.0) */ int axisfat; /* line thickness of box & tics */ int db; /* 0=no detail box; 1=detail box */ int dbfat; /* line thickness for detail box */ int fill; /* fill flag */ int hcopy; /* hardcopy flag */ int lablsz; /* label print size */ int left,top; /* left side and top for detail box */ int ntict; /* number of tics on time axis */ int nticx; /* number of tics on trace axis */ int plotfat; /* line thickness of traces */ int right, bot; /* right side and bottom for detail box */ int ticsz; /* tic labeling print size */ int titlsz; /* title print size */ int tlines; /* 1=timing lines (0=no timing lines) */ register int i; /* counter */ if (!igetpar("fill", &fill)) fill = FILL; if (!fgetpar("overlap", &overlap)) overlap = OVERLAP; if (!fgetpar("zerot", &zerot)) zerot = ZEROT; if (!fgetpar("zerox", &zerox)) zerox = ZEROX; if (!fgetpar("sizet", &sizet)) sizet = SIZET; if (!fgetpar("sizex", &sizex)) sizex = SIZEX; if (!fgetpar("margint", &margint)) margint = MARGINT; if (!fgetpar("marginx", &marginx)) marginx = MARGINX; if (!fgetpar("ltic", <ic)) ltic = LTIC; if (!igetpar("plotfat", &plotfat)) plotfat = PLOTFAT; if (!igetpar("axisfat", &axisfat)) axisfat = AXISFAT; if (!igetpar("titlsz", &titlsz)) titlsz = TITLSZ; if (!igetpar("lablsz", &lablsz)) lablsz = LABLSZ; if (!igetpar("ticsz", &ticsz)) ticsz = TICSZ; if (!igetpar("tlines", &tlines)) tlines = TLINES; /* Detail box parameters */ if (!igetpar("db", &db)) db = DB; if (!igetpar("dbfat", &dbfat)) dbfat = DBFAT; if (!igetpar("left", &left)) left = ntr/2; if (!igetpar("top", &top)) top = nt/4; if (!igetpar("right", &right)) right = 3*ntr/4; if (!igetpar("bot", &bot)) bot = nt/2; if (!fgetpar("dtict", &dtict)) dtict = DTICT; if (!fgetpar("dticx", &dticx)) dticx = DTICX; if (dtict != 0.0) if (!fgetpar("ftict", &ftict)) ftict = tmin; if (dticx != 0.0) if (!fgetpar("fticx", &fticx)) fticx = xmin; if (!igetpar("hcopy", &hcopy)) hcopy = 0; if (hcopy) { titlsz = 3; lablsz = 3; ticsz = 2; sizet = 5.25; sizex = 4.4; zerot = 1.5; zerox = 1.; } vp_tfont(FONT, STRING, OVLY_NORMAL); scalet = -sizet/nt; scalex = sizex/MAX(ntr, 8); vp_scale (scalex, scalet); vp_orig (zerox, zerot + sizet); vp_fat (axisfat); mx = marginx/scalex; mt = margint/scalet; /* Title */ vp_color (BLUE); vp_tjust(TH_CENTER, TH_NORMAL); vp_utext (0.5*ntr, mt + 0.45/scalet, titlsz, 0, title); /* Labels */ vp_color (BLUE); vp_tjust(TH_CENTER, TH_NORMAL); vp_utext (-mx-0.3/scalex, 0.5*nt, lablsz, 90, label1); vp_utext (0.5*ntr, nt-mt-0.6/scalet, lablsz, 0, label2); /* Axis box */ vp_color (GREEN); vp_umove ( -mx , mt ); vp_udraw ( -mx , (float) (nt-1) - mt ); vp_udraw ( (float) (ntr-1) + mx , (float) (nt-1) - mt ); vp_udraw ( (float) (ntr-1) + mx , mt ); vp_udraw ( -mx , mt ); /* Vertical axis tic marks */ tmax = tmin + (nt - 1)*dt; tzero = 0.0001 * (tmax - tmin); tfmt = "%1.4g"; if (dtict == 0.0) { ntict = MAX(NINT(sizet), 5); scaxis(tmin, tmax, &ntict, &dtict, &ftict); } for (tnum = ftict; tnum <= tmax; tnum += dtict) { float t = (tnum - tmin)/dt; vp_umove ( -mx, (tnum-tmin)/dt ); vp_where ( &xpos , &tpos ); vp_draw ( xpos-ltic, tpos ); if (tlines == 1) { vp_umove ( -mx , t ); vp_udraw ( (float) (ntr-1) + mx , t ); } vp_umove ( mx + (float) (ntr-1) , t ); vp_where ( &xpos , &tpos); vp_draw ( xpos + ltic , tpos ); vp_where ( &xpos , &tpos ); sprintf(tval, tfmt, tnum); if (ABS(tnum) < tzero) sprintf(tval, tfmt, 0.0); vp_tjust(TH_LEFT, TH_NORMAL); vp_text (xpos + 0.1, tpos, ticsz, 0, tval); } /* Horizontal axis tic marks */ xmax = xmin + (ntr - 1)*dx; xzero = 0.0001 * (xmax - xmin); xfmt = "%1.4g"; if (dticx == 0.0) { nticx = MAX(NINT(sizex), 4); scaxis(xmin, xmax, &nticx, &dticx, &fticx); } for (xnum = fticx; xnum <= xmax; xnum += dticx) { float x = (xnum - xmin)/dx; vp_umove ( x, mt ); vp_where ( &xpos , &tpos ); vp_draw (xpos, tpos + 2*ltic); vp_umove ( x, -mt + (nt-1) ); vp_where ( &xpos , &tpos ); vp_draw (xpos, tpos - 2*ltic); vp_where ( &xpos , &tpos ); sprintf(xval, xfmt, xnum); if (ABS(xnum) < xzero) sprintf(xval, xfmt, 0.0); vp_tjust(TH_CENTER, TH_NORMAL); vp_text (xpos, tpos - 0.22, ticsz, 0, xval); } /* Draw wiggle traces */ vp_color (RED); vp_fat (plotfat); vp_scale (scalex*overlap, scalet); for (i = 0; i < ntr; ++i) { vp_uorig (-(float) i / overlap, 0.0); vertvwig(dataptr + nt*i, nt, fill); } /* Detail box */ vp_uorig (0,0); vp_scale (scalex, scalet); vp_color (GREEN); if (db) { vp_fat (dbfat); vp_umove ( (float) (left -1) - .5 , (float) (top-1) ); vp_udraw ( (float) (right-1) + .5 , (float) (top-1) ); vp_udraw ( (float) (right-1) + .5 , (float) (bot-1) ); vp_udraw ( (float) (left -1) - .5 , (float) (bot-1) ); vp_udraw ( (float) (left -1) - .5 , (float) (top-1) ); vp_fat (axisfat); } vp_endplot ();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -