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

« back to all changes in this revision

Viewing changes to prim/display/libsrc/subcur.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
/* @(#)subcur.c 19.1 (ES0-DMD) 02/25/03 14:00:01 */
 
2
/*===========================================================================
 
3
  Copyright (C) 1995 European Southern Observatory (ESO)
 
4
 
 
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.
 
9
 
 
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.
 
14
 
 
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, 
 
18
  MA 02139, USA.
 
19
 
 
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 
 
26
                        GERMANY
 
27
===========================================================================*/
 
28
 
 
29
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
30
.COPYRIGHT:  Copyright (c) 1994 European Southern Observatory,
 
31
                                         all rights reserved
 
32
 
 
33
 
 
34
 
 
35
   Not used yet ...
 
36
 
 
37
 
 
38
 
 
39
.IDENTIFIER  SUBCUR_C
 
40
.LANGUAGE    C
 
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
 
48
.INPUT/OUTPUT
 
49
  The following keywords are used:
 
50
 
 
51
  DAZIN/I/1/4           (1) = cursor_form_flag: 
 
52
                              98 for fixed cursor_form no. (only DeAnza)
 
53
                              99 for programmable
 
54
                              100 for IDI cursor shapes
 
55
                              101 for IDI region of interest (ROI)
 
56
                              200 for ANGLE
 
57
                              -1 for CLEAR/CURSOR
 
58
                        (2) = cursor no. (0,1,2) for cursor 1,2 or both
 
59
                        (3) = form_no. if (1) = 98
 
60
                              if (1) = 100 then
 
61
                              shape = 0 (implement. dependent),
 
62
                                      1 (full cross hair), 2 (cross)
 
63
                                      3 (open cross), 7 (arrow)
 
64
                              if (1) = 101 then
 
65
                              shape = 1 (recangular ROI)
 
66
                              shape = 2 (circular ROI)
 
67
                        (4) = colour = 0 (checkered in our case)
 
68
                                       1 (black), 2 (white)
 
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
 
75
  
 
76
  call as    SUBCUR_C( jflag )
 
77
 
 
78
  input:
 
79
          int jflag :           = 1 for display cursor
 
80
                                  2 for graphics cursor
 
81
.RETURNS     nothing
 
82
.ENVIRONment MIDAS
 
83
             #include <midas_def.h>   Prototypes for MIDAS interfaces
 
84
             #include <idinumd.h>     Global variables for DISPLAY interfaces
 
85
 
 
86
.VERSIONS    1.00       940630  from IDAUXZ.FOR    R.M.van Hees
 
87
------------------------------------------------------------*/
 
88
/*
 
89
 * Define _POSIX_SOURCE to indicate
 
90
 * that this is a POSIX program
 
91
 */
 
92
#define  _POSIX_SOURCE 1
 
93
 
 
94
/*
 
95
 * definition of the used functions in this module
 
96
 */
 
97
#include <stdio.h>
 
98
#include <string.h>
 
99
#include <midas_def.h>
 
100
 
 
101
/*
 
102
 * define some macros and constants
 
103
 */
 
104
#include <idinumd.h>
 
105
 
 
106
#ifndef TRUE
 
107
#define TRUE            1
 
108
#define FALSE           0
 
109
#endif
 
110
 
 
111
 
 
112
/*++++++++++++++++++++++++++++++
 
113
 *
 
114
 * here starts the code of the function
 
115
 */
 
116
void SUBCUR_C( jflag )
 
117
int jflag;
 
118
{
 
119
register int nn;
 
120
 
 
121
int    actvals, cindx, cform, color, go_on, imno, knul, ncurs, nrco, 
 
122
       num, shape, unit, npix[2], dazzin[4], coord[5];
 
123
float  rbuff[6];
 
124
double start[2], step[2];
 
125
double dbuff;
 
126
 
 
127
char   *pntr1, *pntr2, cbuff[61], inputc[61];
 
128
 
 
129
/*
 
130
 * Get cursor info
 
131
 */
 
132
(void) SCKRDI( "DAZIN", 1, 4, &actvals, dazzin, &unit, &knul );
 
133
cform = dazzin[0];                                           /* internal no. */
 
134
ncurs = dazzin[1] ;
 
135
if ( ncurs < 0 ) ncurs = 0;
 
136
shape = dazzin[3];
 
137
color = dazzin[4];
 
138
 
 
139
/*
 
140
 * Display cursor
 
141
 */
 
142
if ( jflag == 1 )     
 
143
   DCOPEN( 1 );
 
144
else
 
145
   DCOPEN( 2 );                                      /* open graphics window */
 
146
/*
 
147
 * See, if it's CLEAR/CURSOR
 
148
 */
 
149
if ( cform == -1 )     
 
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 );
 
155
        }
 
156
     else
 
157
        (void) IIRSRV_C( QDSPNO, ncurs, 0 );
 
158
 
 
159
     ncurs = -1;                                      /* update key dazin(2) */
 
160
     (void) SCKWRI( "DAZIN", &ncurs, 2, 1, &unit );
 
161
   }
 
162
else
 
163
   { if ( ncurs > 1 )     
 
164
        { if ( cform == 101 && shape == 2 )     
 
165
             nrco = 5;                                       /* circular roi */
 
166
          else
 
167
             nrco = 4 ;
 
168
        }
 
169
     else
 
170
        nrco = 2;                            /* no. of coordinates needed... */
 
171
/*
 
172
 * now check, if also the cursor coordinates should be set
 
173
 */
 
174
     (void) SCKGETC( "P3", 1, 60, &actvals, inputc  );
 
175
     if ( *inputc == '+' )     
 
176
        { if ( nrco == 5 )                                   /* circular roi */
 
177
             { coord[0] = -1;
 
178
               coord[1] = -1;
 
179
               coord[2] =  5;                /* set inner radius to 5 pixels */
 
180
               coord[3] =  0;
 
181
               coord[4] =  0;
 
182
             }
 
183
          else                            /* indicate that we don't use them */
 
184
             for ( nn = 0; nn < 5; nn++ ) coord[nn] = -1;
 
185
 
 
186
          if ( jflag == 1 )
 
187
             SETCUR_C( QDSPNO, ncurs, shape, color, coord );
 
188
          else
 
189
             SETCUR_C( QDSPNO, ncurs, shape, color, coord );
 
190
        }
 
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 );
 
195
               if ( num <= 0 )
 
196
                  SCETER( 1,"SUBCUR: invalid cursor coords. given..." );
 
197
             }
 
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)
 
208
                  SCETER(69,
 
209
                         "problems with init of world coord. conversion...");
 
210
 
 
211
               if ( ncurs == 1 )
 
212
                  cindx = 2;
 
213
               else
 
214
                  cindx = 0;
 
215
/*
 
216
 * handle cursor #0 or #1
 
217
 */
 
218
               go_on = TRUE;
 
219
               while ( go_on )
 
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 );
 
226
                    else
 
227
                       { pntr1++;
 
228
                         (void) strncpy( cbuff, pntr1, (size_t)(pntr2-pntr1));
 
229
                       }
 
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];
 
234
 
 
235
                    if ( ncurs == 0 )     
 
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);
 
240
                         if ( num <= 0 )
 
241
                            SCETER( 1,"SUBCUR: invalid cursor coords. given" );
 
242
                         go_on = FALSE;
 
243
                       }
 
244
                    else
 
245
                       (void) strcpy( inputc, pntr2 + 1 );
 
246
                  }
 
247
             }
 
248
 
 
249
          if ( jflag == 1 )
 
250
             SETCUR_C( QDSPNO, ncurs, shape, color, coord );
 
251
          else
 
252
             SETCUR_C( QDSPNO, ncurs, shape, color, coord );
 
253
        }
 
254
   }
 
255
}