Skip to content

Commit

Permalink
Fixed empty region browsing
Browse files Browse the repository at this point in the history
  • Loading branch information
kcleal committed Jul 17, 2024
1 parent 1cfe363 commit a54e12f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 10 deletions.
25 changes: 23 additions & 2 deletions src/plot_controls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,10 @@ namespace Manager {
}
}
}
if (collections.empty()) {
processed = false;
redraw = true;
}
printRegionInfo();

} else if (key == opts.scroll_left) {
Expand Down Expand Up @@ -901,6 +905,10 @@ namespace Manager {
}
}
}
if (collections.empty()) {
processed = false;
redraw = true;
}
printRegionInfo();

} else if (key == opts.zoom_out) {
Expand Down Expand Up @@ -952,6 +960,10 @@ namespace Manager {
}
}
}
if (collections.empty()) {
processed = false;
redraw = true;
}
if (opts.link_op != 0) {
HGW::refreshLinked(collections, opts, &samMaxY, sortReadsBy);
}
Expand Down Expand Up @@ -985,7 +997,7 @@ namespace Manager {
cl.collection_processed = false;
}
}
if (bams.empty()) {
if (collections.empty()) {
processed = false;
redraw = true;
} else {
Expand Down Expand Up @@ -1915,6 +1927,10 @@ namespace Manager {
glfwPostEmptyEvent();
return;
} else {
if (collections.empty()) {
redraw = false;
return;
}
if (idx < 0) {
return;
}
Expand Down Expand Up @@ -2020,7 +2036,12 @@ namespace Manager {
}
return;
}
if (collections.empty()) {
redraw = false;
return;
}
assert (rs < collections.size());
assert (!cl.levelsStart.empty());
Segs::ReadCollection &cl = collections[rs];
regionSelection = cl.regionIdx;
int pos = (int) ((((double)xPos_fb - (double)cl.xOffset) / (double)cl.xScaling) + (double)cl.region->start);
Expand All @@ -2034,8 +2055,8 @@ namespace Manager {
updateCursorGenomePos(cl.xOffset, cl.xScaling, (float)xPos_fb, cl.region, cl.bamIdx);
} else if (mode == TILED) {
assert (variantFileSelection < variantTracks.size());
currentVarTrack = &variantTracks[variantFileSelection];
assert (currentVarTrack != nullptr);
currentVarTrack = &variantTracks[variantFileSelection];
int i = 0;
for (auto &b: bboxes) {
if (xPos_fb > b.xStart && xPos_fb < b.xEnd && yPos_fb > b.yStart && yPos_fb < b.yEnd) {
Expand Down
20 changes: 12 additions & 8 deletions src/plot_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -955,8 +955,12 @@ namespace Manager {

frameId += 1;
setGlfwFrameBufferSize();
if (regions.empty() || bams.empty()) {
if (bams.empty() && !regions.empty()) {
canvasR->drawPaint(opts.theme.bgPaint);
setScaling();
if (!regions.empty()) {
fetchRefSeqs();
}
} else {
processBam(); // Reads may be buffered here, or else streamed using the runDrawNoBuffer functions below
setScaling();
Expand Down Expand Up @@ -1021,15 +1025,15 @@ namespace Manager {
}
canvasR->restore();
}
if (opts.max_coverage) {
Drawing::drawCoverage(opts, collections, canvasR, fonts, covY, refSpace);
}
Drawing::drawRef(opts, regions, fb_width, canvasR, fonts, refSpace, (float)regions.size(), gap, monitorScale, opts.scale_bar);
Drawing::drawBorders(opts, fb_width, fb_height, canvasR, regions.size(), bams.size(), trackY, covY, (int)tracks.size(), totalTabixY, refSpace, gap);
Drawing::drawTracks(opts, fb_width, fb_height, canvasR, totalTabixY, tabixY, tracks, regions, fonts, gap, monitorScale, sliderSpace);
Drawing::drawChromLocation(opts, fonts, regions, ideogram, canvasR, fai, fb_width, fb_height, monitorScale, gap);
}

if (opts.max_coverage) {
Drawing::drawCoverage(opts, collections, canvasR, fonts, covY, refSpace);
}
Drawing::drawRef(opts, regions, fb_width, canvasR, fonts, refSpace, (float)regions.size(), gap);
Drawing::drawBorders(opts, fb_width, fb_height, canvasR, regions.size(), bams.size(), trackY, covY, (int)tracks.size(), totalTabixY, refSpace, gap);
Drawing::drawTracks(opts, fb_width, fb_height, canvasR, totalTabixY, tabixY, tracks, regions, fonts, gap, monitorScale, sliderSpace);
Drawing::drawChromLocation(opts, fonts, regions, ideogram, canvasR, fai, fb_width, fb_height, monitorScale, gap);

imageCacheQueue.emplace_back(frameId, rasterSurfacePtr[0]->makeImageSnapshot());
canvas->drawImage(imageCacheQueue.back().second, 0, 0);
Expand Down

0 comments on commit a54e12f

Please sign in to comment.