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

« back to all changes in this revision

Viewing changes to prim/display/libsrc/ccursin.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) 1995-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
 
 
30
.IDENTIFICATION
 
31
  function Ccursin                      version 1.00    860217
 
32
  K. Banse                              ESO - Garching
 
33
 
 
34
.KEYWORDS
 
35
  Image display , cursor positions
 
36
 
 
37
.PURPOSE
 
38
  pick up the image memory pixels of the two cursors on the screen
 
39
 
 
40
.ALGORITHM
 
41
  use IDI routines to bind cursors + read them
 
42
  write ima_mem_pixels to keyword CURSOR(1,..,4)
 
43
 
 
44
.VERSIONS
 
45
 
 
46
 090706         last modif
 
47
-------------------------------------------------------------------------- */
 
48
 
 
49
#include <midas_def.h>
 
50
#include <idinumd.h>
 
51
#include <proto_II.h>
 
52
 
 
53
static int  oldchan;
 
54
 
 
55
/*
 
56
 * first the local functions Rdcur and Rdwin
 
57
 */
 
58
 
 
59
/*++++++++++++++++++++++++++++
 
60
 
 
61
.IDENTIFICATION: 
 
62
  function Rdcur  
 
63
           Rdwin
 
64
 
 
65
.PURPOSE: 
 
66
  read screen coordinates at cursor position 
 
67
  and convert to image memory coordinates 
 
68
 
 
69
.ALGORITHM: 
 
70
  Get all relevant values from DAZMEMI + do it 
 
71
 
 
72
 
 
73
.VERSIONS
 
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
 
77
 
 
78
------------------------------------------------------------------- */
 
79
 
 
80
#ifdef __STDC__
 
81
      static void Rdcur( int dsplay, int cursno, int *chan, int *xy, int *sxy )
 
82
#else
 
83
      static void Rdcur(dsplay,cursno,chan,xy,sxy)
 
84
 
 
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 */
 
90
#endif
 
91
 
 
92
{
 
93
int   stat = 0;
 
94
 
 
95
 
 
96
(void) IICRCP_C(dsplay,-1,cursno,xy,&xy[1],chan);
 
97
*sxy++ = xy[0];                                 /* pure screen coords. */
 
98
*sxy = xy[1];
 
99
 
 
100
if (oldchan != *chan)
 
101
   {
 
102
   oldchan = *chan;
 
103
   stat = DCGICH(oldchan);
 
104
   }
 
105
 
 
106
if (stat != 0)     
 
107
   xy[1] = QMSZY - QDSZY + xy[1];                /* xy[0] already o.k. */
 
108
else
 
109
   Sc2ch(1,xy,xy+1);
 
110
 
 
111
return;
 
112
}
 
113
 
 
114
/*
 
115
 
 
116
*/
 
117
 
 
118
#ifdef __STDC__
 
119
      static void Rdwin( int dsplay, int roiflg,
 
120
                         int *chan, int *xya, int *xyb, int *sxya, int *sxyb )
 
121
#else
 
122
      static void Rdwin(dsplay,roiflg,chan,xya,xyb,sxya,sxyb)
 
123
 
 
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 */
 
131
#endif
 
132
{
 
133
int   stat = 0;
 
134
 
 
135
 
 
136
if (roiflg == 2)     
 
137
   (void) IIRRRI_C(dsplay,-1,0,xya,&xya[1],xyb,&xyb[1],chan);
 
138
else
 
139
   (void) IICRRI_C(dsplay,-1,0,xya,&xya[1],xyb,&xyb[1],&xyb[2],chan);
 
140
 
 
141
*sxya++ = xya[0];                               /* pure screen coords. */
 
142
*sxya = xya[1];
 
143
*sxyb++ = xyb[0];
 
144
*sxyb = xyb[1];
 
145
 
 
146
if (oldchan != *chan)
 
147
   {
 
148
   oldchan = *chan;
 
149
   stat =  DCGICH(oldchan);
 
150
   }
 
151
 
 
152
if (stat != 0)     
 
153
   {
 
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. */
 
156
   }
 
157
else
 
158
   {
 
159
   Sc2ch(1,xya,xya+1);
 
160
   if (roiflg == 2) Sc2ch(1,xyb,xyb+1);
 
161
   }
 
162
 
 
163
return;
 
164
}
 
165
 
 
166
/*
 
167
 
 
168
*/
 
169
 
 
170
void Ccursin(dsplay,iact,nocurs,xya,isca,xyb,iscb)
 
171
 
 
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,
 
180
                               2 for rectangle ROI,
 
181
                               3 for both cursors individually,
 
182
                               12 for circle  ROI  */
 
183
 
 
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 */
 
195
 
 
196
 
 
197
{
 
198
      
 
199
int iav;
 
200
int intaty, intaid, intaop, objty, objid;
 
201
int mca, mcb, trgsta[10];
 
202
 
 
203
char cbuf[4];
 
204
 
 
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  */
 
208
 
 
209
static char nokeys[] = {"0123456789"};
 
210
 
 
211
 
 
212
 
 
213
*isca = 0;
 
214
*iscb = 0;
 
215
if (iact > 0) goto sect_1000;
 
216
 
 
217
 
 
218
/*  ********************************************* */
 
219
 
 
220
/*  IACT = -1 or 0,  bind cursor movement to EXIT trigger */
 
221
 
 
222
/*  ********************************************* */
 
223
 
 
224
oldchan = -1;
 
225
 
 
226
intaty = 0;                          /* interactor type = 0 for locator */
 
227
intaid = 0;                          /* id = 0 of locator */
 
228
intaop = 1;                          /* interactive operation = 1 for move */
 
229
if (nocurs < 2)      
 
230
   {
 
231
   objty = 1;                        /* object type = cursor */
 
232
   objid = nocurs;
 
233
   (void) IIIENI_C(dsplay,intaty,intaid,objty,objid,intaop,exttrg);
 
234
   }
 
235
 
 
236
 
 
237
/*  bind locator 0, id 0 to movements of ROI */
 
238
 
 
239
else if ((nocurs == 2) || (nocurs == 12))     
 
240
   {
 
241
   objty = 4;                        /* object type = roi */
 
242
   objid = 0;
 
243
   (void) IIIENI_C(dsplay,intaty,intaid,objty,objid,intaop,exttrg);
 
244
 
 
245
/*  and bind locator 0, id 1 to modifications of size of ROI */
 
246
 
 
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);
 
250
   }
 
251
 
 
252
 
 
253
/*  bind cursor 0 and 1 independently */
 
254
 
 
255
else
 
256
   {
 
257
   objty = 1;                        /* object type = cursor */
 
258
   objid = 0;
 
259
   (void) IIIENI_C(dsplay,intaty,intaid,objty,objid,intaop,exttrg);
 
260
   intaid = 1;
 
261
   objid = 1;
 
262
   (void) IIIENI_C(dsplay,intaty,intaid,objty,objid,intaop,exttrg);
 
263
   }
 
264
 
 
265
 
 
266
/*  bind ENTER button (trigger) to EXIT trigger as well */
 
267
 
 
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. */
 
271
objid = 0;
 
272
objty = 0;                           /* object type = 0, no visible effect */
 
273
(void) IIIENI_C(dsplay,intaty,intaid,objty,objid,intaop,exttrg);
 
274
 
 
275
 
 
276
/*  also bind EXECUTE trigger to EXIT trigger as well */
 
277
 
 
278
intaid = exetrg;                  /* id = 2, for trigger 2 (execute button) */
 
279
(void) IIIENI_C(dsplay,intaty,intaid,objty,objid,intaop,exttrg);
 
280
 
 
281
 
 
282
/*  if IACT = -1, bind triggers for arrow keys (L,R,D,U)  */
 
283
 
 
284
if (iact < 0)     
 
285
   {
 
286
   for (intaid=4; intaid<8; intaid++)
 
287
      {
 
288
      (void) IIIENI_C(dsplay,intaty,intaid,objty,objid,intaop, exttrg) ;
 
289
      }
 
290
 
 
291
/*  finally bind trigger for special keys h, z, x, c, b, m */
 
292
 
 
293
   intaty = 4;                       /* interactor type = 4 for char. eval. */
 
294
   intaid = 8;
 
295
   (void) IIIENI_C(dsplay,intaty,intaid,objty,objid,intaop, exttrg);
 
296
   }
 
297
 
 
298
return;
 
299
 
 
300
/*  ********************************************* */
 
301
 
 
302
/*  here for IACT = 1,2 */
 
303
 
 
304
/*  ********************************************* */
 
305
 
 
306
sect_1000:
 
307
(void) IIIEIW_C(dsplay,trgsta);
 
308
 
 
309
 
 
310
/*  if EXIT trigger fired - we terminate the interaction + return  */
 
311
 
 
312
if (trgsta[0] == 1)     
 
313
   {
 
314
   (void) IIISTI_C(dsplay);
 
315
   return;                               /* exit trigger 0 is in trgsta[1] */
 
316
   }
 
317
 
 
318
 
 
319
/*  look for arrow keys */
 
320
 
 
321
for (iav=4; iav<8; iav++)
 
322
   {
 
323
   if (trgsta[iav] == 1)     
 
324
      {
 
325
      *isca = -8;
 
326
      *iscb = iav - 8;                    /* map to -4, -3, -2, -1 */
 
327
      return;
 
328
      }
 
329
   }
 
330
 
 
331
if (trgsta[8] == 1)     
 
332
   {
 
333
   (void) IIIGCE_C(dsplay,0,cbuf);      /* get character */
 
334
   if ((cbuf[0] >= 'a') && (cbuf[0] <= 'z'))
 
335
      {                                 /* return lower case chars directly */
 
336
      *isca = -9;
 
337
      *iscb = (int) cbuf[0];
 
338
      return;              
 
339
      }
 
340
 
 
341
   for (iav=0; iav<10; iav++)
 
342
      {
 
343
      if (cbuf[0] == nokeys[iav])     
 
344
         {
 
345
         *isca = -8;
 
346
         *iscb = iav + 1;                 /* map 0,1,2,...,9 */
 
347
         return;                         /* to  1,2,3,...,10 */
 
348
         }
 
349
      }
 
350
   }
 
351
 
 
352
if (iact == 1)                           /* loop, if no enter pushed */
 
353
   {
 
354
   if ( (trgsta[1] == 0) && (trgsta[2] == 0) ) goto sect_1000 ;
 
355
   }
 
356
 
 
357
 
 
358
/*  get channel involved and image pixels at cursor location */
 
359
 
 
360
if (nocurs == 0)     
 
361
   {
 
362
   *isca = 1;
 
363
   (void) Rdcur(dsplay,0,&mca,xya,&xya[3]);
 
364
   xya[2] = mca;
 
365
   }
 
366
else if (nocurs == 1)     
 
367
   {
 
368
   *iscb = 1;
 
369
   (void) Rdcur(dsplay,1,&mcb,xyb,&xyb[3]);
 
370
   xyb[2] = mcb;
 
371
   }
 
372
else if (nocurs == 2)     
 
373
   {
 
374
   *isca = 1;
 
375
   *iscb = 1;
 
376
   (void) Rdwin(dsplay,nocurs,&mca,xya,xyb,&xya[3],&xyb[3]);
 
377
   xya[2] = mca;
 
378
   xyb[2] = mca;
 
379
   }
 
380
else if (nocurs == 12)     
 
381
   {
 
382
   *isca = 1;
 
383
   *iscb = 1;
 
384
   (void) Rdwin(dsplay,nocurs,&mca,xya,xyb,&xya[3],&xyb[3]);
 
385
   xya[2] = mca;
 
386
   }
 
387
else
 
388
   {
 
389
   *isca = 1;
 
390
   *iscb = 1;
 
391
   (void) Rdcur(dsplay,0,&mca,xya,&xya[3]);
 
392
   (void) Rdcur(dsplay,1,&mcb,xyb,&xyb[3]);
 
393
   xya[2] = mca;
 
394
   xyb[2] = mcb;
 
395
   }
 
396
 
 
397
if (trgsta[2] == 1)                     /* show, that execute pushed */
 
398
   {
 
399
   *isca = -2;
 
400
   *iscb = -2;
 
401
   }
 
402
 
 
403
if (trgsta[1] == 1)                     /* show, that enter pushed */
 
404
   {
 
405
   *isca = -1;
 
406
   *iscb = -1;
 
407
   }
 
408
 
 
409
}