1
/*===========================================================================
2
Copyright (C) 1994-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
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
30
.AUTHOR K. Banse IPG-ESO Garching
31
.KEYWORDS Image Display, cursor
33
.PURPOSE enable/disable fixed cursor(s) of different shapes or
34
programmable cursors and (optionally) set cursor coordinates
35
.ALGORITHM use IDI interfaces for interacting with the Image Display
37
call as SETCUR_C( dsplay, cursno, forma, colo, coords )
40
int display : Display unit no.
41
int cursno : Cursor no. = 0, 1 or 2 for both cursors
42
= 3 for two independent cursors
43
int forma : actual cursor form no.
44
if = -1, make cursors/ROI not visible
45
if = 99, use last defined cursor form + colour
46
int colo : cursor colour
47
int *coords : coordinates
52
#include <midas_def.h> Prototypes for MIDAS interfaces
53
#include <idinumd.h> Global variables for DISPLAY interfaces
55
.VERSIONS 1.00 940425 F -> C conversion, RvH
56
.VERSIONS 1.10 941031 cleanup, KB
59
------------------------------------------------------------*/
61
/* Define _POSIX_SOURCE to indicate that this is a POSIX program */
63
#define _POSIX_SOURCE 1
65
#include <midas_def.h>
73
void SETCUR_C(dsplay,cursno,forma,colo,coords)
74
int dsplay, cursno, forma, colo, *coords;
78
int form, colr, actvals, knul, ibuff[4];
80
int roiid = 0; /* This parameter is not used by IDI */
84
if (cursno == 2) /* handle ROIs */
90
(void) SCKRDI("CURSOR",5,4,&actvals,ibuff,&unit,&knul);
100
if (form < 0) /* clear visibility */
101
(void) IIRSRV_C(dsplay,roiid,0);
104
if (form == 2) /* circ. ROI */
105
(void) IICINR_C(dsplay,-1,colr,*coords,coords[1],coords[2],
106
coords[3],coords[4],&roiid);
108
(void) IIRINR_C(dsplay,-1,colr,*coords,coords[1],coords[2],
111
(void) IIRSRV_C(dsplay,roiid,1);
112
(void) SCKWRI("DAZHOLD",&form,16,1,&unit);
115
for (nr=0; nr<4; nr++) kbuff[nr] = coords[nr];
116
kbuff[4] = kbuff[6] = form;
117
kbuff[5] = kbuff[7] = colr;
118
(void) SCKWRI("CURSOR",kbuff,1,8,&unit);
121
else /* handle single cursor */
125
(void) SCKRDI("CURSOR",5,4,&actvals,ibuff,&unit,&knul);
143
(void) IICINC_C(dsplay,-1,cursno,form,colr,*coords,coords[1]);
146
(void) IICSCV_C(dsplay,cursno,1);
148
(void) IICSCV_C(dsplay,cursno,0);
154
(void) SCKWRI("CURSOR",ibuff,5,2,&unit);
155
(void) SCKWRI("CURSOR",coords,1,2,&unit);
159
(void) SCKWRI("CURSOR",ibuff,7,2,&unit);
160
(void) SCKWRI("CURSOR",coords,3,2,&unit);
165
/* Update also keyword DAZHOLD */
169
(void) SCKWRI("DAZHOLD",ibuff,1,2,&unit);
175
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
176
.COPYRIGHT (c) 1994 European Southern Observatory
179
.AUTHOR K. Banse IPG - ESO Garching
180
.KEYWORDS Image Display, cursor
181
.PURPOSE enable/disable fixed cursor(s) of different shapes or
182
programmable cursors and (optionally) set cursor coordinates
183
.ALGORITHM use IDI interfaces for interacting with the Image Display
185
call as CURINF_C( dsplay, nocurs, roiflg )
188
int display : Display unit no.
191
int *nocurs : Numberof available cursors -> 1 or 2
192
int *roiflg : = 1, if ROI is implemented
197
#include <midas_def.h> Prototypes for MIDAS interfaces
199
.VERSIONS 1.00 940425 F -> C conversion, RvH
200
.VERSIONS 1.10 941031 cleanup, KB
201
------------------------------------------------------------*/
203
void CURINF_C( dsplay, nocurs, roiflg )
204
int dsplay, *nocurs, *roiflg;
210
/* 40 = code for asking no. of cursors */
212
(void) IIDQCI_C(dsplay,40,1,nocurs,&ncap);
215
/* 60 = code for asking for roi implementation */
217
(void) IIDQCI_C(dsplay,60,1,roiflg,&ncap);
223
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
224
.IDENTIFIER GetScrPix
226
.AUTHOR K. Banse IPG - ESO Garching
228
.KEYWORDS Image Display, cursor
229
.PURPOSE get the screen pixels for a given w.c. or f.p. value
230
.ALGORITHM use keyword IDIMEMI/IDIMEMR to map w.c.s/f.p.s to screen pixels
232
call as GetScrPix(imno,wc_flag,inval,xy_flag,scrpix)
236
int wc_flag: = 1, inval is world coord value
237
= 0, inval is frame pixel value
238
float inval: w.c. or f.p. value
239
int xy_flag: = 1, use x-direction
241
= 3, use average of x,y-direction
244
int *scrpix: corresponding screen pixels
247
int status: = 0, if o.k.
253
-----------------------------------------------------------*/
255
int GetScrPix(imno,wc_flag,inval,xy_flag,scrpix)
256
int imno, wc_flag, xy_flag, *scrpix;
260
int stat, iav, kuni, knul;
261
int newpix, idimi[8];
263
float rval, idimr[6];
265
double dd1[3], dd2[3], dd3[3];
269
dd1[2] = dd2[2] = dd3[2] = 0.0;
271
stat = Pixconv("INIT",imno,dd1,dd2,dd3);
272
if (stat > 0) return (stat);
275
(void) SCKRDI("IDIMEMI",1,7,&iav,idimi,&kuni,&knul);
276
/* idimi[1] = SSPX, idimi[2] = SSPY, idimi[5] = SFPX, idimi[6] = SFPY
277
idimi[3] = NSX, idimi[4] = NSY */
279
(void) SCKRDR("IDIMEMR",1,6,&iav,idimr,&kuni,&knul);
280
/* idimr[0] = SWCX, idimr[1] = SWCY, idimr[2] = EWCX, idimr[3] = EWCY */
283
{ /* move in y-direction */
285
{ /* use w.c. in y */
286
dd1[0] = (double) idimr[0];
287
if (idimr[3] > idimr[1]) /* ystep > 0 */
288
dd1[1] = (double) (idimr[1] + inval); /* add offset to y */
290
dd1[1] = (double) (idimr[1] - inval); /* add offset to y */
291
stat = Pixconv("WRS",imno,dd1,dd2,dd3);
294
{ /* use f.p. in y */
295
dd1[0] = (double) idimi[5];
296
dd1[1] = (double) (idimi[6] + inval); /* add f.p.s to y */
297
stat = Pixconv("_RS",imno,dd1,dd2,dd3);
302
rval = (float) dd3[1]; /* screen y-pix */
303
newpix = CGN_NINT(rval);
304
*scrpix = newpix - idimi[2]; /* subtract SSPY */
306
/* if (*scrpix > idimi[4]) SCTPUT("screen pixel value > NSY ..."); */
309
else if (xy_flag == 1)
310
{ /* move in x-direction */
312
{ /* use w.c. in x */
313
if (idimr[2] > idimr[0]) /* xstep > 0 */
314
dd1[0] = (double) (idimr[0] + inval); /* add offset to x */
316
dd1[0] = (double) (idimr[0] - inval); /* add offset to x */
317
dd1[1] = (double) idimr[1];
318
stat = Pixconv("WRS",imno,dd1,dd2,dd3);
321
{ /* use f.p. in x */
322
dd1[0] = (double) (idimi[5] + inval); /* add f.p.s to x */
323
dd1[1] = (double) idimi[6];
324
stat = Pixconv("_RS",imno,dd1,dd2,dd3);
329
rval = (float) dd3[0]; /* screen x-pix */
330
newpix = CGN_NINT(rval);
331
*scrpix = newpix - idimi[1]; /* subtract SSPX */
333
/* if (*scrpix > idimi[3]) SCTPUT("screen pixel value > NSX ..."); */
337
{ /* move in x and y-direction */
341
{ /* use w.c. in x */
342
if (idimr[2] > idimr[0]) /* xstep > 0 */
343
dd1[0] = (double) (idimr[0] + inval); /* add offset to x */
345
dd1[0] = (double) (idimr[0] - inval); /* add offset to x */
346
dd1[1] = (double) idimr[1];
347
stat = Pixconv("WRS",imno,dd1,dd2,dd3);
348
if (stat != 0) return stat;
350
rval = (float) dd3[0]; /* screen x-pix */
351
newpix = CGN_NINT(rval);
352
xdif = newpix - idimi[1]; /* subtract SSPX */
354
dd1[0] = (double) idimr[0];
355
if (idimr[3] > idimr[1]) /* ystep > 0 */
356
dd1[1] = (double) (idimr[1] + inval); /* add offset to y */
358
dd1[1] = (double) (idimr[1] - inval); /* add offset to y */
359
stat = Pixconv("WRS",imno,dd1,dd2,dd3);
363
{ /* use f.p. in x */
364
dd1[0] = (double) (idimi[5] + inval); /* add offset to x */
365
dd1[1] = (double) idimi[6];
366
stat = Pixconv("_RS",imno,dd1,dd2,dd3);
367
if (stat != 0) return stat;
369
rval = (float) dd3[0]; /* screen x-pix */
370
newpix = CGN_NINT(rval);
371
xdif = newpix - idimi[1]; /* subtract SSPX */
373
dd1[0] = (double) idimi[5];
374
dd1[1] = (double) (idimi[6] + inval); /* add offset to y */
375
stat = Pixconv("_RS",imno,dd1,dd2,dd3);
380
rval = (float) dd3[1]; /* screen y-pix */
381
newpix = CGN_NINT(rval);
382
ydif = newpix - idimi[2]; /* subtract SSPY */
384
*scrpix = (xdif + ydif) / 2; /* take mean of x, y difference */
386
/* if (*scrpix > (idimi[3]+idimi[4])/2)
387
SCTPUT("screen pixel value > (NSX+NSY)/2 ..."); */