402544fcf638ed533286eee1939579994e3577e4
kate
  Wed Aug 28 14:19:43 2019 -0700
Fix cluster display in multi-region mode. refs #22422

diff --git src/hg/hgTracks/interactTrack.c src/hg/hgTracks/interactTrack.c
index 43fbc96..c41110f 100644
--- src/hg/hgTracks/interactTrack.c
+++ src/hg/hgTracks/interactTrack.c
@@ -245,30 +245,49 @@
 
 struct interactTrackInfo {
     boolean isDirectional; // source and target are distinct item types
     char *offset;          // which end to draw offset (source or target)
     char *clusterMode;     // cluster by source or target (or no cluster if NULL)
     boolean drawUp;          // draw interactions with peak up (hill)
     boolean doOtherLabels;  // true to suppress labels on other chrom items (prevent overlap)
     int maxSize;        // longest interaction (midpoint to midpoint) in bp
     int fontHeight;
     int sameCount;      // number of same chromosome interactions in window
     int sameHeight;     // vertical space for same chromosome interactions
     int otherCount;     // number of other chromosome interactions in window
     int otherHeight;    // vertical space for other chromosome interactions
 } interactTrackInfo;
 
+boolean interactIsClusterMode(struct track *tg)
+/* Determine if track is interact and is in cluster view */
+{
+char *typeLine = tg->tdb->type, *words[8], *type;
+int wordCount;
+if (typeLine == NULL)
+    return FALSE;
+wordCount = chopLine(cloneString(typeLine), words);
+if (wordCount <= 0)
+    return FALSE;
+type = words[0];
+if (sameString(type, "interact") || sameString(type, "bigInteract"))
+    {
+    struct interactTrackInfo *tInfo = tg->customPt;
+    return tInfo->clusterMode == NULL ? FALSE : TRUE;
+    }
+return FALSE;
+}
+
 static void interactGetLayoutInfo(struct track *tg, int seqStart, struct hvGfx *hvg,                                                       int xOff, MgFont *font, double scale)
     /* Get layout info from interact items in window */
 {
     struct interactTrackInfo *tInfo = tg->customPt;
     tInfo->doOtherLabels = TRUE;
 
     char *otherChrom = NULL;
     int prevLabelEnd = 0, prevLabelStart = 0;
     char *prevLabel = 0;
     struct interact *inter;
 
     for (inter = (struct interact *)tg->items; inter; inter = inter->next)
         {
         otherChrom = interactOtherChrom(inter);
         if (otherChrom == NULL)
@@ -291,30 +310,31 @@
             int labelEnd = labelStart + labelWidth - 1;
             if (labelStart <= prevLabelEnd && 
                     !(labelStart == prevLabelStart && labelEnd == prevLabelEnd && 
                         sameString(otherChrom, prevLabel)))
                 tInfo->doOtherLabels = FALSE;
             prevLabelStart = labelStart;
             prevLabelEnd = labelEnd;
             prevLabel = otherChrom;
             }
         }
     tInfo->fontHeight = vgGetFontPixelHeight(hvg->vg, font);
     tInfo->otherHeight = (tInfo->otherCount) ? 3 * tInfo->fontHeight : 0;
     tInfo->sameHeight = (tInfo->sameCount) ? tg->height - tInfo->otherHeight : 0;
 }
 
+
 static int interactRightPixels(struct track *tg, void *item)
     /* Return number of pixels we need to the right, in linked features mode. */
 {
     struct interactTrackInfo *tInfo = tg->customPt;
     if (tInfo->clusterMode || !(tg->visibility == tvPack || tg->visibility == tvFull))
         return 0;
     struct linkedFeatures *lf = (struct linkedFeatures *)item;
     struct interactLfEndNames *ends = getInteractLfEndNames(lf);
     char *rightLabel = ends->target;
     if (lf->orientation != 0)
         rightLabel = (lf->orientation < 0 ? ends->source : ends->target);
     return mgFontStringWidth(tl.font, rightLabel);
 }
 
 static char *interactLfLeftEndName(struct track *tg, void *item)