/* @(#)procedures.c 17.1.1.1 (ES0-DMD) 01/25/02 17:27:21 */ /*=========================================================================== Copyright (C) 1995 European Southern Observatory (ESO) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Massachusetss Ave, Cambridge, MA 02139, USA. Corresponding concerning ESO-MIDAS should be addressed as follows: Internet e-mail: midas@eso.org Postal address: European Southern Observatory Data Management Division Karl-Schwarzschild-Strasse 2 D 85748 Garching bei Muenchen GERMANY ===========================================================================*/ /* @(#)procedures.c 1.1 (ESO) 7/20/93 23:27:48 */ #include #include /* Include structures for the clock bitmap. It should be in an include file (next version of the standards). */ static unsigned char clock1_bits[] = { 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0xfd, 0x32, 0xfe, 0x30, 0xfd, 0x32, 0xfe, 0x30, 0xfd, 0x32, 0xfe, 0x30, 0xfa, 0x32, 0xfe, 0x30, 0x7a, 0x31, 0xfe, 0x30, 0xb4, 0x30, 0xfe, 0x30, 0x48, 0x30, 0xfe, 0x30, 0x48, 0x30, 0xfe, 0x30, 0x84, 0x30, 0xfe, 0x30, 0x02, 0x31, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe}; static unsigned char clock2_bits[] = { 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0xfd, 0x32, 0xfe, 0x30, 0xfd, 0x32, 0xfe, 0x30, 0xfa, 0x32, 0xfe, 0x30, 0x7a, 0x31, 0xfe, 0x30, 0xb4, 0x30, 0xfe, 0x30, 0x78, 0x30, 0xfe, 0x30, 0x78, 0x30, 0xfe, 0x30, 0x84, 0x30, 0xfe, 0x30, 0x02, 0x31, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x31, 0x32, 0xfe, 0x30, 0x79, 0x32, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe}; static unsigned char clock3_bits[] = { 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x85, 0x32, 0xfe, 0x30, 0xfd, 0x32, 0xfe, 0x30, 0xfa, 0x32, 0xfe, 0x30, 0x7a, 0x31, 0xfe, 0x30, 0xb4, 0x30, 0xfe, 0x30, 0x78, 0x30, 0xfe, 0x30, 0x78, 0x30, 0xfe, 0x30, 0x84, 0x30, 0xfe, 0x30, 0x02, 0x31, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x31, 0x32, 0xfe, 0x30, 0x79, 0x32, 0xfe, 0x30, 0xfd, 0x32, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe}; static unsigned char clock4_bits[] = { 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0xfe, 0x32, 0xfe, 0x30, 0x7a, 0x31, 0xfe, 0x30, 0xb4, 0x30, 0xfe, 0x30, 0x78, 0x30, 0xfe, 0x30, 0x78, 0x30, 0xfe, 0x30, 0x84, 0x30, 0xfe, 0x30, 0x02, 0x31, 0xfe, 0x30, 0x31, 0x32, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x31, 0x32, 0xfe, 0x30, 0x79, 0x32, 0xfe, 0x30, 0xfd, 0x32, 0xfe, 0x30, 0xfd, 0x32, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe}; static unsigned char clock5_bits[] = { 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x32, 0x32, 0xfe, 0x30, 0x7a, 0x31, 0xfe, 0x30, 0xb4, 0x30, 0xfe, 0x30, 0x78, 0x30, 0xfe, 0x30, 0x78, 0x30, 0xfe, 0x30, 0x84, 0x30, 0xfe, 0x30, 0x02, 0x31, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x31, 0x32, 0xfe, 0x30, 0xfd, 0x32, 0xfe, 0x30, 0xff, 0x33, 0xfe, 0x30, 0xff, 0x33, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe}; static unsigned char clock6_bits[] = { 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x02, 0x32, 0xfe, 0x30, 0x32, 0x31, 0xfe, 0x30, 0xb4, 0x30, 0xfe, 0x30, 0x78, 0x30, 0xfe, 0x30, 0x78, 0x30, 0xfe, 0x30, 0x84, 0x30, 0xfe, 0x30, 0x32, 0x31, 0xfe, 0x30, 0x31, 0x32, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x31, 0x32, 0xfe, 0x30, 0xfd, 0x32, 0xfe, 0x30, 0xff, 0x33, 0xfe, 0x30, 0xff, 0x33, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe}; static unsigned char clock7_bits[] = { 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x02, 0x32, 0xfe, 0x30, 0x02, 0x31, 0xfe, 0x30, 0x84, 0x30, 0xfe, 0x30, 0x78, 0x30, 0xfe, 0x30, 0x78, 0x30, 0xfe, 0x30, 0x84, 0x30, 0xfe, 0x30, 0x02, 0x31, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x31, 0x32, 0xfe, 0x30, 0x79, 0x32, 0xfe, 0x30, 0xfd, 0x32, 0xfe, 0x30, 0xff, 0x33, 0xfe, 0x30, 0xff, 0x33, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe}; static unsigned char clock8_bits[] = { 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x02, 0x32, 0xfe, 0x30, 0x02, 0x31, 0xfe, 0x30, 0x84, 0x30, 0xfe, 0x30, 0x48, 0x30, 0xfe, 0x30, 0x48, 0x30, 0xfe, 0x30, 0x84, 0x30, 0xfe, 0x30, 0x02, 0x31, 0xfe, 0x30, 0x01, 0x32, 0xfe, 0x30, 0x79, 0x32, 0xfe, 0x30, 0xfd, 0x32, 0xfe, 0x30, 0xfd, 0x32, 0xfe, 0x30, 0xff, 0x33, 0xfe, 0x30, 0xff, 0x33, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0xf8, 0xff, 0x7f, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe}; init_values() { char out_val[80]; sprintf(out_val,"%d",specLineNum); UxPutText(UxFindSwidget("CurrLine"),out_val); sprintf(out_val,"%d",specLineStep); UxPutText(UxFindSwidget("Linestep"),out_val); sprintf(out_val,"%d",fitDegree); UxPutText(UxFindSwidget("degree_text"),out_val); sprintf(out_val,"%d",gaussNumOfComp); UxPutText(UxFindSwidget("Components"),out_val); sprintf(out_val,"%d",gaussMaxIterations); UxPutText(UxFindSwidget("iterations_text"),out_val); sprintf(out_val,"%d",gaussMinIterations); UxPutText(UxFindSwidget("iterations_text1"),out_val); sprintf(out_val,"%d",filterWindWidth); UxPutText(UxFindSwidget("width_text"),out_val); sprintf(out_val,"%g",plotAngle); UxPutText(UxFindSwidget("AngleText"),out_val); sprintf(out_val,"%d",0); UxPutText(UxFindSwidget("dyText"),out_val); UxPutText(UxFindSwidget("nText"),out_val); sprintf(out_val,"%g",plotSize); UxPutText(UxFindSwidget("SizeText"),out_val); XtSetSensitive(UxGetWidget(UxFindSwidget("UndoItem")),0); putFontText(plotFont); specModLineStep = FALSE; specModLineNum = FALSE; fitModFitDeg = FALSE; gaussModNumOfComp = FALSE; filterModWindWidth = FALSE; plotModSize = FALSE; plotModAngle = FALSE; OverPlotMode = FALSE; ApplyOverPlot = FALSE; specCurrCursor = 0; init_AMatrix(); system("rm -f alicel.plt alice.plt TMPalice.tbl pscrplot.0 TMPalice.prg TMPalice.stat"); system("touch TMPalice.tbl TMPalice.prg TMPalice.stat"); } /* getFitValue(fitvalues,i,na) : set the fitvalues array using the gaussAMatrix matrix. i : fitvalues[i] will be setted. na : number of fit value. */ double getFitValue(fitvalues,i,na) double fitvalues[]; int i,na; { int j; double ret = 0.0; i--; if(gaussAMatrix[i][i] == 1.0) return( fitvalues[i+1]); else for(j=0;j OverY[pos][i]) min = OverY[pos][i]; if(max < OverY[pos][i]) max = OverY[pos][i]; } overYmin = min; overYmax = max; sprintf(out_val,"%g",overYmin); UxPutText(UxFindSwidget("yminText"),out_val); UxPutEditable(UxFindSwidget("yminText"),"false"); sprintf(out_val,"%g",overYmax); UxPutText(UxFindSwidget("ymaxText"),out_val); UxPutEditable(UxFindSwidget("ymaxText"),"false"); } Yscaling_manual() { float min,max; UxPutEditable(UxFindSwidget("yminText"),"true"); UxPutEditable(UxFindSwidget("ymaxText"),"true"); sscanf(UxGetText(UxFindSwidget("yminText")),"%f",&min); sscanf(UxGetText(UxFindSwidget("ymaxText")),"%f",&max); overYmin = min; overYmax = max; } /* cursor() : read the "Initial Guess" field and ask for not entered ones. */ cursor() { int i,j,key,ndata; char name[20],out[80],s1[80],s2[80],s3[80],num[4]; float x1,x2,y1,aux,contin,v1,v2,v3; float fit_cont(); for(i=0,j=0;i<9;i++) { sprintf(name,"toggleButton%d",i+1); if(XmToggleButtonGetState(UxGetWidget(UxFindSwidget(name)))) { j++; sprintf(num,"%d",j); UxPutLabelString(UxFindSwidget(name),num); XFlush(UxDisplay); } } for(i=0;i<9 & j x2) { aux = x2; x2 = x1; x1 = aux; } contin = fit_cont(gaussFitValues[j*3+1]); gaussFitValues[j*3] = y1-contin; gaussFitValues[j*3+2] = (x2-x1)/2; sprintf(out,"%9.8g %9.8g %9.8g",gaussFitValues[j*3], gaussFitValues[j*3+1],gaussFitValues[j*3+2]); sprintf(name,"textField%d",i+11); XmTextSetString(UxGetWidget(UxFindSwidget(name)),out); draw_sgauss(gaussFitValues[j*3],gaussFitValues[j*3+1], gaussFitValues[j*3+2],3); } else specAbortCursor = TRUE; } else specAbortCursor = TRUE; } else specAbortCursor = TRUE; j++; } else { sprintf(name,"toggleButton%d",i+1); if(XmToggleButtonGetState(UxGetWidget(UxFindSwidget(name)))) j++; } } } /* put_iterations(i) : set the "Current Iteration" field. i : current iteration. */ put_iterations(i) int i; { char out[20]; sprintf(out,"%d",i); UxPutText(UxFindSwidget("iterations_text2"),out); } /* out_errors() : print the gaussian standar deviation */ out_errors() { char out[1920]; char line[80]; strcpy(out,"\t Gaussian Standard Deviation \n\n Comp\t Amplitude\t Position\t\t Width\n"); for(i=0;i