b5a43eda6548e6d32d9fa32abd96848decd53472
kate
  Wed Apr 19 07:43:10 2017 -0700
Cleanup FIXME and TODO comments. refs #18736

diff --git src/hg/hgTracks/barChartTrack.c src/hg/hgTracks/barChartTrack.c
index 695c956..b74c1f5 100644
--- src/hg/hgTracks/barChartTrack.c
+++ src/hg/hgTracks/barChartTrack.c
@@ -26,56 +26,53 @@
     char *unit;                /* Units for category values (e.g. RPKM) */
     struct barChartCategory *categories; /* Category names, colors, etc. */
     int categCount;             /* Count of categories - derived from above */
     char **categNames;          /* Category names  - derived from above */
     char **categLabels;         /* Category labels  - derived from above */
     struct rgbColor *colors;    /* Colors  for all categories */
     struct hash *categoryFilter;  /* NULL out excluded factors */
     };
 
 struct barChartItem
 /* BED item plus computed values for display */
     {
     struct barChartItem *next;  /* Next in singly linked list */
     struct bed *bed;            /* Item coords, name, exp count and values */
     int height;                 /* Item height in pixels */
-    // TODO: add chartWidth so it's just computed once
     };
 
 /***********************************************/
 /* Organize category info */
 
 struct barChartCategory *getCategories(struct track *tg)
 /* Get and cache category info */
 {
 struct barChartTrack *info = (struct barChartTrack *)tg->extraUiData;
 if (info->categories == NULL)
     info->categories = barChartUiGetCategories(database, tg->tdb);
 return info->categories;
 }
 
 int getCategoryCount(struct track *tg)
 /* Get and cache the number of categories */
 {
 struct barChartTrack *info = (struct barChartTrack *)tg->extraUiData;
 if (info->categCount == 0)
     info->categCount = slCount(getCategories(tg));
 return info->categCount;
 }
 
-/* TODO: Do we need names ? */
-
 char *getCategoryName(struct track *tg, int id)
 /* Get category name from id, cacheing */
 {
 struct barChartCategory *categ;
 int count = getCategoryCount(tg);
 struct barChartTrack *info = (struct barChartTrack *)tg->extraUiData;
 if (!info->categNames)
     {
     struct barChartCategory *categs = getCategories(tg);
     AllocArray(info->categNames, count);
     for (categ = categs; categ != NULL; categ = categ->next)
         info->categNames[categ->id] = cloneString(categ->name);
     }
 if (id >= count)
     errAbort("Bar chart track: can't find id %d\n", id);
@@ -101,55 +98,51 @@
 }
 
 struct rgbColor *getCategoryColors(struct track *tg)
 /* Get RGB colors from category table */
 {
 struct barChartCategory *categs = getCategories(tg);
 struct barChartCategory *categ = NULL;
 int count = slCount(categs);
 struct barChartTrack *info = (struct barChartTrack *)tg->extraUiData;
 if (!info->colors)
     {
     AllocArray(info->colors, count);
     int i = 0;
     for (categ = categs; categ != NULL; categ = categ->next)
         {
-        // TODO: reconcile 
         info->colors[i] = (struct rgbColor){.r=COLOR_32_BLUE(categ->color), .g=COLOR_32_GREEN(categ->color), .b=COLOR_32_RED(categ->color)};
-        //colors[i] = mgColorIxToRgb(NULL, categ->color);
         i++;
         }
     }
 return info->colors;
 }
 
 /*****************************************************************/
 /* Convenience functions for draw */
 
 static int barChartSquishItemHeight()
 /* Height of squished item (request to have it larger than usual) */
 {
 return tl.fontHeight - tl.fontHeight/2;
 }
 
 static int barChartBoxModelHeight()
 /* Height of indicator box drawn under graph to show gene extent */
 {
 long winSize = virtWinBaseCount;
-//FIXME: dupes!!
 
-// TODO: trackDb settings ?
 #define WIN_MAX_GRAPH 50000
 #define WIN_MED_GRAPH 500000
 
 #define MAX_BAR_CHART_MODEL_HEIGHT     2
 #define MED_BAR_CHART_MODEL_HEIGHT     2
 #define MIN_BAR_CHART_MODEL_HEIGHT     1
 
 if (winSize < WIN_MAX_GRAPH)
     return MAX_BAR_CHART_MODEL_HEIGHT;
 else if (winSize < WIN_MED_GRAPH)
     return MED_BAR_CHART_MODEL_HEIGHT;
 else
     return MIN_BAR_CHART_MODEL_HEIGHT;
 }
 
@@ -208,32 +201,30 @@
         {
         maxScore = max(maxScore, expScore);
         maxNum = i;
         }
     totalScore += expScore;
     }
 // threshold to consider this item category specific -- a category contributes > threshold % to 
 // total level
 if (totalScore < 1 || maxScore <= (totalScore * threshold * .01))
     return -1;
 return maxNum;
 }
 
 static Color barChartItemColor(struct track *tg, void *item, struct hvGfx *hvg)
 /* A bit of category-specific coloring in squish mode only, on bed item */
-// TODO: Need a good function here to pick threshold from category count. 
-//      Also maybe trackDb setting
 {
 struct bed *bed = (struct bed *)item;
 int id = maxCategoryForItem(bed, SPECIFICITY_THRESHOLD);
 if (id < 0)
     return MG_BLACK;
 struct barChartTrack *extras = (struct barChartTrack *)tg->extraUiData;
 struct rgbColor color = extras->colors[id];
 return hvGfxFindColorIx(hvg, color.r, color.g, color.b);
 }
 
 static void barChartLoadItems(struct track *tg)
 /* Load method for track items */
 {
 if (tg->visibility == tvSquish || tg->limitedVis == tvSquish)
     tg->itemColor = barChartItemColor;
@@ -394,31 +385,30 @@
 struct bed *bed = (struct bed *)itemInfo->bed;
 struct barChartTrack *extras = (struct barChartTrack *)tg->extraUiData;
 int i;
 double maxExp = 0.0;
 int expCount = bed->expCount;
 double expScore;
 for (i=0; i<expCount; i++)
     {
     if (!filterCategory(tg, getCategoryName(tg, i)))
         continue;
     expScore = bed->expScores[i];
     maxExp = max(maxExp, expScore);
     }
 double viewMax = (double)cartUsualIntClosestToHome(cart, tg->tdb, FALSE, 
                                 BAR_CHART_MAX_LIMIT, BAR_CHART_MAX_LIMIT_DEFAULT);
-// TODO: add trackDb settings for MAX_LIMIT values ?
 double maxMedian = ((struct barChartTrack *)tg->extraUiData)->maxMedian;
 return valToClippedHeight(maxExp, maxMedian, viewMax, barChartMaxHeight(), extras->doLogTransform);
 }
 
 static void drawGraphBox(struct track *tg, struct barChartItem *itemInfo, struct hvGfx *hvg, int x, int y)
 /* Draw white background for graph */
 {
 Color lighterGray = MAKECOLOR_32(0xF3, 0xF3, 0xF3);
 int width = barChartWidth(tg, itemInfo);
 int height = barChartHeight(tg, itemInfo);
 hvGfxOutlinedBox(hvg, x, y-height, width, height, MG_WHITE, lighterGray);
 }
 
 static void drawGraphBase(struct track *tg, struct barChartItem *itemInfo, struct hvGfx *hvg, int x, int y)
 /* Draw faint line under graph to delineate extent when bars are missing (category w/ 0 value) */
@@ -501,38 +491,30 @@
                         BAR_CHART_COLORS_DEFAULT);
 Color clipColor = MG_MAGENTA;
 
 // draw bar graph
 double viewMax = (double)cartUsualIntClosestToHome(cart, tg->tdb, FALSE, 
                                 BAR_CHART_MAX_LIMIT, BAR_CHART_MAX_LIMIT_DEFAULT);
 double maxMedian = ((struct barChartTrack *)tg->extraUiData)->maxMedian;
 int i;
 int expCount = bed->expCount;
 struct barChartCategory *categ;
 for (i=0, categ=extras->categories; i<expCount; i++, categ=categ->next)
     {
     if (!filterCategory(tg, categ->name))
         continue;
     struct rgbColor fillColor = extras->colors[i];
-/*
-    // brighten colors a bit so they'll be more visible at this scale
-    // TODO: think about doing this
-    if (barWidth == 1 && sameString(colorScheme, BAR_CHART_COLORS_USER))
-        {
-        fillColor = barChartBrightenColor(fillColor);
-        }
-*/
     int fillColorIx = hvGfxFindColorIx(hvg, fillColor.r, fillColor.g, fillColor.b);
     double expScore = bed->expScores[i];
     int height = valToClippedHeight(expScore, maxMedian, viewMax, 
                                         barChartMaxHeight(), extras->doLogTransform);
     if (graphPadding == 0 || sameString(colorScheme, BAR_CHART_COLORS_USER))
         hvGfxBox(hvg, x1, yZero-height+1, barWidth, height, fillColorIx);
     else
         hvGfxOutlinedBox(hvg, x1, yZero-height+1, barWidth, height, fillColorIx, lineColorIx);
     // mark clipped bar with magenta tip
     if (!extras->doLogTransform && expScore > viewMax)
         hvGfxBox(hvg, x1, yZero-height+1, barWidth, 2, clipColor);
     x1 = x1 + barWidth + graphPadding;
     }
 }
 
@@ -686,31 +668,30 @@
                                 BAR_CHART_MAX_LIMIT, BAR_CHART_MAX_LIMIT_DEFAULT);
 int i = 0;
 for (categ = categs; categ != NULL; categ = categ->next, i++)
     {
 if (!filterCategory(tg, categ->name))
     continue;
     double expScore = bed->expScores[i];
     int height = valToClippedHeight(expScore, maxMedian, viewMax, 
                                         barChartMaxHeight(), extras->doLogTransform);
     mapBoxHc(hvg, itemStart, itemEnd, x1, yZero-height, barWidth, height, tg->track, mapItemName,  
                 barChartMapText(tg, categ, expScore));
     x1 = x1 + barWidth + padding;
     }
 
 // map over background of chart
-// TODO: more efficient
 int graphWidth = barChartWidth(tg, itemInfo);
 getItemX(start, end, &x1, &x2);
 mapBoxHc(hvg, start, end, x1, y, graphWidth, itemHeight-3,
                     tg->track, mapItemName, itemName);
 }
 
 /* This is lifted nearly wholesale from gtexGene track.  Could be shared */
 
 static int getBarChartHeight(void *item)
 {
 struct barChartItem *itemInfo = (struct barChartItem *)item;
 assert(itemInfo->height != 0);
 return itemInfo->height;
 }
 
@@ -799,31 +780,30 @@
 }
 
 static char *barChartItemName(struct track *tg, void *item)
 /* Return item name for labeling */
 {
 struct barChartItem *chartItem = (struct barChartItem *)item;
 struct bed *bed = (struct bed *)chartItem->bed;
 if (tg->isBigBed)
     return bigBedItemName(tg, bed);
 return bed->name;
 }
 
 void barChartMethods(struct track *tg)
 /* Bar Chart track type: draw fixed width chart of colored bars over a BED item */
 {
-// TODO: derive this from AS or trackDb ?
 tg->bedSize = 8;
 bedMethods(tg);
 tg->canPack = TRUE;
 tg->drawItemAt = barChartDrawAt;
 tg->preDrawItems = barChartPreDrawItems;
 tg->loadItems = barChartLoadItems;
 tg->mapItem = barChartMapItem;
 tg->itemName = barChartItemName;
 tg->mapItemName = barChartMapItemName;
 tg->itemHeight = barChartItemHeight;
 tg->itemStart = barChartItemStart;
 tg->itemEnd = barChartItemEnd;
 tg->totalHeight = barChartTotalHeight;
 tg->nonPropDrawItemAt = barChartNonPropDrawAt;
 tg->nonPropPixelWidth = barChartNonPropPixelWidth;