00f964165ca3cef379e600e38bdb8d6f959723d9 braney Mon Jan 23 12:03:26 2023 -0800 first cut at a demo of squishyPack mode. diff --git src/hg/hgTracks/hgTracks.c src/hg/hgTracks/hgTracks.c index eb42a4b..3be6943 100644 --- src/hg/hgTracks/hgTracks.c +++ src/hg/hgTracks/hgTracks.c @@ -4705,30 +4705,80 @@ { char *id = words[0]; if (hashLookup(nonEmptySubtracksHash, id)) { int i; for (i=1; i<ct; i++) { hashStore(nonEmptySubtracksHash, cloneString(words[i])); } } } lineFileClose(&lf); return nonEmptySubtracksHash; } +static void expandSquishyPackTracks(struct track *trackList) +/* Step through track list and duplicated tracks with squishyPackPoint defined */ +{ +struct track *nextTrack = NULL, *track; +for (track = trackList; track != NULL; track = nextTrack) + { + nextTrack = track->next; + + if (track->visibility != tvPack) + continue; + + char *string = trackDbSetting(track->tdb, "squishyPackPoint"); + if (string != NULL) + { + double squishyPackPoint = atof(string); + + /* clone the track */ + struct track *squishTrack = CloneVar(track); + squishTrack->tdb = CloneVar(track->tdb); + squishTrack->visibility = tvSquish; + squishTrack->limitedVis = tvSquish; + struct linkedFeatures *lf = track->items; + + /* distribute the items based on squishyPackPoint */ + track->items = NULL; + squishTrack->items = NULL; + struct linkedFeatures *nextLf; + for(; lf; lf = nextLf) + { + nextLf = lf->next; + if (lf->squishyPackVal >= squishyPackPoint) + slAddHead(&squishTrack->items, lf); + else + slAddHead(&track->items, lf); + } + slReverse(&track->items); + slReverse(&squishTrack->items); + + /* these should be changed to something more rational. */ + squishTrack->track = cloneString("knownGeneSquish"); + squishTrack->shortLabel = cloneString("knownGeneSquish"); + squishTrack->longLabel = cloneString("knownGeneSquish"); + + /* insert the squished track */ + track->next = squishTrack; + squishTrack->next = nextTrack; + } + } +} + void makeActiveImage(struct track *trackList, char *psOutput) /* Make image and image map. */ { struct track *track; MgFont *font = tl.font; struct hvGfx *hvg; struct tempName pngTn; char *mapName = "map"; int fontHeight = mgFontLineHeight(font); int trackPastTabX = (withLeftLabels ? trackTabWidth : 0); int trackTabX = gfxBorder; int trackPastTabWidth = tl.picWidth - trackPastTabX; int pixWidth, pixHeight; int y=0; int titleHeight = fontHeight; @@ -4836,30 +4886,31 @@ } if (zoomedToBaseLevel) basePositionHeight += baseHeight; yAfterRuler += basePositionHeight; yAfterBases = yAfterRuler; pixHeight += basePositionHeight; if (rulerCds) { yAfterRuler += rulerTranslationHeight; pixHeight += rulerTranslationHeight; } } +expandSquishyPackTracks(trackList); /* Hash tracks/subtracks, limit visibility and calculate total image height: */ // For multiple windows, sets height and visibility // as well as making the flatTrack list. // TODO there is a chance that for pack and squish // I might need to trigger a track-height check here // since it is after all items are loaded for all windows // but before things are checked for overflow or limitedVis? // The fixed non-overflow tracks like knownGene used to initialize // ss and track height during loadItems(). That was delayed // because we now need all windows to be fully loaded before // calculating their joint ss layout and height.