~ubuntu-branches/debian/jessie/eso-midas/jessie

« back to all changes in this revision

Viewing changes to gui/XLong/src/cb_list.c

  • Committer: Package Import Robot
  • Author(s): Ole Streicher
  • Date: 2014-04-22 14:44:58 UTC
  • Revision ID: package-import@ubuntu.com-20140422144458-okiwi1assxkkiz39
Tags: upstream-13.09pl1.2+dfsg
ImportĀ upstreamĀ versionĀ 13.09pl1.2+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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: midas@eso.org
 
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
    090821              last 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 void DisplayExtendedHelp(), DisplayShortHelp(), PopupLong();
 
48
extern void SetFileList(), WriteKeyword();
 
49
extern void ReadParamsLong(), DisplayParamsLong(), UpdateDescriptors();
 
50
 
 
51
extern int exist_airmass(), AppendDialogText();
 
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, "*.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
            AppendDialogText(C_DISPLAY);
 
128
            sprintf(command, "%s%s", C_LOAD_IMA, choice);
 
129
            break;
 
130
        case LIST_SESSION:
 
131
            ReadParamsLong(choice);
 
132
            DisplayParamsLong();
 
133
            sprintf(command, "%s%s", C_INIT, choice);
 
134
            break;
 
135
        case LIST_WLC:
 
136
            UpdateDescriptors(choice);
 
137
            strcpy(command, C_SEARCH);
 
138
            break;
 
139
        case LIST_LINCAT:
 
140
            UxPutValue(TextFieldSwidget, choice);
 
141
            strcpy(Lincat, choice);
 
142
            WriteKeyword(Lincat, K_LINCAT);
 
143
            break;
 
144
        case LIST_GUESS:
 
145
            UxPutValue(TextFieldSwidget, choice);
 
146
            strcpy(Guess, choice);
 
147
            WriteKeyword(Guess, K_GUESS);
 
148
            break;
 
149
        case LIST_REBIN_RBR:
 
150
        case LIST_REBIN_2D:
 
151
        case LIST_REBIN_TBL:
 
152
            /*generation of the output image name */
 
153
            for ( i = 0; choice[i] != '.' && choice[i] != '\0'; i++ )
 
154
                ;
 
155
            strncpy(FileOut, choice, i);
 
156
            FileOut[i] = '\0';
 
157
            sprintf(FileOut, "%s_reb", FileOut);
 
158
            strcpy(FileIn, choice);
 
159
            PopupDialogWindow = TRUE;
 
160
            break;
 
161
        case LIST_EXTIN_TBL:
 
162
            UxPutValue(TextFieldSwidget, choice);
 
163
            strcpy(Extab, choice);
 
164
            WriteKeyword(Extab, K_EXTAB);
 
165
            break;
 
166
        case LIST_FLUX_TBL:
 
167
            UxPutValue(TextFieldSwidget, choice);
 
168
            strcpy(Fluxtab, choice);
 
169
            WriteKeyword(Fluxtab, K_FLUXTAB);
 
170
            break;
 
171
        case LIST_INTEGR:
 
172
            sprintf(command, "%s%s", C_INTEGR, choice);
 
173
            break;
 
174
        case LIST_FLUX_FILT:
 
175
            sprintf(command, "%s%s", C_FLUX_FILT, choice);
 
176
            break;
 
177
        case LIST_EXTIN:
 
178
            /* generation of the output image name */
 
179
            for ( i = 0; choice[i] != '.' && choice[i] != '\0'; i++ )
 
180
                ;
 
181
            strncpy(FileOut, choice, i);
 
182
            FileOut[i] = '\0';
 
183
            sprintf(FileOut, "%s_ext", FileOut);
 
184
            strcpy(FileIn, choice);
 
185
            PopupExtinWindow = TRUE;
 
186
            break;
 
187
        case LIST_FIT_SKY:
 
188
            sky = XmTextGetString(UxGetWidget(UxFindSwidget("tf_sky")));
 
189
            sprintf(command, "%s%s %s", C_EXTR_FIT_SKY, choice, sky);
 
190
            XtFree(sky);
 
191
            break;
 
192
        case LIST_EXT_AVER:
 
193
        case LIST_EXT_WEIGHT:
 
194
            /* generation of the output image name */
 
195
            for ( i = 0; choice[i] != '.' && choice[i] != '\0'; i++ )
 
196
                ;
 
197
            strncpy(FileOut, choice, i);
 
198
            FileOut[i] = '\0';
 
199
            sprintf(FileOut, "%s_obj", FileOut);
 
200
            strcpy(FileIn, choice);
 
201
            PopupDialogWindow = TRUE;
 
202
            break;
 
203
        case LIST_CORRECT:
 
204
            /* generation of the output image name */
 
205
            for ( i = 0; choice[i] != '.' && choice[i] != '\0'; i++ )
 
206
                ;
 
207
            strncpy(FileOut, choice, i);
 
208
            FileOut[i] = '\0';
 
209
            sprintf(FileOut, "%s_cor", FileOut);
 
210
            strcpy(FileIn, choice);
 
211
            PopupDialogWindow = TRUE;
 
212
            break;
 
213
        case LIST_BROWSER:
 
214
            for ( i = 0; choice[i] != DIR_DELIMITER && choice[i] != '\0'; i++ )
 
215
                ;
 
216
            if ( choice[i] == DIR_DELIMITER ) {
 
217
                strcat(DirSpecs, choice);
 
218
                PopupList(LIST_BROWSER);
 
219
                popdown_filelist = FALSE;
 
220
            }
 
221
            else
 
222
                sprintf(command, "$cp %s%s %s", DirSpecs, choice, choice);
 
223
            break;
 
224
    }
 
225
    XtFree(choice);
 
226
 
 
227
    if ( popdown_filelist )
 
228
        UxPopdownInterface(FileListInterface);
 
229
    
 
230
    if ( PopupExtinWindow ) {
 
231
        DialogType = DIALOG_EXTIN;
 
232
        UxPutValue(UxFindSwidget("tf_output_extin"), FileOut);
 
233
        if ( exist_airmass(FileIn, &fval) )
 
234
            Airmass = fval;
 
235
        sprintf(str, "%.4f", Airmass);
 
236
        UxPutValue(UxFindSwidget("tf_airmass"), str);
 
237
        UxPopupInterface(UxFindSwidget("extin_dialog"), exclusive_grab);
 
238
    }
 
239
    else if ( PopupDialogWindow ) {
 
240
        switch ( ListType ) {
 
241
            case LIST_REBIN_RBR:
 
242
                SET_DIALOG_PROMPT("Enter output image :");
 
243
                DialogType = DIALOG_REBIN_RBR;
 
244
                break;
 
245
            case LIST_REBIN_2D:
 
246
                SET_DIALOG_PROMPT("Enter output image :");
 
247
                DialogType = DIALOG_REBIN_2D;
 
248
                break;
 
249
            case LIST_REBIN_TBL:
 
250
                SET_DIALOG_PROMPT("Enter output table :");
 
251
                DialogType = DIALOG_REBIN_TBL;
 
252
                break;
 
253
            case LIST_EXT_AVER:
 
254
                SET_DIALOG_PROMPT("Enter output image :");
 
255
                DialogType = DIALOG_EXT_AVER;
 
256
                break;
 
257
            case LIST_EXT_WEIGHT:
 
258
                SET_DIALOG_PROMPT("Enter output image :");
 
259
                DialogType = DIALOG_EXT_WEIGHT;
 
260
                break;
 
261
            case LIST_CORRECT:
 
262
                SET_DIALOG_PROMPT("Enter output image :");
 
263
                DialogType = DIALOG_CORRECT;
 
264
                break;
 
265
        }
 
266
        UxPutValue(UxFindSwidget("tf_file_dialog"), FileOut);
 
267
        UxPopupInterface(UxFindSwidget("file_dialog"), exclusive_grab);
 
268
    }
 
269
    else if ( command[0] != '\0' )
 
270
        AppendDialogText(command);
 
271
 
 
272
}
 
273
 
 
274
void CallbackDialog()
 
275
{
 
276
    char command[128];
 
277
    char *out, *fout, *sky;
 
278
 
 
279
    out = XmTextGetString(UxGetWidget(UxFindSwidget("tf_file_dialog")));
 
280
    switch ( DialogType ) {
 
281
        case DIALOG_SESSION:
 
282
            strcpy(Session, out);
 
283
            UxPutValue(UxFindSwidget("tf_session"), Session);
 
284
            WriteKeyword(Session, K_SESSION);
 
285
            sprintf(command, "%s%s", C_SAVE, Session);
 
286
            break;
 
287
        case DIALOG_REBIN_RBR:
 
288
            sprintf(command, "%s%s %s", C_REBIN, FileIn, out);
 
289
            break;
 
290
        case DIALOG_REBIN_2D:
 
291
            sprintf(command, "%s%s %s", C_RECTIFY, FileIn, out);
 
292
            break;
 
293
        case DIALOG_REBIN_TBL:
 
294
            sprintf(command, "%s%s %s", C_APP_DISP, FileIn, out);
 
295
            break;
 
296
        case DIALOG_EXT_AVER:
 
297
            sprintf(command, "%s%s %s", C_EXTR_AVERAGE, FileIn, out);
 
298
            break;
 
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);
 
302
            XtFree(sky);
 
303
            break;
 
304
        case DIALOG_CORRECT:
 
305
            sprintf(command, "%s%s %s", C_CORRECT, FileIn, out);
 
306
            break;
 
307
        case DIALOG_EXTIN:
 
308
            fout = XmTextGetString(UxGetWidget(UxFindSwidget("tf_output_extin")));
 
309
            sprintf(command, "%s%s %s %f", C_EXTIN, FileIn, fout, Airmass);
 
310
            XtFree(fout);
 
311
            UxPopdownInterface(UxFindSwidget("extin_dialog"));
 
312
            break;
 
313
    }
 
314
    AppendDialogText(command);
 
315
    XtFree(out);
 
316
    UxPopdownInterface(UxFindSwidget("file_dialog"));
 
317
}