1
/* @(#)subcur.c 19.1 (ES0-DMD) 02/25/03 14:00:01 */
2
/*===========================================================================
3
Copyright (C) 1995 European Southern Observatory (ESO)
5
This program is free software; you can redistribute it and/or
6
modify it under the terms of the GNU General Public License as
7
published by the Free Software Foundation; either version 2 of
8
the License, or (at your option) any later version.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
15
You should have received a copy of the GNU General Public
16
License along with this program; if not, write to the Free
17
Software Foundation, Inc., 675 Massachusetss Ave, Cambridge,
20
Corresponding concerning ESO-MIDAS should be addressed as follows:
21
Internet e-mail: midas@eso.org
22
Postal address: European Southern Observatory
23
Data Management Division
24
Karl-Schwarzschild-Strasse 2
25
D 85748 Garching bei Muenchen
27
===========================================================================*/
29
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
30
.COPYRIGHT: Copyright (c) 1994 European Southern Observatory,
41
.AUTHOR R.M. van Hees IPG-ESO Garching
42
.KEYWORDS ImageDisplay, cursor
43
.PURPOSE Enable/Disable fixed cursor(s) of different shapes or
44
programmable cursors and (optionally) set cursor coordinates
45
.ALGORITHM use IDI interfaces for interacting with the DeAnza
46
(form = 0,...,15) or programmed shape (form=99) or from=100,101
47
for X11; disable cursors with form=-1
49
The following keywords are used:
51
DAZIN/I/1/4 (1) = cursor_form_flag:
52
98 for fixed cursor_form no. (only DeAnza)
54
100 for IDI cursor shapes
55
101 for IDI region of interest (ROI)
58
(2) = cursor no. (0,1,2) for cursor 1,2 or both
59
(3) = form_no. if (1) = 98
61
shape = 0 (implement. dependent),
62
1 (full cross hair), 2 (cross)
63
3 (open cross), 7 (arrow)
65
shape = 1 (recangular ROI)
66
shape = 2 (circular ROI)
67
(4) = colour = 0 (checkered in our case)
69
cf. IDI-doc. page 44 and 38
70
P3/C/1/60 x1,y1,x2,y2 - cursor coordinates
71
xc,yc,r1,r2,r3 if circular ROI
72
P4/C/1/5 = F(RAME) to indicate, that coordinates in P2
73
are not screen coords. but frame related ones
74
INPUTR/R/1/2 angle, length in case of DAZIN(1) = 200
76
call as SUBCUR_C( jflag )
79
int jflag : = 1 for display cursor
83
#include <midas_def.h> Prototypes for MIDAS interfaces
84
#include <idinumd.h> Global variables for DISPLAY interfaces
86
.VERSIONS 1.00 940630 from IDAUXZ.FOR R.M.van Hees
87
------------------------------------------------------------*/
89
* Define _POSIX_SOURCE to indicate
90
* that this is a POSIX program
92
#define _POSIX_SOURCE 1
95
* definition of the used functions in this module
99
#include <midas_def.h>
102
* define some macros and constants
112
/*++++++++++++++++++++++++++++++
114
* here starts the code of the function
116
void SUBCUR_C( jflag )
121
int actvals, cindx, cform, color, go_on, imno, knul, ncurs, nrco,
122
num, shape, unit, npix[2], dazzin[4], coord[5];
124
double start[2], step[2];
127
char *pntr1, *pntr2, cbuff[61], inputc[61];
132
(void) SCKRDI( "DAZIN", 1, 4, &actvals, dazzin, &unit, &knul );
133
cform = dazzin[0]; /* internal no. */
135
if ( ncurs < 0 ) ncurs = 0;
145
DCOPEN( 2 ); /* open graphics window */
147
* See, if it's CLEAR/CURSOR
150
{ if ( ncurs == 2 ) /* region of interest */
151
(void) IIRSRV_C( QDSPNO, 0, 0 );
152
else if ( ncurs == 3 ) /* two independent cursors */
153
{ (void) IIRSRV_C( QDSPNO, 0, 0 );
154
(void) IIRSRV_C( QDSPNO, 1, 0 );
157
(void) IIRSRV_C( QDSPNO, ncurs, 0 );
159
ncurs = -1; /* update key dazin(2) */
160
(void) SCKWRI( "DAZIN", &ncurs, 2, 1, &unit );
164
{ if ( cform == 101 && shape == 2 )
165
nrco = 5; /* circular roi */
170
nrco = 2; /* no. of coordinates needed... */
172
* now check, if also the cursor coordinates should be set
174
(void) SCKGETC( "P3", 1, 60, &actvals, inputc );
175
if ( *inputc == '+' )
176
{ if ( nrco == 5 ) /* circular roi */
179
coord[2] = 5; /* set inner radius to 5 pixels */
183
else /* indicate that we don't use them */
184
for ( nn = 0; nn < 5; nn++ ) coord[nn] = -1;
187
SETCUR_C( QDSPNO, ncurs, shape, color, coord );
189
SETCUR_C( QDSPNO, ncurs, shape, color, coord );
191
else /* yes. set coordinates (frame or screen coords. input) */
192
{ (void) SCKGETC( "P4", 1, 1, &actvals, cbuff );
193
if ( *cbuff != 'f' && *cbuff != 'F' ) /* screen coordinates */
194
{ num = CGN_CNVT( inputc, 1, nrco, coord, rbuff, &dbuff );
196
SCETER( 1,"SUBCUR: invalid cursor coords. given..." );
198
else /* we work with frame coordinates */
199
{ (void) DCGICH(QIMCH);
200
(void) SCFOPN(dzmemc,D_R4_FORMAT,0,F_IMA_TYPE,&imno);
201
(void) SCDRDI(imno, "NPIX" , 1, 2,
202
&actvals, npix, &unit, &knul );
203
(void) SCDRDD( imno, "START", 1, 2,
204
&actvals, start, &unit, &knul );
205
(void) SCDRDD( imno, "STEP" , 1, 2,
206
&actvals, step, &unit, &knul );
207
if (Pixconv("INIT",imno,dd1,dd2,dd3) != 0)
209
"problems with init of world coord. conversion...");
216
* handle cursor #0 or #1
220
{ if ( (pntr1 = strchr( inputc, ',' )) == NULL )
221
SCETER( 1,"SUBCUR: invalid cursor coords. given..." );
222
(void) strncpy( cbuff, inputc, (size_t)(pntr1 - inputc));
223
rbuff[0] = Cgetsng( cbuff, *npix, *start, *step );
224
if ( (pntr2 = strchr( pntr1+1, ',' )) == NULL )
225
(void) strcpy( cbuff, pntr1+1 );
228
(void) strncpy( cbuff, pntr1, (size_t)(pntr2-pntr1));
230
rbuff[1] = Cgetsng( cbuff, npix[1], start[1], step[1] );
231
Pixconv( "_RS", rbuff, start, step );
232
coord[cindx++] = rbuff[4];
233
coord[cindx++] = rbuff[5];
236
go_on = FALSE; /* we're done */
237
else if ( nrco == 5 ) /* circular roi */
238
{ (void) strcpy( inputc, pntr2 + 1 );
239
num = CGN_CNVT( inputc, 1, 3, coord+2, rbuff, &dbuff);
241
SCETER( 1,"SUBCUR: invalid cursor coords. given" );
245
(void) strcpy( inputc, pntr2 + 1 );
250
SETCUR_C( QDSPNO, ncurs, shape, color, coord );
252
SETCUR_C( QDSPNO, ncurs, shape, color, coord );