2d741abfd9e3a4a8163249aeb6bb70468cc6d281 hiram Fri Aug 1 12:52:21 2014 -0700 changing methods names to be more consistent and formatting blank space after function calls() refs #13706 diff --git src/hg/hgTracks/rmskJoinedTrack.c src/hg/hgTracks/rmskJoinedTrack.c index d1aead8..a0452b1 100644 --- src/hg/hgTracks/rmskJoinedTrack.c +++ src/hg/hgTracks/rmskJoinedTrack.c @@ -42,31 +42,31 @@ #define LABEL_PADDING 5 // TODO: Document static float pixelsPerBase = 1.0; /* Hash of the repeatItems ( tg->items ) for this track. * This is used to hold display names for the lines of * the track, the line heights, and class colors. */ struct hash *classHash = NULL; static struct repeatItem *otherRepeatItem = NULL; /* Hash of subtracks * The joinedRmskTrack is designed to be used as a composite track. - * When jRepeatLoad is called this hash is populated with the + * When rmskJoinedLoadItems is called this hash is populated with the * results of one or more table queries */ struct hash *subTracksHash = NULL; struct subTrack { // The number of display levels used in levels[] int levelCount; // The rmskJoined records from table query struct rmskJoined *levels[30]; }; // Repeat Classes: Display names static char *rptClassNames[] = { @@ -80,31 +80,31 @@ "Satellite", "RNA", "Other", "Unknown", }; /* Repeat class to color mappings. I took these from a * online color dictionary website: * * http://people.csail.mit.edu/jaffer/Color/Dictionaries * * I used the html4 catalog and tried to the 10 most distinct * colors. * * NOTE: If these are changed, do not forget to update the * help table in joinedRmskTrack.html */ -static Color jRepeatClassColors[] = { +static Color rmskJoinedClassColors[] = { 0xff0000ff, // SINE - red 0xff00ff00, // LINE - lime 0xff000080, // LTR - maroon 0xffff00ff, // DNA - fuchsia 0xff00ffff, // Simple - yellow 0xff008080, // LowComplex - olive 0xffff0000, // Satellite - blue 0xff008000, // RNA - green 0xff808000, // Other - teal 0xffffff00, // Unknown - aqua }; // Basic range type struct Extents { @@ -186,63 +186,61 @@ } static struct repeatItem * makeJRepeatItems() /* Initialize the track */ { classHash = newHash(6); struct repeatItem *ri, *riList = NULL; int i; int numClasses = ArraySize(rptClasses); for (i = 0; i < numClasses; ++i) { AllocVar(ri); ri->class = rptClasses[i]; ri->className = rptClassNames[i]; // New color attribute - ri->color = jRepeatClassColors[i]; + ri->color = rmskJoinedClassColors[i]; slAddHead(&riList, ri); // Hash now prebuilt to hold color attributes hashAdd(classHash, ri->class, ri); if (sameString(rptClassNames[i], "Other")) otherRepeatItem = ri; } slReverse(&riList); return riList; } -static void jRepeatLoad (struct track *tg) +static void rmskJoinedLoadItems(struct track *tg) /* We do the query(ies) here so we can report how deep the track(s) - * will be when jRepeatTotalHeight() is called later on. + * will be when rmskJoinedTotalHeight() is called later on. */ { /* * Initialize the subtracks hash - This will eventually contain * all the repeat data for each displayed subtrack. */ if (!subTracksHash) subTracksHash = newHash(20); tg->items = makeJRepeatItems(); int baseWidth = winEnd - winStart; pixelsPerBase = (float) insideWidth / (float) baseWidth; if (tg->visibility == tvFull && baseWidth <= DETAIL_VIEW_MAX_SCALE) { struct subTrack *st = NULL; AllocVar(st); - if (st) - { st->levels[0] = NULL; st->levelCount = 0; struct rmskJoined *rm = NULL; char **row; int rowOffset; struct sqlConnection *conn = hAllocConn(database); struct sqlResult *sr = hRangeQuery(conn, tg->table, chromName, winStart, winEnd, NULL, &rowOffset); struct rmskJoined *detailList = NULL; while ((row = sqlNextRow(sr)) != NULL) { rm = rmskJoinedLoad(row + rowOffset); slAddHead(&detailList, rm); } @@ -286,83 +284,84 @@ detailList = rm->next; rm = rm->next; cr->next = NULL; } else { // Save for a lower level prev = rm; rm = rm->next; } } // while ( rm ) } // while ( detailList ) // Create Hash Entry hashReplace(subTracksHash, tg->table, st); - } // if ( st ) } // if ( tg->visibility == tvFull } -static void jRepeatFree (struct track *tg) -/* Free up jRepeatMasker items. */ +static void rmskJoinedFreeItems(struct track *tg) +/* Free up rmskJoinedMasker items. */ { slFreeList(&tg->items); } -static char * jRepeatName (struct track *tg, void *item) -/* Return name of jRepeat item track. */ +static char * rmskJoinedName(struct track *tg, void *item) +/* Return name of rmskJoined item track. */ { static char empty = '\0'; struct repeatItem *ri = item; /* * In detail view mode the items represent different packing * levels. No need to display a label at each level. Instead * Just return a label for the first level. */ if (tg->limitedVis == tvFull && winBaseCount <= DETAIL_VIEW_MAX_SCALE) { if (strcmp(ri->className, "SINE") == 0) return("Repeats"); else return ∅ } return ri->className; } -int jRepeatTotalHeight (struct track *tg, enum trackVisibility vis) +#define HEIGHT24 24 + +int rmskJoinedTotalHeight(struct track *tg, enum trackVisibility vis) { // Are we in full view mode and at the scale needed to display // the detail view? if (tg->limitedVis == tvFull && winBaseCount <= DETAIL_VIEW_MAX_SCALE) { // Lookup the depth of this subTrack and report it struct subTrack *st = hashFindVal(subTracksHash, tg->table); if (st) - return ((st->levelCount + 1) * 24); + return ((st->levelCount + 1) * HEIGHT24); else - return (24); // Just display one line + return (HEIGHT24); // Just display one line } else return tgFixedTotalHeightNoOverflow(tg, vis); } -int jRepeatItemHeight (struct track *tg, void *item) +int rmskJoinedItemHeight(struct track *tg, void *item) { // Are we in full view mode and at the scale needed to display // the detail view? if (tg->limitedVis == tvFull && winBaseCount <= DETAIL_VIEW_MAX_SCALE) - return 24; + return HEIGHT24; else return tgFixedItemHeight(tg, item); } static void drawDashedHorizLine(struct hvGfx *hvg, int x1, int x2, int y, int dashLen, int gapLen, Color lineColor) // ie. - - - - - - - - - - - - - - - - { int cx1 = x1; int cx2; while (1) { cx2 = cx1 + dashLen; if (cx2 > x2) cx2 = x2; @@ -559,31 +558,31 @@ int lx1, lx2; int cx1, cx2; int w; struct repeatItem *ri; /* * heightPer is the God given height of a single * track item...respect your overlord. */ int alignedBlockHeight = heightPer * 0.5; int alignedBlockOffset = heightPer - alignedBlockHeight; int unalignedBlockHeight = heightPer * 0.75; int unalignedBlockOffset = heightPer - unalignedBlockHeight; Color black = hvGfxFindColorIx(hvg, 0, 0, 0); Color fillColor = shadesOfGray[5]; -Color outlineColor = jRepeatClassColors[0]; +Color outlineColor = rmskJoinedClassColors[0]; // Break apart the name and get the class of the // repeat. char class[256]; // Simplify repClass for lookup: strip trailing '?', // simplify *RNA to RNA: char *poundPtr = index(rm->name, '#'); if (poundPtr) { safecpy(class, sizeof(class), poundPtr + 1); char *slashPtr = index(class, '/'); if (slashPtr) *slashPtr = '\0'; } else @@ -1085,46 +1084,46 @@ w = 1; hvGfxBox(hvg, x1, yOff, w, heightPer, MG_BLACK); } } } } dyStringFree(&query); } sqlFreeResult(&sr); hFreeConn(&conn); } /* Main callback for displaying this track in the viewport * of the browser. */ -static void jRepeatDraw (struct track *tg, int seqStart, int seqEnd, +static void rmskJoinedDrawItems(struct track *tg, int seqStart, int seqEnd, struct hvGfx *hvg, int xOff, int yOff, int width, MgFont * font, Color color, enum trackVisibility vis) { int baseWidth = seqEnd - seqStart; // TODO: Document pixelsPerBase = (float) width / (float) baseWidth; /* * Its unclear to me why heightPer is not updated to the - * value set in jRepeatItemHeight() at the time this callback + * value set in rmskJoinedItemHeight() at the time this callback * is invoked. Getting the correct value myself. * was: * int heightPer = tg->heightPer; */ -int heightPer = jRepeatItemHeight (tg, NULL); +int heightPer = rmskJoinedItemHeight(tg, NULL); boolean isFull = (vis == tvFull); struct rmskJoined *rm; // If we are in full view mode and the scale is sufficient, // display the new visualization. if (isFull && baseWidth <= DETAIL_VIEW_MAX_SCALE) { int level = yOff; struct subTrack *st = hashFindVal(subTracksHash, tg->table); if (!st) return; int lidx = st->levelCount; int currLevel = 0; @@ -1154,29 +1153,29 @@ w, heightPer, tg->track, rm->id, statusLine); rm = rm->next; } level += heightPer; rmskJoinedFreeList(&(st->levels[currLevel])); } } else { // Draw the stereotypical view origRepeatDraw(tg, seqStart, seqEnd, hvg, xOff, yOff, width, font, color, vis); } } -void jRepeatMethods (struct track *tg) +void rmskJoinedMethods(struct track *tg) { -tg->loadItems = jRepeatLoad; -tg->freeItems = jRepeatFree; -tg->drawItems = jRepeatDraw; +tg->loadItems = rmskJoinedLoadItems; +tg->freeItems = rmskJoinedFreeItems; +tg->drawItems = rmskJoinedDrawItems; tg->colorShades = shadesOfGray; -tg->itemName = jRepeatName; -tg->mapItemName = jRepeatName; -tg->totalHeight = jRepeatTotalHeight; -tg->itemHeight = jRepeatItemHeight; +tg->itemName = rmskJoinedName; +tg->mapItemName = rmskJoinedName; +tg->totalHeight = rmskJoinedTotalHeight; +tg->itemHeight = rmskJoinedItemHeight; tg->itemStart = tgItemNoStart; tg->itemEnd = tgItemNoEnd; tg->mapsSelf = TRUE; }