| 1 |
/* @(#)idiutil2.c 19.1 (ESO-DMD) 02/25/03 13:54:47 */ |
| 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 |
* * |
| 31 |
* file: idiutil2.c * |
| 32 |
* * |
| 33 |
* X11 independent internal service routines * |
| 34 |
* * |
| 35 |
************************************************************************ |
| 36 |
* V 1.1 871201: P. Santin - Trieste Astronomical Observatory (X10) * |
| 37 |
* V 2.0 890102: K. Banse - ESO Garching (from now on) * |
| 38 |
|
| 39 |
010522 last modif |
| 40 |
|
| 41 |
************************************************************************ |
| 42 |
|
| 43 |
* contains the following routines: |
| 44 |
* |
| 45 |
* allrefr : Display Refresh of memories , cursors and roi |
| 46 |
* rectrefr : Display Refresh of rect_memories |
| 47 |
* clgraph : Clear graphics of a memory |
| 48 |
* curmove : Interactive Cursor Movement; |
| 49 |
* loc_mod : Modify Locator Data; |
| 50 |
* loc_zero : Zero Locator Data; |
| 51 |
* polyclear : Clear a polyline; |
| 52 |
* roimodify : Interactive Region of Interest Modify; |
| 53 |
* roimove : Interactive Region of Interest Move; |
| 54 |
* txtclear : Clear a text string; |
| 55 |
* copy_over : Copy overlay graphics to image channel |
| 56 |
* |
| 57 |
***********************************************************************/ |
| 58 |
|
| 59 |
|
| 60 |
# include <idi.h> |
| 61 |
# include <idistruct.h> |
| 62 |
# include <proto_idi.h> |
| 63 |
|
| 64 |
|
| 65 |
static int epsi2 = 2; /* must be synchronized with send_event */ |
| 66 |
/* in module idilocal3.c ! */ |
| 67 |
static int movcount = 0; |
| 68 |
static int temp; |
| 69 |
static int xdif, ydif; |
| 70 |
static int x, y, dxsize, dysize; |
| 71 |
|
| 72 |
static unsigned char pixls[2]; |
| 73 |
|
| 74 |
static LOCATOR *loca; |
| 75 |
|
| 76 |
|
| 77 |
/* |
| 78 |
|
| 79 |
*/ |
| 80 |
|
| 81 |
/* ---- Refresh ------------------------------------------------------ */ |
| 82 |
|
| 83 |
/* general refresh of image memories */ |
| 84 |
|
| 85 |
void allrefr(dspno,mem,memid,flag) |
| 86 |
int dspno, memid, flag; |
| 87 |
MEM_DATA *mem; |
| 88 |
|
| 89 |
{ |
| 90 |
int i, sx, sy, dx, dy; |
| 91 |
CONF_DATA *conf; |
| 92 |
ALPH_DATA *alph; |
| 93 |
|
| 94 |
|
| 95 |
conf = ididev[dspno].confptr; |
| 96 |
|
| 97 |
if (memid != conf->overlay) |
| 98 |
{ |
| 99 |
if (mem->mmbm == (char *) 0) |
| 100 |
i = allo_mem(dspno,mem,memid); |
| 101 |
|
| 102 |
if (ididev[dspno].devtyp == 'g') |
| 103 |
cl_win(dspno,-1); /* ensure right background colour */ |
| 104 |
|
| 105 |
sx = mem->xscroll; |
| 106 |
if (sx >= 0) |
| 107 |
dx = 0; |
| 108 |
else |
| 109 |
{ |
| 110 |
dx = -sx; |
| 111 |
sx = 0; |
| 112 |
} |
| 113 |
|
| 114 |
sy = mem->ysize - (ididev[dspno].ysize + mem->yscroll); |
| 115 |
if (sy >= 0) |
| 116 |
dy = 0; |
| 117 |
else |
| 118 |
{ |
| 119 |
dy = -sy; |
| 120 |
sy = 0; |
| 121 |
} |
| 122 |
|
| 123 |
smv(flag,dspno,mem,memid,sx,sy,mem->xsize,mem->ysize,dx,dy); |
| 124 |
|
| 125 |
if (ididev[dspno].alpno >= 90) |
| 126 |
{ |
| 127 |
alph = conf->alpmem[memid]; |
| 128 |
alprfr(dspno,alph); |
| 129 |
} |
| 130 |
} |
| 131 |
|
| 132 |
if (flag != 0) /* we don't come from IIZWSC_C */ |
| 133 |
{ |
| 134 |
if (mem->gpntr != 0) polyrefr(dspno,mem,0,0); |
| 135 |
if (mem->tpntr != 0) txtrefr(dspno,mem,0,0); |
| 136 |
} |
| 137 |
|
| 138 |
} |
| 139 |
/* |
| 140 |
|
| 141 |
*/ |
| 142 |
|
| 143 |
/* refresh only rectangles of image memories */ |
| 144 |
|
| 145 |
void rectrefr(dspno,mem,memid) |
| 146 |
int dspno, memid; |
| 147 |
MEM_DATA *mem; |
| 148 |
|
| 149 |
{ |
| 150 |
int flag, sx, sy, dx, dy; |
| 151 |
|
| 152 |
CONF_DATA *conf; |
| 153 |
|
| 154 |
ALPH_DATA *alph; |
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
conf = ididev[dspno].confptr; |
| 159 |
|
| 160 |
if (mem->mmbm != (char *) 0) |
| 161 |
{ |
| 162 |
sx = mem->xscroll + mem->xwoff; |
| 163 |
dx = mem->xwoff; |
| 164 |
|
| 165 |
sy = mem->ysize - (mem->ywoff + mem->ywdim); |
| 166 |
dy = ididev[dspno].ysize - (mem->ywoff+mem->ywdim); |
| 167 |
|
| 168 |
if (mem->zoom > 1) |
| 169 |
flag = 1; |
| 170 |
else |
| 171 |
flag = 11; /* to update only a rectangle */ |
| 172 |
smv(flag,dspno,mem,memid,sx,sy,mem->xwdim,mem->ywdim,dx,dy); |
| 173 |
|
| 174 |
if (ididev[dspno].alpno >= 90) |
| 175 |
{ |
| 176 |
alph = conf->alpmem[memid]; |
| 177 |
alprfr(dspno,alph); |
| 178 |
} |
| 179 |
} |
| 180 |
} |
| 181 |
|
| 182 |
/* |
| 183 |
|
| 184 |
*/ |
| 185 |
|
| 186 |
/* ---- Clear Graphics ------------------------------------------- */ |
| 187 |
|
| 188 |
void clgraph(mem) |
| 189 |
|
| 190 |
MEM_DATA *mem; |
| 191 |
|
| 192 |
{ |
| 193 |
GLIST *gp; |
| 194 |
TLIST *tp; |
| 195 |
|
| 196 |
if (mem->gpntr != 0) |
| 197 |
{ |
| 198 |
gp = mem->gpntr; |
| 199 |
gp->geln = 0; |
| 200 |
*gp->off = 0; |
| 201 |
} |
| 202 |
|
| 203 |
if (mem->tpntr != (TLIST *)0) |
| 204 |
{ |
| 205 |
tp = mem->tpntr; |
| 206 |
tp->teln = 0; |
| 207 |
tp->off[0] = 0; |
| 208 |
} |
| 209 |
|
| 210 |
} |
| 211 |
|
| 212 |
/* |
| 213 |
|
| 214 |
*/ |
| 215 |
|
| 216 |
/* ---- locator positions zero --------------------------------------- */ |
| 217 |
|
| 218 |
void loc_zero (dspno) |
| 219 |
int dspno; |
| 220 |
|
| 221 |
{ |
| 222 |
ROI_DATA *roi; |
| 223 |
|
| 224 |
register int loopi; |
| 225 |
|
| 226 |
|
| 227 |
for (loopi=0; loopi<intdevtable[dspno].nloc; loopi++) |
| 228 |
{ |
| 229 |
loca = intdevtable[dspno].loc[loopi]; |
| 230 |
loca->xpos = 0; |
| 231 |
loca->ypos = 0; |
| 232 |
loca->xdif = 0; |
| 233 |
loca->ydif = 0; |
| 234 |
loca->lowsp = 1; |
| 235 |
loca->spfact = 0; /* not used... */ |
| 236 |
loca->speed = loca->lowsp; |
| 237 |
} |
| 238 |
|
| 239 |
roi = ididev[dspno].roi; |
| 240 |
roi->radno = 4; /* reset to default */ |
| 241 |
} |
| 242 |
|
| 243 |
/* |
| 244 |
|
| 245 |
*/ |
| 246 |
|
| 247 |
/* ---- locator modify ----------------------------------------------- */ |
| 248 |
|
| 249 |
|
| 250 |
void loc_mod(dspno,locno,lkey) |
| 251 |
|
| 252 |
int dspno, locno, lkey; |
| 253 |
|
| 254 |
/* dspno : display no. */ |
| 255 |
/* locno : locator no. */ |
| 256 |
/* lkey : locator key */ |
| 257 |
|
| 258 |
{ |
| 259 |
static int locinc[10] = {0,1,2,4,8,16,32,64,100,200}; |
| 260 |
|
| 261 |
ROI_DATA *roi; |
| 262 |
|
| 263 |
|
| 264 |
if ((lkey < 10) && (lkey != -5)) |
| 265 |
{ |
| 266 |
if (lkey < -10) /* just update */ |
| 267 |
{ |
| 268 |
roi = ididev[dspno].roi; |
| 269 |
roi->radno = -(lkey + 10); /* -11,-12,-13,... => 1,2,3,... */ |
| 270 |
if (roi->radno == 2) |
| 271 |
roi->ymax = roi->xmax - roi->radiusm; /* distance value */ |
| 272 |
else if (roi->radno == 3) |
| 273 |
roi->ymax = roi->xmax - roi->radiuso; |
| 274 |
else |
| 275 |
roi->ymax = roi->xmax - roi->radiusi; |
| 276 |
} |
| 277 |
|
| 278 |
else |
| 279 |
{ |
| 280 |
loca = intdevtable[dspno].loc[locno]; |
| 281 |
|
| 282 |
if (lkey < 0) |
| 283 |
{ |
| 284 |
if (lkey == -1) /* update locator positions */ |
| 285 |
{ |
| 286 |
loca->xdif = 0; |
| 287 |
loca->ydif = loca->speed; |
| 288 |
loca->ypos += loca->ydif; |
| 289 |
} |
| 290 |
else if (lkey == -2) |
| 291 |
{ |
| 292 |
loca->xdif = 0; |
| 293 |
loca->ydif = - loca->speed; |
| 294 |
loca->ypos += loca->ydif; |
| 295 |
} |
| 296 |
else if (lkey == -3) |
| 297 |
{ |
| 298 |
loca->ydif = 0; |
| 299 |
loca->xdif = loca->speed; |
| 300 |
loca->xpos += loca->xdif; |
| 301 |
} |
| 302 |
else |
| 303 |
{ |
| 304 |
loca->ydif = 0; |
| 305 |
loca->xdif = - loca->speed; |
| 306 |
loca->xpos += loca->xdif; |
| 307 |
} |
| 308 |
} |
| 309 |
else |
| 310 |
loca->speed = loca->lowsp + locinc[lkey]; |
| 311 |
} |
| 312 |
} |
| 313 |
} |
| 314 |
|
| 315 |
/* |
| 316 |
|
| 317 |
*/ |
| 318 |
|
| 319 |
/* ---- cursor move -------------------------------------------------- */ |
| 320 |
|
| 321 |
/* curno : cursor number */ |
| 322 |
/* locno : locator no. */ |
| 323 |
/* ldat : locator data */ |
| 324 |
/* lpos : locator positions */ |
| 325 |
|
| 326 |
void curmove (dspno,curno,locno,ldat,lpos) |
| 327 |
|
| 328 |
int dspno, curno, locno, ldat, *lpos; |
| 329 |
|
| 330 |
{ |
| 331 |
CURS_DATA *curs; |
| 332 |
|
| 333 |
int kk, jj; |
| 334 |
|
| 335 |
|
| 336 |
curs = ididev[dspno].cursor[curno]; |
| 337 |
loca = intdevtable[dspno].loc[locno]; |
| 338 |
dxsize = ididev[dspno].xsize - 1; |
| 339 |
dysize = ididev[dspno].ysize - 1; |
| 340 |
|
| 341 |
|
| 342 |
/* depending on type of locator we compute new location or just read it */ |
| 343 |
|
| 344 |
if (locno > 0) /* if it's the arrow keys ... */ |
| 345 |
{ |
| 346 |
loc_mod(dspno,locno,ldat); |
| 347 |
xdif = loca->xdif; |
| 348 |
ydif = loca->ydif; |
| 349 |
loca->xdif = 0; |
| 350 |
loca->ydif = 0; |
| 351 |
if ((xdif == 0) && (ydif == 0)) return; /* nothing to do */ |
| 352 |
|
| 353 |
curs->xpos += xdif; |
| 354 |
curs->ypos += ydif; |
| 355 |
} |
| 356 |
|
| 357 |
else |
| 358 |
{ |
| 359 |
if ((lpos[0] == loca->xpos) && (lpos[1] == loca->ypos)) return; |
| 360 |
|
| 361 |
loca->xpos = lpos[0]; |
| 362 |
loca->ypos = lpos[1]; |
| 363 |
|
| 364 |
curs->xpos = loca->xpos + epsi2; |
| 365 |
curs->ypos = dysize - loca->ypos + epsi2; |
| 366 |
} |
| 367 |
|
| 368 |
if (curs->xpos < 0) |
| 369 |
curs->xpos = 0; |
| 370 |
else |
| 371 |
{ |
| 372 |
if (curs->xpos > dxsize) curs->xpos = dxsize; |
| 373 |
} |
| 374 |
if (curs->ypos < 0) |
| 375 |
curs->ypos = 0; |
| 376 |
else |
| 377 |
{ |
| 378 |
if (curs->ypos > dysize) curs->ypos = dysize; |
| 379 |
} |
| 380 |
|
| 381 |
draw_curs(dspno,1,dysize,curno,curs->xpos,curs->ypos,curs->sh,curs->col); |
| 382 |
show_pix8(dspno,curno,curs->xpos,curs->ypos,curs->xpos,curs->ypos,pixls); |
| 383 |
|
| 384 |
if (++movcount == 3) |
| 385 |
{ |
| 386 |
movcount = 0; |
| 387 |
jj = 0; |
| 388 |
sh_loop: |
| 389 |
kk = ididev[dspno].shadow[jj++]; |
| 390 |
if (kk != -1) |
| 391 |
{ |
| 392 |
draw_curs(kk,1,dysize,curno,curs->xpos,curs->ypos,curs->sh,curs->col); |
| 393 |
show_pix8(kk,curno,curs->xpos,curs->ypos,curs->xpos,curs->ypos,pixls); |
| 394 |
goto sh_loop; |
| 395 |
} |
| 396 |
} |
| 397 |
|
| 398 |
} |
| 399 |
|
| 400 |
/* |
| 401 |
|
| 402 |
*/ |
| 403 |
|
| 404 |
/* ---- roi move ----------------------------------------------------- */ |
| 405 |
|
| 406 |
void roimove (dspno,locno,lpos) |
| 407 |
|
| 408 |
int dspno, locno, *lpos; |
| 409 |
|
| 410 |
{ |
| 411 |
int cposx, cposy; |
| 412 |
int xd1, xd2, yd1, yd2; |
| 413 |
int xmi,xma,ymi,yma; |
| 414 |
int kk, jj; |
| 415 |
register int ra, rb; |
| 416 |
|
| 417 |
ROI_DATA *roi; |
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
loca = intdevtable[dspno].loc[locno]; |
| 422 |
if ((lpos[0] == loca->xpos) && (lpos[1] == loca->ypos)) return; |
| 423 |
|
| 424 |
roi = ididev[dspno].roi; |
| 425 |
dxsize = ididev[dspno].xsize -1; |
| 426 |
dysize = ididev[dspno].ysize -1; |
| 427 |
|
| 428 |
ra = lpos[0] + epsi2; /* new center */ |
| 429 |
rb = dysize - lpos[1] + epsi2; |
| 430 |
|
| 431 |
if (roi->sh == 0) /* rectangle */ |
| 432 |
{ |
| 433 |
cposx = (roi->xmin + roi->xmax) / 2; /* old center */ |
| 434 |
cposy = (roi->ymin + roi->ymax) / 2; |
| 435 |
xd1 = cposx - roi->xmin; /* distance to borders */ |
| 436 |
xd2 = roi->xmax - cposx; |
| 437 |
yd1 = cposy - roi->ymin; |
| 438 |
yd2 = roi->ymax - cposy; |
| 439 |
|
| 440 |
|
| 441 |
/* if we are at the window border, we stay put */ |
| 442 |
|
| 443 |
xmi = ra - xd1; |
| 444 |
if ((xmi < 0) || (xmi > dxsize)) return; |
| 445 |
xma = ra + xd2; |
| 446 |
if (xma < xmi) |
| 447 |
xma = xmi; |
| 448 |
else |
| 449 |
{ |
| 450 |
if (xma > dxsize) return; |
| 451 |
} |
| 452 |
ymi = rb - yd1; |
| 453 |
if ((ymi < 0) || (ymi > dysize)) return; |
| 454 |
yma = rb + yd2; |
| 455 |
if (yma < ymi) |
| 456 |
yma = ymi; |
| 457 |
else |
| 458 |
{ |
| 459 |
if (yma > dysize) return; |
| 460 |
} |
| 461 |
|
| 462 |
|
| 463 |
/* update locator position */ |
| 464 |
|
| 465 |
|
| 466 |
roi->xmin = xmi; |
| 467 |
roi->xmax = xma; |
| 468 |
roi->ymin = ymi; |
| 469 |
roi->ymax = yma; |
| 470 |
draw_rroi(dspno,1,dysize,roi->xmin,roi->ymin,roi->xmax,roi->ymax,roi->col); |
| 471 |
show_pix8(dspno,2,roi->xmin,roi->ymin,roi->xmax,roi->ymax,pixls); |
| 472 |
} |
| 473 |
|
| 474 |
else /* circle(s) */ |
| 475 |
{ |
| 476 |
|
| 477 |
/* if we are at the window border, we stay put */ |
| 478 |
|
| 479 |
xmi = ra - roi->radiusi; |
| 480 |
if ((xmi < 0) || (xmi > dxsize)) return; |
| 481 |
xma = ra + roi->radiusi; |
| 482 |
if ((xma < 0) || (xma > dxsize)) return; |
| 483 |
ymi = rb - roi->radiusi; |
| 484 |
if ((ymi < 0) || (ymi > dysize)) return; |
| 485 |
yma = rb + roi->radiusi; |
| 486 |
if ((yma < 0) || (yma > dysize)) return; |
| 487 |
|
| 488 |
roi->xmin = ra; |
| 489 |
roi->ymin = rb; |
| 490 |
draw_croi(dspno,1,dysize,roi->xmin,roi->ymin, |
| 491 |
roi->radiusi,roi->radiusm,roi->radiuso,roi->col); |
| 492 |
show_pix8(dspno,0,roi->xmin,roi->ymin,roi->xmin,roi->ymin,pixls); |
| 493 |
} |
| 494 |
|
| 495 |
loca->xpos = lpos[0]; |
| 496 |
loca->ypos = lpos[1]; |
| 497 |
|
| 498 |
|
| 499 |
if (++movcount == 3) |
| 500 |
{ |
| 501 |
movcount = 0; |
| 502 |
jj = 0; |
| 503 |
sh_loop: |
| 504 |
kk = ididev[dspno].shadow[jj++]; |
| 505 |
if (kk != -1) |
| 506 |
{ |
| 507 |
if (roi->sh == 0) |
| 508 |
{ |
| 509 |
draw_rroi(kk,1,dysize,roi->xmin,roi->ymin,roi->xmax,roi->ymax, |
| 510 |
roi->col); |
| 511 |
show_pix8(kk,2,roi->xmin,roi->ymin,roi->xmax,roi->ymax,pixls); |
| 512 |
} |
| 513 |
else |
| 514 |
{ |
| 515 |
draw_croi(kk,1,dysize,roi->xmin,roi->ymin, |
| 516 |
roi->radiusi,roi->radiusm,roi->radiuso,roi->col); |
| 517 |
show_pix8(kk,0,roi->xmin,roi->ymin,roi->xmin,roi->ymin,pixls); |
| 518 |
} |
| 519 |
goto sh_loop; |
| 520 |
} |
| 521 |
} |
| 522 |
|
| 523 |
} |
| 524 |
|
| 525 |
/* |
| 526 |
|
| 527 |
*/ |
| 528 |
|
| 529 |
/* ---- roi modify --------------------------------------------------- */ |
| 530 |
|
| 531 |
void roimodify (dspno,locno) |
| 532 |
|
| 533 |
int dspno, locno; |
| 534 |
|
| 535 |
{ |
| 536 |
int kk, jj; |
| 537 |
register int ra, rb; |
| 538 |
|
| 539 |
ROI_DATA *roi; |
| 540 |
|
| 541 |
|
| 542 |
loca = intdevtable[dspno].loc[locno]; |
| 543 |
|
| 544 |
x = loca->xdif; y = loca->ydif; |
| 545 |
loca->xdif = 0; loca->ydif = 0; |
| 546 |
|
| 547 |
roi = ididev[dspno].roi; |
| 548 |
dysize = ididev[dspno].ysize - 1; |
| 549 |
|
| 550 |
if (roi->sh == 0) /* rectangle */ |
| 551 |
{ |
| 552 |
ra = roi->xmax; |
| 553 |
rb = roi->ymax; |
| 554 |
|
| 555 |
if (x != 0) |
| 556 |
{ |
| 557 |
ra += x; |
| 558 |
if (ra < 0) |
| 559 |
ra = 0; |
| 560 |
else |
| 561 |
{ |
| 562 |
dxsize = ididev[dspno].xsize - 1; |
| 563 |
if (ra > dxsize) ra = dxsize; |
| 564 |
} |
| 565 |
if (ra < roi->xmin) ra = roi->xmin; |
| 566 |
} |
| 567 |
else |
| 568 |
{ |
| 569 |
if (y == 0) return; /* x=0 and y=0, => nothing to do */ |
| 570 |
} |
| 571 |
|
| 572 |
if (y != 0) |
| 573 |
{ |
| 574 |
rb += y; |
| 575 |
if (rb < 0) |
| 576 |
rb = 0; |
| 577 |
else |
| 578 |
{ |
| 579 |
if (rb > dysize) rb = dysize; |
| 580 |
} |
| 581 |
if (rb < roi->ymin) rb = roi->ymin; |
| 582 |
} |
| 583 |
|
| 584 |
roi->xmax = ra; |
| 585 |
roi->ymax = rb; |
| 586 |
draw_rroi(dspno,1,dysize,roi->xmin,roi->ymin,roi->xmax,roi->ymax,roi->col); |
| 587 |
show_pix8(dspno,2,roi->xmin,roi->ymin,roi->xmax,roi->ymax,pixls); |
| 588 |
} |
| 589 |
|
| 590 |
else /* circle(s) */ |
| 591 |
{ |
| 592 |
if (x == 0) |
| 593 |
{ |
| 594 |
if (y == 0) return; /* x=0 and y=0, => nothing to do */ |
| 595 |
x = y; /* so we only use x */ |
| 596 |
} |
| 597 |
rb = (roi->xmax + x) - roi->ymax; /* new rad = new ref_rad - distance */ |
| 598 |
|
| 599 |
|
| 600 |
/* update according to function keys F1, F2, F3 or F4 */ |
| 601 |
|
| 602 |
if (roi->radno == 2) /* only middle radius */ |
| 603 |
{ |
| 604 |
if (roi->radiusm < 1) return; |
| 605 |
if (rb == roi->radiusm) |
| 606 |
{ |
| 607 |
if (x < 0) |
| 608 |
rb -- ; /* for x/y = -1 */ |
| 609 |
else |
| 610 |
rb ++ ; /* for x/y = +1 */ |
| 611 |
} |
| 612 |
|
| 613 |
if ((roi->radiuso > 0) && (rb > roi->radiuso)) rb = roi->radiuso; |
| 614 |
if (rb < roi->radiusi) rb = roi->radiusi; |
| 615 |
|
| 616 |
roi->radiusm = rb; |
| 617 |
} |
| 618 |
|
| 619 |
else if (roi->radno == 3) /* only outer radius */ |
| 620 |
{ |
| 621 |
if (roi->radiuso < 1) return; |
| 622 |
if (rb == roi->radiuso) |
| 623 |
{ |
| 624 |
if (x < 0) |
| 625 |
rb -- ; /* for x/y = -1 */ |
| 626 |
else |
| 627 |
rb ++ ; /* for x/y = +1 */ |
| 628 |
} |
| 629 |
|
| 630 |
if (roi->radiusm > 0) |
| 631 |
{ |
| 632 |
if (rb < roi->radiusm) rb = roi->radiusm; |
| 633 |
} |
| 634 |
else |
| 635 |
{ |
| 636 |
if (rb < roi->radiusi) rb = roi->radiusi; |
| 637 |
} |
| 638 |
|
| 639 |
roi->radiuso = rb; |
| 640 |
} |
| 641 |
|
| 642 |
else |
| 643 |
{ |
| 644 |
if (rb == roi->radiusi) |
| 645 |
{ |
| 646 |
if (x < 0) |
| 647 |
rb -- ; /* for x/y = -1 */ |
| 648 |
else |
| 649 |
rb ++ ; /* for x/y = +1 */ |
| 650 |
} |
| 651 |
if (rb < 1) rb = 1; /* at least 1 pixel radius */ |
| 652 |
|
| 653 |
if (roi->radno == 4) /* change inner circle + others (relative) */ |
| 654 |
{ |
| 655 |
ra = rb - roi->radiusi; /* diff. of new + old radius */ |
| 656 |
if (roi->radiusm > 0) roi->radiusm += ra; |
| 657 |
if (roi->radiuso > 0) roi->radiuso += ra; |
| 658 |
} |
| 659 |
else /* only inner radius */ |
| 660 |
{ |
| 661 |
if (roi->radiusm > 0) |
| 662 |
{ |
| 663 |
if (rb > roi->radiusm) rb = roi->radiusm; |
| 664 |
} |
| 665 |
else if (roi->radiuso > 0) |
| 666 |
{ |
| 667 |
if (rb > roi->radiuso) rb = roi->radiuso; |
| 668 |
} |
| 669 |
} |
| 670 |
roi->radiusi = rb; |
| 671 |
} |
| 672 |
roi->xmax = rb + roi->ymax; /* update ref_radius */ |
| 673 |
|
| 674 |
draw_croi(dspno,1,dysize,roi->xmin,roi->ymin, |
| 675 |
roi->radiusi,roi->radiusm,roi->radiuso,roi->col); |
| 676 |
show_pix8(dspno,0,roi->xmin,roi->ymin,roi->xmin,roi->ymin,pixls); |
| 677 |
} |
| 678 |
|
| 679 |
jj = 0; |
| 680 |
sh_loop: |
| 681 |
kk = ididev[dspno].shadow[jj++]; |
| 682 |
if (kk != -1) |
| 683 |
{ |
| 684 |
if (roi->sh == 0) |
| 685 |
{ |
| 686 |
draw_rroi(kk,1,dysize,roi->xmin,roi->ymin,roi->xmax,roi->ymax, |
| 687 |
roi->col); |
| 688 |
show_pix8(kk,2,roi->xmin,roi->ymin,roi->xmax,roi->ymax,pixls); |
| 689 |
} |
| 690 |
else |
| 691 |
{ |
| 692 |
draw_croi(kk,1,dysize,roi->xmin,roi->ymin, |
| 693 |
roi->radiusi,roi->radiusm,roi->radiuso,roi->col); |
| 694 |
show_pix8(kk,0,roi->xmin,roi->ymin,roi->xmin,roi->ymin,pixls); |
| 695 |
} |
| 696 |
goto sh_loop; |
| 697 |
} |
| 698 |
} |
| 699 |
|
| 700 |
/* |
| 701 |
|
| 702 |
*/ |
| 703 |
|
| 704 |
/* ---- Clear Polyline on display bitmap ----------------------------- */ |
| 705 |
|
| 706 |
void polyclear(dspno,mem,xs,ys,np) |
| 707 |
|
| 708 |
int dspno, *xs, *ys, np; |
| 709 |
MEM_DATA *mem; |
| 710 |
|
| 711 |
{ |
| 712 |
int kindx, koff, hit; |
| 713 |
int *goff, *gx, *gy, *gcount, *gcol, *glw; |
| 714 |
register int loopi, loopk; |
| 715 |
|
| 716 |
GLIST *gp; |
| 717 |
|
| 718 |
|
| 719 |
gp = mem->gpntr; |
| 720 |
if (gp == 0) return; |
| 721 |
|
| 722 |
kindx = gp->geln; |
| 723 |
if (kindx <= 0) return; |
| 724 |
|
| 725 |
x = *xs; |
| 726 |
dysize = ididev[dspno].ysize - 1; |
| 727 |
y = dysize - (*ys); |
| 728 |
hit = 0; |
| 729 |
|
| 730 |
|
| 731 |
again: |
| 732 |
goff = gp->off; |
| 733 |
gcount = gp->count; |
| 734 |
gcol = gp->color; |
| 735 |
glw = gp->lwidth; |
| 736 |
|
| 737 |
for (loopi=0; loopi<kindx; loopi++) |
| 738 |
{ |
| 739 |
koff = *goff; |
| 740 |
gx = gp->x + koff; |
| 741 |
if (*gx == x) |
| 742 |
{ |
| 743 |
gy = gp->y + koff; |
| 744 |
if (*gy == y) |
| 745 |
{ |
| 746 |
if (gp->geln == 1) |
| 747 |
{ |
| 748 |
gp->geln = 0; |
| 749 |
*gp->off = 0; |
| 750 |
} |
| 751 |
else |
| 752 |
{ |
| 753 |
hit = 1; |
| 754 |
temp = loopi; |
| 755 |
goto clean_up; |
| 756 |
} |
| 757 |
} |
| 758 |
} |
| 759 |
goff ++; gcount ++; gcol ++; glw ++; |
| 760 |
} |
| 761 |
|
| 762 |
if (hit == 1) polyrefr(dspno,mem,0,0); |
| 763 |
return; |
| 764 |
|
| 765 |
|
| 766 |
clean_up: |
| 767 |
for (loopi=temp; loopi<(kindx-1); loopi++) |
| 768 |
{ |
| 769 |
*gcount = *(gcount+1); |
| 770 |
*gcol = *(gcol+1); |
| 771 |
*glw = *(glw+1); |
| 772 |
|
| 773 |
for (loopk=0; loopk<(*gcount); loopk++) |
| 774 |
{ |
| 775 |
*gx = *(gx+np); |
| 776 |
*gy = *(gy+np); |
| 777 |
gx ++; gy ++; |
| 778 |
} |
| 779 |
*(goff+1) = (*goff) + (*gcount); |
| 780 |
goff ++; gcount ++; gcol ++; glw ++; |
| 781 |
} |
| 782 |
|
| 783 |
gp->geln --; |
| 784 |
kindx = gp->geln; |
| 785 |
goto again; /* there may be more */ |
| 786 |
|
| 787 |
} |
| 788 |
|
| 789 |
/* |
| 790 |
|
| 791 |
*/ |
| 792 |
|
| 793 |
/* ---- Clear Text on display bitmap ----------------------------- */ |
| 794 |
|
| 795 |
void txtclear(dspno,mem,xs,ys,np) |
| 796 |
|
| 797 |
int dspno, xs, ys, np; |
| 798 |
MEM_DATA *mem; |
| 799 |
|
| 800 |
{ |
| 801 |
int tindx, toff, hit, zoff; |
| 802 |
register int loopi, loopk; |
| 803 |
|
| 804 |
TLIST *tp; |
| 805 |
|
| 806 |
|
| 807 |
tp = mem->tpntr; |
| 808 |
if (tp == (TLIST *)0) return; |
| 809 |
|
| 810 |
tindx = tp->teln; |
| 811 |
if (tindx <= 0) return; |
| 812 |
|
| 813 |
x = xs; |
| 814 |
dysize = ididev[dspno].ysize - 1; |
| 815 |
y = dysize - ys; |
| 816 |
hit = 0; |
| 817 |
temp = 0; |
| 818 |
|
| 819 |
again: |
| 820 |
for (loopi=temp; loopi<tindx; loopi++) |
| 821 |
{ |
| 822 |
if ((tp->x[loopi] == x) && (tp->y[loopi] == y)) |
| 823 |
{ |
| 824 |
if (tp->teln == 1) |
| 825 |
{ |
| 826 |
tp->teln = 0; |
| 827 |
tp->off[0] = 0; |
| 828 |
} |
| 829 |
else |
| 830 |
{ |
| 831 |
hit = 1; |
| 832 |
temp = loopi; |
| 833 |
goto clean_up; |
| 834 |
} |
| 835 |
} |
| 836 |
} |
| 837 |
|
| 838 |
if (hit == 1) txtrefr(dspno,mem,0,0); |
| 839 |
return; |
| 840 |
|
| 841 |
|
| 842 |
clean_up: |
| 843 |
zoff = tp->off[temp+1]; /* offset of next element */ |
| 844 |
for (loopi=temp; loopi<(tindx-1); loopi++) |
| 845 |
{ |
| 846 |
toff = tp->off[loopi]; |
| 847 |
tp->count[loopi] = tp->count[loopi+1]; |
| 848 |
tp->x[loopi] = tp->x[loopi+1]; |
| 849 |
tp->y[loopi] = tp->y[loopi+1]; |
| 850 |
tp->size[loopi] = tp->size[loopi+1]; |
| 851 |
tp->color[loopi] = tp->color[loopi+1]; |
| 852 |
|
| 853 |
for (loopk=0; loopk<tp->count[loopi+1]; loopk++) |
| 854 |
{ |
| 855 |
tp->text[toff++] = tp->text[zoff++]; |
| 856 |
} |
| 857 |
zoff = tp->off[loopi+2]; /* offset of [loop+1] in next loop */ |
| 858 |
tp->off[loopi+1] = tp->off[loopi] + tp->count[loopi]; |
| 859 |
} |
| 860 |
|
| 861 |
tp->teln --; |
| 862 |
tindx = tp->teln; |
| 863 |
goto again; /* there may be more */ |
| 864 |
|
| 865 |
} |
| 866 |
|
| 867 |
/* |
| 868 |
|
| 869 |
*/ |
| 870 |
|
| 871 |
/* ---- Copy graphics from overlay channel to image memory ----------- */ |
| 872 |
|
| 873 |
void copy_over(dspno,memid,append) |
| 874 |
int dspno, memid, append; |
| 875 |
|
| 876 |
{ |
| 877 |
int *x, *y, *off, *colo, *lw, *cou; |
| 878 |
int *ovx, *ovy, *ovoff, *ovcolo, *ovlw, *ovcou; |
| 879 |
int kk, kindx, ioff, coff; |
| 880 |
register int nr, mr; |
| 881 |
|
| 882 |
char *inpntr, *cpntr; |
| 883 |
|
| 884 |
CONF_DATA *conf; |
| 885 |
MEM_DATA *ovmem, *mem; |
| 886 |
GLIST *gpov, *gp; |
| 887 |
TLIST *tpov, *tp; |
| 888 |
|
| 889 |
|
| 890 |
conf = ididev[dspno].confptr; |
| 891 |
if (memid == conf->overlay) return; |
| 892 |
|
| 893 |
mem = conf->memory[memid]; |
| 894 |
ovmem = conf->memory[conf->overlay]; |
| 895 |
|
| 896 |
|
| 897 |
/* work on the graphics */ |
| 898 |
|
| 899 |
gpov = ovmem->gpntr; |
| 900 |
nr = gpov->geln; |
| 901 |
if (nr == 0) goto text_section; /* no graphics to copy */ |
| 902 |
|
| 903 |
gp = mem->gpntr; |
| 904 |
if (append == 1) |
| 905 |
{ |
| 906 |
kindx = gp->geln; |
| 907 |
gp->geln += gpov->geln; |
| 908 |
} |
| 909 |
else |
| 910 |
{ |
| 911 |
kindx = 0; |
| 912 |
gp->geln = gpov->geln; |
| 913 |
} |
| 914 |
|
| 915 |
off = gp->off + kindx; |
| 916 |
colo = gp->color + kindx; |
| 917 |
lw = gp->lwidth + kindx; |
| 918 |
cou = gp->count + kindx; |
| 919 |
x = gp->x + kindx; |
| 920 |
y = gp->y + kindx; |
| 921 |
|
| 922 |
ovoff = gpov->off; |
| 923 |
ovcolo = gpov->color; |
| 924 |
ovlw = gpov->lwidth; |
| 925 |
ovcou = gpov->count; |
| 926 |
ovx = gpov->x; |
| 927 |
ovy = gpov->y; |
| 928 |
|
| 929 |
for (nr=0; nr<gpov->geln; nr++) |
| 930 |
{ /* copy offset, colour, linewidth, no_pnts */ |
| 931 |
*off++ = *ovoff++; |
| 932 |
*colo++ = *ovcolo++; |
| 933 |
*lw++ = *ovlw++; |
| 934 |
*cou++ = *ovcou++; |
| 935 |
} |
| 936 |
*off = *ovoff; /* offset is 1 index farther... */ |
| 937 |
|
| 938 |
cou = gp->count + kindx; |
| 939 |
for (nr=0; nr<gpov->geln; nr++) |
| 940 |
{ /* for each graph_elem copy x,y */ |
| 941 |
for (mr=0; mr<(*cou); mr++) |
| 942 |
{ |
| 943 |
*x++ = *ovx++; |
| 944 |
*y++ = *ovy++; |
| 945 |
} |
| 946 |
cou ++; |
| 947 |
} |
| 948 |
|
| 949 |
polyrefr(dspno,mem,1,memid); |
| 950 |
|
| 951 |
|
| 952 |
/* work on the text */ |
| 953 |
|
| 954 |
text_section: |
| 955 |
tpov = ovmem->tpntr; |
| 956 |
nr = tpov->teln; |
| 957 |
if (nr == 0) return; /* no text to copy */ |
| 958 |
|
| 959 |
tp = mem->tpntr; |
| 960 |
if (append == 1) |
| 961 |
{ |
| 962 |
kindx = tp->teln; |
| 963 |
tp->teln += tpov->teln; |
| 964 |
} |
| 965 |
else |
| 966 |
{ |
| 967 |
kindx = 0; |
| 968 |
tp->teln = tpov->teln; |
| 969 |
} |
| 970 |
|
| 971 |
off = tp->off + kindx; |
| 972 |
colo = tp->color + kindx; |
| 973 |
lw = tp->size + kindx; |
| 974 |
cou = tp->count + kindx; |
| 975 |
x = tp->x + kindx; |
| 976 |
y = tp->y + kindx; |
| 977 |
|
| 978 |
ovoff = tpov->off; |
| 979 |
ovcolo = tpov->color; |
| 980 |
ovlw = tpov->size; |
| 981 |
ovcou = tpov->count; |
| 982 |
ovx = tpov->x; |
| 983 |
ovy = tpov->y; |
| 984 |
|
| 985 |
for (nr=0; nr<tpov->teln; nr++) |
| 986 |
{ /* copy offset, colour, size, no_pnts */ |
| 987 |
*x++ = *ovx++; |
| 988 |
*y++ = *ovy++; |
| 989 |
*off++ = *ovoff++; |
| 990 |
*colo++ = *ovcolo++; |
| 991 |
*lw++ = *ovlw++; |
| 992 |
*cou++ = *ovcou++; |
| 993 |
} |
| 994 |
*off = *ovoff; /* offset is 1 index farther... */ |
| 995 |
|
| 996 |
coff = tp->off[kindx]; |
| 997 |
for (nr=0; nr<tpov->teln; nr++) |
| 998 |
{ |
| 999 |
ioff = tpov->off[nr]; |
| 1000 |
inpntr = &(tpov->text[ioff]); |
| 1001 |
cpntr = &(tp->text[coff]); |
| 1002 |
kk = tpov->count[nr]; |
| 1003 |
for (mr=0; mr<kk; mr++) *cpntr++ = *inpntr++; |
| 1004 |
coff += kk; |
| 1005 |
} |
| 1006 |
|
| 1007 |
txtrefr(dspno,mem,1,memid); |
| 1008 |
} |