// called by draw/redraw after cells are ccreated and filled with data. void AspFrame::dsAgain() { // if(AspMouse::getState() == AspMouse::noState ) // AspMouse::setState(AspMouse::cursor1); AspDis1D::display(AspFrameMgr::get()->getFrame(id)); Wsetgraphicsdisplay("asp1D('again')"); }
/*--------------------------------------- | | | df2d() | | | | This function displays a 2D FID | | data set. | | | +--------------------------------------*/ int df2d(int argc, char *argv[], int retc, char *retv[]) { ftparInfo ftpar; dfilehead fidhead, datahead, phasehead; (void) retc; (void) retv; if ( i_ft(argc, argv, (S_DATA|S_FLOAT), 0, 1, &ftpar, &fidhead, &datahead, &phasehead) ) { ABORT; } acqflag = FALSE; ftpar.zeroflag = FALSE; if (ftpar.combineflag) { Werrprintf("%s(...) cannot combine fid's: too many arguments", argv[0]); ABORT; } if (convertfids(&ftpar, &fidhead)) { disp_index(0); ABORT; } D_close(D_USERFILE); disp_index(0); if (!Bnmr) { releasevarlist(); appendvarlist("dconi"); Wsetgraphicsdisplay("dconi"); /* activate the dconi program */ } RETURN; }
/************************************* fiddle() **************************************/ int fiddle(int argc, char *argv[], int retc, char *retv[]) { int pwr,cblock,res,dc_correct=TRUE; register int i,ntval; dpointers inblock; float a,b,c,d,denom; int ocount; /* initialization bits */ if (i_fiddle(argc,argv)) ABORT; dc_correct=dccorr; pwr = fnpower(fn0); max=0.0; cfcount=0; count=0; firstrefint=0.0; phasetweek=0.0; degtorad=3.141592654/180.0; ocount=0; ntval = 1; if (!P_getreal(PROCESSED, "nt", &tmp, 1)) { ntval = (int) (tmp + 0.5); if (ntval < 1) ntval = 1; } disp_status("IN3 "); /* check range of transforms */ if (startno>=fidhead.nblocks) startno=fidhead.nblocks-1; if (startno<0) { startno=0; finishno=fidhead.nblocks; stepno=1; } if (finishno>fidhead.nblocks) finishno=fidhead.nblocks; if (stepno==0) stepno=1; /* setup destination fidfile and/or correction function file if requested */ if (writefg) setupwritefile(); if (writecfflg) setupwritecf(); /* start of main loop */ incno=0; t1=0; rp0=rp; for (cblock = startno; cblock < finishno; cblock+=stepno) { if ( (res = D_getbuf(D_DATAFILE, fidhead.nblocks, cblock, &inblock)) ) { D_error(res); freall(TRUE); } if ( (inblock.head->status & (S_DATA|S_SPEC|S_FLOAT|S_COMPLEX)) == (S_DATA|S_SPEC|S_FLOAT|S_COMPLEX) ) { disp_index(cblock+1); incno+=1; if (verbose) Wscrprintf("Increment no. %d \n",incno); if (!aphflg) incrementrp(); inp = (float *)inblock.data; /* DEBUGGING ONLY if (verbose) Wscrprintf("Real part of 1st point of original fid %f \n", inp[0]); if (verbose) Wscrprintf("Imag part of 1st point of original fid %f \n", inp[1]); */ /* dc (not normally used!) if (dc_correct) { disp_status("DC "); cmplx_dc(inp, &lvl_re, &lvl_im, &tlt_re, &tlt_im, np0/2, CMPLX_DC); vvrramp(inp, 2, inp, 2, lvl_re, tlt_re, np0/2); vvrramp(inp+1, 2, inp+1, 2, lvl_im, tlt_im, np0/2); } */ /* phase correct spectrum */ finalph=0.0; rotate2(inp,np0/2,lp,rp); if (aphflg) { faph(inp,leftpos,rightpos,&finalph); rotate2(inp,np0/2,0.0,finalph); } /* if baseline then zero imag. */ if (baseline||hilbert) fiddle_zeroimag(); /* move first to data1, ready for ift, n.b. fn0==np0 */ transpmove(inp,data1); /* do zeroing for reference region */ if (solvent) solventextract(); else { for (i=0;i<leftpos;i++) { inp[i]=0.0; } for (i=rightpos+2;i<np0;i++) { inp[i]=0.0; } if (ldcflag) baseline_correct(inp,leftpos,rightpos); if (extrap) extrapolate(); } /* !solvent */ transpmove(inp,data2); /* now do the ift's */ if (!noift) { disp_status("IFT1 "); fft(data1,fn0/2,pwr,0,COMPLEX,COMPLEX,1.0,FTNORM/ntval,np0/2); disp_status("IFT2 "); fft(data2,fn0/2,pwr,0,COMPLEX,COMPLEX,1.0,FTNORM/ntval,np0/2); } if (makereffg) makeideal(); /* need to weight data3 to create ideal fid */ if (makereffg&&!noift) { disp_status("WT "); weightfid(wtfunc,data3,np0w/2,FALSE,COMPLEX); } if (stopflag<1||stopflag>3) { /* DEBUGGING ONLY if (verbose) Wscrprintf("Real part of 1st point of original fid %f \n", data1[0]); if (verbose) Wscrprintf("Imag part of 1st point of original fid %f \n", data1[1]); */ /* divide (3) by (2) */ disp_status("DIV "); for (i=0;i<npi;i+=2) { a=data3[i]; b=data3[i+1]; c=data2[i]; d=data2[i+1]; denom=c*c+d*d; data2[i]=(a*c+b*d)/denom; data2[i+1]=(b*c-a*d)/denom; } if (writecfflg) writeoutcf(); if (readcfflg) readincf(); /* and multiply by (1) */ /* DEBUGGING ONLY if (verbose) Wscrprintf("Real part of 1st point of correction function %f \n", data2[0]); if (verbose) Wscrprintf("Imag part of 1st point of correction function %f \n", data2[1]); */ disp_status("MUL "); if (!corfunc) { for (i=0;i<npi;i+=2) { a=data2[i]; b=data2[i+1]; c=data1[i]; d=data1[i+1]; inp[i]=(a*c-b*d); inp[i+1]=(b*c+a*d); } } /* DEBUGGING ONLY if (verbose) Wscrprintf("Real part of 1st point of corrected fid %f \n", inp[0]); if (verbose) Wscrprintf("Imag part of 1st point of corrected fid %f \n", inp[1]); */ /* Halve first point of corrected fid */ /* hang about, does this do anything??? */ if (halffg) /* default true */ { data1[0]=0.5*(data1[0]); data1[1]=0.5*(data1[1]); } if (npi<np0) for (i=npi;i<np0;i++) inp[i]=0.0; } /* stopflag not 1 - 3 */ if (firstfg&&!nosub) movmem((char *)inp,(char *)data4,sizeof(float)*np0,1,4); if (secondfg&&!nosub) { disp_status("SUB "); submem(inp,data4,np0); if (invert) invertmem(inp,np0); } /* inp contains result fid - write out and/or FT! */ if (writefg&&!firstfg) writeoutresult(); if (!noftflag) { disp_status("FT "); fft(inp,fn0/2,pwr,0,COMPLEX,COMPLEX,-1.0,FTNORM/ct,np0/2); } /* move intermediate result for display if requested */ if (stopflag||corfunc) { disp_status("MOVE "); switch (stopflag) { case 1: p=data1; break; case 2: p=data2; break; case 4: p=data4; break; default: p=data3; break; } if (corfunc) p=data2; if (difffg&&(stopflag<4)) { if (firstfg) movmem((char *)p,(char *)data4,sizeof(float)*np0,1,4); if (!firstfg) { submem(p,data4,np0); if (invert) invertmem(p,np0); } } if (noift) transpmove(p,inp); else movmem((char *)p,(char *)inp,sizeof(float)*np0,1,4); } /* re-phase back to rp,lp */ disp_status("PHASE "); if (!(writefg&&!firstfg)) /* if not both writing and subsequent fid */ { rotate2(inp,np0/2,-lp,-rp); } else rotate2(inp,np0/2,-lp,0.0); if (difffg) { secondfg=!secondfg; firstfg=!firstfg; } if (udifffg) { secondfg=TRUE; firstfg=FALSE; } if (secondfg||oflag) makereffg=FALSE; else makereffg=TRUE; /* oflag increment */ if (oflag) { rp+=odat[ocount]; ocount++; if (ocount>3) ocount=0; } /* release result */ if ( (res=D_markupdated(D_DATAFILE,cblock)) ) { D_error(res); disp_status(" "); freall(TRUE); } if ( (res = D_release(D_DATAFILE, cblock)) ) { D_error(res); disp_status(" "); freall(TRUE); } if (interuption) /* ? not fully working ? */ { Werrprintf("Fiddle processing halted"); freall(TRUE); ABORT; } if (flag2d) { if (altfg) { if ((incno % 2)==0) t1=t1+1/sw1; } else { t1=t1+1/sw1; } } } /* end of if ( (inblock.head->status &c at start of main loop */ } /* end of main loop */ start_from_ft=TRUE; releasevarlist(); appendvarlist("cr"); Wsetgraphicsdisplay("ds"); /* free memory */ freall(FALSE); disp_status(" "); disp_index(0); RETURN; }
/************************************* makeslice() **************************************/ int makeslice(int argc, char *argv[], int retc, char *retv[]) { int i,j,k,l,m,n,h_min_pt,h_max_pt,v_min_pt,v_max_pt; int trace_number_in_block,ending_block; float *inp,*buffer; dpointers inblock; int data_in_block[MAXBLOCKS]; /* MANCHESTER VERSION 6.1 14 vii 98 GAM */ /* This function present in file ll2d.c */ #ifdef DEBUG_MAKESLICE strcpy (rubbish, curexpdir); strcat (rubbish, "/dosy/debug_makeslice"); debug = fopen (rubbish, "w"); /* file for debugging information */ fprintf (debug, "Start of makeslice\n"); fclose(debug); #endif /* initialization bits */ /* Wclear_text(); */ disp_index(0); Wsettextdisplay("clear"); if (init_makeslice(argc,argv)) ABORT; #ifdef DEBUG_MAKESLICE strcpy (rubbish, curexpdir); strcat (rubbish, "/dosy/debug_makeslice"); debug = fopen (rubbish, "a"); /* file for debugging information */ fprintf (debug, "After init_makeslice\n"); fclose(debug); #endif for (i=0;i<MAXBLOCKS;i++) data_in_block[i] = FALSE; m = 0; h_min_pt = h_max_pt = 0; /* Start of the loop to evaluate the blocks in which the various peaks are */ for (n = 0; n < peak_table->num_peaks; n++) { if (pk[m].num == peak->key) { /* Calculate the limits of peak region, always as follows (does not depend on trace value) because working with data file */ v_min_pt = ll2d_frq_to_dp(peak->f1_min,sw1,fn1_int*f1pts); if (peak->f1_min > ll2d_dp_to_frq((double)v_min_pt,sw1,fn1_int*f1pts)) v_min_pt--; v_max_pt = ll2d_frq_to_dp(peak->f1_max,sw1,fn1_int*f1pts); if (peak->f1_max < ll2d_dp_to_frq((double)v_max_pt,sw1,fn1_int*f1pts)) v_max_pt++; h_min_pt = ll2d_frq_to_dp(peak->f2_min,sw,fn_int); if (peak->f2_min > ll2d_dp_to_frq((double)h_min_pt,sw,fn_int)) h_min_pt--; h_max_pt = ll2d_frq_to_dp(peak->f2_max,sw,fn_int); if (peak->f2_max < ll2d_dp_to_frq((double)h_max_pt,sw,fn_int)) h_max_pt++; pk[m].h_min_pt = h_min_pt; pk[m].h_max_pt = h_max_pt; pk[m].v_min_pt = v_min_pt; pk[m].v_max_pt = v_max_pt; /* find out in which block(s) the peak lives */ pk[m].block = (int)(h_max_pt/fidhead.ntraces); if (!data_in_block[pk[m].block]) data_in_block[pk[m].block] = TRUE; ending_block = (int)(h_min_pt/fidhead.ntraces); pk[m].status = NOT_DONE; if (ending_block == pk[m].block) pk[m].two_blks = FALSE; else { pk[m].two_blks = TRUE; if (!data_in_block[pk[m].block+1]) data_in_block[pk[m].block+1] = TRUE; } m++; } peak = peak->next; } /* allocate memory for the temporary data buffer */ if ((buffer = (float *)malloc(sizeof(float)*fidhead.ntraces*fidhead.np)) == 0) { Werrprintf("makeslice: could not allocate memory\n"); ABORT; } for (n = 0; n < fidhead.nblocks; n++) { disp_index(n+1); /* First get the data buffer ... */ if ( (r = D_getbuf(D_DATAFILE, fidhead.nblocks, n, &inblock)) ) { D_error(r); } inp = (float *)inblock.data; /* ... and zero 'inp' while keeping a copy in 'buffer' */ for (j = 0; j < fidhead.np*fidhead.ntraces; j++) { buffer[j] = inp[j]; inp[j] = 0.0; } if (data_in_block[n]) /* If some peaks of interest in the block */ { m = 0; peak = peak_table->head; for (l = 0; l < peak_table->num_peaks; l++) { if (pk[m].num == peak->key) /* found one peak */ { if (pk[m].block == n && pk[m].status != DONE) { if (pk[m].status == NOT_DONE) { if (pk[m].two_blks == FALSE) { h_max_pt = pk[m].h_max_pt; h_min_pt = pk[m].h_min_pt; } if (pk[m].two_blks == TRUE) { h_max_pt = pk[m].h_max_pt; h_min_pt = ((n+1)*fidhead.ntraces)-1; } } else if (pk[m].status == PARTIAL) { h_max_pt = (n*fidhead.ntraces); h_min_pt = pk[m].h_min_pt; } if (display_mode == 's') { for (i = h_max_pt; i <= h_min_pt; i++) { trace_number_in_block = (n > 0 ? (i % (n*fidhead.ntraces)) : i); for (j = 0; j <= pk[m].v_min_pt-pk[m].v_max_pt; j++) { k = j+(trace_number_in_block)*fidhead.np+pk[m].v_max_pt; inp[k] = buffer[k]; } } } else if (display_mode == 'i') { for (i = h_max_pt; i <= h_min_pt; i++) { trace_number_in_block = (n > 0 ? (i % (n*fidhead.ntraces)) : i); for (j = 0; j <= pk[m].v_min_pt-pk[m].v_max_pt; j++) { k = j+(trace_number_in_block)*fidhead.np+pk[m].v_max_pt; /* The signal intensity is multiplied by the (part integral / full integral) ratio */ inp[k] = pk[m].intensity*buffer[k]; } } } if (pk[m].two_blks == FALSE) pk[m].status = DONE; if (pk[m].two_blks == TRUE) { if (pk[m].status == PARTIAL) pk[m].status = DONE; else if (pk[m].status == NOT_DONE) { pk[m].status = PARTIAL; (pk[m].block)++; } } } m++; } peak = peak->next; } } if ( (r = D_markupdated(D_DATAFILE,n)) ) { D_error(r); ABORT; } if ( (r = D_release(D_DATAFILE,n)) ) { D_error(r); ABORT; } } delete_peak_table(&peak_table); free(buffer); start_from_ft=TRUE; releasevarlist(); appendvarlist("dconi"); Wsetgraphicsdisplay("dconi"); disp_index(0); RETURN; }
int pipeRead(int argc, char *argv[], int retc, char *retv[]) /****************************/ { char path[MAXPATH]; int elem; float fdata[FDATASIZE]; int fd; int dimCount; int num; int xSize, ySize; int xFtSize, xCenter; int xDomain, yDomain, zDomain, aDomain; int xMode, yMode; int blockStat; int blocks2D, traces2D, np2D; int block2D; int totSize; int zeroTraces; int firstTrace; int r; float *ptr; float *start; float *dptr; float multRe, multIm; if (argc<2) { Werrprintf("usage - %s('filename'<,index>)",argv[0]); ABORT; } jeolFlag = (strcmp(argv[0],"jread")) ? 0 : 1; Wturnoff_buttons(); D_allrelease(); if (argv[1][0] == '/') strcpy(path,argv[1]); else sprintf(path,"%s/%s",curexpdir,argv[1]); elem = 1; if (jeolFlag) { multRe = multIm = 100.0; } else { multRe = multIm = FTNORM; } if (argc >= 3) { if (isReal(argv[2])) { elem = atoi(argv[2]); if (elem < 1) elem = 1; } else if ( ! strcmp(argv[2],"rev") ) { multIm = -multRe; } if (argc >= 4) { if (isReal(argv[3])) { elem = atoi(argv[3]); if (elem < 1) elem = 1; } else if ( ! strcmp(argv[3],"rev") ) { multIm = -multRe; } } } if ( access(path,R_OK) ) { Werrprintf("%s: cannot access %s",argv[0],path); ABORT; } if ( (fd = open(path,O_RDONLY)) < 0) { Werrprintf("%s: unable to open %s",argv[0],path); ABORT; } if ( read(fd, fdata, sizeof(float)*FDATASIZE) != sizeof(float)*FDATASIZE) { Werrprintf("%s: unable to read %s",argv[0],path); close(fd); ABORT; } /* 1D Data */ if ( (dimCount = (int) getParm( fdata, FDDIMCOUNT, 0 )) == 1) { int realOnly; realOnly = getParm( fdata, FDQUADFLAG, 0 ); xSize = (int) getParm( fdata, NDSIZE, CUR_XDIM ); if ( (r = checkFnSize(xSize, "1D")) ) { close(fd); ABORT; } if ( ! realOnly ) /* Complex counts complex pairs */ xSize *= 2; if (jeolFlag) { if ( (elem == 1) && setFidFile1D(xSize)) { close(fd); ABORT; } if ( (elem != 1) && getFidFile1D(xSize,elem)) { close(fd); ABORT; } } else { if ( (argc != 3) && setDataFile1D(xSize,realOnly)) { close(fd); ABORT; } if ( (argc == 3) && getDataFile1D(xSize,realOnly,elem)) { close(fd); ABORT; } } start = (float *) mmap(0,sizeof(float) * (xSize+FDATASIZE), PROT_READ, MAP_PRIVATE, fd, 0); ptr = start + FDATASIZE; dptr = data; if (realOnly) { num = xSize; while ( num-- ) { *dptr++ = *ptr++ * multRe; } } else { num = xSize / 2; while ( num-- ) { *dptr++ = *ptr * multRe; *dptr++ = *(ptr+xSize/2) * multIm; ptr++; } } munmap(start, sizeof(float) * (xSize+FDATASIZE) ); close(fd); if (jeolFlag) { if ( (r=D_markupdated(D_USERFILE,elem-1)) ) { D_error(r); ABORT; } if ( (r=D_flush(D_USERFILE)) ) { D_error(r); ABORT; } if ( (r=D_release(D_USERFILE,elem-1)) ) { D_error(r); ABORT; } D_close(D_USERFILE); Wsetgraphicsdisplay(""); /* activate the ds program */ } else { if ( (r=D_markupdated(D_DATAFILE,elem-1)) ) { D_error(r); ABORT; } if ( (r=D_release(D_DATAFILE,elem-1)) ) { D_error(r); ABORT; } if (!Bnmr) { releasevarlist(); appendvarlist("cr"); Wsetgraphicsdisplay("ds"); /* activate the ds program */ start_from_ft = 1; } } RETURN; } /* 2D data */ xDomain = (int) getParm( fdata, NDFTFLAG, CUR_XDIM ); yDomain = (int) getParm( fdata, NDFTFLAG, CUR_YDIM ); zDomain = (int) getParm( fdata, NDFTFLAG, CUR_ZDIM ); aDomain = (int) getParm( fdata, NDFTFLAG, CUR_ADIM ); #ifdef XXX /* For 4D testing only */ if ( strstr(path,".ft4") ) { aDomain=1; } #endif /* zDomain is the 3D flag; aDomain is 4D flag */ if ( (dimCount < 1) || (xDomain + yDomain != 2) ) { Winfoprintf("%s: file %s not 1D nor 2D data",argv[0], path); close(fd); RETURN; } xMode = (int) getParm( fdata, NDQUADFLAG, CUR_XDIM ); yMode = (int) getParm( fdata, NDQUADFLAG, CUR_YDIM ); xSize = (int) getParm( fdata, NDSIZE, CUR_XDIM ); ySize = (int) getParm( fdata, NDSIZE, CUR_YDIM ); xFtSize = (int) getParm( fdata, NDFTSIZE, CUR_XDIM ); xCenter = (int) getParm( fdata, NDCENTER, CUR_XDIM ); zeroTraces = 0; if (xSize != xFtSize) { zeroTraces = xFtSize/2 - xCenter + 1; } if ( (r = checkFnSize(xFtSize, "2D x")) ) { close(fd); ABORT; } if ( (r = checkFnSize(ySize, "2D y")) ) { close(fd); ABORT; } blocks2D = 0; totSize = 0; if (xMode && yMode) /* Real Real */ { if ( setDataFile2D3D(xFtSize, xMode, ySize, yMode, &blockStat, &blocks2D, &traces2D, &np2D, zDomain, aDomain) ) { close(fd); ABORT; } /* Winfoprintf("%s: Real Real 2D data from %s",argv[0], path); Winfoprintf("%s: blocks= %d traces= %d np= %d",argv[0], blocks2D, traces2D, np2D); */ totSize = traces2D * np2D; totSize = xSize * ySize; } else { Werrprintf("%s: Only Real Real 2D data is currently handled",argv[0]); close(fd); ABORT; } start = (float *) mmap(0,sizeof(float) * (totSize+FDATASIZE), PROT_READ, MAP_PRIVATE, fd, 0); ptr = start + FDATASIZE; close(fd); firstTrace = 0; for (block2D=0; block2D < blocks2D; block2D++) { int tracesPerBlk = traces2D / blocks2D; int trace = 0; int tracesDone = 0; int pt; if (getBuffer2D(block2D, blockStat)) { munmap(start, sizeof(float) * (totSize+FDATASIZE) ); ABORT; } dptr = data; if (zeroTraces) { tracesDone = (zeroTraces < tracesPerBlk) ? zeroTraces : tracesPerBlk; for (trace = 0; trace < tracesDone; trace++) { for (pt=0; pt < np2D; pt++) *dptr++ = 0.0; } zeroTraces -= tracesDone; } if ( !zeroTraces && (tracesDone < tracesPerBlk) ) { while ( (firstTrace < xSize) && (tracesDone < tracesPerBlk) ) { int toffset = firstTrace + (tracesPerBlk * block2D); for (pt=0; pt < np2D; pt++) *dptr++ = *(ptr + toffset + pt*xSize) * multRe; firstTrace++; tracesDone++; } while (tracesDone < tracesPerBlk) { for (pt=0; pt < np2D; pt++) *dptr++ = 0.0; tracesDone++; } } if ( (r=D_markupdated(D_DATAFILE,block2D)) ) { D_error(r); munmap(start, sizeof(float) * (totSize+FDATASIZE) ); ABORT; } if ( (r=D_release(D_DATAFILE,block2D)) ) { D_error(r); munmap(start, sizeof(float) * (totSize+FDATASIZE) ); ABORT; } } munmap(start, sizeof(float) * (totSize+FDATASIZE) ); RETURN; }
/* checkstatus if TRUE, check datafile status only */ int dataheaders(int getphasefile, int checkstatus) { char filepath[MAXPATH]; int e; /****************************************** * Get header information from datafile. * ******************************************/ D_allrelease(); if ( (e = D_gethead(D_DATAFILE, &datahead)) ) { /******************************************* * If the datafile is not open, open with * * the filehandler routines. * *******************************************/ if (e == D_NOTOPEN) { if ( (e = D_getfilepath(D_DATAFILE, filepath, curexpdir)) ) { D_error(e); return(ERROR); } e = D_open(D_DATAFILE, filepath, &datahead); /* open the file */ } if (e) { D_error(e); return(ERROR); } } /*********************************************** * Get header information from the phasefile. * ***********************************************/ if (getphasefile) { if ( (e = D_gethead(D_PHASFILE, &phasehead)) ) { /******************************************** * If the phasefile is not open, open with * * the filehandler routines. * *********************************************/ if (e == D_NOTOPEN) { if ( (e = D_getfilepath(D_PHASFILE, filepath, curexpdir)) ) { D_error(e); return(ERROR); } e = D_open(D_PHASFILE, filepath, &phasehead); /* open the file */ } if (e && removephasefile()) { D_error(e); return(ERROR); } } } /******************************************************** * Check to insure that there is data in the datafile. * ********************************************************/ if (checkstatus) { if (!(datahead.status & S_DATA)) { Wseterrorkey("aw"); Werrprintf("Data are not processed"); Wsetgraphicsdisplay(""); return(ERROR); } } return(COMPLETE); }
int dfww(int argc, char *argv[], int retc, char *retv[]) /*************/ { int firstindex; int lastindex; int step; int ctrace; int do_ww; int local_color; int imag_on; int redoDscale; int color_traces; int index=1; int maxindex=nblocks * specperblock; double save_sc, save_wc, save_sc2, save_wc2; (void) retc; (void) retv; redoDscale = dscale_onscreen(); Wturnoff_buttons(); plot = (argv[0][0] == 'p'); do_ww = (argv[0][2] == 'w'); if (Bnmr && !plot) return(COMPLETE); revflag = 0; if(initfid(plot+1)) return(ERROR); dispcalib = (float) (mnumypnts-ymin) / (float) wc2max; if (init_vars2()) return(ERROR); clearMspec(); checkinput(argc,argv,&firstindex,&lastindex,&step,&imag_on,&color_traces); if (!plot) setwindows(argv); if ((firstindex < 1) || (firstindex > maxindex)) { Werrprintf("spectrum %d does not exist",firstindex); return(ERROR); } save_sc=sc; save_wc=wc; save_sc2=sc2; save_wc2=wc2; if (lastindex < firstindex) lastindex = firstindex; if (lastindex > maxindex) lastindex = maxindex; //setscwc(firstindex,lastindex,step); if(plot) setscwc(firstindex,lastindex,step); else setscwc_new(firstindex,lastindex,step); setspecmaxmin(); disp_specIndex(firstindex); /* Need to change this for multiple traces... */ get_fid_color(argc,argv,&local_color,imag_on); ctrace = index = firstindex; if (!plot && inRepaintMode && redoDscale) new_dscale(FALSE,TRUE); if (do_ww) if (init_whitewash(mnumxpnts)) do_ww = FALSE; while ((ctrace <= lastindex) && !interuption) { if(plot) exp_factors(FALSE); else calcDisplayPars(); if(color_traces) local_color=((index % (NUM_AV_COLORS-2)) + FIRST_AV_COLOR + 1); if (calc_fid(ctrace-1)) return(ERROR); if (imag_on) imagdisp(local_color, do_ww); else fiddisp(local_color, do_ww); if(plot) { sc += ho; if (!horizontal) sc2 += vo; } else { dss_sc += ho; if (!horizontal) dss_sc2 += vo; } ctrace += step; index++; } if (!plot) { ResetLabels(); DispField(FIELD1,PARAM_COLOR,"vf",vs,1); InitVal(FIELD2,HORIZ,SP_NAME, PARAM_COLOR,UNIT4, SP_NAME, PARAM_COLOR,SCALED,2); InitVal(FIELD3,HORIZ,WP_NAME, PARAM_COLOR,UNIT4, WP_NAME, PARAM_COLOR,SCALED,2); if (firstindex != lastindex) { DispField(FIELD4,PARAM_COLOR,"first",(double) firstindex,0); DispField(FIELD5,PARAM_COLOR,"last",(double) lastindex,0); DispField(FIELD6,PARAM_COLOR,"step",(double) step,0); } } if (plot) amove(0,0); else { exit_display(); Wsetgraphicsdisplay("dfs"); } endgraphics(); sc=save_sc; wc=save_wc; sc2=save_sc2; wc2=save_wc2; P_setreal(CURRENT,"sc",sc,0); P_setreal(CURRENT,"wc",wc,0); P_setreal(CURRENT,"sc2",sc2,0); P_setreal(CURRENT,"wc2",wc2,0); if (do_ww) close_whitewash(); if (freebuffers()) return(ERROR); appendvarlist("dss_sc,dss_wc,sc,wc,vo,ho"); return(COMPLETE); }
int AspFrame::loadSession(char *path) { struct stat fstat; string dir=""; char sessionFile[MAXSTR2],file[MAXSTR2]; if(stat(path, &fstat) != 0) { Winfoprintf("Error: cannot find %s.",path); return 0; } else if(fstat.st_mode & S_IFDIR) { // is a directory dir = string(path); sprintf(sessionFile,"%s/aspSession",path); } else { string tmp = string(path); dir = tmp.substr(0,tmp.find_last_of("/")); sprintf(sessionFile,"%s",path); } FILE *fp; if(!(fp = fopen(sessionFile, "r"))) { Winfoprintf("Failed to open session file %s.",sessionFile); return 0; } traceList->clearList(); selTraceList->clearList(); peakList->clearList(); integList->clearList(); annoList->clearList(); char buf[MAXSTR2], words[MAXWORDNUM][MAXSTR2], *tokptr; int nw, count=0; int ntraces = 0; char str[MAXSTR2]; string root=""; while (fgets(buf,sizeof(buf),fp)) { if(strlen(buf) < 1 || buf[0] == '#') continue; // break buf into tok of parameter names nw=0; tokptr = strtok(buf, ", :\n\r"); while(tokptr != NULL) { if(strlen(tokptr) > 0) { strcpy(words[nw], tokptr); nw++; } tokptr = strtok(NULL, ", :\n\r"); } if(nw < 2) continue; if(strcasecmp(words[0],"disFlags")==0 && nw > 4) { //e.g. disFlags: 0 132096 0 256 disFlag = atoi(words[1]); axisFlag = atoi(words[2]); annoFlag = atoi(words[3]); specFlag = atoi(words[4]); if(nw > 5) peakFlag = atoi(words[5]); if(nw > 6) integFlag = atoi(words[6]); } else if(strcasecmp(words[0],"disParams")==0 && nw > 1) { //e.g. disParams: 22.000000 8.000000 if(nw > 2) { P_setreal(CURRENT, "vp", atof(words[1]), 1); P_setreal(CURRENT, "vo", atof(words[2]), 1); } } else if(strcasecmp(words[0],"root")==0 && nw > 1) { root=string(words[1]); if(root.find_last_of("/") == root.length()-1) root=root.substr(0,root.length()-1); } else if(strcasecmp(words[0],"procpar")==0 && nw > 1) { P_read(CURRENT,words[1]); } else if(nw > 11 && strstr(words[0],"load") == words[0]) { if(root != "" && words[2][0] != '/') { strcpy(str,words[2]); sprintf(words[2],"%s/%s",root.c_str(),str); } //e.g. load 1 /tmp/spec.fdf spec1 spec1 0 -2.022703 14.022636 1.000000 0.000000 11 0 //e.g. load 2 /tmp/spec.fdf spec1 spec1 1 -2.022703 14.022636 1.000000 0.000000 11 0 // each line corresponds to a AspTrace spAspTrace_t trace = spAspTrace_t(new AspTrace(words,nw)); trace->rootPath=string(root); sprintf(str,"%s:%d",trace->dataKey.c_str(),trace->dataInd); string newKey = string(str); traceList->addTrace(newKey, trace); selTraceList->maxInd= traceList->getSize(); ntraces++; count++; } else if(nw > 11 && (strstr(words[0],"add") == words[0] || strstr(words[0],"sub") == words[0] || strstr(words[0],"rep") == words[0])) { if(root != "" && words[2][0] != '/') { strcpy(str,words[2]); sprintf(words[2],"%s/%s",root.c_str(),str); } //e.g. add 1 /tmp/spec.fdf spec1 spec1 0 -2.022703 14.022636 1.000000 0.000000 11 0 //e.g. sub 1 /tmp/spec.fdf spec1 spec1 1 -2.022703 14.022636 1.000000 0.000000 11 0 // each line corresponds to a AspTrace to be add/sub to a specified trace spAspTrace_t trace = spAspTrace_t(new AspTrace(words,nw)); trace->rootPath=string(root); int flag = (strstr(words[0],"sub") == words[0]) ? SUB_TRACE:ADD_TRACE; if(strstr(words[0],"rep") == words[0]) flag = REP_TRACE; spAspTrace_t sumTrace = traceList->getTraceByInd(atoi(words[1])-1); if(sumTrace != nullAspTrace) sumTrace->sumTrace(trace,flag); else { sprintf(str,"%s:%d",trace->dataKey.c_str(),trace->dataInd); string newKey = string(str); traceList->addTrace(newKey, trace); selTraceList->maxInd= traceList->getSize(); } count++; } else if(strcasecmp(words[0],"color")==0 && nw > 4) { spAspTrace_t trace = traceList->getTraceByInd(atoi(words[1])-1); if(trace != nullAspTrace) { double min = atof(words[3]); double max = atof(words[4]); string str = string(""); spAspTrace_t sumTrace = spAspTrace_t(new AspTrace(0,str,str,0,0,min,max)); sumTrace->colorStr=string(words[2]); list<spAspTrace_t> *sumList = trace->getSumTraceList(); sumList->push_back(sumTrace); } } else if(strcasecmp(words[0],"displayed_traces")==0 && nw > 1) { //e.g. displayed_traces: 1 2 3 4 5 6 7 8 9 10 int i; for(i=1; i<nw;i++) { spAspTrace_t trace = traceList->getTraceByInd(atoi(words[i])-1); if(trace != nullAspTrace) { trace->selected=false; selTraceList->addTrace(trace->getKeyInd(), trace); } } selTraceList->maxInd= traceList->getSize(); } else if(strcasecmp(words[0],"roiFile")==0 && nw > 1) { sprintf(file,"%s/%s",dir.c_str(),words[1]); loadRois(file); } else if(strcasecmp(words[0],"annoFile")==0 && nw > 1) { spAspFrame_t frame = AspFrameMgr::get()->getFrame(this); sprintf(file,"%s/%s",dir.c_str(),words[1]); AspDisAnno::load(frame, file); } else if(strcasecmp(words[0],"peakFile")==0 && nw > 1) { sprintf(file,"%s/%s",dir.c_str(),words[1]); spAspFrame_t frame = AspFrameMgr::get()->getFrame(this); AspDisPeaks::load(frame, file); } else if(strcasecmp(words[0],"integFile")==0 && nw > 1) { sprintf(file,"%s/%s",dir.c_str(),words[1]); spAspFrame_t frame = AspFrameMgr::get()->getFrame(this); AspDisInteg::load(frame, file); } } // display all traces if displayed_traces: is missing if(selTraceList->getSize() < 1) { for(int i=0; i<traceList->getSize(); i++) { spAspTrace_t trace = traceList->getTraceByInd(i); if(trace != nullAspTrace) { trace->selected=false; selTraceList->addTrace(trace->getKeyInd(), trace); } } } fclose(fp); if(specFlag) { AspMouse::setState(AspMouse::cursor1); Wsetgraphicsdisplay(""); } else { AspMouse::setState(AspMouse::noState); } getDefaultDataInfo(true); draw(); return count; }
void AspFrame::setCellFOV(int rows, int cols) { Wclear(2); // clear graphics window Wsetgraphicsdisplay(""); clearGraphFunc(); // so won't redo ds etc... if(!aspMode) setFullSize(); cellList->clearList(); aspMode=true; spAspDataInfo_t dataInfo = getDefaultDataInfo(true); double vstx = dataInfo->haxis.start; double vsty = dataInfo->vaxis.start; double vwd = dataInfo->haxis.width; double vht = dataInfo->vaxis.width; double mx,my,mw,mh; getFOVLimits(mx,my,mw,mh); if(pstx < mx) pstx=mx; if((pstx+pwd) > (mx+mw)) pwd=(mx+mw)-pstx;; if(psty < my) psty=my; if((psty+pht) > (my+mh)) pht=(my+mh)-psty;; /* // for now, use FOV of ds or dconi pstx = ((double)(mnumxpnts-right_edge)*(wcmax-sc-wc)/wcmax); pwd = ((double)(mnumxpnts-right_edge)*wc/wcmax); psty = ((double)(mnumypnts-ymin)*sc2/wc2max)+ymin; pht = ((double)(mnumypnts-ymin)*wc2/wc2max); psty = mnumypnts - (psty+pht); if(axisFlag & AX_SOUTH) { } else { pht += ymin; } if(pstx < xcharpixels) { pwd -= (xcharpixels - pstx); pstx = xcharpixels; } if((axisFlag & AX_WEST)) { double west = xcharpixels * 8; if (west > pstx && west < pwd) { west = west - pstx; pstx += west; pwd -= west; } } if ((pstx + pwd) > (pixstx+pixwd-xcharpixels)) { pwd -= (pstx + pwd -pixstx - pixwd + xcharpixels); } if(psty < ycharpixels) { pht -= (ycharpixels - psty); psty = ycharpixels; } if((psty + pht) > (pixsty+pixht-2*ycharpixels)) { pht -= (psty + pht -pixsty - pixht + 2*ycharpixels); } */ // divide into rows, cols. double wd = pwd/cols; double ht = pht/rows; int i,j,k; for(i=0;i<rows;i++) { for(j=0;j<cols;j++) { k=1 + i*cols + j; spAspCell_t cell = spAspCell_t(new AspCell(pstx+j*wd,psty+i*ht,wd,ht,vstx,vsty,vwd,vht)); cell->setAxisNames(dataInfo->haxis.name,dataInfo->vaxis.name); cell->setDataInfo(dataInfo); cellList->addCell(k,cell); // DEBUG // AspUtil::drawBox(pstx+j*wd,psty+i*ht,wd,ht,3); } } }
/*----------------------------------------------- | | | lpcmd() | | | | This function performs 1D LP on a single | | or arrayed FID data set. A new fid file | | is write to argv[1] or curexpdir/lp.fid | | if not specified. | | | +----------------------------------------------*/ int lpcmd(int argc, char *argv[], int retc, char *retv[]) { char filepath[MAXPATHL]; int status, res, cblock, lastcblock, blocksdone, lsfidx, fidnum = 0, arg_no, npx, npadj, ftflag, noreal, element_no, lastfid, first, last, step, i, ctcount, realt2data; float *outp; dpointers inblock; dpointers outblock; dfilehead fidhead, datahead, phasehead; lpstruct parLPinfo; ftparInfo ftpar; char newfidpath[MAXPATHL]; Wturnoff_buttons(); ftpar.procstatus = (CMPLX_t2|LP_F2PROC); /************************************ * Initialize all parameterizeable * * variables * ************************************/ arg_no = first = step = element_no = 1; ftpar.nblocks = MAXINT; last = MAXINT; noreal = ftflag = TRUE; ftpar.t2dc = -1; ftpar.zeroflag = FALSE; ftpar.sspar.lfsflag = ftpar.sspar.zfsflag = FALSE; ftpar.dspar.dsflag = FALSE; ftpar.dspar.fileflag = FALSE; ftpar.dspar.newpath[0] = '\0'; ftpar.ftarg.useFtargs = 0; // default newfidpath sprintf(newfidpath,"%s/lp.fid",curexpdir); /********************************* * Parse STRING arguments first * *********************************/ while ( (argc > arg_no) && (noreal = !isReal(argv[arg_no])) ) { if(strcmp(argv[arg_no],"rlp") == 0) { // e.g., lp('/tmp/lp.fid') ftpar.procstatus = (REAL_t2|LP_F2PROC); } else if(argv[arg_no][0] == '/') { // e.g., lp('/tmp/lp.fid') strcpy(newfidpath,argv[arg_no]); } else { sprintf(newfidpath,"%s/%s",curexpdir,argv[arg_no]); } arg_no++; } if(strcmp(newfidpath+strlen(newfidpath)-4,".fid") != 0 && strcmp(newfidpath+strlen(newfidpath)-5,".fid/") != 0) strcat(newfidpath,".fid"); /****************************** * Initialize data files and * * FT parameters. * ******************************/ if ( i_ft(argc, argv, (S_DATA | S_FLOAT), 0, 0, &ftpar, &fidhead, &datahead, &phasehead) ) { disp_status(" "); ABORT; } if ( (res = D_getbuf(D_USERFILE, fidhead.nblocks, 0, &inblock)) ) { ctcount=1; } else ctcount = inblock.head->ctcount; if(ctcount<1) ctcount=1; if (ftpar.t2dc == -1) { ftpar.t2dc = (fidhead.status & S_DDR) ? FALSE : TRUE; } disp_current_seq(); ftpar.cf = first; specIndex = first; /* tells interactive programs that new data exist */ /*************************************************** * np0 = total number of points in the fid * * npx = used number of points in the fid * * * * Adjust "npx" and "lsfidx". * ***************************************************/ lsfidx = ftpar.lsfid0; npx = ftpar.np0; npadj = npx - lsfidx; /* adjusted number of FID data points */ if (lsfidx < 0) { if (npx < 2) { Werrprintf("lsfid is too large in magnitude"); ABORT; } } else { if (lsfidx >= npx) { Werrprintf("lsfid is too large in magnitude"); ABORT; } } realt2data = (ftpar.procstatus & REAL_t2); fpointmult = getfpmult(S_NP, fidhead.status & S_DDR); // note, limit for forward LP is npadj (5th arg) if ( setlppar(&parLPinfo, S_NP, ftpar.procstatus, npadj/2, MAXINT, LPALLOC, "ft2d") ) { disp_status(" "); releaseAllWithId("ft2d"); Wsetgraphicsdisplay(""); /* TRY THIS! SF */ ABORT; } if (parLPinfo.sizeLP) { int maxlpnp, nptmp; if (realt2data) { Werrprintf("LP analysis is not supported for real t2 data"); releaseAllWithId("ft2d"); disp_status(" "); ABORT; } maxlpnp = npadj; for (i = 0; i < parLPinfo.sizeLP; i++) { lpparams = *(parLPinfo.parLP + i); if (lpparams.status & FORWARD) { nptmp = 2*(lpparams.startextpt + lpparams.ncextpt - 1); if (nptmp > maxlpnp) maxlpnp = nptmp; } } npadj = maxlpnp; } /************************** * Start loop over FIDs. * **************************/ lastfid = ftpar.ni0 * ftpar.ni1 * ftpar.arraydim; if (lastfid > ftpar.nblocks) lastfid = ftpar.nblocks; if (first > lastfid) { last = lastfid; } D_trash(D_DATAFILE); if(access(newfidpath,F_OK) != 0) { if(mkdir(newfidpath,0777)) { Winfoprintf("cannot create %s",newfidpath); ABORT; } } status = (S_DATA | S_FLOAT | S_COMPLEX | ftpar.D_cmplx); // now write out fid to newfidpath strcpy(filepath,newfidpath); strcat(filepath,"/fid"); datahead.status = fidhead.status; datahead.vers_id = fidhead.vers_id; datahead.nbheaders = fidhead.nbheaders; datahead.nblocks = fidhead.nblocks; datahead.ntraces = 1; datahead.np = npadj; datahead.ebytes = fidhead.ebytes; datahead.tbytes = npadj*fidhead.ebytes; datahead.bbytes = datahead.tbytes + sizeof(dblockhead);; if (D_newhead(D_DATAFILE, filepath, &datahead) ) { Werrprintf("cannot open file %s", filepath); ABORT; } /*********************************************** * Necessary until I can devise a function to * * read only the FID block header in order to * * determine if FID data exists in that block. * ***********************************************/ blocksdone = FALSE; lastcblock = ftpar.nblocks; cblock = 0; while ((cblock < lastcblock) && (!blocksdone)) { DPRINT1("block %d\n", cblock); if ( (res = D_allocbuf(D_DATAFILE, cblock, &outblock)) ) { D_error(res); releaseAllWithId("ft2d"); disp_status(" "); ABORT; } outblock.head->ctcount = ctcount; /* default setting */ outblock.head->scale = 0; /* default setting */ outp = (float *)outblock.data; /********************************************************** * Start filling at the start of the output data buffer. * * This facilitates the automatic array-like processing * * of 'cf' and 'nf' in 1D. * **********************************************************/ fidnum = cblock; if (interuption) { releaseAllWithId("ft2d"); D_trash(D_PHASFILE); D_trash(D_DATAFILE); disp_status(" "); ABORT; } if ((cblock + 1) == first) { if ( ! ((cblock+1) & 15) ) disp_index(cblock + 1); if ( getfid(fidnum, outp, &ftpar, &fidhead, &lastfid) ) { Werrprintf("Unable to get FID data"); releaseAllWithId("ft2d"); disp_index(0); disp_status(" "); ABORT; } if (lastfid == 0) { releaseAllWithId("ft2d"); disp_index(0); disp_status(" "); ABORT; } else if (cblock == lastfid) { status = 0; blocksdone = TRUE; if (last == MAXINT) { last = cblock; } } else { if (parLPinfo.sizeLP) { for (i = 0; i < parLPinfo.sizeLP; i++) { lpparams = *(parLPinfo.parLP + i); disp_status(lpparams.label); if (lpz(fidnum, outp, (npx - lsfidx)/2, lpparams)) { Werrprintf("LP analysis failed"); releaseAllWithId("ft2d"); disp_index(0); disp_status(" "); ABORT; } } } if (fpointmult != 1.0) { *outp *= fpointmult; *(outp + 1) *= fpointmult; } //zerofill(outp + npadj, ftpar.fn0 - npadj); last = cblock + 1; } // multiply outp by ctcount outp = (float *)outblock.data; outp += npadj; for(i = 0; i < npadj; i++) *(--outp) *= ctcount; setheader(&outblock, status, 0, cblock+1, ftpar.hypercomplex); first += step; } else { setheader(&outblock, 0, 0, cblock, ftpar.hypercomplex); } if ( (res = D_markupdated(D_DATAFILE, cblock)) ) { D_error(res); releaseAllWithId("ft2d"); disp_index(0); disp_status(" "); ABORT; } if ( (res = D_release(D_DATAFILE, cblock)) ) { D_error(res); releaseAllWithId("ft2d"); disp_index(0); disp_status(" "); ABORT; } cblock++; if (!blocksdone) blocksdone = (first > lastcblock); } if ( (last != ftpar.nblocks) && (last != MAXINT) ) { if ( (res = D_gethead(D_DATAFILE, &datahead)) ) { D_error(res); disp_index(0); disp_status(" "); ABORT; } datahead.nblocks = last; if ( (res = D_updatehead(D_DATAFILE, &datahead)) ) { D_error(res); disp_index(0); disp_status(" "); ABORT; } } releasevarlist(); releaseAllWithId("ft2d"); disp_index(0); disp_status(" "); D_close(D_USERFILE); D_flush(D_DATAFILE); D_trash(D_DATAFILE); D_trash(D_PHASFILE); // save procpar strcpy(filepath,newfidpath); strcat(filepath,"/procpar"); if(npx == npadj) { saveProcpar(filepath); } else { double sw,at, oldat; P_getreal(PROCESSED,"at", &oldat, 1); P_setreal(PROCESSED,"np",(double)npadj,1); if(!P_getreal(PROCESSED,"sw",&sw,1) && sw > 0) { at = npadj/(2*sw); P_setreal(PROCESSED,"at",at,1); } saveProcpar(filepath); P_setreal(PROCESSED,"np",(double)npx,1); P_setreal(PROCESSED,"at",oldat,1); } RETURN; }
int dpir(int argc, char *argv[], int retc, char *retv[]) /*************/ { int groups; int resets; int i, min, ysize; char name[64]; char tmpstr[MAXSTR]; (void) retc; (void) retv; if (argc > 1 && strcmp(argv[1],"off") == 0) { set_dpir_flag(0,""); redo_dpf_dpir(); RETURN; } else if (argc > 1 && strcmp(argv[1],"turnoff") == 0) { set_dpir_flag(0,""); RETURN; } vertflag=0; if ( ! P_getstring(GLOBAL, "integralOrient", tmpstr, 1, MAXSTR) ) { vertflag = (strcmp(tmpstr,"vert") == 0); } if (argc > 1 && strcmp(argv[1],"vert") == 0) { vertflag=1; } if(argc == 1 || strcmp(argv[1],"noli") != 0) { execString("nli\n"); } if (check_int(&resets)) { Werrprintf("intmod must not be set to 'full'"); ABORT; } if (resets <= 1) { Werrprintf("no integral resets are defined"); ABORT; } plot = (argv[0][0] == 'p'); if (select_init( 0, plot+1, NO_FREQ_DIM, NO_HEADERS, DO_CHECK2D, DO_SPECPARS, NO_BLOCKPARS, NO_PHASEFILE )) { ABORT; } if(strlen(argv[0]) > 4 && argv[0][4] == 'N') { normInt = 1; } else if(strlen(argv[0]) > 3 && argv[0][3] == 'N') { normInt = 1; } if ((groups = getregions(resets)) == 0) { ABORT; } min=mnumxpnts; for (i = 1; i <= groups; i++) { if(gb[i].lowlimit <= 0 || gb[i].highlimit <= 0 || gb[i].lowlimit >= (mnumxpnts-xcharpixels) || gb[i].highlimit >= (mnumxpnts-xcharpixels)) continue; if((gb[i].highlimit-gb[i].lowlimit) < min) min = gb[i].highlimit-gb[i].lowlimit; } if(min != 0 && min < 3*xcharpixels) ysize = 3; else ysize=2; if (!plot) { setwindows(); dispcalib = (float) (mnumypnts-ymin) / (float) wc2max; CharSize = ycharpixels + ycharpixels / 5; getOptName(INTEG_MARK,name); set_line_thickness(name); getOptName(INTEG_NUM,name); set_graphics_font(name); } else { double size = G_getCharSize("IntegralNum"); charsize(size); //charsize((double)0.7); dispcalib = ppmm / ymultiplier; CharSize = ycharpixels; } if (showPlotBox()) dpir_off=0.0; else dpir_off=9.0; if(dispcalib>0) { int size= 12; G_getSize("IntegralNum", &size); i = (int)(vp*dispcalib); if (vertflag && i < 4*size) { char cmd[64]; i = (int)(4*size/dispcalib)+1; if(vertflag) sprintf(cmd,"vp=%d ds %s('vert')\n",i,argv[0]); else sprintf(cmd,"vp=%d ds %s\n",i,argv[0]); if(!plot) execString(cmd); //Werrprintf("pir requires minimum vp of %d",i); RETURN; } else if (i < 3*size) { char cmd[64]; i = (int)(3*size/dispcalib)+1; if(vertflag) sprintf(cmd,"vp=%d ds %s('vert')\n",i,argv[0]); else sprintf(cmd,"vp=%d ds %s\n",i,argv[0]); if(!plot) execString(cmd); //Werrprintf("pir requires minimum vp of %d",i); RETURN; } } else { if (vp < 30) { char cmd[64]; i=30; if(vertflag) sprintf(cmd,"vp=%d ds %s('vert')\n",i,argv[0]); else sprintf(cmd,"vp=%d ds %s\n",i,argv[0]); if(!plot) execString(cmd); //Werrprintf("pir requires minimum vp of 30"); RETURN; } } //color(PARAM_COLOR); color(INTEG_MARK_COLOR); if (debug1) { Wscrprintf("dispcalib= %g, dfpnt2= %d, CharSize= %d, bottom= %d\n", dispcalib,dfpnt2,CharSize, dfpnt2 - CharSize + (int) (dispcalib * (vp - dpir_off - 5.0))); Wscrprintf("index highlimit lowlimit below\n"); for (i = 1; i <= groups; i++) Wscrprintf("%d %d %d %s\n",i,gb[i].highlimit,gb[i].lowlimit, (gb[i].below) ? "true" : "false"); } if(vertflag) { for (i = 1; i <= groups; i++) label_pirv(i); } else { for (i = 1; i <= groups; i++) label_pir(i, ysize); } if (!plot) { char cmd[64]; if(argc > 1) { if (isReal(argv[1]) ) sprintf(cmd,"%s(%s",argv[0],argv[1]); else sprintf(cmd,"%s('%s'",argv[0],argv[1]); for(i=2;i<argc;i++) { if (isReal(argv[i]) ) { strcat(cmd,","); strcat(cmd,argv[i]); } else { strcat(cmd,",'"); strcat(cmd,argv[i]); strcat(cmd,"'"); } } strcat(cmd,")\n"); } else sprintf(cmd,"%s\n",argv[0]); Wsetgraphicsdisplay("ds"); set_dpir_flag(1,cmd); } releaseAllWithId("dpir"); endgraphics(); disp_status(" "); set_graphics_font("Default"); RETURN; }
int dpf(int argc, char *argv[], int retc, char *retv[]) /*************/ { int groups; int noisemult_p = 0; int numlines,maxlines; int i; int donll = TRUE; int noneg = FALSE; int top = FALSE; char command[128]; char name[64]; (void) retc; (void) retv; Wturnoff_buttons(); leader_len = 20.0; axish = FALSE; axisp = FALSE; axisp_freq = 1.0; if (argc > 1) { for (i=1; i<argc; i++) { if (strcmp(argv[i],"off") == 0) { set_dpf_flag(0,""); redo_dpf_dpir(); RETURN; } else if (strcmp(argv[i],"turnoff") == 0) { set_dpf_flag(0,""); RETURN; } else if (strcmp(argv[i],"noll") == 0) donll = FALSE; else if (strcmp(argv[i],"pos") == 0) noneg = TRUE; else if (strcmp(argv[i],"top") == 0) top = TRUE; else if (strcmp(argv[i],"axish") == 0) axish = TRUE; else if (strcmp(argv[i],"axisp") == 0) { axisp = TRUE; P_getreal(PROCESSED,"sfrq",&axisp_freq,1); } else if (strcmp(argv[i],"leader") == 0) { if (((i+1) < argc) && isReal(argv[i+1]) ) { i++; leader_len = stringReal(argv[i]); } } else if (isReal(argv[i])) noisemult_p = i; } } if (donll) /* if not donll, dpf uses last previous line listing */ { if (noisemult_p != 0) { if (noneg) strcpy(command,"nll('dpf','pos',"); else strcpy(command,"nll('dpf',"); strcat(command,argv[noisemult_p]); strcat(command,")\n"); } else { if (noneg) strcpy(command,"nll('dpf','pos')\n"); else strcpy(command,"nll('dpf')\n"); } execString(command); } if(P_getreal(CURRENT, "dpf_sc2",&dpf_sc2,1)) dpf_sc2=sc2; if(P_getreal(CURRENT, "dpf_wc2",&dpf_wc2,1)) dpf_wc2=wc2; if(dpf_wc2>wc2) dpf_wc2=wc2; if(dpf_sc2<sc2) dpf_sc2=sc2; /* if (init2d(1,1)) return(ERROR); */ scale = vs; if (normflag) scale *= normalize; /* Wscrprintf("normflag=%d normalize=%g\n",normflag,normalize); */ plot = (argv[0][0] == 'p'); /*select_init(get_rev, dis_setup, fdimname, doheaders, docheck2d, dospecpars, doblockpars, dophasefile)*/ /*if (init2d(0,plot + 1)) return(ERROR); */ if (select_init( 0, plot+1, NO_FREQ_DIM, NO_HEADERS, DO_CHECK2D, DO_SPECPARS, NO_BLOCKPARS, NO_PHASEFILE )) return(ERROR); if ((numlines = getlines(noneg)) == 0) RETURN; if (!plot) { setwindows(); dispcalib = (float) (mnumypnts-ymin) / (float) wc2max; getOptName(PEAK_MARK,name); set_line_thickness(name); getOptName(PEAK_NUM,name); set_graphics_font(name); } else { double size = G_getCharSize("PeakNum"); charsize(size); //charsize((double)0.7); dispcalib = ppmm / ymultiplier; } CharSize = ycharpixels + ycharpixels / 5; maxlines = dnpnt / CharSize; if (maxlines < numlines) remove_lines(maxlines,&numlines); if (numlines > 0) { //color(PARAM_COLOR); color(PEAK_MARK_COLOR); groups = groupcheck(numlines); if (debug1) { Wscrprintf("index high low newhigh newlow highlimit lowlimit\n"); for (i = 1; i <= groups; i++) Wscrprintf("%d %d %d %d %d %d %d\n",i,ga[i].high,ga[i].low, ga[i].newhigh,ga[i].newlow,ga[i].highlimit,ga[i].lowlimit); } label_proc = (top) ? (PFV) label_top : (PFV) label_bot; for (i = 1; i <= groups; i++) label_group(i); if (!plot) { // construct the command, and set the flag and command char cmd[64]; if(argc > 1) { if (isReal(argv[1]) ) sprintf(cmd,"%s(%s",argv[0],argv[1]); else sprintf(cmd,"%s('%s'",argv[0],argv[1]); for(i=2;i<argc;i++) { if (isReal(argv[i]) ) { strcat(cmd,","); strcat(cmd,argv[i]); } else { strcat(cmd,",'"); strcat(cmd,argv[i]); strcat(cmd,"'"); } } strcat(cmd,")\n"); } else sprintf(cmd,"%s\n",argv[0]); Wsetgraphicsdisplay("ds"); set_dpf_flag(1, cmd); } } releaseAllWithId("dpf"); endgraphics(); disp_status(" "); set_graphics_font("Default"); RETURN; }