8c908f948b09826c6cb4452ee5b282aca41be85e galt Tue Dec 8 21:52:59 2015 -0800 Multi-region (exonMostly). This work allows people to look at virtual chromosomes from a list of regions and then navigate and perform all of the usual functions on it. diff --git src/hg/hgTracks/imageV2.h src/hg/hgTracks/imageV2.h index 44e4174..afe0cc2 100644 --- src/hg/hgTracks/imageV2.h +++ src/hg/hgTracks/imageV2.h @@ -1,65 +1,68 @@ // imageV2 - API for creating the image V2 features. /* Copyright (C) 2014 The Regents of the University of California * See README in this or parent directory for licensing information. */ #ifndef IMAGEV2_H #define IMAGEV2_H // DRAG_SCROLL means dragging the image left-right to reposition the viewing window on the chrom. // NOTE: 1x works fine and is released. Set IMAGEv2_DRAG_SCROLL_SZ > 1 (3=3x) // to see hidden image while dragging. +#ifndef IMAGEv2_DRAG_SCROLL_SZ #define IMAGEv2_DRAG_SCROLL_SZ 1 +#endif #if defined(IMAGEv2_DRAG_SCROLL_SZ) && (IMAGEv2_DRAG_SCROLL_SZ > 1) #define IMAGEv2_SHORT_MAPITEMS //#define IMAGEv2_SHORT_TOGGLE //#define IMAGEv2_NO_LEFTLABEL_ON_FULL // Because the sideLabel clipping will leave a no longer needed label // aligned with the centerLabel, we will need to either: remove sideLabels // (which otherwise work) OR add a new side-slice to match the centerlabel #endif //defined(IMAGEv2_DRAG_SCROLL_SZ) && (IMAGEv2_DRAG_SCROLL_SZ > 1) // CURRENT PROBLEMS with dragScroll > 1X: // o Dynamic height for data/label based on image map currently works EXCEPT, // occasionally does not resize. Consider resize while dragging! // o next item feature '>>' arrows should check if items are in the wings // o next exon feature '>>' arrows are only seen in the wings and only look beyond the wings // UNCOMMENT USE_NAVIGATION_LINKS for so far experimental UI changes to replace buttons at top // with more streamlined links //#define USE_NAVIGATION_LINKS extern struct imgBox *theImgBox; // Make this global for now to avoid huge rewrite //extern struct image *theOneImg; // Make this global for now to avoid huge rewrite extern struct imgTrack *curImgTrack; // Make this global for now to avoid huge rewrite //extern struct imgSlice *curSlice; // Make this global for now to avoid huge rewrite //extern struct mapSet *curMap; // Make this global for now to avoid huge rewrite //extern struct mapItem *curMapItem; // Make this global for now to avoid huge rewrite ///////////////////////// // FLAT TRACKS // A simplistic way of flattening the track list before building the image -// NOTE: Strategy is NOT to use imgBox->imgTracks, since this should be independednt of imageV2 +// NOTE: Strategy is NOT to use imgBox->imgTracks, since this should be independent of imageV2 // These should probably be moved to hgTracks.h ///////////////////////// struct flatTracks // List of tracks in image, flattened to promote subtracks { struct flatTracks *next; // Next on list. struct track *track; // Track (the track list is still heirarchical int order; // Image order: This keeps track of dragReorder + int maxHeight; // largest height among all windows in image. }; void flatTracksAdd(struct flatTracks **flatTracks,struct track *track,struct cart *cart); // Adds one track into the flatTracks list int flatTracksCmp(const void *va, const void *vb); // Compare to sort on flatTrack->order void flatTracksSort(struct flatTracks **flatTracks); // This routine sorts the imgTracks then forces tight ordering, so new tracks wil go to the end void flatTracksFree(struct flatTracks **flatTracks); // Frees all memory used to support flatTracks (underlying tracks are untouched) ///////////////////////// @@ -274,66 +277,66 @@ void sliceFree(struct imgSlice **pSlice); // frees all memory assocated with a slice // (not including the image or a map belonging to the image) /////////////////////// imgTracks enum centerLabelSeen { clUnknown=0, // Invalid clAlways=1, // Default is always seen clNowSeen=2, // Conditionally and currently seen clNotSeen=3 // Conditionally and currently unseen }; -struct imgTrack // IMAGEv2: imageBox conatins list of displayed imageTracks +struct imgTrack // IMAGEv2: imageBox contains list of displayed imageTracks { struct imgTrack *next; // slList struct trackDb *tdb; // trackDb entry (should this be struct track* entry?) char *name; // It is possible to have an imgTrack without a tdb, // but then it must have a name char *db; // Image for db (species) (assert imgTrack matches imgBox) char *chrom; // Image for chrom (assert imgTrack matches imgBox) - int chromStart; // Image start (absolute, not portal position) - int chromEnd; // Image end (absolute, not portal position) + long chromStart; // Image start (absolute, not portal position) + long chromEnd; // Image end (absolute, not portal position) boolean plusStrand; // Image covers plus strand, not minus strand boolean hasCenterLabel; // A track may have a center label but not show it enum centerLabelSeen centerLabelSeen; // Conditionally displayed center labels are always // there but sometimes hidden boolean reorderable; // Is this track reorderable (by drag and drop) ? boolean ajaxRetrieval; // This track needs to be retrieved via ajax int order; // Image order: This keeps track of dragReorder enum trackVisibility vis; // Current visibility of track image struct imgSlice *slices; // Currently there should be four slices for every track: // data, centerLabel, sideLabel, button }; #define IMG_ANYORDER -2 #define IMG_FIXEDPOS -1 #define IMG_ORDERTOP 10000 #define IMG_ORDEREND 20000 #define IMG_ORDER_VAR "imgOrd" struct imgTrack *imgTrackStart(struct trackDb *tdb,char *name,char *db, - char *chrom,int chromStart,int chromEnd,boolean plusStrand, + char *chrom, long chromStart, long chromEnd, boolean plusStrand, boolean hasCenterLabel, enum trackVisibility vis, int order); // Starts an image track which will contain all image slices needed to render one track // Must completed by adding slices with imgTrackAddSlice() struct imgTrack *imgTrackUpdate(struct imgTrack *imgTrack,struct trackDb *tdb,char *name, - char *db,char *chrom,int chromStart,int chromEnd,boolean plusStrand, + char *db,char *chrom, long chromStart, long chromEnd, boolean plusStrand, boolean hasCenterLabel, enum trackVisibility vis, int order); // Updates an already existing image track void imgTrackMarkForAjaxRetrieval(struct imgTrack *imgTrack,boolean ajaxRetrieval); // Updates the imgTrack to trigger an ajax callback from the html client to get this track #define imgTrackMarkedForAjaxRetrieval(imgTrack) ((imgTrack)->ajaxRetrieval) // Is this imgTrack marked for Ajax retrieval #define imgTrackUpdateCenterLabelSeen(slice,seen) { (slice)->centerLabelSeen = (seen); } // Center slices are occasionally unseen int imgTrackOrderCmp(const void *va, const void *vb); // Compare to sort on label. @@ -374,72 +377,72 @@ // Returns count of map items added, which could be 0, 1 or more than one if item spans slices // NOTE: Precedence is given to first map item when adding items with same coordinates! boolean imgTrackIsComplete(struct imgTrack *imgTrack,boolean verbose); // Tests the completeness and consistency of this imgTrack (including slices) void imgTrackFree(struct imgTrack **pImgTrack); // frees all memory assocated with an imgTrack (including slices) /////////////////////// Image Box struct imgBox // IMAGEv2: imageBox conatins all the definitions to draw an image in hgTracks { char *db; // database (species) char *chrom; // chrom - int chromStart; // Image start (absolute, not portal position) - int chromEnd; // Image end (absolute, not portal position) + long chromStart; // Image start (absolute, not portal position) + long chromEnd; // Image end (absolute, not portal position) boolean plusStrand; // imgBox currently shows plus strand, not minus strand struct image *images; // Contains all images for the imgBox. TEMPORARY: hgTracks creates // it's current one image and I'll store it here struct image *bgImg; // When track images are transparent, bgImage contains blue lines // that are db coordinate granularity. int width; // in pixels (note that portalWidth in visible position within // image position in db coodinates) boolean showSideLabel; // Initially display side label? (use 'plusStrand' for left/right) int sideLabelWidth; // in pixels (note this is needed when setting up a portal // and dragScrolling) boolean showPortal; // Rather than showing the entire data range, only show a portion, // and allow dragScrolling double basesPerPixel; // number of bases covered by a single pixel - int portalStart; // initial visible portal within html image table (db coodinates) + long portalStart; // initial visible portal within html image table (db coodinates) // [May be obsoleted by js client] - int portalEnd; // initial visible portal within html image table (db coodinates) + long portalEnd; // initial visible portal within html image table (db coodinates) // [May be obsoleted by js client] int portalWidth; // in pixels (should be equal to the visible position of data slice) struct imgTrack *imgTracks; // slList of all images to display }; -struct imgBox *imgBoxStart(char *db,char *chrom,int chromStart,int chromEnd, +struct imgBox *imgBoxStart(char *db, char *chrom, long chromStart, long chromEnd, boolean plusStrand, int sideLabelWidth, int width); // Starts an imgBox which should contain all info needed to draw the hgTracks image with // multiple tracks. The image box must be completed using imgBoxImageAdd() and imgBoxTrackAdd() -boolean imgBoxPortalDefine(struct imgBox *imgBox,int *chromStart,int *chromEnd, +boolean imgBoxPortalDefine(struct imgBox *imgBox, long *chromStart, long *chromEnd, int *imgWidth,double imageMultiple); // Defines the portal of the imgBox. The portal is the initial viewable region when dragScroll // is being used. The new chromStart,chromEnd and imgWidth are returned as OUTs, while the // portal becomes the initial defined size // Returns TRUE if successfully defined as having a portal. -boolean imgBoxPortalRemove(struct imgBox *imgBox,int *chromStart,int *chromEnd,int *imgWidth); +boolean imgBoxPortalRemove(struct imgBox *imgBox, long *chromStart, long *chromEnd, int *imgWidth); // Will redefine the imgBox as the portal dimensions and return the dimensions as OUTs. // Returns TRUE if a portal was defined in the first place -boolean imgBoxPortalDimensions(struct imgBox *imgBox,int *chromStart,int *chromEnd, +boolean imgBoxPortalDimensions(struct imgBox *imgBox, long *chromStart, long *chromEnd, int *imgWidth, int *sideLabelWidth, - int *portalStart,int *portalEnd,int *portalWidth, + long *portalStart, long *portalEnd, int *portalWidth, double *basesPerPixel); // returns the imgBox portal dimensions in the OUTs returns TRUE if portal defined struct image *imgBoxImageAdd(struct imgBox *imgBox,char *png,char *title,int width,int height, boolean backGround); // Adds an image to an imgBox. The image may be extended with imgMapStart(),mapSetItemAdd() struct image *imgBoxImageFind(struct imgBox *imgBox,char *png); // Finds a specific image already added to this imgBox struct imgTrack *imgBoxTrackAdd(struct imgBox *imgBox,struct trackDb *tdb,char *name, enum trackVisibility vis,boolean hasCenterLabel,int order); // Adds an imgTrack to an imgBox. The imgTrack needs to be extended with imgTrackAddSlice() struct imgTrack *imgBoxTrackFind(struct imgBox *imgBox,struct trackDb *tdb,char *name);