/* @(#)LoadFile.c 1.21 03 Mar 1995 */ /*----------------------------------------------------------------------------- Copyright (C) 1993, Molecular Structure Group of Biochemestry Dept. at University of California at San Francisco. These coded instructions, statements, and computer programs comprise unpublished proprietary information of the Molecular Structure Group of the Biochemistry Department at University of California at San Francisco, and are protected by Federal copyright law. They may not be disclosed to third parties, copied or duplicated in any form - in whole or in part - without the prior written consent of Molecular Structure Group of Biochemistry Department at University of California at San Francisco. -------------------------------------------------------------------------*/ #include "IWInclude.h" #include "WMInclude.h" #include "region.h" #define REGION_GROUP (1<<8) #define AUTO_SC_GROUP (1<<9) static int wmwgt, wmwgt1; Widget wave_wigt[IW_MAX_WAVE]; Widget str_wigt[IW_MAX_WAVE]; int convert = 0; int autotoggle = 0; char wave_str[5][40]; ProcData(nxyz, dmmm) int nxyz[3]; float dmmm[3]; { int i; int nxy; unsigned char *barray; int iw; float *src,*des; iw = region->in_cur_zwt[1]; if (region->header_mode[region->out_ar[0]] == IW_COMPLEX) nxy = nxyz[0] * nxyz[1] << 1; else nxy = nxyz[0] * nxyz[1]; src = (float *)region->data[one]; des = (float *)region->data[two]; if(convert) { barray = (unsigned char *)calloc(nxy,sizeof(char)); IWScaleImage(region->data[one],nxyz[0],nxyz[1], IW_FLOAT,region->scale[iw][0], region->scale[iw][1], region->scale[iw][2],region->scale[iw][3], barray); for(i=0;i dmmm[1]) dmmm[1] = des[i]; dmmm[2] += des[i]; } } void OpenFile(fid) int fid; { int i, dummy; int nwave; int nxyz[3],mxyz[3],mode; float fdummy; irdhdr_(&fid,nxyz,mxyz,&mode,&(region->scale[0][0]), &(region->scale[0][1]),&fdummy); sprintf(wave_str[0],"%.3f %.3f 1 0",region->scale[0][0], region->scale[0][1]); WMUpdateField(wave_wigt[0]); irtzwt_(&fid, &dummy, &nwave, &dummy, &dummy); for (i = 1; i < IW_MAX_WAVE; i++) { if (i < nwave) { irtwav_mm_(&fid, &i, &(region->scale[i][0]), &(region->scale[i][1])); sprintf(wave_str[i],"%.3f %.3f 1 0",region->scale[i][0], region->scale[i][1]); WMPasteWidget(wave_wigt[i]); WMPasteWidget(str_wigt[i]); WMUpdateField(wave_wigt[i]); } else { WMUnpasteWidget(wave_wigt[i]); WMUnpasteWidget(str_wigt[i]); } } WMUpdateGroup(REGION_GROUP); } set_scaling() { if (autotoggle) { region->file_scale[two] = 0; IPSetDefOutPutMode(SAME_AS_FIRST_INPUT); convert = 1; WMUpdateGroup(AUTO_SC_GROUP); convert = 0; WMUpdateGroup(AUTO_SC_GROUP); } else { if(convert) { region->file_scale[two] = 1; IPSetDefOutPutMode(0); } else { region->file_scale[two] = 0; IPSetDefOutPutMode(SAME_AS_FIRST_INPUT); } } } SetScaleSel() { if (region->header_mode[one] == IW_COMPLEX) { autotoggle = 0; region->noautoscale = 1; convert = 0; WMUpdateGroup(AUTO_SC_GROUP); WMDisableField(wmwgt); WMDisableField(wmwgt1); } else { WMEnableField(wmwgt); WMEnableField(wmwgt1); } } void reset_autoscale() { if (autotoggle == 0) region->noautoscale = 1; else { region->noautoscale = 0; set_scaling(); } } read_new_scale(wv) int wv; { sscanf(wave_str[wv],"%g %g %g %g",®ion->scale[wv][0], ®ion->scale[wv][1],®ion->scale[wv][2],®ion->scale[wv][3]); } SetMenu() { int i; float fone; char *sc_str = "W Scl: "; char *to_scale[] ={" load raw data ", "load scaled data"}; int loopcount[5] = {0,1,2,3,4}; region->noautoscale = 1; WMSetOffset(0, 0, 0, 0); WMNewRow(); WMAddInfoButton("?","LoadFile LOADING_MODE"); wmwgt = WMAddPulldown(to_scale, 2, &convert, set_scaling, NULL, 1, AUTO_SC_GROUP); wmwgt1 = WMAddToggleButton("autoscale ",&autotoggle,reset_autoscale,NULL,0,AUTO_SC_GROUP); WMNewRow(); for (i = 0; i < IW_MAX_WAVE; i++) { WMNewRow(); sprintf(sc_str, "W%d Scl", i); str_wigt[i] = (Widget) WMAddInfoButton(sc_str,"LoadFile W_SCL"); /* wave_wigt[i] = (Widget) WMAddFloatField(region->scale[i], 4, 22, 23, &fone, &fone, &one, NULL, NULL, 0, REGION_GROUP); */ sprintf(wave_str[i],"0.0 0.0 0 0"); wave_wigt[i] = (Widget)WMAddCharField(wave_str[i],40,22, read_new_scale,loopcount[i],1,REGION_GROUP); WMAttachRightSide(); WMNewRow(); } } IPAppSpecifics() { IPSetMenuTitle("LoadFile"); IPSetMenuLoc(450, 400); IPAddInput( one, " In:", True, False, OpenFile, one); IPAddOutput(two, "Out Window:", True, True, set_scaling, NULL); IPSetCustRoutine(PROC_FUNC,ProcData, NULL); IPSetCustRoutine(CUS_MENU,SetMenu,NULL); IPSetCustRoutine(OPEN_FILE,SetScaleSel,NULL); }