📄 wview.c
字号:
printer_setup(hDlg, tprinter);
break;
case IDOK:
GetDlgItemText(hDlg, IDD_PPRINTER, curdev, sizeof(curdev));
if (curdev != cprdevstr) strcpy(cprdevstr, curdev);
for (adp = alldev; *adp; adp += strlen(adp) + 1)
if (strncmp(curdev, adp, strlen(adp)) == 0)
printer = adp;
print_to_file = IsDlgButtonChecked(hDlg, IDD_PFILE);
collate = IsDlgButtonChecked(hDlg, IDD_PCOLLATE);
switch (print_range = tprint_range) {
case IDD_PRREC:
pt0 = 0L;
pt1 = tf;
break;
case IDD_PRWIN:
default:
pt0 = t0;
pt1 = t1;
break;
case IDD_PRSEG:
GetDlgItemText(hDlg, IDD_PRFROM, prtst, sizeof(prtst));
pt0 = strtim(prtst);
GetDlgItemText(hDlg, IDD_PRTO, prtst, sizeof(prtst));
pt1 = strtim(prtst);
if (pt0 < 0L) pt0 = -pt0;
if (pt1 < 0L) pt1 = -pt1;
if (pt0 >= pt1) pt1 = pt0 + t1-t0;
break;
}
ncopies = GetDlgItemInt(hDlg, IDD_PCOPIES, NULL, FALSE);
if (ncopies > MAXCOPIES) ncopies = MAXCOPIES;
else if (ncopies < 1) ncopies = 1;
for (i = 0; i < ncopies; i++)
print_window(hDlg, printer);
EndDialog(hDlg, TRUE);
return (TRUE);
break;
case IDCANCEL:
EndDialog(hDlg, TRUE);
return (TRUE);
break;
}
}
return (FALSE);
}
static char pcomments[80];
static double ptscale = 25.0, pvscale = 10.0;
static int pbflag = 1, pgtflag = 1, pgvflag = 1, pmflag = 0, pnflag = 1,
pshow_subtyp = 0, pshow_chan = 0, pshow_num = 0, pshow_aux = 0,
ptsi = TSI, pvsi = VSI, ptmode = 0;
void copy_display_options()
{
ptscale = tsc[ptsi = tsi]; /* time scale */
pvscale = vsc[pvsi = vsi]; /* amplitude scale */
pbflag = bflag; /* signal baselines */
pgtflag = gtflag; /* time grid */
pgvflag = gvflag; /* amplitude grid */
pmflag = mflag; /* markers */
pnflag = nflag; /* signal names */
pshow_subtyp = show_subtyp; /* annotation subtypes */
pshow_chan = show_chan; /* annotation chan fields */
pshow_num = show_num; /* annotation num fields */
pshow_aux = show_aux; /* annotation aux fields */
ptmode = tmode; /* time display mode */
}
BOOL FAR PASCAL PrintOptions(hDlg, message, wParam, lParam)
HWND hDlg;
unsigned message;
WORD wParam;
LONG lParam;
{
int i;
static int use_display_options = 1;
HWND hlist;
switch (message) {
case WM_INITDIALOG:
CheckDlgButton(hDlg, IDD_PODEF, use_display_options);
if (use_display_options) copy_display_options();
hlist = GetDlgItem(hDlg, IDD_POSTIME);
for (i = 0; i <= MAXTSI; i++)
SendMessage(hlist, CB_ADDSTRING, 0, (LONG)(LPSTR)tst[i]);
SendMessage(hlist, CB_SETCURSEL, ptsi, 0L);
hlist = GetDlgItem(hDlg, IDD_POSAMP);
for (i = 0; i <= MAXVSI; i++)
SendMessage(hlist, CB_ADDSTRING, 0, (LONG)(LPSTR)vst[i]);
SendMessage(hlist, CB_SETCURSEL, pvsi, 0L);
CheckDlgButton(hDlg, IDD_POGTIME, pgtflag);
CheckDlgButton(hDlg, IDD_POGAMP, pgvflag);
CheckDlgButton(hDlg, IDD_POAMARK, pmflag);
CheckDlgButton(hDlg, IDD_POASUB, pshow_subtyp);
CheckDlgButton(hDlg, IDD_POACHAN, pshow_chan);
CheckDlgButton(hDlg, IDD_POANUM, pshow_num);
CheckDlgButton(hDlg, IDD_POAAUX, pshow_aux);
CheckDlgButton(hDlg, IDD_POOSB, pbflag);
CheckDlgButton(hDlg, IDD_POOSN, pnflag);
CheckDlgButton(hDlg, IDD_POTMODE, ptmode);
return (TRUE);
case WM_COMMAND:
switch (wParam) {
case IDD_PODEF:
use_display_options = IsDlgButtonChecked(hDlg, IDD_PODEF);
if (use_display_options) {
copy_display_options();
hlist = GetDlgItem(hDlg, IDD_POSTIME);
SendMessage(hlist, CB_SETCURSEL, ptsi, 0L);
hlist = GetDlgItem(hDlg, IDD_POSAMP);
SendMessage(hlist, CB_SETCURSEL, pvsi, 0L);
CheckDlgButton(hDlg, IDD_POGTIME, pgtflag);
CheckDlgButton(hDlg, IDD_POGAMP, pgvflag);
CheckDlgButton(hDlg, IDD_POAMARK, pmflag);
CheckDlgButton(hDlg, IDD_POASUB, pshow_subtyp);
CheckDlgButton(hDlg, IDD_POACHAN, pshow_chan);
CheckDlgButton(hDlg, IDD_POANUM, pshow_num);
CheckDlgButton(hDlg, IDD_POAAUX, pshow_aux);
CheckDlgButton(hDlg, IDD_POOSB, pbflag);
CheckDlgButton(hDlg, IDD_POOSN, pnflag);
CheckDlgButton(hDlg, IDD_POTMODE, ptmode);
}
break;
case IDD_POSTIME:
case IDD_POSAMP:
case IDD_POGTIME:
case IDD_POGAMP:
case IDD_POAMARK:
case IDD_POASUB:
case IDD_POACHAN:
case IDD_POANUM:
case IDD_POAAUX:
case IDD_POOSB:
case IDD_POOSN:
case IDD_POTMODE:
CheckDlgButton(hDlg, IDD_PODEF, use_display_options = 0);
break;
case IDD_POHELP:
WinHelp(hDlg, "wview.hlp", HELP_CONTEXT, (long)Options_Topic);
break;
case IDOK:
hlist = GetDlgItem(hDlg, IDD_POSTIME);
i = (int)SendMessage(hlist, CB_GETCURSEL, 0, 0L);
if (0 <= i && i <= MAXTSI)
ptscale = tsc[ptsi = i];
hlist = GetDlgItem(hDlg, IDD_POSAMP);
i = (int)SendMessage(hlist, CB_GETCURSEL, 0, 0L);
if (0 <= i && i <= MAXVSI)
pvscale = vsc[pvsi = i];
pgtflag = IsDlgButtonChecked(hDlg, IDD_POGTIME);
pgvflag = IsDlgButtonChecked(hDlg, IDD_POGAMP);
pmflag = IsDlgButtonChecked(hDlg, IDD_POAMARK);
pshow_subtyp = IsDlgButtonChecked(hDlg, IDD_POASUB);
pshow_chan = IsDlgButtonChecked(hDlg, IDD_POACHAN);
pshow_num = IsDlgButtonChecked(hDlg, IDD_POANUM);
pshow_aux = IsDlgButtonChecked(hDlg, IDD_POAAUX);
pbflag = IsDlgButtonChecked(hDlg, IDD_POOSB);
pnflag = IsDlgButtonChecked(hDlg, IDD_POOSN);
ptmode = IsDlgButtonChecked(hDlg, IDD_POTMODE);
EndDialog(hDlg, TRUE);
return (TRUE);
case IDCANCEL:
EndDialog(hDlg, TRUE);
return (TRUE);
}
break;
}
return (FALSE);
}
void copy_default_options()
{
tscale = tsc[tsi = TSI]; /* time scale */
vscale = vsc[vsi = VSI]; /* amplitude scale */
bflag = 0; /* signal baselines */
gtflag = 1; /* time grid */
gvflag = 1; /* amplitude grid */
mflag = 0; /* markers */
nflag = 1; /* signal names */
show_subtyp = 0; /* annotation subtypes */
show_chan = 0; /* annotation chan fields */
show_num = 0; /* annotation num fields */
show_aux = 0; /* annotation aux fields */
}
BOOL FAR PASCAL ViewOptions(hDlg, message, wParam, lParam)
HWND hDlg;
unsigned message;
WORD wParam;
LONG lParam;
{
int i;
static int use_default_options = 1;
HWND hlist;
switch (message) {
case WM_INITDIALOG:
CheckDlgButton(hDlg, IDD_VODEF, use_default_options);
if (use_default_options) copy_default_options();
hlist = GetDlgItem(hDlg, IDD_VOSTIME);
for (i = 0; i <= MAXTSI; i++)
SendMessage(hlist, CB_ADDSTRING, 0, (LONG)(LPSTR)tst[i]);
SendMessage(hlist, CB_SETCURSEL, tsi, 0L);
hlist = GetDlgItem(hDlg, IDD_VOSAMP);
for (i = 0; i <= MAXVSI; i++)
SendMessage(hlist, CB_ADDSTRING, 0, (LONG)(LPSTR)vst[i]);
SendMessage(hlist, CB_SETCURSEL, vsi, 0L);
CheckDlgButton(hDlg, IDD_VOGTIME, gtflag);
CheckDlgButton(hDlg, IDD_VOGAMP, gvflag);
CheckDlgButton(hDlg, IDD_VOAMARK, mflag);
CheckDlgButton(hDlg, IDD_VOASUB, show_subtyp);
CheckDlgButton(hDlg, IDD_VOACHAN, show_chan);
CheckDlgButton(hDlg, IDD_VOANUM, show_num);
CheckDlgButton(hDlg, IDD_VOAAUX, show_aux);
CheckDlgButton(hDlg, IDD_VOOSB, bflag);
CheckDlgButton(hDlg, IDD_VOOSN, nflag);
CheckDlgButton(hDlg, IDD_VOTMODE, tmode);
return (TRUE);
case WM_COMMAND:
switch (wParam) {
case IDD_VODEF:
use_default_options = IsDlgButtonChecked(hDlg, IDD_VODEF);
if (use_default_options) {
copy_default_options();
hlist = GetDlgItem(hDlg, IDD_VOSTIME);
SendMessage(hlist, CB_SETCURSEL, tsi, 0L);
hlist = GetDlgItem(hDlg, IDD_VOSAMP);
SendMessage(hlist, CB_SETCURSEL, vsi, 0L);
CheckDlgButton(hDlg, IDD_VOGTIME, gtflag);
CheckDlgButton(hDlg, IDD_VOGAMP, gvflag);
CheckDlgButton(hDlg, IDD_VOAMARK, mflag);
CheckDlgButton(hDlg, IDD_VOASUB, show_subtyp);
CheckDlgButton(hDlg, IDD_VOACHAN, show_chan);
CheckDlgButton(hDlg, IDD_VOANUM, show_num);
CheckDlgButton(hDlg, IDD_VOAAUX, show_aux);
CheckDlgButton(hDlg, IDD_VOOSB, bflag);
CheckDlgButton(hDlg, IDD_VOOSN, nflag);
CheckDlgButton(hDlg, IDD_VOTMODE, tmode);
}
break;
case IDD_VOSTIME:
case IDD_VOSAMP:
case IDD_VOGTIME:
case IDD_VOGAMP:
case IDD_VOAMARK:
case IDD_VOASUB:
case IDD_VOACHAN:
case IDD_VOANUM:
case IDD_VOAAUX:
case IDD_VOOSB:
case IDD_VOOSN:
case IDD_VOTMODE:
CheckDlgButton(hDlg, IDD_VODEF, use_default_options = 0);
break;
case IDD_VOHELP:
WinHelp(hDlg, "wview.hlp", HELP_CONTEXT, (long)Options_Topic);
break;
case IDOK:
hlist = GetDlgItem(hDlg, IDD_VOSTIME);
i = (int)SendMessage(hlist, CB_GETCURSEL, 0, 0L);
if (0 <= i && i <= MAXTSI)
tscale = tsc[tsi = i];
hlist = GetDlgItem(hDlg, IDD_VOSAMP);
i = (int)SendMessage(hlist, CB_GETCURSEL, 0, 0L);
if (0 <= i && i <= MAXVSI)
vscale = vsc[vsi = i];
gtflag = IsDlgButtonChecked(hDlg, IDD_VOGTIME);
gvflag = IsDlgButtonChecked(hDlg, IDD_VOGAMP);
mflag = IsDlgButtonChecked(hDlg, IDD_VOAMARK);
show_subtyp = IsDlgButtonChecked(hDlg, IDD_VOASUB);
show_chan = IsDlgButtonChecked(hDlg, IDD_VOACHAN);
show_num = IsDlgButtonChecked(hDlg, IDD_VOANUM);
show_aux = IsDlgButtonChecked(hDlg, IDD_VOAAUX);
bflag = IsDlgButtonChecked(hDlg, IDD_VOOSB);
nflag = IsDlgButtonChecked(hDlg, IDD_VOOSN);
tmode = IsDlgButtonChecked(hDlg, IDD_VOTMODE);
EndDialog(hDlg, TRUE);
return (TRUE);
case IDCANCEL:
EndDialog(hDlg, TRUE);
return (TRUE);
}
break;
}
return (FALSE);
}
open_record()
{
char *s;
int i;
WFDB_Calinfo ci;
/* Save the current time in string format. */
if (t0 > 0L) s = timstr(t0);
wfdbquit();
/* Open the signal file(s) for the record to be browsed. */
nsig = isigopen(record, si, WFDB_MAXSIG);
/* Recalculate the current time (necessary if the sampling frequencies
of the new record and the old record differ). */
if (t0 > 0L) t0 = strtim(s);
/* Get the sampling frequency. */
if ((sps = sampfreq(NULL)) <= 0.) sps = WFDB_DEFFREQ;
/* Get the record length. Since the scrollbar units are determined
from the record length, this must be non-zero; if the length of
the chosen record is undefined or implausibly short, assume it is
30 minutes. */
if ((tf = strtim("e")) <= 0L && (tf = si[0].nsamp) < sps*10.)
tf = (long)(sps*1800.);
for (i = 0; i < nsig; i++) {
sg[i] = (si[i].gain != 0.0) ? si[i].gain : WFDB_DEFGAIN;
if (getcal(si[i].desc, si[i].units, &ci) == 0 && ci.scale != 0.0)
sg[i] *= ci.scale;
}
return (nsig);
}
int open_annotation_file()
{
static WFDB_Anninfo ai;
ai.name = annotator; ai.stat = WFDB_READ;
return (nann = annopen(record, &ai, 1) + 1);
}
void set_title()
{
if (*record && nann > 0)
sprintf(title, "WVIEW -- Record %s, Annotator %s",
record, annotator);
else if (*record)
sprintf(title, "WVIEW -- Record %s", record);
else
sprintf(title, "WVIEW");
}
void paint_main_window(hWnd)
HWND hWnd;
{
char *p, ts[30];
double xppsi, yppadu[WFDB_MAXSIG], ysc;
DWORD dwextent;
HDC hDC;
HPEN hOldPen;
int base[WFDB_MAXSIG], compress = 0, j, s, slen, tbhigh, tblow, tbmid,
*v, *vp, vmax[WFDB_MAXSIG], vmin[WFDB_MAXSIG], v0, x, y, yb;
long i, trlen;
PAINTSTRUCT ps;
/* Set up a display context to begin painting. */
hDC = BeginPaint(hWnd, &ps);
/* Determine the window size in sec and mV. */
wwsec = wwidth/(tscale*xppmm);
whmv = wheight/(vscale*yppmm);
/* Calculate the time scale in pixels per sample interval. */
xppsi = xppmm * tscale / sps;
/* Draw in transparent mode (do not clear spaces around letters,
etc., to white). */
SetBkMode(hDC, TRANSPARENT);
/* Draw the grid, if requested. */
hOldPen = SelectObject(hDC, grid_pen);
if (gtflag) {
double gdx = xppmm*tscale/GTICKSPERSEC;
int i;
for (i = 1, x = (int)gdx; x < wwidth; i++, x = (int)(i*gdx)) {
MoveTo(hDC, x, 0);
LineTo(hDC, x, wheight - 1);
}
}
if (gvflag) {
double gdy = yppmm*vscale/GTICKSPERMV;
int i;
for (i = 1, y = (int)gdy; y < wheight; i++, y = (int)(i*gdy)){
MoveTo(hDC, 0, y);
LineTo(hDC, wwidth - 1, y);
}
}
if (nsig > 0 || nann > 0) {
/* Set color for time stamps and signal names. */
SetTextColor(hDC, SIGNAL_COLOR);
/* Show the starting time in the lower left corner. */
slen = sprintf(ts, "%s", timstr(tmode ? -t0 : t0));
for (p = ts; *p == ' '; p++, slen--)
; /* discard initial spaces, if any */
x = xtr(2.);
y = ytr(5.) - tm.tmExternalLeading;
TextOut(hDC, x, y, p, slen);
/* Determine the ending time. */
t1 = t0 + (WFDB_Time)(sps*(int)wwsec);
/* Show the ending time in the lower right corner. */
slen = sprintf(ts, "%s", timstr(tmode ? -t1 : t1));
for (p = ts; *p == ' '; p++, slen--)
; /* discard initial spaces, if any */
dwextent = GetTextExtent(hDC, p, slen);
x = xt(sps*(int)wwsec) - LOWORD(dwextent) - xtr(2.);
TextOut(hDC, x, y, p, slen);
}
if (nsig < 1)
tbmid = wheight/2; /* Set standard ordinate for annotations. */
else { /* Draw signals. */
/* Determine signal amplitude scales and baselines. */
for (s = 0; s < nsig; s++) {
yppadu[s] = (yppmm * vscale) / sg[s];
base[s] = ((2*s+1)*wheight)/(2*nsig);
vmin[s] = 9999; vmax[s] = -9999;
}
tbmid = (nsig==1)?(int)(0.75*wheight):(base[nsig/2-1]+base[nsig/2])/2;
/* Allocate the signal buffer. */
trlen = (long)(wwsec * sps);
if (xppsi < 0.75) {
compress = 1;
while ((v=malloc((unsigned)(1.5*wwidth*nsig*sizeof(int))))==NULL)
wwidth /= 2;
}
else while ((v = malloc((unsigned)(trlen*nsig*sizeof(int)))) == NULL)
trlen -= (long)(sps/5.);
/* Skip to the starting time. */
isigsettime(t0);
if (compress) {
static int x0, vv0[WFDB_MAXSIG], vmn[WFDB_MAXSIG],
vmx[WFDB_MAXSIG], vv[WFDB_MAXSIG];
getvec(vp = v);
for (s = 0; s < nsig; s++)
vmax[s] = vmin[s] = vmn[s] = vmx[s] = vv0[s] = vp[s];
for (i = 1, x0 = 0; i < trlen && getvec(vv) > 0; i++) {
int xx;
if ((xx = (int)(i*xppsi)) > x0) {
x0 = xx;
vp += nsig;
for (s = 0; s < nsig; s++) {
if (vv[s] > vmx[s]) vmx[s] = vv[s];
else if (vv[s] < vmn[s]) vmn[s] = vv[s];
if (vmx[s] - vv0[s] > vv0[s] - vmn[s])
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -