1
/*===========================================================================
2
Copyright (C) 1995-2005 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
/* --------- III -------------------------------------------------- */
30
/* ----------------------------------------------------------------- */
32
/* file III.C : contains the following routines
34
* IIIENI_C : Enable Interaction;
35
* IIISTI_C : Stop Interaction;
36
* IIIEIW_C : Execute Interaction & Wait;
37
* IIIGLD_C : get Locator Displacement;
38
* IIIGLE_C : get Logical Evaluator;
39
* IIIGSE_C : get String Evaluator;
40
* IIIGCE_C : get (single) Character Evaluator ;
41
* - this is an extension of the IDIs !!
44
* version 2.2 890612 KB
51
# include <idistruct.h>
52
# include <proto_idi.h>
57
extern int osawrite();
59
static char evchar[12];
61
static INTER_DATA *intdata;
68
/************************************************************************
69
* IIIENI_C routine : enable interaction *
71
* synopsis IIIENI_C (display , intype , intid , objtype , objid , *
74
* int display; input display identifier *
75
* int intype; input interactor type *
76
* int intid; input interactor id *
77
* int objtype; input object type *
78
* int objid; input object id *
79
* int oper; input interactive operation *
80
* int trigger; input exit trigger *
81
************************************************************************/
83
int IIIENI_C (display, intype, intid, objtype, objid, oper, trigger)
85
int intype , objtype , oper;
86
int display , intid , objid , trigger;
92
if (ididev[display].opened == 0) return(DEVNOTOP);
93
noint = ididev[display].n_inter;
96
/* check exit trigger with previous enabled interactions */
98
if ((noint > 0) && (trigger != ididev[display].trigger))
102
/* check max number of enabled interactions */
104
if (noint == MAX_INTER)
106
(void) printf("max_inter = MAX_INTER, n_inter = %d\n",noint);
110
intdata = ididev[display].inter[noint];
111
intdata->inttype = intype;
112
intdata->intid = intid;
117
if ((intid>= 0) && (intid < intdevtable[display].nloc))
118
intdata->interactor = intdevtable[display].loc[intid]->interactor;
124
if ((intid>= 0) && (intid < intdevtable[display].ntrig))
126
intdata->interactor = intdevtable[display].trig[intid]->interactor;
127
intdevtable[display].trig[intid]->def = II_TRG;
134
if ((intid>= 0) && (intid < intdevtable[display].ntrig))
136
intdata->interactor = intdevtable[display].trig[intid]->interactor;
137
intdevtable[display].trig[intid]->def = II_EVLC;
148
intdata->objtype = objtype;
149
intdata->objid = objid;
167
intdata->oper = oper;
174
ididev[display].trigger = trigger;
175
ididev[display].n_inter ++;
184
/************************************************************************
185
* IIISTI_C routine : stop interaction *
187
* synopsis IIISTI_C (display); *
189
* int display; input display identifier *
190
************************************************************************/
192
int IIISTI_C (display)
197
if (ididev[display].opened == 0) return(DEVNOTOP);
199
ididev[display].n_inter = 0;
200
int_disable (display);
209
/************************************************************************
210
* IIIEIW_C routine : execute interaction & wait *
212
* synopsis IIIEIW_C (display , trgstatus); *
214
* int display; input display identifier *
215
* int trgstatus[]; output output trigger status *
216
************************************************************************/
218
int IIIEIW_C (display , trgstatus)
219
int display , trgstatus[MAX_TRG];
222
int i, trgflg, exitflg, trgno, userstatus;
223
int evdata, evtype, evpos[2];
228
if (ididev[display].opened == 0) return(DEVNOTOP);
231
/* check if any interaction has been enabled */
233
if (ididev[display].n_inter == 0) return(INTNOEN);
235
int_enable (display); /* enable interactive ididevs */
236
exit_trg_enable (display); /* Exit trigger enable */
242
for (i = 0; i < MAX_TRG; i++) /* zero trigger status array */
246
/* loop on enabled interactions
247
wait until exit trigger is fired or some USER interaction is verified */
250
if (auto_cursor_fid > 0)
251
send_event(display); /* if AUTO_CURSOR => an event */
252
wait_int (display,&evtype,&evdata,evchar,evpos);
255
/* loop on multiple enabled interactions */
257
for (i=0; i<ididev[display].n_inter; i++)
259
intdata = ididev[display].inter[i];
260
if (intdata->inttype == II_LOC)
262
if (intdata->objtype == II_CURSOR)
264
if (intdata->oper == II_MOVE)
265
curmove(display,intdata->objid,intdata->intid,evdata,evpos);
268
else if (intdata->objtype == II_ROI)
270
if (intdata->oper == II_MOVE)
271
roimove(display,intdata->intid,evpos);
272
else if (intdata->oper == II_MODIFY)
274
loc_mod(display,intdata->intid,evdata);
275
roimodify(display,intdata->intid);
280
loc_mod(display,intdata->intid,evdata);
283
else if ((intdata->inttype == II_TRG) || (intdata->inttype == II_EVLC))
285
trgno = intdata->intid;
286
trgflg = trigsta(display,trgno,evtype,evdata,evchar);
287
if (trgflg == 1) trgstatus[trgno] = 1;
290
if (intdata->oper == II_USER) /* look for user option */
295
/* check, if we are in record_cursor mode */
297
if (record_cursor_fid > 0) /* record all cursor/key input */
299
int do_store, fpos[2];
303
if ((evtype == 4) && (evdata == 1)) /* mouse button event */
306
fpos[0] = evpos[0] + 2; /* because of epsi2 ... */
307
fpos[1] = ididev[display].ysize - evpos[1] + 1;
308
(void) sprintf(cbuf,"1,%d,%d",fpos[0],fpos[1]);
311
else if (evtype == 2) /* keyboard event */
314
if (evdata == -5) /* check for RETURN key */
316
fpos[0] = evpos[0] + 2;
317
fpos[1] = ididev[display].ysize - evpos[1] + 1;
318
(void) sprintf(cbuf,"1,%d,%d",fpos[0],fpos[1]);
321
(void) sprintf(cbuf,"2,%d",evdata);
325
(void) osawrite(record_cursor_fid,cbuf,(int)strlen(cbuf));
329
/* test the exit trigger */
331
trgno = ididev[display].trigger;
332
trgflg = trigsta(display,trgno,evtype,evdata,evchar);
335
trgstatus[trgno] = 1;
337
set_wcur(display,1); /* let window cursor show the end */
339
if (record_cursor_fid > 0) /* record also exit button */
340
(void) osawrite(record_cursor_fid,"0",1);
343
if ((userstatus != 1) && (exitflg != 1))
353
/************************************************************************
354
* IIIGLE_C routine : Get logical Evaluator
356
* synopsis IIIGLE (display, evalno, cbuf)
358
* int display; input display identifier *
359
* int evalno; input evaluator no. *
360
* < 0, wait for char. from keyboard, *
361
* = 0, use character from interrupt before *
362
* int *cbuf; output logical *
363
************************************************************************/
365
int IIIGLE_C (display,evalno,cbuf)
370
if (ididev[display].opened == 0) return(DEVNOTOP);
372
/* just a dummy stub routine for now */
380
/************************************************************************
381
* IIIGCE_C routine : Get character Evaluator
383
* synopsis IIICSE (display, evalno, cbuf)
385
* int display; input display identifier *
386
* int evalno; input evaluator no. *
387
* < 0, wait for char. from keyboard, *
388
* = 0, use character from interrupt before *
389
* char *cbuf; output character *
390
************************************************************************/
392
int IIIGCE_C (display,evalno,cbuf)
397
if (ididev[display].opened == 0) return(DEVNOTOP);
400
get_char(display,cbuf);
411
/************************************************************************
412
* IIIGSE_C routine : Get String Evaluator
414
* synopsis IIIGSE (display, evalno, cbuf, lcbuf)
416
* int display; input display identifier *
417
* int evalno; input evaluator no. (not used...) *
418
* char *cbuf; output character string *
419
* int *lcbuf; output length of above *
420
************************************************************************/
422
int IIIGSE_C (display, evalno, cbuf, lcbuf)
423
int display, evalno, *lcbuf;
427
if (ididev[display].opened == 0)
431
get_string(display,cbuf,lcbuf);
437
/************************************************************************
438
* IIIGLD_C routine : Get Locator Displacement *
440
* synopsis IIIGLD_C (display , locn , xdis , ydis); *
442
* int display; input display identifier *
443
* int locn; input locator number *
444
* int *xdis; output X displacement *
445
* int *ydis; output Y displacement *
446
************************************************************************/
448
int IIIGLD_C(display,locn,xdis,ydis)
449
int display , locn , *xdis , *ydis;
452
if (ididev[display].opened == 0) return(DEVNOTOP);
454
loca = intdevtable[display].loc[locn];
456
*xdis = loca->xdif * 3;
457
*ydis = loca->ydif * 3;