void open_freq_file(Widget w, char *str, XtPointer call_data) { double fl, fu, tmp; void SetWatchCursor(), SetAnyToggle(); double SpecUnitConv(); fl = SpecUnitConv(UNIT_FRE, vP->xunit, vP->xleft); fu = SpecUnitConv(UNIT_FRE, vP->xunit, vP->xright); if (fl > fu) {tmp = fl; fl = fu; fu = tmp;} SetWatchCursor(True); if (strncmp(str, "SLAIM", 5)==0) { make_freq_file("SLAIM", 0, fl, fu); } else if (strncmp(str, "JPL", 3)==0) { make_freq_file("JPL", 0, fl, fu); } else if (strncmp(str, "LOVAS", 5)==0) { make_freq_file("LOVAS", 0, fl, fu); } else if (strncmp(str, "iSLAIM", 6)==0) { make_freq_file("SLAIM", -1, fl, fu); } else if (strncmp(str, "iJPL", 4)==0) { make_freq_file("JPL", -1, fl, fu); } else if (strncmp(str, "iLOVAS", 6)==0) { make_freq_file("LOVAS", -1, fl, fu); } else if (strncmp(str, "mSLAIM", 6)==0) { make_freq_file("SLAIM", 1, fl, fu); SetAnyToggle("markers", 1); } else if (strncmp(str, "mJPL", 4)==0) { make_freq_file("JPL", 1, fl, fu); SetAnyToggle("markers", 1); } else if (strncmp(str, "mIDENT", 6)==0) { make_freq_file("IDENT", 1, fl, fu); SetAnyToggle("markers", 1); } else if (strncmp(str, "sgrb2", 5)==0) { make_freq_file(str, 1, fl, fu); SetAnyToggle("markers", 1); } else if (strncmp(str, "orion", 5)==0) { make_freq_file(str, 1, fl, fu); SetAnyToggle("markers", 1); } else if (strncmp(str, "mLOVAS", 6)==0) { make_freq_file("LOVAS", 1, fl, fu); SetAnyToggle("markers", 1); } else if (strncmp(str, "imSLAIM", 7)==0) { make_freq_file("SLAIM", 2, fl, fu); SetAnyToggle("markers", 1); } else if (strncmp(str, "imJPL", 5)==0) { make_freq_file("JPL", 2, fl, fu); SetAnyToggle("markers", 1); } else if (strncmp(str, "imLOVAS", 7)==0) { make_freq_file("LOVAS", 2, fl, fu); SetAnyToggle("markers", 1); } SetWatchCursor(False); }
void GUI_GeneralPreview(Widget w,XtPointer client, XtPointer call) { struct CTransform *ctransform=(struct CTransform *)client; struct FFTSound *copy; int length; PlayStopHard(); if( ! DA_initialized(ctransform->fftsound)){ fprintf(stderr,"No Sound loaded\n"); return; } XmUpdateDisplay(w); SetWatchCursor(topLevel); if(ctransform->doprogress==true){ XtVaSetValues(progressScale, XmNvalue, 0, NULL); XtManageChild(progressDialog); } while (XtAppPending(app_context)) { XtAppProcessEvent(app_context,XtIMXEvent|XtIMTimer|XtIMAlternateInput); } length=min(areat2-areat1,CONFIG_getMaxPreviewLength(ctransform->fftsound)); copy=makeFFTSoundCopy(ctransform->fftsound,areat1,areat1+length); copyFFTSound(ctransform->fftsound,copy,areat1); // copy=ctransform->fftsound; (*ctransform->Transform)(ctransform,ctransform->pointer,copy,0,length,areat1); Play(copy,0,length); /* if(pthread_create(&pthread,NULL,DoPlay,copy)!=0){ fprintf(stderr,"Could not make pthread\n"); } */ // RedrawWin(ctransform->fftsound); if(ctransform->doprogress==true) XtUnmanageChild(progressDialog); ResetCursor(topLevel); }
OSErr EditCDOGProfilesDialog(DepthValuesSetH *depthvals, /*float *cellLength, long *numCells,*/ WindowPtr parentWindow) { short item; sgDepthValuesH = *depthvals; //sCellLength = *cellLength; //sNumCells = *numCells; item = MyModalDialog(EDIT_PROFILES_DLGID, mapWindow, 0, EditProfilesInit, EditProfilesClick); SetWatchCursor(); if(item == EPOK) { *depthvals = sgDepthValuesH; //*cellLength = sCellLength; //*numCells = sNumCells; model->NewDirtNotification();// JLM return 0; } else if(item == EPCANCEL) return USERCANCEL; else return -1; }
void GUI_GeneralOk(Widget w,XtPointer client, XtPointer call) { struct CTransform *ctransform=(struct CTransform *)client; if( ! DA_initialized(ctransform->fftsound)){ fprintf(stderr,"No Sound loaded\n"); return; } XmUpdateDisplay(w); SetWatchCursor(topLevel); if(ctransform->doprogress==true){ XtVaSetValues(progressScale, XmNvalue, 0, NULL); XtManageChild(progressDialog); } while (XtAppPending(app_context)) { XtAppProcessEvent(app_context,XtIMXEvent|XtIMTimer|XtIMAlternateInput); } UNDO_addTransform(ctransform->fftsound); (*ctransform->Transform)(ctransform,ctransform->pointer,ctransform->fftsound,areat1,areat2,0); SetVisibleFunc(1,2); SetVisibleFunc(2,2); SetVisibleFunc(3,2); RedrawWin(ctransform->fftsound); if(ctransform->doprogress==true) XtUnmanageChild(progressDialog); ResetCursor(topLevel); XtUnmanageChild(ctransform->parentwidget); }
static void DoInterpolateMap(Widget w, StdForm *sf, XmListCallbackStruct *cb) { int i, j, nX, nY; int err, type, order, corners; double xspa, yspa; string buf; MAP *m, *old = (MAP *)sf->any; int **L; double **A; int FillHolesInArray(), InterpolateArray(); void FreeIntArray(), FreeDoubleArray(); int **AllocIntArray(); double **AllocDoubleArray(); void send_line(), wsscanf(), SetWatchCursor(); void MapDraw(), SetIntpOrder(); int GetIntpType(), GetIntpOrder(), GetIntpCorners(); MAP *new_map(); list *get_maplist(); if (!old) { PostErrorDialog(w, "No map selected to be interpolated."); return; } type = GetIntpType(); order = GetIntpOrder(); corners = GetIntpCorners(); if (order <= 0) { PostWarningDialog(w, "Selected interpolation order is zero."); return; } nX = old->i_no; nY = old->j_no; xspa = old->xspacing; yspa = old->yspacing; A = AllocDoubleArray(nX, nY); if (!A) { PostErrorDialog(NULL, "InterpolateMap: Out of memory."); return; } L = AllocIntArray(nX, nY); if (!L) { FreeDoubleArray(A, nX, nY); PostErrorDialog(NULL, "InterpolateMap: Out of memory."); return; } SetWatchCursor(True); for (i=0; i<nX; i++) { for (j=0; j<nY; j++) { A[i][j] = old->d[i][j]; if (old->f[i][j] <= BLANK) L[i][j] = EMPTY; else L[i][j] = FILLED; } } if (corners > 0) err = FillHolesInArray(A, L, nX, nY, corners); if ((i = order)) { while (i) { err = InterpolateArray(&A, &L, &nX, &nY, type); if (err != 0) { sprintf(buf, "Couldn't interpolate array. err=%d.", err); send_line(buf); if (A) FreeDoubleArray(A, nX, nY); if (L) FreeIntArray(L, nX, nY); SetWatchCursor(False); PostErrorDialog(NULL, buf); return; } xspa /= 2.0; yspa /= 2.0; i--; if (corners > 0) err = FillHolesInArray(A, L, nX, nY, corners); } } m = new_map(get_maplist(), nX, nY); m->type = old->type; m->swapped = old->swapped; m->memed = old->memed; m->original = old->original; m->x0 = old->x0; m->y0 = old->y0; m->xleft = old->xleft; m->xright = old->xright; m->ylower = old->ylower; m->yupper = old->yupper; m->date = old->date; strcpy(m->molecule, old->molecule); m->interpolated = old->interpolated + 1; m->equinox = old->equinox; m->epoch = old->epoch; m->ndata = nX * nY; m->i_min = NINT(m->xleft/xspa); m->i_max = NINT(m->xright/xspa); m->j_min = NINT(m->ylower/yspa); m->j_max = NINT(m->yupper/yspa); m->xspacing = xspa; m->yspacing = yspa; for (i=0; i<nX; i++) { for (j=0; j<nY; j++) { if (L[i][j] == FILLED) { m->f[i][j] = UNBLANK; m->d[i][j] = A[i][j]; m->e[i][j] = UNDEF; } else { m->f[i][j] = BLANK; m->d[i][j] = UNDEF; m->e[i][j] = UNDEF; } } } FreeDoubleArray(A, nX, nY); FreeIntArray(L, nX, nY); SetWatchCursor(False); wsscanf(sf->edit[0], m->name); sprintf(buf, "Interpolated map stored as '%s': %dx%d\n", m->name, nX, nY); send_line(buf); XtDestroyWidget(sf->form); SetIntpOrder(0); MapDraw(NULL, m, NULL); }
Boolean AskUserForGetFileName(char* prompt_string, short numTypes, OSType typeList[], // char* pathOfFileSelected, short maxPathLength, FSSpec *specPtr, MyCustomNavItemsData *myCustomItemsDataPtr) { OSStatus err = 0; NavDialogCreationOptions dialogOptions; NavTypeListHandle inTypeList = 0; NavEventUPP inEventProc = 0; NavPreviewUPP inPreviewProc = 0; NavObjectFilterUPP inFilterProc = 0; Ptr inClientData = (Ptr)myCustomItemsDataPtr; NavDialogRef navDialogRef = 0; NavReplyRecord replyRecord; Boolean gotReply = false; FSSpec fsSpec; char pathName[256]=""; CFStringRef windowTitleCFStrRef = 0; CFStringRef clientNameCFStrRef = 0; if(specPtr) memset(specPtr,0,sizeof(specPtr)); if(pathOfFileSelected && maxPathLength > 0) pathOfFileSelected[0] = 0; err = NavGetDefaultDialogCreationOptions(&dialogOptions); if(err) return false; // for now don't customize the dialogs, may want to do this later /*if(myCustomItemsDataPtr && myCustomItemsDataPtr->ditlResID) { inEventProc = GetMyNavEventHandlerUPP(); }*/ if(prompt_string && prompt_string[0]) { windowTitleCFStrRef = CFStringCreateWithCString(NULL, prompt_string, kCFStringEncodingMacRoman); dialogOptions.windowTitle = windowTitleCFStrRef; } // set the client name so the system can remember the last place the user looked clientNameCFStrRef = CFStringCreateWithCString(NULL, "GNOME", kCFStringEncodingMacRoman); dialogOptions.clientName = clientNameCFStrRef; //inTypeList = MyCreateNavTypeListHandle(gMySignature,numTypes,typeList); // for now allow all files to be shown, filtering is messed up on 10.6 //err = NavCreateChooseFileDialog (&dialogOptions,inTypeList,inEventProc,inPreviewProc,inFilterProc,inClientData,&navDialogRef); err = NavCreateChooseFileDialog (&dialogOptions,inTypeList,inEventProc,inPreviewProc,inFilterProc,NULL,&navDialogRef); if(err) return false; InitCursor(); err = NavDialogRun(navDialogRef); SetWatchCursor(); if(err) goto done; err = NavDialogGetReply(navDialogRef,&replyRecord); if(err) goto done; gotReply = true; err = AEGetNthPtr(&(replyRecord.selection), 1, typeFSS, NULL, NULL, &fsSpec, sizeof(fsSpec), NULL); if(err) goto done; (void)PathNameFromDirID(fsSpec.parID,fsSpec.vRefNum,pathName);//GetPathWithDelimiterFromDirID mypstrcatJM((StringPtr)pathName,fsSpec.name); my_p2cstr(pathName); if(strlen(pathName) < maxPathLength){ strcpy(pathOfFileSelected,pathName); } else { err = -1; // path is too long to return } if(!err && specPtr) *specPtr = fsSpec; done: if(inTypeList) {DisposeHandle((Handle)inTypeList); inTypeList = 0;} if(windowTitleCFStrRef) { CFRelease(windowTitleCFStrRef); windowTitleCFStrRef = 0;} if(clientNameCFStrRef) { CFRelease(clientNameCFStrRef); clientNameCFStrRef = 0;} if(gotReply) NavDisposeReply(&replyRecord); NavDialogDispose(navDialogRef); if(gotReply && !err) return true; return false; } /* end MyGetMacFile() */
Boolean AskUserForPutFileName(char* promptStr, char* defaultName, char* pathOfFileSelected, short maxPathLength, FSSpec *specPtr, MyCustomNavItemsData *myCustomItemsDataPtr) { OSStatus err = 0; NavDialogCreationOptions dialogOptions; OSType inFileType = 'TEXT'; // what will happen if we always just say TEXT and change our mind later ? (perhaps it will add .txt) ? OSType inFileCreator = kNavGenericSignature; NavEventUPP inEventProc = 0; Ptr inClientData = (Ptr)myCustomItemsDataPtr; NavDialogRef navDialogRef = 0; NavReplyRecord replyRecord; Boolean gotReply = false; FSSpec fsSpec; char pathName[256]=""; char theFileName[256]=""; CFStringRef windowTitleCFStrRef = 0; CFStringRef clientNameCFStrRef = 0; CFStringRef saveFileNameCFStrRef = 0; if(specPtr) memset(specPtr,0,sizeof(specPtr)); if(pathOfFileSelected && maxPathLength > 0) pathOfFileSelected[0] = 0; err = NavGetDefaultDialogCreationOptions(&dialogOptions); if(err) return false; // for now don't customize the dialogs, may want to do this later /*if(myCustomItemsDataPtr && myCustomItemsDataPtr->ditlResID) { inEventProc = GetMyNavEventHandlerUPP(); }*/ if(promptStr && promptStr[0]) { windowTitleCFStrRef = CFStringCreateWithCString(NULL, promptStr,kCFStringEncodingMacRoman); dialogOptions.windowTitle = windowTitleCFStrRef; } // set the client name so the system can remember the last place the user looked clientNameCFStrRef = CFStringCreateWithCString(NULL,"GNOME",kCFStringEncodingMacRoman); dialogOptions.clientName = clientNameCFStrRef; if(defaultName && defaultName[0]) { saveFileNameCFStrRef = CFStringCreateWithCString(NULL, defaultName,kCFStringEncodingMacRoman); dialogOptions.saveFileName = saveFileNameCFStrRef; } //err = NavCreatePutFileDialog(&dialogOptions,inFileType,inFileCreator,inEventProc,inClientData,&navDialogRef); err = NavCreatePutFileDialog(&dialogOptions,inFileType,inFileCreator,inEventProc,NULL,&navDialogRef); if(err) return false; InitCursor(); err = NavDialogRun(navDialogRef); SetWatchCursor(); if(err) goto done; err = NavDialogGetReply(navDialogRef,&replyRecord); if(err) goto done; gotReply = true; err = AEGetNthPtr(&(replyRecord.selection), 1, typeFSS, NULL, NULL, &fsSpec, sizeof(fsSpec), NULL); if(err) goto done; (void)PathNameFromDirID(fsSpec.parID,fsSpec.vRefNum,pathName); // GetPathWithDelimiterFromDirID mypstrcatJM((StringPtr)pathName,fsSpec.name); my_p2cstr(pathName); (void)CFStringGetCString(replyRecord.saveFileName,theFileName,256,kCFStringEncodingMacRoman); if( (strlen(pathName) + 1 + strlen(theFileName)) < maxPathLength){ strcpy(pathOfFileSelected,pathName); strcat(pathOfFileSelected,":"); strcat(pathOfFileSelected,theFileName); } else { err = -1; // path is too long to return } if(!err && specPtr) *specPtr = fsSpec; done: if(windowTitleCFStrRef) { CFRelease(windowTitleCFStrRef); windowTitleCFStrRef = 0;} if(clientNameCFStrRef) { CFRelease(clientNameCFStrRef); clientNameCFStrRef = 0;} if(saveFileNameCFStrRef) { CFRelease(saveFileNameCFStrRef); saveFileNameCFStrRef = 0;} if(gotReply) NavDisposeReply(&replyRecord); NavDialogDispose(navDialogRef); if(gotReply && !err) return true; return false; }