1 /* $Id: ddvcolor.h,v 1.18 2001/05/08 19:04:29 lewisg Exp $ 2 * =========================================================================== 3 * 4 * PUBLIC DOMAIN NOTICE 5 * National Center for Biotechnology Information (NCBI) 6 * 7 * This software/database is a "United States Government Work" under the 8 * terms of the United States Copyright Act. It was written as part of 9 * the author's official duties as a United States Government employee and 10 * thus cannot be copyrighted. This software/database is freely available 11 * to the public for use. The National Library of Medicine and the U.S. 12 * Government do not place any restriction on its use or reproduction. 13 * We would, however, appreciate having the NCBI and the author cited in 14 * any work or product based on this material 15 * 16 * Although all reasonable efforts have been taken to ensure the accuracy 17 * and reliability of the software and data, the NLM and the U.S. 18 * Government do not and cannot warrant the performance or results that 19 * may be obtained by using this software or data. The NLM and the U.S. 20 * Government disclaim all warranties, express or implied, including 21 * warranties of performance, merchantability or fitness for any particular 22 * purpose. 23 * 24 * =========================================================================== 25 * 26 * File Name: $Id: ddvcolor.h,v 1.18 2001/05/08 19:04:29 lewisg Exp $ 27 * 28 * Author: Lewis Geer 29 * 30 * Version Creation Date: 6/2/99 31 * 32 * $Revision: 1.18 $ 33 * 34 * File Description: Shared color information for viewers 35 * 36 * Modifications: 37 * -------------------------------------------------------------------------- 38 * $Log: ddvcolor.h,v $ 39 * Revision 1.18 2001/05/08 19:04:29 lewisg 40 * bitfield to unsigned 41 * 42 * Revision 1.17 2000/02/15 22:40:57 lewisg 43 * add ability to launch udv so that it colors by row, fixes to colormgr, track rows from viewmgr, fix visual c projects 44 * 45 * Revision 1.16 2000/02/10 15:51:58 lewisg 46 * cn3d responds and send correct update messages. many coloring bug fixes 47 * 48 * Revision 1.15 2000/02/10 14:15:18 durand 49 * add a function to build Feature colors table 50 * 51 * Revision 1.14 2000/01/28 19:25:39 lewisg 52 * columnwise binary search on color data 53 * 54 * Revision 1.13 1999/12/29 22:55:02 lewisg 55 * get rid of seqalign id 56 * 57 * Revision 1.12 1999/12/13 23:20:43 lewisg 58 * bug fixes: duplicate color structures eliminated, clear color doesn't clear case 59 * 60 * Revision 1.11 1999/12/10 20:59:22 durand 61 * add support for italic, bold and underlined letters 62 * 63 * Revision 1.10 1999/11/24 21:24:24 vakatov 64 * Fixed for the C++ and/or MSVC DLL compilation 65 * 66 * Revision 1.9 1999/11/24 15:23:19 lewisg 67 * added color selection dialogs for SS 68 * 69 * Revision 1.8 1999/11/22 17:29:54 lewisg 70 * add back color selection dialogs, fix viewer3d half-selection bug 71 * 72 * Revision 1.7 1999/11/01 22:10:26 lewisg 73 * add ability to call color functions by type, and add this to cn3d 74 * 75 * Revision 1.6 1999/10/25 20:28:48 lewisg 76 * move ddvcolor to libncbiobj 77 * 78 * Revision 6.6 1999/10/15 20:56:40 lewisg 79 * append DDV_ColorGlobal as userdata. free memory when cn3d terminates. 80 * 81 * Revision 6.5 1999/10/08 23:20:36 lewisg 82 * add case and box attributes to DDV_ColorCell 83 * 84 * Revision 6.4 1999/10/05 23:18:26 lewisg 85 * add ddv and udv to cn3d with memory management 86 * 87 * Revision 6.3 1999/09/21 18:09:13 lewisg 88 * binary search added to color manager, various bug fixes, etc. 89 * 90 * Revision 1.8 1999/09/01 23:02:59 lewisg 91 * binary search in color functions 92 * 93 * Revision 1.7 1999/08/13 22:08:16 lewisg 94 * color manager updated to use alignment coords 95 * 96 * Revision 1.6 1999/08/09 18:09:33 lewisg 97 * copy of ddvcolor from distrib to avoid changing daily build 98 * 99 * Revision 6.2 1999/07/19 19:12:21 lewisg 100 * fix bug adding new pColor in old pMediaInfo. Also added ability to detect overlaps when allocating new pColor 101 * 102 * Revision 6.1 1999/07/16 18:46:46 lewisg 103 * moved ddvcolor from api to tools 104 * 105 * Revision 1.4 1999/07/13 23:24:48 lewisg 106 * added DDV_SipList 107 * 108 * Revision 1.3 1999/07/13 17:02:00 lewisg 109 * fix forward declaration error in sgi compiler 110 * 111 * Revision 1.2 1999/07/13 14:38:39 lewisg 112 * separated out networking code 113 * 114 * Revision 1.4 1999/06/24 17:48:28 lewisg 115 * added SpecialColors to global 116 * 117 * Revision 1.3 1999/06/16 13:51:50 lewisg 118 * added palette management functions from cn3d 119 * 120 * Revision 1.2 1999/06/14 17:20:47 lewisg 121 * minor bug fix for leaks 122 * 123 * Revision 1.1 1999/06/11 23:37:10 lewisg 124 * color management functions 125 * 126 * 127 * 128 * ========================================================================== 129 */ 130 131 132 #ifndef DDVCOLOR_H 133 #define DDVCOLOR_H 134 135 #include <ncbilcl.h> 136 #include <ncbistd.h> 137 #include <objall.h> 138 #include <binary.h> 139 140 #undef NLM_EXTERN 141 #ifdef NLM_IMPORT 142 #define NLM_EXTERN NLM_IMPORT 143 #else 144 #define NLM_EXTERN extern 145 #endif 146 147 #ifdef __cplusplus 148 extern "C" { 149 #endif 150 151 152 /* the default size of the buffer to allocate. */ 153 #define DDV_BUFSIZE 1024 154 155 typedef struct _DDV_Id { 156 Boolean fAlign; /* pointing to alignment or sequence? */ 157 SeqId *sip; /* for the sequence. duplicate */ 158 Int4 lRow; /* for the alignment */ 159 } DDV_Id; 160 161 /* a range on a sequence or alignment row */ 162 typedef struct _DDV_Range { 163 Int4 lFrom; 164 Int4 lTo; 165 } DDV_Range; 166 167 typedef struct _DDV_ColorCell { 168 Uint1 rgb[3]; /* standard rgb color cell */ 169 unsigned LowerCase:1, TopBox:1, RightBox:1, BottomBox:1, LeftBox:1, UseBold:1, UseItalic:1, UseUnderline:1; 170 } DDV_ColorCell; 171 172 typedef struct _DDV_Color { 173 DDV_Range Range; /* the coordinates of the entity covered by the colorcell */ 174 DDV_ColorCell *pColorCell; /* the array of colors */ 175 } DDV_Color; 176 177 /* standard color entry */ 178 typedef struct _DDV_ColorEntry { 179 DDV_ColorCell ColorCell; /* the color cell */ 180 Char * Name; /* the name of the color */ 181 Char * Paints; /* what the color paints */ 182 Int4 Index; /* an index assigned to the colors after they are allocated */ 183 } DDV_ColorEntry; 184 185 typedef struct _DDV_MediaInfo { 186 DDV_Id Id; /* the id for either sequence or alignment row */ 187 ValNode *pvnColor; /* ValNode list of DDV_Color associated with the object */ 188 Boolean fVisible; /* is the sequence visible? */ 189 B_Global *pSearchColor; /* used to search pvnColor structure by position */ 190 } DDV_MediaInfo; 191 192 /*bag to put various "standard color tables"*/ 193 typedef struct _DDV_SpecialColor { 194 DDV_ColorCell * pFeatColorTable;/*Table of color for features; max size=FEATDEF_MAX*/ 195 } DDV_SpecialColor; 196 197 /***************************************************************************** 198 * 199 * This is the global structure that contains all of the color info 200 * 201 *****************************************************************************/ 202 203 typedef struct _DDV_ColorGlobal { 204 ValNode *pvnMediaInfo; /* ValNode list of DDV_MediaInfo */ 205 SeqId *MasterSeqId; /* this refers to the master sequence */ 206 Boolean fColorByMaster; /* use only the master sequence to color */ 207 Boolean fDefaultColor; /* fDefaultColor means run the default coloration */ 208 ValNode *pvnColorQueue; /* Valnode list of DDV_ColorQueue */ 209 ValNode *pvnAllColorFns; /* Valnode list of all color functions that can 210 be exposed externally to the viewers. to be used 211 by SAM */ 212 ValNode *Palette; /* ValNode list of DDV_ColorEntries */ 213 ValNode *pvnSpecialColors; /* ValNode list of DDV_ColorEntries. used for 214 highlight, secondary structure, etc. */ 215 B_Global *pSearchMI; /* used to search the MediaInfo structure for sips */ 216 B_Global *pSearchMIRow; /* used to search the MediaInfo structure for sips */ 217 DDV_SpecialColor SpeClr; /*"standard color tables"*/ 218 ValNode *pvnUser2Row; /* associates user keys with rows */ 219 void *pObject; /* pointer to the object we are coloring */ 220 } DDV_ColorGlobal; 221 222 /***************************************************************************** 223 * 224 * The color function queue. The queue is used to 225 * register color function by szName (like "Color by Conservation") and to 226 * give each function an lPriority. The algorithm to determine what function 227 * to call is: 228 * - if requested, a default coloration is performed. 229 * - look for an fOverride algorithm with the correct szName. If found, run it, 230 * then stop. 231 * - look for all function that match the correct szName OR have fCallMe set. 232 * Run each algorithm in priority order. 233 * 234 * Viewers must take care to set the visible bits beforehand as this 235 * influences coloration. 236 * 237 * DDV_ColorFunc takes as arguments pData for user data and a range 238 * pRange. If To < From, the range should be ignored. 239 * 240 *****************************************************************************/ 241 242 /* standard lPriority's */ 243 #define DDV_PRIHI 20 244 #define DDV_PRIMED 0 245 #define DDV_PRILO -20 246 247 typedef void (*DDV_ColorFunc)(DDV_ColorGlobal *pColorGlobal, void *pData, 248 DDV_Range *pRange); 249 250 typedef struct _DDV_ColorQueue { 251 Char * szName; /* the menu name. must be unique if used by SAM to add 252 and delete functions */ 253 DDV_ColorFunc pfnColorFunc; 254 Int4 lPriority; /* order that the functions are called */ 255 Boolean fOverride; /* ignore priority and only call this function */ 256 Uint2 procid; /* the procid of the viewer that owns this function */ 257 struct _DDV_ColorQueue * next; /* these are used to sort the color functions */ 258 struct _DDV_ColorQueue * prev; /* *not* for storing them together. */ 259 } DDV_ColorQueue; 260 261 262 /***************************************************************************** 263 * 264 * get a color for a Feature. 265 * 266 *****************************************************************************/ 267 NLM_EXTERN DDV_ColorCell DDV_GetFeatColor(DDV_ColorGlobal* pColorGlobal, Int1 idx); 268 269 /***************************************************************************** 270 * 271 * setup a DDV_ColorCell with r,g,b values. 272 * 273 *****************************************************************************/ 274 NLM_EXTERN DDV_ColorCell DDV_GetColorRGB(Uint1 r, Uint1 g, Uint1 b); 275 276 /***************************************************************************** 277 * 278 * Set default values for DDV_Range. 279 * 280 *****************************************************************************/ 281 282 NLM_EXTERN Int4 DDV_DefaultRange(DDV_Range *pRange, Int4 lFrom, Int4 lTo); 283 284 /***************************************************************************** 285 * 286 * Constructor for DDV_ColorEntry structure. DDV_ColorEntry is a 287 * (Red, Green, Blue) color triplet and associated szName. 288 * 289 *****************************************************************************/ 290 291 NLM_EXTERN DDV_ColorEntry * DDV_CreateColorEntry(Char *szName, Nlm_Uint1 Red, 292 Nlm_Uint1 Green, Nlm_Uint1 Blue); 293 294 /***************************************************************************** 295 * 296 * Destructor for DDV_ColorEntry Color. 297 * 298 *****************************************************************************/ 299 300 NLM_EXTERN void DDV_DeleteColorEntry(DDV_ColorEntry *Color); 301 302 /***************************************************************************** 303 * 304 * Frees a Palette. 305 * Note that it frees the entire Valnode list pointed to by Palette and 306 * sets Palette to NULL. 307 * 308 *****************************************************************************/ 309 310 NLM_EXTERN void DDV_FreePalette(ValNode **Palette); 311 312 /***************************************************************************** 313 * 314 * Sets the Index in a DDV_ColorEntry according to position in Palette 315 * 316 *****************************************************************************/ 317 318 NLM_EXTERN void DDV_SetColorChoice(ValNode *Palette); 319 320 /***************************************************************************** 321 * 322 * Looks for ColorCell on the Palette. Returns * to the DDV_ColorEntry 323 * 324 *****************************************************************************/ 325 326 NLM_EXTERN DDV_ColorEntry * DDV_SearchColor(ValNode *Palette, 327 DDV_ColorCell *ColorCell); 328 329 /***************************************************************************** 330 * 331 * Looks for a DDV_ColorEntry on the Palette by szName. Returns * 332 * to the DDV_ColorEntry. 333 * 334 *****************************************************************************/ 335 336 NLM_EXTERN DDV_ColorEntry * DDV_SearchColorbyName(ValNode *Palette, 337 Char *szName); 338 339 /***************************************************************************** 340 * 341 * Looks for a DDV_ColorEntry on the Palette by szName. Returns * 342 * to ColorCell in the DDV_ColorEntry. 343 * 344 *****************************************************************************/ 345 346 NLM_EXTERN DDV_ColorCell * DDV_SearchColorCellbyName(ValNode *Palette, Char *szName); 347 348 /***************************************************************************** 349 * 350 * Puts ColorCell on the Palette list if it isn't there already. 351 * 352 *****************************************************************************/ 353 354 NLM_EXTERN void DDV_RequestColor(ValNode **Palette, DDV_ColorCell *ColorCell); 355 356 /***************************************************************************** 357 * 358 * Puts ColorEntry on the Palette list if the sZname isn't there already, 359 * Otherwise replaces the entry. Does NOT make a copy of the DDV_ColorEntry 360 * 361 *****************************************************************************/ 362 363 NLM_EXTERN void DDV_RequestColorbyName(ValNode **Palette, 364 DDV_ColorEntry *pColorIn); 365 366 /***************************************************************************** 367 * 368 * Returns the index into the Palette for a given ColorCell. 369 * Return index on success, 0 on failure. 370 * 371 *****************************************************************************/ 372 373 NLM_EXTERN Int4 DDV_ColorIndex(ValNode *Palette, DDV_ColorCell *ColorCell); 374 375 376 /***************************************************************************** 377 * 378 * Sets colors in a ColorCell. 379 * 380 *****************************************************************************/ 381 382 NLM_EXTERN void DDV_SetColorInCell(DDV_ColorCell *pColorTo, Uint1 *Color); 383 384 385 /***************************************************************************** 386 * 387 * Copy a DDV_ColorCell. 388 * Return 1 on success, 0 on failure. 389 * 390 *****************************************************************************/ 391 392 NLM_EXTERN Int4 DDV_CopyColorCell(DDV_ColorCell * pDestination, 393 DDV_ColorCell * pSource); 394 395 /***************************************************************************** 396 * 397 * Set a color cell using Uint1 values 398 * Return 1 on success, 0 on failure 399 * 400 *****************************************************************************/ 401 402 NLM_EXTERN Int4 DDV_SetColorCell(DDV_ColorCell * pColorCell, Nlm_Uint1 Red, 403 Nlm_Uint1 Green, Nlm_Uint1 Blue); 404 405 406 /***************************************************************************** 407 408 Function: DDV_CreateColorCell() 409 410 Purpose: Creates a new DDV_ColorCell and initializes it. 411 412 Parameters: none 413 414 Returns: pointer to new DDV_ColorCell or NULL on error 415 416 *****************************************************************************/ 417 418 NLM_EXTERN DDV_ColorCell * DDV_CreateColorCell(void); 419 420 421 /***************************************************************************** 422 * 423 * Returns a DDV_ColorCell for a given lPosition if it is inside of pColor. 424 * Returns NULL otherwise. 425 * 426 *****************************************************************************/ 427 428 NLM_EXTERN DDV_ColorCell * DDV_GetCellByPosition(DDV_Color *pColor, 429 Int4 lPosition); 430 431 /***************************************************************************** 432 * 433 * Sets a DDV_ColorCell for a given position if it is inside of pColor. 434 * Returns 1 on success, 0 on failure. 435 * 436 *****************************************************************************/ 437 438 NLM_EXTERN Int4 DDV_SetCellByPosition(DDV_Color * pColor, Int4 lPosition, 439 DDV_ColorCell *pColorCell); 440 441 /***************************************************************************** 442 * 443 * Creates a DDV_Color that spans the entire object with 444 * coordinates lFrom to lTo. 445 * The default color is black. 446 * Returns NULL on error. 447 * 448 *****************************************************************************/ 449 450 NLM_EXTERN DDV_Color * DDV_CreateDefaultColor(DDV_ColorGlobal *pColorGlobal, 451 Int4 lFrom, Int4 lTo); 452 453 /***************************************************************************** 454 * 455 * Deletes a DDV_Color. 456 * Returns 1 on success, 0 on failure. 457 * 458 *****************************************************************************/ 459 460 NLM_EXTERN Int4 DDV_DeleteColor(DDV_Color *pColor); 461 462 /***************************************************************************** 463 * 464 * Creates a new DDV_MediaInfo structure. Creates a default color structure 465 * for the given object specified by sip OR row. 466 * Inserts the given pColor and sets fVisible. Duplicates the sip. 467 * 468 * Returns NULL on error. 469 * 470 *****************************************************************************/ 471 472 NLM_EXTERN DDV_MediaInfo* DDV_NewMediaInfo 473 (SeqId *sip, Int4 lRow, DDV_Color *pColor, Boolean fVisible); 474 475 /***************************************************************************** 476 * 477 * Returns a ValNode list, each element of which points to the SeqId of a 478 * sequence that has a corresponding DDV_MediaInfo structure in pColorGlobal. 479 * 480 * The Valnode list should be freed by the calling routine. However, the 481 * SeqIds pointed to by the list should *not* be freed. 482 * 483 * Returns NULL on error. 484 * 485 *****************************************************************************/ 486 487 NLM_EXTERN ValNode * DDV_IdList(DDV_ColorGlobal *pColorGlobal); 488 489 /***************************************************************************** 490 * 491 * Creates a default MediaInfo structure if necessary and adds it to 492 * pColorGlobal for the given object specified by sip OR lRow. 493 * Duplicates the sip. 494 * The sequence is visible by default. 495 * 496 * If the coordinates do not exist in the MediaInfo structure (whether the 497 * MediaInfo was freshly created or not) then a DDV_Color is added to the 498 * MediaInfo to cover the coordinate requested. 499 * 500 * Coordinates lFrom to lTo. 501 * 502 *****************************************************************************/ 503 504 505 NLM_EXTERN Int4 DDV_DefaultMediaInfoByLen 506 (DDV_ColorGlobal * pColorGlobal, SeqId *sip, Int4 lRow, Int4 lFrom, Int4 lTo); 507 508 /* simplified version of above that retrieves the length and sets the coordinate 509 system to sequence */ 510 511 NLM_EXTERN Int4 DDV_DefaultMediaInfo(DDV_ColorGlobal* pColorGlobal,SeqId *sip); 512 513 /***************************************************************************** 514 * 515 * Returns a ValNode list, each element of which points to the SeqId of a 516 * sequence that has a corresponding DDV_MediaInfo structure in pColorGlobal. 517 * 518 * The Valnode list should be freed by the calling routine. However, the 519 * SeqIds pointed to by the list should *not* be freed. 520 * 521 * Returns NULL on error. 522 * 523 *****************************************************************************/ 524 525 NLM_EXTERN ValNode * DDV_SipList(DDV_ColorGlobal *pColorGlobal); 526 527 /***************************************************************************** 528 * 529 * Deletes a DDV_MediaInfo structure. 530 * 531 * Returns 1 on success, 0 on failure 532 * 533 *****************************************************************************/ 534 535 NLM_EXTERN Int4 DDV_DeleteMediaInfo(DDV_MediaInfo *pMediaInfo); 536 537 538 /***************************************************************************** 539 * 540 * Returns a new color queue entry with name szName, priority lPriority. 541 * fOverride is explained above. 542 * 543 *****************************************************************************/ 544 545 NLM_EXTERN DDV_ColorQueue * DDV_NewColorQueue 546 (DDV_ColorFunc pfnColorFunc, Char * szName, 547 Int4 lPriority, Boolean fOverride, Uint2 procid); 548 549 /***************************************************************************** 550 * 551 * Deletes a DDV_ColorQueue. 552 * Returns 1 on success, 0 on failure 553 * 554 *****************************************************************************/ 555 556 NLM_EXTERN Int4 DDV_DeleteColorQueue(DDV_ColorQueue *pColorQueue); 557 558 #define DDVRED(y) ((y)>>16&0xff) 559 #define DDVGRN(y) ((y)>>8&0xff) 560 #define DDVBLU(y) ((y)&0xff) 561 562 /***************************************************************************** 563 564 Function: DDV_SetPaletteColor() 565 566 Purpose: Sets a single color in the palette. Trys to read the color out of 567 the configuration file. If it isn't there, puts it in the file using 568 the supplied default 569 570 Parameters: pColorGlobal, the color global object 571 ParamFile, the name of the app property parameter file 572 ColorName, the name of the color 573 red, grn, blue, the default color 574 575 *****************************************************************************/ 576 577 NLM_EXTERN void DDV_SetPaletteColor 578 (DDV_ColorGlobal * pColorGlobal, Char * ColorName, 579 Char * ParamFile, Uint1 red, Uint1 grn, Uint1 blu); 580 581 582 /***************************************************************************** 583 * 584 * Sets up default secondary structure colors in 585 * pColorGlobal->pvnSpecialColors palette. 586 * Returns 0 on failure. 587 * 588 *****************************************************************************/ 589 590 NLM_EXTERN Int4 DDV_DefaultSSColor 591 (DDV_ColorGlobal * pColorGlobal, Char *ParamFile); 592 NLM_EXTERN void DDV_LoadSSColor 593 (DDV_ColorGlobal * pColorGlobal, Char *ParamFile); 594 595 /***************************************************************************** 596 * 597 * Returns a new DDV_ColorGlobal structure. 598 * Returns NULL on failure. 599 * 600 * Parameters: fDefaultColor, sets everything to the default color before 601 * executing color functions 602 * pObject, the object this structure is coloring. can be NULL. 603 * 604 *****************************************************************************/ 605 606 NLM_EXTERN DDV_ColorGlobal * DDV_CreateColorGlobal(Boolean fDefaultColor, 607 void *pObject); 608 609 /***************************************************************************** 610 * 611 * Deletes a DDV_ColorGlobal structure. 612 * Returns 1 on success, 0 on failture 613 * 614 *****************************************************************************/ 615 616 NLM_EXTERN Int4 DDV_DeleteColorGlobal(DDV_ColorGlobal *pColorGlobal); 617 618 /***************************************************************************** 619 * 620 * Completely deallocate all of the DDV_Color structures in pColorGlobal 621 * This is intended for simple minded garbage collection. 622 * Returns 1 on success, 0 on failure 623 * 624 *****************************************************************************/ 625 626 NLM_EXTERN Int4 DDV_ClearColor(DDV_ColorGlobal *pColorGlobal); 627 628 /***************************************************************************** 629 * 630 * Clears all the colors to the default 631 * 632 *****************************************************************************/ 633 634 NLM_EXTERN Int4 DDV_Clear2Default(DDV_ColorGlobal *pColorGlobal); 635 636 /***************************************************************************** 637 * 638 * Delete all information for the given sip OR lRow. 639 * Returns 1 on success, 0 on failure 640 * 641 *****************************************************************************/ 642 643 NLM_EXTERN Int4 DDV_RemoveMediaInfo(DDV_ColorGlobal *pColorGlobal, SeqId *sip, 644 Int4 lRow); 645 646 /***************************************************************************** 647 * 648 * Add MediaInfo to DDV_ColorGlobal 649 * Returns 1 on success, 0 on failure 650 * 651 *****************************************************************************/ 652 653 NLM_EXTERN Int4 DDV_AddMediaInfo(DDV_ColorGlobal *pColorGlobal, 654 DDV_MediaInfo *pMediaInfo); 655 656 /***************************************************************************** 657 * 658 * Given a sip OR lRow, return the associated DDV_MediaInfo. 659 * 660 *****************************************************************************/ 661 662 NLM_EXTERN DDV_MediaInfo * DDV_GetMediaInfo 663 (DDV_ColorGlobal *pColorGlobal, SeqId * sip, Int4 lRow); 664 665 /***************************************************************************** 666 * 667 * Given an sip OR lRow, return the visible state. 668 * 669 *****************************************************************************/ 670 671 NLM_EXTERN Boolean DDV_IsVisible(DDV_ColorGlobal *pColorGlobal, SeqId *sip, 672 Int4 lRow); 673 674 /***************************************************************************** 675 * 676 * Set the visible state (fVisible) of a sip OR lRow. 677 * Returns 1 on success, 0 on failure. 678 * 679 *****************************************************************************/ 680 681 NLM_EXTERN Int4 DDV_SetVisible(DDV_ColorGlobal *pColorGlobal, SeqId *sip, 682 Int4 lRow, Boolean fVisible); 683 684 /***************************************************************************** 685 * 686 * Retrieve a color for a sip OR lRow at lPosition in. 687 * Returns a DDV_ColorCell containing the color. NULL on failure. 688 * 689 * The DDV_ColorCell returned is read only. 690 * 691 *****************************************************************************/ 692 693 NLM_EXTERN DDV_ColorCell * DDV_GetColor 694 (DDV_ColorGlobal *pColorGlobal, SeqId *sip, Int4 lRow, Int4 lPosition); 695 696 /***************************************************************************** 697 * 698 * Set a color for in a DDV_MediaInfo at lPosition. The color set is 699 * pColorCell. 700 * Returns 1 on success, 0 on failure. 701 * 702 *****************************************************************************/ 703 704 NLM_EXTERN Int4 DDV_SetColorInMediaInfo(DDV_ColorGlobal *pColorGlobal, 705 DDV_MediaInfo *pMediaInfo, Int4 lPosition, 706 DDV_ColorCell *pColorCell); 707 708 /***************************************************************************** 709 * 710 * Set a color for a sip OR lRow at lPosition. The color set is 711 * pColorCell. Makes a copy of pColorCell. 712 * Returns 1 on success, 0 on failure. 713 * 714 *****************************************************************************/ 715 716 NLM_EXTERN Int4 DDV_SetColor(DDV_ColorGlobal *pColorGlobal, SeqId *sip, 717 Int4 lRow, Int4 lPosition, DDV_ColorCell *pColorCell); 718 719 /***************************************************************************** 720 * 721 * Set a color for a sip OR lRow at lPosition. 722 * Uses Uint1's for color input. 723 * Returns 1 on success, 0 on failure. 724 * 725 *****************************************************************************/ 726 727 NLM_EXTERN Int4 DDV_SetColorbyColor(DDV_ColorGlobal *pColorGlobal, SeqId *sip, 728 Int4 lRow, Int4 lPosition, 729 Uint1 red, Uint1 green, Uint1 blue); 730 731 /***************************************************************************** 732 * 733 * Calls the color functions. pData is for user data. 734 * 735 * Returns 1 on success, 0 on failure. 736 * 737 * fColorByMaster in DDV_ColorGlobal (i.e. color all sequence like the master 738 * sequence) is NOT handled by this function. This 739 * is because this code has, in general, no idea if it is using alignment 740 * coordinates or alignment coordinates. To color by master, the user must 741 * register a specific function to do this. 742 * 743 * pRange the range coloring is done over. 744 * 745 *****************************************************************************/ 746 747 NLM_EXTERN Int4 DDV_ColorExecute(DDV_ColorGlobal *pColorGlobal, void * pData, 748 DDV_Range *pRange, char *szName); 749 750 /***************************************************************************** 751 * 752 * Callback for coloring all ColorCells by the default color. 753 * 754 * 755 *****************************************************************************/ 756 757 NLM_EXTERN void DDV_DefaultColor(DDV_ColorGlobal *pColorGlobal, void *pData, 758 DDV_Range *pRange); 759 760 /***************************************************************************** 761 * 762 * Adds a DDV_ColorQueue to pColorGlobal 763 * Returns 1 on success, 0 on failure. 764 * 765 *****************************************************************************/ 766 767 NLM_EXTERN Int4 DDV_AddColorFunc(DDV_ColorGlobal *pColorGlobal, 768 DDV_ColorQueue *pColorQueue); 769 770 /***************************************************************************** 771 * 772 * Deletes the given DDV_ColorFunc out of the ColorQueue 773 * Returns number deleted on success, 0 on failure. 774 * 775 *****************************************************************************/ 776 777 NLM_EXTERN Int4 DDV_DeleteColorFunc(DDV_ColorGlobal *pColorGlobal, 778 DDV_ColorFunc pfnColorFunc); 779 780 781 /***************************************************************************** 782 783 Function: DDV_AddColorGlobal() 784 785 Purpose: Adds a DDV_ColorGlobal to an entity as userdata. 786 787 Parameters: pColorGlobal, the OMProcControlPtr. 788 pObject, pointer to the entity. 789 790 Returns: 1 on success, 0 on failure 791 792 Notes: - will only add to objects registered with the object manager 793 - adds a free function to the userdata 794 - the DDV_ColorGlobal userdata is identified by proc type 795 OMPROC_COLORMGR 796 797 *****************************************************************************/ 798 799 NLM_EXTERN Int4 DDV_AddColorGlobal 800 (DDV_ColorGlobal *pColorGlobal, void * pObject); 801 802 803 /***************************************************************************** 804 805 Function: DDV_GetColorGlobal() 806 807 Purpose: Returns the DDV_ColorGlobal attached to an entity as userdata. 808 809 Parameters: pObject, pointer to the entity. 810 811 Returns: DDV_ColorGlobal * on success, NULL on failure 812 813 *****************************************************************************/ 814 815 NLM_EXTERN DDV_ColorGlobal * DDV_GetColorGlobal(void * pObject); 816 817 818 /***************************************************************************** 819 820 Function: DDV_GetColorGlobalEx() 821 822 Purpose: Returns the DDV_ColorGlobal attached to an entity as userdata. If 823 none is attached, create one and attach it. 824 825 Parameters: pObject, pointer to the entity. 826 827 Returns: DDV_ColorGlobal * on success, NULL on failure 828 829 *****************************************************************************/ 830 831 NLM_EXTERN DDV_ColorGlobal * DDV_GetColorGlobalEx(void * pObject); 832 833 834 #ifdef __cplusplus 835 } 836 #endif 837 838 #undef NLM_EXTERN 839 #ifdef NLM_EXPORT 840 #define NLM_EXTERN NLM_EXPORT 841 #else 842 #define NLM_EXTERN 843 #endif 844 845 #endif /* DDVCOLOR_H */ 846