1
/*===========================================================================
2
Copyright (C) 1995-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
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
31
function Ccursin version 1.00 860217
32
K. Banse ESO - Garching
35
Image display , cursor positions
38
pick up the image memory pixels of the two cursors on the screen
41
use IDI routines to bind cursors + read them
42
write ima_mem_pixels to keyword CURSOR(1,..,4)
47
-------------------------------------------------------------------------- */
49
#include <midas_def.h>
56
* first the local functions Rdcur and Rdwin
59
/*++++++++++++++++++++++++++++
66
read screen coordinates at cursor position
67
and convert to image memory coordinates
70
Get all relevant values from DAZMEMI + do it
74
1.10 write raw screen coords. of cursor into keyword CURSOR
75
1.20 take care of channels with no image loaded...
76
1.30 use SCTOCH (ScreenToChannel) instead of SCRLIM
78
------------------------------------------------------------------- */
81
static void Rdcur( int dsplay, int cursno, int *chan, int *xy, int *sxy )
83
static void Rdcur(dsplay,cursno,chan,xy,sxy)
85
int dsplay; /* IN: display no. */
86
int cursno; /* IN: cursor no. 0 or 1 */
87
int *chan; /* OUT: image channel (memory) in use */
88
int *xy; /* OUT: x,y coord of image memory */
89
int *sxy; /* OUT: x,y screen coords */
96
(void) IICRCP_C(dsplay,-1,cursno,xy,&xy[1],chan);
97
*sxy++ = xy[0]; /* pure screen coords. */
100
if (oldchan != *chan)
103
stat = DCGICH(oldchan);
107
xy[1] = QMSZY - QDSZY + xy[1]; /* xy[0] already o.k. */
119
static void Rdwin( int dsplay, int roiflg,
120
int *chan, int *xya, int *xyb, int *sxya, int *sxyb )
122
static void Rdwin(dsplay,roiflg,chan,xya,xyb,sxya,sxyb)
124
int dsplay; /* IN: display no. */
125
int roiflg; /* IN: rectangular (= 2) or circular ROI */
126
int *chan; /* OUT: image channel (memory) in use */
127
int *xya; /* OUT: x,y coord of image memory */
128
int *xyb; /* OUT: x,y coord of image memory */
129
int *sxya; /* OUT: x,y screen coords */
130
int *sxyb; /* OUT: x,y screen coords */
137
(void) IIRRRI_C(dsplay,-1,0,xya,&xya[1],xyb,&xyb[1],chan);
139
(void) IICRRI_C(dsplay,-1,0,xya,&xya[1],xyb,&xyb[1],&xyb[2],chan);
141
*sxya++ = xya[0]; /* pure screen coords. */
146
if (oldchan != *chan)
149
stat = DCGICH(oldchan);
154
xya[1] = QMSZY - QDSZY + xya[1]; /* xya[0] already o.k. */
155
if (roiflg == 2) xyb[1] = QMSZY - QDSZY + xyb[1]; /* xyb[0] already o.k. */
160
if (roiflg == 2) Sc2ch(1,xyb,xyb+1);
170
void Ccursin(dsplay,iact,nocurs,xya,isca,xyb,iscb)
172
int dsplay; /* IN: display no. */
173
int iact; /* IN: action flag,
174
-1 = as 0 but also enable arrow keys
175
0 = setup cursor binding, enable keyboard input
176
1 = get cursor position on ENTER only
177
2 = get cursor position each time we poll
178
in that case, ISCi = -1 if ENTER was pressed */
179
int nocurs; /* IN: cursor no. = 0,1 for cursor #1 and #2,
181
3 for both cursors individually,
184
int *xya; /* OUT: x,y position in image channel of cursor 0
185
+ memory boards for cursor 0
186
+ x,y screen coordinates (so 5 elements) */
187
int *isca; /* OUT: status of cursor 0 (0/1 for off/on)
188
or = -9, if ISCB contains info about arrow key
189
or keys 0, ..., 9 or special keys */
190
int *xyb; /* OUT: x,y position in image channel of cursor 1
191
+ memory boards for cursor 1
192
+ x,y screen coordinates */
193
int *iscb; /* OUT: status of cursor 1 (0/1 for off/on)
194
if ISCA = -9, holds info about key pressed */
200
int intaty, intaid, intaop, objty, objid;
201
int mca, mcb, trgsta[10];
205
static int enttrg = 1; /* trigger no 1 for enter trigger */
206
static int exetrg = 2; /* trigger no 2 for execute trigger */
207
static int exttrg = 0; /* trigger no 0 for exit trigger */
209
static char nokeys[] = {"0123456789"};
215
if (iact > 0) goto sect_1000;
218
/* ********************************************* */
220
/* IACT = -1 or 0, bind cursor movement to EXIT trigger */
222
/* ********************************************* */
226
intaty = 0; /* interactor type = 0 for locator */
227
intaid = 0; /* id = 0 of locator */
228
intaop = 1; /* interactive operation = 1 for move */
231
objty = 1; /* object type = cursor */
233
(void) IIIENI_C(dsplay,intaty,intaid,objty,objid,intaop,exttrg);
237
/* bind locator 0, id 0 to movements of ROI */
239
else if ((nocurs == 2) || (nocurs == 12))
241
objty = 4; /* object type = roi */
243
(void) IIIENI_C(dsplay,intaty,intaid,objty,objid,intaop,exttrg);
245
/* and bind locator 0, id 1 to modifications of size of ROI */
247
intaid = 1; /* use id = 1 of locator */
248
intaop = 7; /* int. operation = 7 for modify */
249
(void) IIIENI_C(dsplay,intaty,intaid,objty,objid,intaop,exttrg);
253
/* bind cursor 0 and 1 independently */
257
objty = 1; /* object type = cursor */
259
(void) IIIENI_C(dsplay,intaty,intaid,objty,objid,intaop,exttrg);
262
(void) IIIENI_C(dsplay,intaty,intaid,objty,objid,intaop,exttrg);
266
/* bind ENTER button (trigger) to EXIT trigger as well */
268
intaty = 5; /* interactor type = 5 for trigger */
269
intaid = enttrg; /* id = 1, for trigger 1 (enter button) */
270
intaop = 0; /* inter. operation = 0 for applic spec. */
272
objty = 0; /* object type = 0, no visible effect */
273
(void) IIIENI_C(dsplay,intaty,intaid,objty,objid,intaop,exttrg);
276
/* also bind EXECUTE trigger to EXIT trigger as well */
278
intaid = exetrg; /* id = 2, for trigger 2 (execute button) */
279
(void) IIIENI_C(dsplay,intaty,intaid,objty,objid,intaop,exttrg);
282
/* if IACT = -1, bind triggers for arrow keys (L,R,D,U) */
286
for (intaid=4; intaid<8; intaid++)
288
(void) IIIENI_C(dsplay,intaty,intaid,objty,objid,intaop, exttrg) ;
291
/* finally bind trigger for special keys h, z, x, c, b, m */
293
intaty = 4; /* interactor type = 4 for char. eval. */
295
(void) IIIENI_C(dsplay,intaty,intaid,objty,objid,intaop, exttrg);
300
/* ********************************************* */
302
/* here for IACT = 1,2 */
304
/* ********************************************* */
307
(void) IIIEIW_C(dsplay,trgsta);
310
/* if EXIT trigger fired - we terminate the interaction + return */
314
(void) IIISTI_C(dsplay);
315
return; /* exit trigger 0 is in trgsta[1] */
319
/* look for arrow keys */
321
for (iav=4; iav<8; iav++)
323
if (trgsta[iav] == 1)
326
*iscb = iav - 8; /* map to -4, -3, -2, -1 */
333
(void) IIIGCE_C(dsplay,0,cbuf); /* get character */
334
if ((cbuf[0] >= 'a') && (cbuf[0] <= 'z'))
335
{ /* return lower case chars directly */
337
*iscb = (int) cbuf[0];
341
for (iav=0; iav<10; iav++)
343
if (cbuf[0] == nokeys[iav])
346
*iscb = iav + 1; /* map 0,1,2,...,9 */
347
return; /* to 1,2,3,...,10 */
352
if (iact == 1) /* loop, if no enter pushed */
354
if ( (trgsta[1] == 0) && (trgsta[2] == 0) ) goto sect_1000 ;
358
/* get channel involved and image pixels at cursor location */
363
(void) Rdcur(dsplay,0,&mca,xya,&xya[3]);
366
else if (nocurs == 1)
369
(void) Rdcur(dsplay,1,&mcb,xyb,&xyb[3]);
372
else if (nocurs == 2)
376
(void) Rdwin(dsplay,nocurs,&mca,xya,xyb,&xya[3],&xyb[3]);
380
else if (nocurs == 12)
384
(void) Rdwin(dsplay,nocurs,&mca,xya,xyb,&xya[3],&xyb[3]);
391
(void) Rdcur(dsplay,0,&mca,xya,&xya[3]);
392
(void) Rdcur(dsplay,1,&mcb,xyb,&xyb[3]);
397
if (trgsta[2] == 1) /* show, that execute pushed */
403
if (trgsta[1] == 1) /* show, that enter pushed */