| 1 |
/* @(#)iil.c 19.1 (ESO-DMD) 02/25/03 13:54:48 */ |
| 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 Massachusetts Ave, Cambridge, |
| 18 |
MA 02139, USA. |
| 19 |
|
| 20 |
Correspondence concerning ESO-MIDAS should be addressed as follows: |
| 21 |
Internet e-mail: [email protected] |
| 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 |
/* --------- IIL -------------------------------------------------- */ |
| 31 |
/* ----------------------------------------------------------------- */ |
| 32 |
|
| 33 |
/* file iil.c : contains the following routines |
| 34 |
* |
| 35 |
* IILWIT_C : Write Intensity Transformation Table; |
| 36 |
* IILRIT_C : Read Intensity Transformation Table; |
| 37 |
* IILWLT_C : Write Video Look-up Table; |
| 38 |
* IILRLT_C : Read Video Look-up Table; |
| 39 |
* IILSBV_C : Set Bar Visibility; |
| 40 |
* |
| 41 |
* V 1.1 871201: P. Santin - Trieste Astronomical Observatory |
| 42 |
* V 2.0 881221: K. Banse - ESO Garching |
| 43 |
|
| 44 |
020527 last modif |
| 45 |
|
| 46 |
********************************************************************** |
| 47 |
*/ |
| 48 |
|
| 49 |
# include <idi.h> |
| 50 |
# include <idistruct.h> |
| 51 |
# include <proto_idi.h> |
| 52 |
|
| 53 |
|
| 54 |
static CONF_DATA *conf; |
| 55 |
static MEM_DATA *mem; |
| 56 |
static LUT_DATA *lut; |
| 57 |
static ITT_DATA *itt; |
| 58 |
|
| 59 |
/* |
| 60 |
|
| 61 |
*/ |
| 62 |
|
| 63 |
/************************************************************************ |
| 64 |
* IILWIT_C routine : write intensity transformation table * |
| 65 |
* * |
| 66 |
* synopsis IILWIT_C (display , memid , ittn , ittstart , ittlen , * |
| 67 |
* ittdata); * |
| 68 |
* * |
| 69 |
* int display; input display identifier * |
| 70 |
* int memid; input memory identifier * |
| 71 |
* int ittn; input ITT identifier * |
| 72 |
* int ittstart; input ITT offset * |
| 73 |
* int ittlen; input ITT length * |
| 74 |
* float *ittdata; input ITT data * |
| 75 |
************************************************************************/ |
| 76 |
|
| 77 |
int IILWIT_C (display, memid, ittn, ittstart, ittlen, ittdata) |
| 78 |
|
| 79 |
int display , memid , ittn , ittstart , ittlen; |
| 80 |
float ittdata []; |
| 81 |
|
| 82 |
{ |
| 83 |
register float fq; |
| 84 |
|
| 85 |
int no; |
| 86 |
register int i, k; |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
no = ididev[display].screen; |
| 91 |
if ((Xworkst[no].visual != 4) && (Xworkst[no].ownlut != 1)) return(II_SUCCESS); |
| 92 |
|
| 93 |
if (ididev[display].opened == 0) return(DEVNOTOP); |
| 94 |
if (ittstart + ittlen > Xworkst[no].lutlen) return(ITTLENERR); |
| 95 |
|
| 96 |
/* store ITT values */ |
| 97 |
|
| 98 |
conf = ididev[display].confptr; |
| 99 |
if ((memid < 0) || (memid>= conf->nmem)) return(ILLMEMID); |
| 100 |
|
| 101 |
mem = conf->memory[memid]; |
| 102 |
itt = mem->ittpntr; |
| 103 |
fq = Xworkst[no].lutlen - 1.0; |
| 104 |
|
| 105 |
for (i=0,k=ittstart; i<ittlen; i++,k++) |
| 106 |
itt->val[k] = (int) (ittdata[i] * fq); /* => [0,LUTsize-1] */ |
| 107 |
|
| 108 |
itt->vis = 1; |
| 109 |
|
| 110 |
lut = ididev[display].lookup; |
| 111 |
wr_lut(display,lut,lut->vis); /* make the ITT visible */ |
| 112 |
|
| 113 |
return(II_SUCCESS); |
| 114 |
} |
| 115 |
|
| 116 |
/* |
| 117 |
|
| 118 |
*/ |
| 119 |
|
| 120 |
/************************************************************************ |
| 121 |
* IILRIT_C routine : read intensity transformation table * |
| 122 |
* * |
| 123 |
* synopsis IILRIT_C (display , memid , ittn , ittstart , ittlen , * |
| 124 |
* ittdata); * |
| 125 |
* * |
| 126 |
* int display; input display identifier * |
| 127 |
* int memid; input memory identifier * |
| 128 |
* int ittn; input ITT identifier * |
| 129 |
* int ittstart; input ITT offset * |
| 130 |
* int ittlen; input ITT length * |
| 131 |
* float *ittdata; input ITT data * |
| 132 |
************************************************************************/ |
| 133 |
|
| 134 |
int IILRIT_C (display, memid, ittn, ittstart, ittlen, ittdata) |
| 135 |
|
| 136 |
int display , memid , ittn , ittstart , ittlen; |
| 137 |
float ittdata []; |
| 138 |
|
| 139 |
{ |
| 140 |
register float fq, rval; |
| 141 |
|
| 142 |
int no; |
| 143 |
register int i, k; |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
no = ididev[display].screen; |
| 148 |
if ((Xworkst[no].visual != 4) && (Xworkst[no].ownlut != 1)) return(II_SUCCESS); |
| 149 |
|
| 150 |
if (ididev[display].opened == 0) return(DEVNOTOP); |
| 151 |
if (ittstart + ittlen > Xworkst[no].lutlen) return(ITTLENERR); |
| 152 |
|
| 153 |
conf = ididev[display].confptr; |
| 154 |
if ((memid < 0) || (memid>= conf->nmem)) return(ILLMEMID); |
| 155 |
mem = conf->memory[memid]; |
| 156 |
itt = mem->ittpntr; |
| 157 |
|
| 158 |
/* now copy from itt structure to return data */ |
| 159 |
|
| 160 |
fq = 1.0 / (Xworkst[no].lutlen - 1.0); |
| 161 |
for (i=0,k=ittstart; i<ittlen; i++,k++) |
| 162 |
{ |
| 163 |
rval = (float) itt->val[k]; |
| 164 |
ittdata[i] = rval * fq; /* => [0.,1.] */ |
| 165 |
} |
| 166 |
|
| 167 |
return(II_SUCCESS); |
| 168 |
} |
| 169 |
|
| 170 |
/* |
| 171 |
|
| 172 |
*/ |
| 173 |
|
| 174 |
/************************************************************************ |
| 175 |
* IILWLT_C routine : write video look-up table * |
| 176 |
* * |
| 177 |
* synopsis IILWLT_C (display , lutn , lutstart , lutlen , lutdata) * |
| 178 |
* * |
| 179 |
* int display; input display identifier * |
| 180 |
* int lutn; input look-up identifier * |
| 181 |
* int lutstart; input look-up offset * |
| 182 |
* int lutlen; input look-up length * |
| 183 |
* float *lutdata; input look-up data * |
| 184 |
************************************************************************/ |
| 185 |
|
| 186 |
int IILWLT_C (display , lutn , lutstart , lutlen , lutdata) |
| 187 |
|
| 188 |
int display , lutn , lutstart , lutlen; |
| 189 |
float lutdata []; |
| 190 |
|
| 191 |
{ |
| 192 |
register float fq; |
| 193 |
|
| 194 |
int no; |
| 195 |
register int ltlen2, i, k, icolr, icolg, icolb; |
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
no = ididev[display].screen; |
| 200 |
if ((Xworkst[no].visual != 4) && (Xworkst[no].ownlut != 1)) return(II_SUCCESS); |
| 201 |
|
| 202 |
if (ididev[display].opened == 0) return(DEVNOTOP); |
| 203 |
|
| 204 |
if (lutn < -1) return(LUTIDERR); |
| 205 |
if (lutstart + lutlen > Xworkst[no].lutlen) return(LUTLENERR); |
| 206 |
|
| 207 |
lut = ididev[display].lookup; |
| 208 |
|
| 209 |
ltlen2 = lutlen + lutlen; |
| 210 |
|
| 211 |
|
| 212 |
/* store LUT values for R G B */ |
| 213 |
|
| 214 |
fq = Xworkst[no].lutfct; |
| 215 |
for (i=0,k=lutstart; i<lutlen; i++,k++) |
| 216 |
{ |
| 217 |
icolr = fq * lutdata[i]; |
| 218 |
icolg = fq * lutdata[lutlen + i]; |
| 219 |
icolb = fq * lutdata[ltlen2 + i]; |
| 220 |
lut->lutr[k] = icolr; |
| 221 |
lut->lutg[k] = icolg; |
| 222 |
lut->lutb[k] = icolb; |
| 223 |
} |
| 224 |
|
| 225 |
lut->vis = 1; |
| 226 |
wr_lut(display,lut,lut->vis); |
| 227 |
|
| 228 |
return(II_SUCCESS); |
| 229 |
} |
| 230 |
|
| 231 |
/* |
| 232 |
|
| 233 |
*/ |
| 234 |
|
| 235 |
/************************************************************************ |
| 236 |
* IILRLT_C routine : read video look-up table * |
| 237 |
* * |
| 238 |
* synopsis IILRLT_C (display , lutn , lutstart , lutlen , lutdata) * |
| 239 |
* * |
| 240 |
* int display; input display identifier * |
| 241 |
* int lutn; input look-up identifier * |
| 242 |
* int lutstart; input look-up offset * |
| 243 |
* int lutlen; input look-up length * |
| 244 |
* float *lutdata; output look-up data * |
| 245 |
************************************************************************/ |
| 246 |
|
| 247 |
int IILRLT_C (display , lutn , lutstart , lutlen , lutdata) |
| 248 |
|
| 249 |
int display , lutn , lutstart , lutlen; |
| 250 |
float lutdata []; |
| 251 |
|
| 252 |
{ |
| 253 |
register float fq; |
| 254 |
|
| 255 |
int no; |
| 256 |
register int ltlen2, i, k; |
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
no = ididev[display].screen; |
| 261 |
if ((Xworkst[no].visual != 4) && (Xworkst[no].ownlut != 1)) return(II_SUCCESS); |
| 262 |
|
| 263 |
if (ididev[display].opened == 0) return(DEVNOTOP); |
| 264 |
|
| 265 |
if (lutn < -1) return(LUTIDERR); |
| 266 |
if (lutstart + lutlen > Xworkst[no].lutlen) return(LUTLENERR); |
| 267 |
|
| 268 |
lut = ididev[display].lookup; |
| 269 |
ltlen2 = lutlen + lutlen; |
| 270 |
fq = Xworkst[no].lutinv; |
| 271 |
|
| 272 |
|
| 273 |
/* lutn = 99, means plot colours ... */ |
| 274 |
|
| 275 |
if (lutn == 99) |
| 276 |
{ |
| 277 |
LUT_DATA plut; |
| 278 |
|
| 279 |
rd_pllut(display,&plut); /* read LUT values for plot colours */ |
| 280 |
|
| 281 |
|
| 282 |
for (i=0; i<PLOT_COLOURS; i++) /* copy from pLUT to return data */ |
| 283 |
{ |
| 284 |
lutdata[i] = fq * plut.lutr[i]; |
| 285 |
lutdata[lutlen + i] = fq * plut.lutg[i]; |
| 286 |
lutdata[ltlen2 + i] = fq * plut.lutb[i]; |
| 287 |
} |
| 288 |
} |
| 289 |
|
| 290 |
else |
| 291 |
{ |
| 292 |
rd_lut(display,lut); /* read LUT values for R G B */ |
| 293 |
|
| 294 |
for (i=0,k=lutstart; i<lutlen; i++,k++) /* copy from LUT to return data */ |
| 295 |
{ |
| 296 |
lutdata[i] = fq * lut->lutr[k]; |
| 297 |
lutdata[lutlen + i] = fq * lut->lutg[k]; |
| 298 |
lutdata[ltlen2 + i] = fq * lut->lutb[k]; |
| 299 |
} |
| 300 |
} |
| 301 |
|
| 302 |
return(II_SUCCESS); |
| 303 |
} |
| 304 |
|
| 305 |
/* |
| 306 |
|
| 307 |
*/ |
| 308 |
|
| 309 |
/************************************************************************ |
| 310 |
* IILSBV_C routine : set bar visibility * |
| 311 |
* * |
| 312 |
* synopsis IILSBV_C (display , memid , vis); * |
| 313 |
* * |
| 314 |
* int display; input display identifier * |
| 315 |
* int memid; input memory identifier * |
| 316 |
* int vis; input bar visibility [0/1] * |
| 317 |
************************************************************************/ |
| 318 |
|
| 319 |
int IILSBV_C(display, memid, vis) |
| 320 |
int display, memid, vis; |
| 321 |
|
| 322 |
{ |
| 323 |
INTBAR *bar; |
| 324 |
MEM_DATA *ovmem; |
| 325 |
|
| 326 |
int i, no; |
| 327 |
|
| 328 |
|
| 329 |
no = ididev[display].screen; |
| 330 |
if (ididev[display].opened == 0) return(DEVNOTOP); |
| 331 |
|
| 332 |
bar = ididev[display].bar; |
| 333 |
if (vis == 1) |
| 334 |
{ |
| 335 |
if (bar->wp == 0) |
| 336 |
crelutbar(display,bar); |
| 337 |
else |
| 338 |
vislutbar(display,bar,vis); |
| 339 |
} |
| 340 |
|
| 341 |
else |
| 342 |
{ |
| 343 |
if (bar->vis == 1) |
| 344 |
{ |
| 345 |
conf = ididev[display].confptr; |
| 346 |
if (conf->RGBmode == 1) |
| 347 |
{ |
| 348 |
if (memid == 3) |
| 349 |
memid = conf->overlay; |
| 350 |
else |
| 351 |
memid = 0; /* single memory for 3 channels */ |
| 352 |
} |
| 353 |
else |
| 354 |
{ |
| 355 |
if ((memid < 0) || (memid >= conf->nmem)) return(ILLMEMID); |
| 356 |
} |
| 357 |
mem = conf->memory[memid]; |
| 358 |
|
| 359 |
vislutbar(display,bar,vis); |
| 360 |
allrefr(display,mem,memid,1); |
| 361 |
i = conf->overlay; |
| 362 |
if (memid != i) |
| 363 |
{ |
| 364 |
ovmem = conf->memory[i]; |
| 365 |
allrefr(display,ovmem,i,1); |
| 366 |
} |
| 367 |
} |
| 368 |
} |
| 369 |
|
| 370 |
bar->vis = vis; |
| 371 |
|
| 372 |
return(II_SUCCESS); |
| 373 |
} |
| 374 |
|