1
/*===========================================================================
2
Copyright (C) 1993-2009 European Southern Observatory (ESO)
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.
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.
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,
19
Correspondence concerning ESO-MIDAS should be addressed as follows:
20
Internet e-mail: midas@eso.org
21
Postal address: European Southern Observatory
22
Data Management Division
23
Karl-Schwarzschild-Strasse 2
24
D 85748 Garching bei Muenchen
26
===========================================================================*/
28
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
29
/* .IDENT cb_list.c */
30
/* .AUTHORS Pascal Ballester (ESO/Garching) */
31
/* Cristian Levin (ESO/La Silla) */
32
/* .KEYWORDS XLong, Spectroscopy, Long-Slit */
34
/* .VERSION 1.0 Package Creation 17-MAR-1993
37
/* ------------------------------------------------------- */
41
#include <main_defs.h>
42
#include <spec_comm.h>
45
#define DIR_DELIMITER '/'
47
extern void DisplayExtendedHelp(), DisplayShortHelp(), PopupLong();
48
extern void SetFileList(), WriteKeyword();
49
extern void ReadParamsLong(), DisplayParamsLong(), UpdateDescriptors();
51
extern int exist_airmass(), AppendDialogText();
53
static char FileIn[MAXLINE], FileOut[MAXLINE];
54
static int PopupDialogWindow, PopupExtinWindow;
57
int PopupList( list_type )
60
int strip = 1; /* strip off the directories */
62
extern swidget FileListInterface;
63
extern Widget FileListWidget;
64
extern char DirSpecs[];
68
switch ( list_type ) {
70
SET_LIST_TITLE("Enter calibration frame");
71
strcpy(DirSpecs, "*.bdf");
83
SET_LIST_TITLE("Enter input image");
84
strcpy(DirSpecs, "*.bdf");
87
SET_LIST_TITLE("Enter image to load");
88
strcpy(DirSpecs, "*.bdf");
91
SET_LIST_TITLE("Enter parameters table");
92
strcpy(DirSpecs, "*.tbl");
95
SET_LIST_TITLE("MIDAS browser");
96
/* DirSpecs[] was setted in the Browse menu callback first time */
97
strip = 0; /* keep the directories */
103
SetFileList(FileListWidget, strip, DirSpecs);
104
UxPopupInterface(FileListInterface, exclusive_grab);
108
void CallbackList( choice )
111
char command[512], str[256];
115
int popdown_filelist = TRUE;
117
extern swidget FileListInterface;
118
extern swidget TextFieldSwidget;
119
extern char DirSpecs[];
121
PopupDialogWindow = PopupExtinWindow = FALSE;
125
switch ( ListType ) {
127
AppendDialogText(C_DISPLAY);
128
sprintf(command, "%s%s", C_LOAD_IMA, choice);
131
ReadParamsLong(choice);
133
sprintf(command, "%s%s", C_INIT, choice);
136
UpdateDescriptors(choice);
137
strcpy(command, C_SEARCH);
140
UxPutValue(TextFieldSwidget, choice);
141
strcpy(Lincat, choice);
142
WriteKeyword(Lincat, K_LINCAT);
145
UxPutValue(TextFieldSwidget, choice);
146
strcpy(Guess, choice);
147
WriteKeyword(Guess, K_GUESS);
152
/*generation of the output image name */
153
for ( i = 0; choice[i] != '.' && choice[i] != '\0'; i++ )
155
strncpy(FileOut, choice, i);
157
sprintf(FileOut, "%s_reb", FileOut);
158
strcpy(FileIn, choice);
159
PopupDialogWindow = TRUE;
162
UxPutValue(TextFieldSwidget, choice);
163
strcpy(Extab, choice);
164
WriteKeyword(Extab, K_EXTAB);
167
UxPutValue(TextFieldSwidget, choice);
168
strcpy(Fluxtab, choice);
169
WriteKeyword(Fluxtab, K_FLUXTAB);
172
sprintf(command, "%s%s", C_INTEGR, choice);
175
sprintf(command, "%s%s", C_FLUX_FILT, choice);
178
/* generation of the output image name */
179
for ( i = 0; choice[i] != '.' && choice[i] != '\0'; i++ )
181
strncpy(FileOut, choice, i);
183
sprintf(FileOut, "%s_ext", FileOut);
184
strcpy(FileIn, choice);
185
PopupExtinWindow = TRUE;
188
sky = XmTextGetString(UxGetWidget(UxFindSwidget("tf_sky")));
189
sprintf(command, "%s%s %s", C_EXTR_FIT_SKY, choice, sky);
193
case LIST_EXT_WEIGHT:
194
/* generation of the output image name */
195
for ( i = 0; choice[i] != '.' && choice[i] != '\0'; i++ )
197
strncpy(FileOut, choice, i);
199
sprintf(FileOut, "%s_obj", FileOut);
200
strcpy(FileIn, choice);
201
PopupDialogWindow = TRUE;
204
/* generation of the output image name */
205
for ( i = 0; choice[i] != '.' && choice[i] != '\0'; i++ )
207
strncpy(FileOut, choice, i);
209
sprintf(FileOut, "%s_cor", FileOut);
210
strcpy(FileIn, choice);
211
PopupDialogWindow = TRUE;
214
for ( i = 0; choice[i] != DIR_DELIMITER && choice[i] != '\0'; i++ )
216
if ( choice[i] == DIR_DELIMITER ) {
217
strcat(DirSpecs, choice);
218
PopupList(LIST_BROWSER);
219
popdown_filelist = FALSE;
222
sprintf(command, "$cp %s%s %s", DirSpecs, choice, choice);
227
if ( popdown_filelist )
228
UxPopdownInterface(FileListInterface);
230
if ( PopupExtinWindow ) {
231
DialogType = DIALOG_EXTIN;
232
UxPutValue(UxFindSwidget("tf_output_extin"), FileOut);
233
if ( exist_airmass(FileIn, &fval) )
235
sprintf(str, "%.4f", Airmass);
236
UxPutValue(UxFindSwidget("tf_airmass"), str);
237
UxPopupInterface(UxFindSwidget("extin_dialog"), exclusive_grab);
239
else if ( PopupDialogWindow ) {
240
switch ( ListType ) {
242
SET_DIALOG_PROMPT("Enter output image :");
243
DialogType = DIALOG_REBIN_RBR;
246
SET_DIALOG_PROMPT("Enter output image :");
247
DialogType = DIALOG_REBIN_2D;
250
SET_DIALOG_PROMPT("Enter output table :");
251
DialogType = DIALOG_REBIN_TBL;
254
SET_DIALOG_PROMPT("Enter output image :");
255
DialogType = DIALOG_EXT_AVER;
257
case LIST_EXT_WEIGHT:
258
SET_DIALOG_PROMPT("Enter output image :");
259
DialogType = DIALOG_EXT_WEIGHT;
262
SET_DIALOG_PROMPT("Enter output image :");
263
DialogType = DIALOG_CORRECT;
266
UxPutValue(UxFindSwidget("tf_file_dialog"), FileOut);
267
UxPopupInterface(UxFindSwidget("file_dialog"), exclusive_grab);
269
else if ( command[0] != '\0' )
270
AppendDialogText(command);
274
void CallbackDialog()
277
char *out, *fout, *sky;
279
out = XmTextGetString(UxGetWidget(UxFindSwidget("tf_file_dialog")));
280
switch ( DialogType ) {
282
strcpy(Session, out);
283
UxPutValue(UxFindSwidget("tf_session"), Session);
284
WriteKeyword(Session, K_SESSION);
285
sprintf(command, "%s%s", C_SAVE, Session);
287
case DIALOG_REBIN_RBR:
288
sprintf(command, "%s%s %s", C_REBIN, FileIn, out);
290
case DIALOG_REBIN_2D:
291
sprintf(command, "%s%s %s", C_RECTIFY, FileIn, out);
293
case DIALOG_REBIN_TBL:
294
sprintf(command, "%s%s %s", C_APP_DISP, FileIn, out);
296
case DIALOG_EXT_AVER:
297
sprintf(command, "%s%s %s", C_EXTR_AVERAGE, FileIn, out);
299
case DIALOG_EXT_WEIGHT:
300
sky = XmTextGetString(UxGetWidget(UxFindSwidget("tf_sky")));
301
sprintf(command, "%s%s %s %s", C_EXTR_WEIGHTED, FileIn, out, sky);
305
sprintf(command, "%s%s %s", C_CORRECT, FileIn, out);
308
fout = XmTextGetString(UxGetWidget(UxFindSwidget("tf_output_extin")));
309
sprintf(command, "%s%s %s %f", C_EXTIN, FileIn, fout, Airmass);
311
UxPopdownInterface(UxFindSwidget("extin_dialog"));
314
AppendDialogText(command);
316
UxPopdownInterface(UxFindSwidget("file_dialog"));