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
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
31
.AUTHOR K. Banse IPG-ESO Garching
32
.KEYWORDS ImageDisplay, memory control regs.
33
.PURPOSE manipulate the memory control registers of a given channel
34
.ALGORITHM use IDIs to do the job
36
The following keywords are used:
38
DAZIN/I/1/2 LUT/ITT section no., flag for graphics memory
40
INPUTI/I/1/5 channel1, channel2, ..., -1, delay in 10th of seconds
42
call as SUBMEM_C( action, dazhld )
45
char *action : action flag:
46
B, for blinking between two image channels
47
C, for clearing the memory channel
48
D, display in a user friendly format
49
all image channel related info (SHOW/CHANNEL)
50
I, for setting ITT section
51
L, for setting LUT section
52
M, for loading an image/graphics memory into FCR's
53
R, for displaying the refscale/intensity_bar
54
S, startup afresh = initialize the ima_display
59
#include <midas_def.h> Prototypes for MIDAS interfaces
60
#include <idinumd.h> Global variables for DISPLAY interfaces
62
.VERSIONS 1.00 940630 converted from IDAUXZ.FOR R.M.van Hees
65
------------------------------------------------------------*/
67
/* Define _POSIX_SOURCE to indicate that this is a POSIX program */
69
#define _POSIX_SOURCE 1
73
#include <midas_def.h>
83
void SUBMEM_C(action,dazhld)
88
int actvals, inputi, itt, knul, lutno, lutvis, refsc;
89
int actcha, splmod, unit, dazzin[2], jarea;
92
char output[84], frame[16];
93
char *info_usr = "switch cursor(s) on - next time we exit...",
94
*str_chpi = "start channel pixels: %8d%8d",
95
*str_used = "channel pixels used: %8d%8d",
96
*str_frpi = "start frame pixels: %8d%8d",
97
*str_scal = "scaling factors: %8d%8d",
98
*str_scro = "scroll values: %8d%8d",
99
*str_zoom = "zoom factors: %8d%8d",
100
*str_chsz = "channel size: %8d%8d",
101
*war_lutno = "Invalid lut section - forced to section 0 ...";
108
splmod = dazhld[2]; /* initialisation */
113
(void) SCKRDI("DAZIN",1,2,&actvals,dazzin,&unit,&knul);
117
if (*action != 'S') /* not for CLEAR/DISPLAY */
119
if ((*action == 'L') && (inputi >= 0)) /* enable LUT */
120
(void) SCKGETC("P2",1,10,&actvals,output);
122
(void) SCKGETC("P1",1,10,&actvals,output);
124
(void) CGN_UPCOPY(frame,output,8);
127
else if (frame[0] == 'O')
135
stat = CGN_CNVT(frame,1,1,&actcha,&rdum,&ddum);
136
if ((stat != 1) || (actcha < 0) || (actcha > QLSTCH))
140
(void)sprintf(cdum,"invalid image channel (= %s) ...",output);
147
/* branch to desired action */
149
if (*action == 'B') /* blink between channels */
151
int ink[MAXCHN], maxchan, mm, dummy[4];
152
float delay[MAXCHN], dt;
154
(void) SCKRDI("DAZDEVR",20,1,&actvals,&maxchan,&unit,&knul); /* max chans */
155
if (maxchan > MAXCHN)
156
SCETER(11,"Max. no. of channels out of sync with DAZDEVR(20)!");
158
(void) SCKRDI("CHANLS",1,maxchan,&actvals,ink,&unit,&knul);
160
for (ii=0; ii<maxchan; ii++)
168
if (mm < 2) (void) SCETER(11,"Bad (or not enough) channels entered...");
171
(void) Cdazvis(QDSPNO,QIMCH,2,1);
174
(void) SCKRDR("INPUTR",1,1,&actvals,&dt,&unit,&knul);
175
for (ii=0; ii<mm; ii++) delay[ii] = dt; /* DELAY is in seconds */
178
/* check, what option for blinking area we have */
180
(void) SCKGETC("P3",1,60,&actvals,output);
181
if (output[0] == '+')
186
if (strcmp(output,"CURSOR") == 0)
192
int give_info, cooco, coords[4];
193
int worky, statA, statB, xwdim, ywdim, xwoff, ywoff;
197
for (ii=0; ii<4; ii++) coords[ii] = -1;
199
CONCHA_C(QDSPNO,QOVCH,1,0); /* Clear ov_chan if necessary */
200
(void) SETCUR_C(QDSPNO,2,1,0,coords); /* setup cursor rectange */
203
/* read cursor position(s) */
205
cooco = 0; /* counter for cursor reading */
208
Ccursin(QDSPNO,0,2,xya,&statA,xyb,&statB);
211
Ccursin(QDSPNO,1,2,xya,&statA,xyb,&statB);
213
if ((statA == 0) && (statB == 0))
215
if ((give_info == 0) && (cooco == 0)) /* EXIT (1) */
220
Ccursin(QDSPNO,0,2,xya,&statA,xyb,&statB);
230
CONCHA_C(QDSPNO,QOVCH,1,0);
231
(void) IIISTI_C(QDSPNO);
233
xwdim = xyb[0] - xya[0] + 1;
234
ywdim = xyb[1] - xya[1] + 1;
235
xwoff = xya[0]; /* rectangle offset in memory */
239
/* 1. chanl -> full view, all other chanls -> rectangle only */
241
(void) IIMSTW_C(QDSPNO,ink[0],-99,QMSZX,QMSZY,-99,0,0);
242
for (ii=1; ii<mm; ii++)
243
(void) IIMSTW_C(QDSPNO,ink[ii],-99,xwdim,ywdim,-99,xwoff,ywoff);
245
(void) IIMBLM_C(QDSPNO,ink,mm,delay);
247
(void) Cdazvis(QDSPNO,QIMCH,2,1);
249
SCTDIS(" Move to next rectangle, or push EXIT button",80);
250
Ccursin(QDSPNO,0,2,xya,&statA,xyb,&statB);
256
{ /* do it via IIMBLM, we get out of there via Exit button */
257
for (ii=0; ii<mm; ii++)
258
(void) IIMSTW_C(QDSPNO,ink[ii],-99,QMSZX,QMSZY,-99,0,0);
260
(void) IIMBLM_C(QDSPNO,ink,mm,delay);
262
/* get currently displayed channel */
264
(void) IIDQDC_C(QDSPNO,0,1,1,dummy,ink,dummy,dummy,dummy,dummy,&mm);
266
DCGICH(QIMCH); /* update memory info */
270
else if (*action == 'C') /* handle CLEAR/CHANNEL business here */
272
CONCHA_C(QDSPNO,actcha,0,*dazzin);
273
(void) strcpy(dzmemc," "); /* prepare data for cleaned channel */
276
NSX = QMSZX; /* nopix in image memory */
280
SCROLX = 0; /* pixel 0 -> left edge of display screen */
281
SCROLY = QMSZY - 1; /* last chan line -> top line of display */
288
DCPICH(actcha); /* store new setup of channel */
291
else if (*action == 'D') /* handle SHOW/CHANNEL here */
295
if ((actcha == QOVCH) && (IDINUM == 11))
297
(void) sprintf(mybuf,
298
"Overlay channel (%d) is emulated by software for X11",actcha);
303
(void) DCGICH(actcha); /* get info from IDI display */
307
if (actcha != QOVCH) /* display usage of channel */
308
(void) sprintf(mybuf,"Image channel %d:",actcha);
310
(void) sprintf(mybuf,"Overlay channel %d:",actcha);
312
if (SOURCE > 0) /* from LOAD/IMAGE */
313
(void) sprintf(output,"%s frame %s loaded",mybuf,dzmemc);
315
(void) sprintf(output,"%s unused... ",mybuf);
320
(void) sprintf(output,"plane_no. loaded: %d",ZPLANE);
326
(void) sprintf(mybuf,"Image channel 0:");
327
if (SOURCE > 0) /* from LOAD/IMAGE */
328
(void) sprintf(output,"%s frame %s loaded",mybuf,dzmemc);
330
(void) sprintf(output,"%s unused... ",mybuf);
334
SCTPUT("channel 0 used for red color");
335
else if (actcha == 1)
336
SCTPUT("channel 1 used for green color");
338
SCTPUT("channel 2 used for blue color");
342
/* display channel size; */
344
(void) sprintf( output, str_chsz, QMSZX, QMSZY );
348
/* display start screen pixels */
350
(void) sprintf( output, str_chpi, SSPX, SSPY );
354
/* display no. of ima_mempixels */
356
(void) sprintf( output, str_used, NSX, NSY );
360
/* display start frame pixels */
362
(void) sprintf( output, str_frpi, SFPX, SFPY );
366
/* display scaling factors */
377
(void) sprintf(output,str_scal,*dazzin,dazzin[1]);
381
/* display scroll values */
383
(void) sprintf( output, str_scro, SCROLX, SCROLY );
387
/* display zoom factors */
389
(void) sprintf( output, str_zoom, ZOOMX, ZOOMY );
396
(void) SCKGETC("HCITTLUT",1,42,&actvals,output);
397
(void) strncpy(cbuff, output, 20 );
399
(void) sprintf(output,"current ITT = %s",cbuff);
402
(void) strcpy(output,"no ITT used");
406
(void) strcpy(output,"no graphics in channel ");
408
(void) strcpy(output,"graphics in channel ");
414
else if (*action == 'I') /* handle ITT business here */
420
if ( inputi < 0 ) /* clear ITT */
423
ITTYES = 1; /* set to visible */
426
ittno = 0; /* ITT section always = 0 */
430
/* Get last referenced LUT section no.
431
LUTNO in [0,3] (enabled LUT_sect) or in [100,103] (disabled LUT_sect) */
433
if ( lutno > 99 ) lutno -= 100;
436
/* select desired ITT and same LUT + en/disable visibility */
438
if (ittvis > 0) (void) IIMSLT_C(QDSPNO,actcha,lutno,ittno);
441
/* leave lut visibility as it is */
444
(void) IIDSDP_C(QDSPNO,&actcha,1,&lutvis,&ittvis);
446
(void) Cdazvis(QDSPNO,QIMCH,2,1);
449
else if (*action == 'L') /* en/disable LUT */
454
if (lutno < 100) lutno += 100; /* force to 100,101,102,103 */
459
if (inputi == 99) /* if 99, use last lut_section */
461
if (lutno >= 100) lutno -= 100; /* force to 0,1,2,3 */
465
if ( (inputi >= 0) && (inputi <= 3) )
469
(void) SCTDIS(war_lutno,0);
470
lutno = 0; /* default to section 0 */
475
(void) SCKWRI("DAZHOLD",&lutno,10,1,&unit);
478
/* select LUT + ITT section */
481
(void) IIMSLT_C(QDSPNO,actcha,inputi,itt);
484
/* set LUT + ITT visibility */
486
(void) IIDSDP_C(QDSPNO,&actcha,1,&lutvis,&itt);
488
(void) Cdazvis( QDSPNO,QIMCH,2,1); /* display channel */
491
else if ( *action == 'M' ) /* load image memory into FCR's */
495
if (QIMCH == QOVCH) /* only for non-X11 */
498
(void)SCETER(5,"invalid image channel (= overlay channel) ...");
501
(void) Cdazvis(QDSPNO,QIMCH,2,1);
502
if (QRGBFL != 1) Alphamem(QIMCH);
507
(void) DCGICH(QIMCH);
510
/* handle pseudo-colour + RGB mode differently ...! */
512
if (QRGBFL != 1) /* here in non-RGB (3 channels) mode */
516
lutvis = 7; /* use LUT... */
517
if ( inputi >= 0 && inputi <= 3 )
520
(void) SCKWRI("DAZHOLD",&lutno,10,1,&unit);
528
lutvis = 0; /* bypass LUT... */
532
/* select LUT + ITT section */
535
(void) IIMSLT_C(QDSPNO,QIMCH,inputi,itt);
538
/* display channel on screen + use given LUT section */
540
(void) Cdazvis(QDSPNO,QIMCH,2,1);
543
(void) IIDSDP_C(QDSPNO,&QIMCH,1,&lutvis,&itt);
546
else /* RGB mode: only handle the alpha part */
550
else if (*action == 'R') /* handle DISPLAY/LUT business here */
552
(void) Cdazvis(QDSPNO,QIMCH,1,refsc);
555
/* draw outer rectangle and bars, if graphics channel exists */
557
if ((QOVCH != -1) && (IDINUM != 11))
559
int color, posx, posy, lrecx[18], lrecy[18];
561
static char *str[5] = { "50", "100", "150", "200", "250" };
565
factx = QDSZX / 512.; /* these numbers were calculated */
566
facty = QDSZY / 512.; /* for 512*512 display initially */
568
lrecx[0] = lrecx[1] = 0;
569
lrecx[2] = CGN_NINT( 87 * factx );
571
lrecy[1] = lrecy[2] = CGN_NINT( 19 * facty );
572
(void) IIGPLY_C(QDSPNO,QOVCH,lrecx,lrecy,3,color,1);
574
lrecx[0] = CGN_NINT( 110 * factx );
575
lrecx[1] = CGN_NINT( 183 * factx );
576
(void) IIGPLY_C(QDSPNO,QOVCH,lrecx,lrecy+1,2, color,1);
578
lrecx[0] = CGN_NINT( 216 * factx );
579
lrecx[1] = CGN_NINT( 283 * factx );
580
(void) IIGPLY_C( QDSPNO, QOVCH, lrecx, lrecy + 1, 2, color, 1 );
582
lrecx[0] = CGN_NINT( 316 * factx );
583
lrecx[1] = CGN_NINT( 383 * factx );
584
(void) IIGPLY_C( QDSPNO, QOVCH, lrecx, lrecy + 1, 2, color, 1 );
586
lrecx[0] = CGN_NINT( 416 * factx );
587
lrecx[1] = CGN_NINT( 483 * factx );
588
(void) IIGPLY_C( QDSPNO, QOVCH, lrecx, lrecy + 1, 2, color, 1 );
590
lrecx[0] = lrecx[1] = CGN_NINT( 511 * factx );
591
lrecx[2] = lrecx[3] = lrecx[4] = CGN_NINT( 500 * factx );
592
lrecx[5] = lrecx[6] = lrecx[7] = CGN_NINT( 400 * factx );
593
lrecx[8] = lrecx[9] = lrecx[10] = CGN_NINT( 300 * factx );
594
lrecx[11] = lrecx[12] = lrecx[13] = CGN_NINT( 200 * factx );
595
lrecx[14] = lrecx[15] = lrecx[16] = CGN_NINT( 100 * factx );
597
for ( ii = 0; ii < 18; ii++ ) lrecy[ii] = 0;
598
lrecy[0] = CGN_NINT( 19 * facty );
599
for ( ii = 3; ii < 18; ii += 3 ) lrecy[ii] = CGN_NINT( 8 * facty );
600
(void) IIGPLY_C( QDSPNO, QOVCH, lrecx, lrecy , 18, color, 1 );
605
posx = CGN_NINT( 94 * factx );
606
posy = CGN_NINT( 12 * facty );
607
(void) IIGTXT_C( QDSPNO, QOVCH, str[0], posx, posy, 0, 0, color, 0 );
609
posx = CGN_NINT( 190 * factx );
610
(void) IIGTXT_C( QDSPNO, QOVCH, str[1], posx, posy, 0, 0, color, 0 );
612
posx = CGN_NINT( 290 * factx );
613
(void) IIGTXT_C( QDSPNO, QOVCH, str[2], posx, posy, 0, 0, color, 0 );
615
posx = CGN_NINT( 390 * factx );
616
(void) IIGTXT_C( QDSPNO, QOVCH, str[3], posx, posy, 0, 0, color, 0 );
618
posx = CGN_NINT( 490 * factx );
619
(void) IIGTXT_C( QDSPNO, QOVCH, str[4], posx, posy, 0, 0, color, 0 );
623
else if (*action == 'S') /* handle CLEAR/DISPLAY here */
625
QOVCH = QLSTCH; /* use last channel as overlay channel */
626
QIMCH = 0; /* start with channel 0 for images... */
629
/* Now use IIDSEL to do the default configuration */
631
(void) IIDRST_C(QDSPNO); /* this call needed on other devices... */
632
(void) IIDSEL_C(QDSPNO,1);
635
/* Initialize data for cleaned channels */
637
(void) strcpy(dzmemc," ");
640
NSX = QMSZX; /* nopix in image memory */
644
SCROLX = 0; /* pixel 0 -> left edge of display screen */
645
SCROLY = QMSZY - 1; /* last chan line -> top line of display */
652
for (ii=0; ii<=QLSTCH; ii++) DCPICH(ii);
655
/* Set up values for key DAZHOLD */
657
dazhld[0] = 0; /* cursor no. */
658
dazhld[1] = -1; /* cursor form (-1 = disabled) */
659
dazhld[2] = 0; /* user split mode (0 = off, 1 = on) */
660
dazhld[3] = (QDSZX - 1) / 2; /* split addresses in x,y */
661
dazhld[4] = (QDSZY - 1) / 2; /* set to center of display */
662
dazhld[5] = 1; /* zoom factors in x,y */
664
dazhld[7] = 0; /* refscale flag */
665
dazhld[8] = 1; /* overlay_set flag */
666
dazhld[9] = 0; /* last referenced lut section */
667
dazhld[10] = 1; /* no. of memory boards per channel */
668
(void) SCKWRI( "DAZHOLD", dazhld, 1, 11, &unit );
670
/* finally clear + enable also the overlay */
672
(void) IIMCMY_C(QDSPNO,&QOVCH,1,0);
673
(void) Cdazvis(QDSPNO,QOVCH,2,1);
677
SCETER(1,"SUBMEM: unknown option");
685
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
686
.COPYRIGHT (c) 1994 European Southern Observatory
689
.AUTHOR K. Banse IPG-ESO Garching
690
.KEYWORDS Image Display , memory board
691
.PURPOSE fill the channel with a constant value
692
.ALGORITHM use IDI interfaces
695
call as CONCHA_C(display,chan,aux_flag,value)
698
int display device id
699
int chan memory channel no.
700
int aux_flag if set to 1, check keyword AUX_MODE(9) first,
701
if we should update the channel;
702
AUX_MODE(9) = 1, yes do it
703
AUX_MODE(9) = 0, no don't do it
704
int value constant to write into memory channel
708
.VERSIONS 1.00 940325 F2C, taken from LOADWN.FOR RvH
709
1.10 960522 change meaning of parameter #3, KB
710
------------------------------------------------------------*/
713
void CONCHA_C(display,chan,aux_flag,value)
714
int display, chan, aux_flag, value;
717
if (aux_flag == 1) /* check AUX_MODE(9) first ... */
719
int iav, knul, unit, doit;
721
(void) SCKRDI("AUX_MODE",9,1,&iav,&doit,&unit,&knul);
722
if (doit != 1) return;
726
(void) IIMCMY_C(display,&chan,1,value);