void cytoBandIdeoMapItem(struct track *tg, struct hvGfx *hvg, void *item, char *itemName, char *mapItemName, int start, int end, int x, int y, int width, int height) /* Print out a box to jump to band in browser window .*/ { struct cytoBand *cb = item; x = hvGfxAdjXW(hvg, x, width); hPrintf("<AREA SHAPE=RECT COORDS=\"%d,%d,%d,%d\" ", x, y, x+width, y+height); hPrintf("HREF=\"#\" class='cytoBand'"); mapStatusMessage("%s %s:%d-%d", (cb->name==NULL?"":cb->name),cb->chrom, cb->chromStart+1, cb->chromEnd); hPrintf(">\n"); }
void hvGfxNextItemButton(struct hvGfx *hvg, int x, int y, int w, int h, Color color, Color hvgColor, boolean nextItem) /* Draw a button that looks like a fast-forward or rewind button on */ /* a remote control. If nextItem is TRUE, it points right, otherwise */ /* left. color is the outline color, and hvgColor is the fill color. */ { x = hvGfxAdjXW(hvg, x, w); if (hvg->rc) nextItem = !nextItem; struct gfxPoly *t1, *t2; /* Make the triangles */ t1 = gfxPolyNew(); t2 = gfxPolyNew(); if (nextItem) /* point right. */ { gfxPolyAddPoint(t1, x, y); gfxPolyAddPoint(t1, x+w/2, y+h/2); gfxPolyAddPoint(t1, x, y+h); gfxPolyAddPoint(t2, x+w/2, y); gfxPolyAddPoint(t2, x+w, y+h/2); gfxPolyAddPoint(t2, x+w/2, y+h); } else /* point left. */ { gfxPolyAddPoint(t1, x, y+h/2); gfxPolyAddPoint(t1, x+w/2, y); gfxPolyAddPoint(t1, x+w/2, y+h); gfxPolyAddPoint(t2, x+w/2, y+h/2); gfxPolyAddPoint(t2, x+w, y); gfxPolyAddPoint(t2, x+w, y+h); } /* The two filled triangles. */ vgDrawPoly(hvg->vg, t1, hvgColor, TRUE); vgDrawPoly(hvg->vg, t2, hvgColor, TRUE); /* The two outline triangles. */ vgDrawPoly(hvg->vg, t1, color, FALSE); vgDrawPoly(hvg->vg, t2, color, FALSE); gfxPolyFree(&t1); gfxPolyFree(&t2); }
void hvGfxBarbedHorizontalLine(struct hvGfx *hvg, int x, int y, int width, int barbHeight, int barbSpacing, int barbDir, Color color, boolean needDrawMiddle) /* Draw a horizontal line starting at xOff, yOff of given width. Will * put barbs (successive arrowheads) to indicate direction of line. * BarbDir of 1 points barbs to right, of -1 points them to left. */ { barbDir = (hvg->rc) ? -barbDir : barbDir; if (barbDir == 0) return; // fully clipped, or no barbs x = hvGfxAdjXW(hvg, x, width); int x1, x2; int yHi, yLo; int offset, startOffset, endOffset, barbAdd; int scrOff = (barbSpacing - 1) - (x % (barbSpacing)); yHi = y + barbHeight; yLo = y - barbHeight; if (barbDir < 0) { startOffset = scrOff - barbHeight; startOffset = (startOffset >= 0) ?startOffset : 0; endOffset = width - barbHeight; barbAdd = barbHeight; } else { startOffset = scrOff + barbHeight; endOffset = width; barbAdd = -barbHeight; } for (offset = startOffset; offset < endOffset; offset += barbSpacing) { x1 = x + offset; x2 = x1 + barbAdd; vgLine(hvg->vg, x1, y, x2, yHi, color); vgLine(hvg->vg, x1, y, x2, yLo, color); } }
static void cgDrawEither(struct track *tg, int seqStart, int seqEnd, struct hvGfx *hvg, int xOff, int yOff, int width, MgFont *font, Color color, enum trackVisibility vis, char *binFileName) /* Draw chromosome graph - either built in or not. */ { struct chromGraphSettings *cgs = tg->customPt; int x,y,lastX=0,lastY=0, llastX = 0, llastY = 0; int height = tg->height; int maxGapToFill = cgs->maxGapToFill; int lastPos = -maxGapToFill-1; double minVal = cgs->minVal; double yScale = (height-1)/(cgs->maxVal - minVal); double xScale = scaleForPixels(width); Color myColor = cgColorLikeHgGenome(tg, hvg); /* Draw background lines in full mode. */ if (vis == tvFull && cgs->linesAtCount != 0) { int i; Color lightBlue = hvGfxFindRgb(hvg, &guidelineColor); for (i=0; i<cgs->linesAtCount; ++i) { y = height - 1 - (cgs->linesAt[i] - minVal)*yScale + yOff; hvGfxBox(hvg, xOff, y, width, 1, lightBlue); } } if (binFileName) { struct chromGraphBin *cgb = chromGraphBinOpen(binFileName); if (chromGraphBinSeekToChrom(cgb, chromName)) { int seqStartMinus = seqStart - cgs->maxGapToFill; while (chromGraphBinNextVal(cgb)) { int pos = cgb->chromStart; if (pos >= seqStartMinus) { double val = cgb->val; x = (pos - seqStart)*xScale + xOff; y = height - 1 - (val - minVal)*yScale + yOff; if (x >= xOff) { if (pos - lastPos <= maxGapToFill) { if (llastX != lastX || llastY != lastY || lastX != x || lastY != y) hvGfxLine(hvg, lastX, lastY, x, y, myColor); } else hvGfxDot(hvg, x, y, myColor); } llastX = lastX; llastY = lastY; lastX = x; lastY = y; lastPos = pos; if (pos >= seqEnd) break; } } } } else { struct sqlConnection *conn = hAllocConn(database); char query[512]; struct sqlResult *sr; char **row; /* Construct query. Set up a little more than window so that * we can draw connecting lines. */ sqlSafef(query, sizeof(query), "select chromStart,val from %s " "where chrom='%s' and chromStart>=%d and chromStart<%d", tg->table, chromName, seqStart - cgs->maxGapToFill, seqEnd + cgs->maxGapToFill); sr = sqlGetResult(conn, query); /* Loop through drawing lines from one point to another unless * the points are too far apart. */ while ((row = sqlNextRow(sr)) != NULL) { int pos = sqlUnsigned(row[0]); double val = atof(row[1]); x = (pos - seqStart)*xScale + xOff; y = height - 1 - (val - minVal)*yScale + yOff; if (x >= xOff) { if (pos - lastPos <= maxGapToFill) { if (llastX != lastX || llastY != lastY || lastX != x || lastY != y) hvGfxLine(hvg, lastX, lastY, x, y, myColor); } else hvGfxDot(hvg, x, y, myColor); } llastX = lastX; llastY = lastY; lastX = x; lastY = y; lastPos = pos; if (pos >= seqEnd) break; } sqlFreeResult(&sr); hFreeConn(&conn); } /* Do map box */ xOff = hvGfxAdjXW(hvg, xOff, width); char *encodedTrack = cgiEncode(tg->track); if (theImgBox && curImgTrack) { char link[512]; // FIXME: winStart/winEnd are not right when using a portal safef(link,sizeof(link),"%s&c=%s&o=%d&t=%d&g=%s", hgcNameAndSettings(), chromName, winStart, winEnd, encodedTrack); #ifdef IMAGEv2_SHORT_MAPITEMS if (xOff < insideX && xOff+width > insideX) warn("cgDrawEither(%s) map item spanning slices. LX:%d TY:%d RX:%d BY:%d link:[%s]", encodedTrack,xOff, yOff, xOff+width, yOff+height, link); #endif//def IMAGEv2_SHORT_MAPITEMS imgTrackAddMapItem(curImgTrack,link,NULL,xOff,yOff,xOff+width,yOff+height,tg->track); } else { hPrintf("<AREA SHAPE=RECT COORDS=\"%d,%d,%d,%d\" ", xOff, yOff, xOff+width, yOff+height); hPrintf("HREF=\"%s&o=%d&t=%d&g=%s&c=%s&l=%d&r=%d&db=%s&pix=%d\">\n", hgcNameAndSettings(), winStart, winEnd, encodedTrack, chromName, winStart, winEnd, database, tl.picWidth); } }