| 1 |
/*=========================================================================== |
| 2 |
Copyright (C) 1993-2009 European Southern Observatory (ESO) |
| 3 |
|
| 4 |
This program is free software; you can redistribute it and/or |
| 5 |
modify it under the terms of the GNU General Public License as |
| 6 |
published by the Free Software Foundation; either version 2 of |
| 7 |
the License, or (at your option) any later version. |
| 8 |
|
| 9 |
This program is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
GNU General Public License for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU General Public |
| 15 |
License along with this program; if not, write to the Free |
| 16 |
Software Foundation, Inc., 675 Massachusetts Ave, Cambridge, |
| 17 |
MA 02139, USA. |
| 18 |
|
| 19 |
Correspondence concerning ESO-MIDAS should be addressed as follows: |
| 20 |
Internet e-mail: [email protected] |
| 21 |
Postal address: European Southern Observatory |
| 22 |
Data Management Division |
| 23 |
Karl-Schwarzschild-Strasse 2 |
| 24 |
D 85748 Garching bei Muenchen |
| 25 |
GERMANY |
| 26 |
===========================================================================*/ |
| 27 |
|
| 28 |
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ |
| 29 |
/* .IDENT cb_list.c */ |
| 30 |
/* .AUTHORS Pascal Ballester (ESO/Garching) */ |
| 31 |
/* Cristian Levin (ESO/La Silla) */ |
| 32 |
/* .KEYWORDS XLong, Spectroscopy, Long-Slit */ |
| 33 |
/* .PURPOSE */ |
| 34 |
/* .VERSION 1.0 Package Creation 17-MAR-1993 |
| 35 |
|
| 36 |
090825 laast modif */ |
| 37 |
/* ------------------------------------------------------- */ |
| 38 |
|
| 39 |
#include <gl_defs.h> |
| 40 |
#include <xm_defs.h> |
| 41 |
#include <main_defs.h> |
| 42 |
#include <spec_comm.h> |
| 43 |
#include <UxLib.h> |
| 44 |
|
| 45 |
#define DIR_DELIMITER '/' |
| 46 |
|
| 47 |
extern int AppendDialogText(), exist_airmass(); |
| 48 |
|
| 49 |
extern void InitSession(), SetFileList(), WriteKeyword(), UpdateDescriptors(); |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
static char FileIn[MAXLINE], FileOut[MAXLINE]; |
| 54 |
static int PopupDialogWindow, PopupExtinWindow; |
| 55 |
static float Airmass; |
| 56 |
|
| 57 |
int PopupList( list_type ) |
| 58 |
int list_type; |
| 59 |
{ |
| 60 |
int strip = 1; /* strip off the directories */ |
| 61 |
|
| 62 |
extern swidget FileListInterface; |
| 63 |
extern Widget FileListWidget; |
| 64 |
extern char DirSpecs[]; |
| 65 |
|
| 66 |
ListType = list_type; |
| 67 |
|
| 68 |
switch ( list_type ) { |
| 69 |
case LIST_WLC: |
| 70 |
SET_LIST_TITLE("Enter calibration frame"); |
| 71 |
strcpy(DirSpecs, "*.bdf"); |
| 72 |
break; |
| 73 |
case LIST_REBIN_RBR: |
| 74 |
case LIST_REBIN_2D: |
| 75 |
case LIST_REBIN_TBL: |
| 76 |
case LIST_EXTIN: |
| 77 |
case LIST_INTEGR: |
| 78 |
case LIST_FLUX_FILT: |
| 79 |
case LIST_FIT_SKY: |
| 80 |
case LIST_EXT_AVER: |
| 81 |
case LIST_EXT_WEIGHT: |
| 82 |
case LIST_CORRECT: |
| 83 |
SET_LIST_TITLE("Enter input image"); |
| 84 |
strcpy(DirSpecs, "*.bdf"); |
| 85 |
break; |
| 86 |
case LIST_LOAD_IMA: |
| 87 |
SET_LIST_TITLE("Enter image to load"); |
| 88 |
strcpy(DirSpecs, "*.bdf"); |
| 89 |
break; |
| 90 |
case LIST_SESSION: |
| 91 |
SET_LIST_TITLE("Enter parameters table"); |
| 92 |
strcpy(DirSpecs, "*ORDE.tbl"); |
| 93 |
break; |
| 94 |
case LIST_BROWSER: |
| 95 |
SET_LIST_TITLE("MIDAS browser"); |
| 96 |
/* DirSpecs[] was setted in the Browse menu callback first time */ |
| 97 |
strip = 0; /* keep the directories */ |
| 98 |
break; |
| 99 |
default: |
| 100 |
break; |
| 101 |
} |
| 102 |
|
| 103 |
SetFileList(FileListWidget, strip, DirSpecs); |
| 104 |
UxPopupInterface(FileListInterface, exclusive_grab); |
| 105 |
return 0; |
| 106 |
} |
| 107 |
|
| 108 |
void CallbackList( choice ) |
| 109 |
char *choice; |
| 110 |
{ |
| 111 |
char command[512], str[256]; |
| 112 |
char *sky; |
| 113 |
float fval; |
| 114 |
int i; |
| 115 |
int popdown_filelist = TRUE; |
| 116 |
|
| 117 |
extern swidget FileListInterface; |
| 118 |
extern swidget TextFieldSwidget; |
| 119 |
extern char DirSpecs[]; |
| 120 |
|
| 121 |
PopupDialogWindow = PopupExtinWindow = FALSE; |
| 122 |
Airmass = 1.0; |
| 123 |
command[0] = '\0'; |
| 124 |
|
| 125 |
switch ( ListType ) { |
| 126 |
case LIST_LOAD_IMA: |
| 127 |
sprintf(command, "%s %s", "LOAD/IMAGE", choice); |
| 128 |
break; |
| 129 |
case LIST_SESSION: |
| 130 |
choice[strlen(choice)-8] = '\0'; |
| 131 |
InitSession(choice); |
| 132 |
sprintf(command, "%s%s", C_INIT, choice); |
| 133 |
break; |
| 134 |
case LIST_WLC: |
| 135 |
UpdateDescriptors(choice); |
| 136 |
strcpy(command, C_SEARCH); |
| 137 |
break; |
| 138 |
case LIST_LINCAT: |
| 139 |
UxPutValue(TextFieldSwidget, choice); |
| 140 |
strcpy(Lincat, choice); |
| 141 |
WriteKeyword(Lincat, K_LINCAT); |
| 142 |
break; |
| 143 |
case LIST_GUESS: |
| 144 |
UxPutValue(TextFieldSwidget, choice); |
| 145 |
strcpy(Guess, choice); |
| 146 |
WriteKeyword(Guess, K_GUESS); |
| 147 |
break; |
| 148 |
case LIST_REBIN_RBR: |
| 149 |
case LIST_REBIN_2D: |
| 150 |
case LIST_REBIN_TBL: |
| 151 |
/*generation of the output image name */ |
| 152 |
for ( i = 0; choice[i] != '.' && choice[i] != '\0'; i++ ) |
| 153 |
; |
| 154 |
strncpy(FileOut, choice, i); |
| 155 |
FileOut[i] = '\0'; |
| 156 |
sprintf(FileOut, "%s_reb", FileOut); |
| 157 |
strcpy(FileIn, choice); |
| 158 |
PopupDialogWindow = TRUE; |
| 159 |
break; |
| 160 |
case LIST_EXTIN_TBL: |
| 161 |
UxPutValue(TextFieldSwidget, choice); |
| 162 |
strcpy(Extab, choice); |
| 163 |
WriteKeyword(Extab, K_EXTAB); |
| 164 |
break; |
| 165 |
case LIST_FLUX_TBL: |
| 166 |
UxPutValue(TextFieldSwidget, choice); |
| 167 |
strcpy(Fluxtab, choice); |
| 168 |
WriteKeyword(Fluxtab, K_FLUXTAB); |
| 169 |
break; |
| 170 |
case LIST_INTEGR: |
| 171 |
sprintf(command, "%s%s", C_INTEGR, choice); |
| 172 |
break; |
| 173 |
case LIST_FLUX_FILT: |
| 174 |
sprintf(command, "%s%s", C_FLUX_FILT, choice); |
| 175 |
break; |
| 176 |
case LIST_EXTIN: |
| 177 |
/* generation of the output image name */ |
| 178 |
for ( i = 0; choice[i] != '.' && choice[i] != '\0'; i++ ) |
| 179 |
; |
| 180 |
strncpy(FileOut, choice, i); |
| 181 |
FileOut[i] = '\0'; |
| 182 |
sprintf(FileOut, "%s_ext", FileOut); |
| 183 |
strcpy(FileIn, choice); |
| 184 |
PopupExtinWindow = TRUE; |
| 185 |
break; |
| 186 |
case LIST_FIT_SKY: |
| 187 |
sky = XmTextGetString(UxGetWidget(UxFindSwidget("tf_sky"))); |
| 188 |
sprintf(command, "%s%s %s", C_EXTR_FIT_SKY, choice, sky); |
| 189 |
XtFree(sky); |
| 190 |
break; |
| 191 |
case LIST_EXT_AVER: |
| 192 |
case LIST_EXT_WEIGHT: |
| 193 |
/* generation of the output image name */ |
| 194 |
for ( i = 0; choice[i] != '.' && choice[i] != '\0'; i++ ) |
| 195 |
; |
| 196 |
strncpy(FileOut, choice, i); |
| 197 |
FileOut[i] = '\0'; |
| 198 |
sprintf(FileOut, "%s_obj", FileOut); |
| 199 |
strcpy(FileIn, choice); |
| 200 |
PopupDialogWindow = TRUE; |
| 201 |
break; |
| 202 |
case LIST_CORRECT: |
| 203 |
/* generation of the output image name */ |
| 204 |
for ( i = 0; choice[i] != '.' && choice[i] != '\0'; i++ ) |
| 205 |
; |
| 206 |
strncpy(FileOut, choice, i); |
| 207 |
FileOut[i] = '\0'; |
| 208 |
sprintf(FileOut, "%s_cor", FileOut); |
| 209 |
strcpy(FileIn, choice); |
| 210 |
PopupDialogWindow = TRUE; |
| 211 |
break; |
| 212 |
case LIST_BROWSER: |
| 213 |
for ( i = 0; choice[i] != DIR_DELIMITER && choice[i] != '\0'; i++ ) |
| 214 |
; |
| 215 |
if ( choice[i] == DIR_DELIMITER ) { |
| 216 |
strcat(DirSpecs, choice); |
| 217 |
PopupList(LIST_BROWSER); |
| 218 |
popdown_filelist = FALSE; |
| 219 |
} |
| 220 |
else |
| 221 |
sprintf(command, "$cp %s%s %s", DirSpecs, choice, choice); |
| 222 |
break; |
| 223 |
} |
| 224 |
XtFree(choice); |
| 225 |
|
| 226 |
if ( popdown_filelist ) |
| 227 |
UxPopdownInterface(FileListInterface); |
| 228 |
|
| 229 |
if ( PopupExtinWindow ) { |
| 230 |
DialogType = DIALOG_EXTIN; |
| 231 |
UxPutValue(UxFindSwidget("tf_output_extin"), FileOut); |
| 232 |
if ( exist_airmass(FileIn, &fval) ) |
| 233 |
Airmass = fval; |
| 234 |
sprintf(str, "%.4f", Airmass); |
| 235 |
UxPutValue(UxFindSwidget("tf_airmass"), str); |
| 236 |
UxPopupInterface(UxFindSwidget("extin_dialog"), exclusive_grab); |
| 237 |
} |
| 238 |
else if ( PopupDialogWindow ) { |
| 239 |
switch ( ListType ) { |
| 240 |
case LIST_REBIN_RBR: |
| 241 |
SET_DIALOG_PROMPT("Enter output image :"); |
| 242 |
DialogType = DIALOG_REBIN_RBR; |
| 243 |
break; |
| 244 |
case LIST_REBIN_2D: |
| 245 |
SET_DIALOG_PROMPT("Enter output image :"); |
| 246 |
DialogType = DIALOG_REBIN_2D; |
| 247 |
break; |
| 248 |
case LIST_REBIN_TBL: |
| 249 |
SET_DIALOG_PROMPT("Enter output table :"); |
| 250 |
DialogType = DIALOG_REBIN_TBL; |
| 251 |
break; |
| 252 |
case LIST_EXT_AVER: |
| 253 |
SET_DIALOG_PROMPT("Enter output image :"); |
| 254 |
DialogType = DIALOG_EXT_AVER; |
| 255 |
break; |
| 256 |
case LIST_EXT_WEIGHT: |
| 257 |
SET_DIALOG_PROMPT("Enter output image :"); |
| 258 |
DialogType = DIALOG_EXT_WEIGHT; |
| 259 |
break; |
| 260 |
case LIST_CORRECT: |
| 261 |
SET_DIALOG_PROMPT("Enter output image :"); |
| 262 |
DialogType = DIALOG_CORRECT; |
| 263 |
break; |
| 264 |
} |
| 265 |
UxPutValue(UxFindSwidget("tf_file_dialog"), FileOut); |
| 266 |
UxPopupInterface(UxFindSwidget("file_dialog"), exclusive_grab); |
| 267 |
} |
| 268 |
else if ( command[0] != '\0' ) |
| 269 |
AppendDialogText(command); |
| 270 |
|
| 271 |
} |
| 272 |
|
| 273 |
void CallbackDialog() |
| 274 |
{ |
| 275 |
char command[128]; |
| 276 |
char *out, *fout, *sky; |
| 277 |
|
| 278 |
out = XmTextGetString(UxGetWidget(UxFindSwidget("tf_file_dialog"))); |
| 279 |
switch ( DialogType ) { |
| 280 |
case DIALOG_SESSION: |
| 281 |
strcpy(Session, out); |
| 282 |
sprintf(command, "%s%s", C_SAVE, Session); |
| 283 |
break; |
| 284 |
case DIALOG_REBIN_RBR: |
| 285 |
sprintf(command, "%s%s %s", C_REBIN, FileIn, out); |
| 286 |
break; |
| 287 |
case DIALOG_REBIN_2D: |
| 288 |
sprintf(command, "%s%s %s", C_RECTIFY, FileIn, out); |
| 289 |
break; |
| 290 |
case DIALOG_REBIN_TBL: |
| 291 |
sprintf(command, "%s%s %s", C_APP_DISP, FileIn, out); |
| 292 |
break; |
| 293 |
case DIALOG_EXT_AVER: |
| 294 |
sprintf(command, "%s%s %s", C_EXTR_AVERAGE, FileIn, out); |
| 295 |
break; |
| 296 |
case DIALOG_EXT_WEIGHT: |
| 297 |
sky = XmTextGetString(UxGetWidget(UxFindSwidget("tf_sky"))); |
| 298 |
sprintf(command, "%s%s %s %s", C_EXTR_WEIGHTED, FileIn, out, sky); |
| 299 |
XtFree(sky); |
| 300 |
break; |
| 301 |
case DIALOG_CORRECT: |
| 302 |
sprintf(command, "%s%s %s", C_CORRECT, FileIn, out); |
| 303 |
break; |
| 304 |
case DIALOG_EXTIN: |
| 305 |
fout = XmTextGetString(UxGetWidget(UxFindSwidget("tf_output_extin"))); |
| 306 |
sprintf(command, "%s%s %s %f", C_EXTIN, FileIn, fout, Airmass); |
| 307 |
XtFree(fout); |
| 308 |
UxPopdownInterface(UxFindSwidget("extin_dialog")); |
| 309 |
break; |
| 310 |
} |
| 311 |
AppendDialogText(command); |
| 312 |
XtFree(out); |
| 313 |
UxPopdownInterface(UxFindSwidget("file_dialog")); |
| 314 |
} |