Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/high resolution screenshot #37

Open
wants to merge 140 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
140 commits
Select commit Hold shift + click to select a range
5bcb1ec
feat: simple screenshot button in settings
seankmartin Jul 12, 2024
5f296e8
poc: scalable screenshot
seankmartin Jul 12, 2024
c425f54
Merge branch 'master' into feature/high-resolution-screenshot
seankmartin Jul 29, 2024
a111495
feat(ui): add camera icon to top bar
seankmartin Aug 27, 2024
71b4ec7
refactor: pull viewer complexity for screenshot into new class
seankmartin Aug 27, 2024
0472c12
refactor: clarify variable
seankmartin Aug 27, 2024
e2b15b9
refactor: move interface for screenshot to utils
seankmartin Aug 28, 2024
504228a
fix: revert help menu change for temp testing
seankmartin Aug 28, 2024
e0b1504
feat(ui): add screenshot UI elements
seankmartin Aug 28, 2024
bd52bd7
fix: allow forcing screenshot if viewer not ready
seankmartin Aug 28, 2024
58deb88
feat: crop screenshot to view panels
seankmartin Aug 28, 2024
4ef21f4
refactor: clean up screenshot code
seankmartin Aug 28, 2024
ac9fe69
refactor: remove atob and btoa to reduce complexity of codebase
seankmartin Aug 28, 2024
0c219d3
fix(ui): remove SVG titles in buttons
seankmartin Aug 28, 2024
eac9be3
fix(ui): better icon fix
seankmartin Aug 29, 2024
17c8a88
feat: switch between buttons for save or force screenshot
seankmartin Aug 29, 2024
d651e55
refactor: remove event listener complexity from viewer
seankmartin Aug 29, 2024
570650a
feat: first version of screenshot statistics
seankmartin Aug 30, 2024
aed271e
feat: auto force screenshot if no updates
seankmartin Aug 30, 2024
3b87bee
refactor: simplify logic for object interaction
seankmartin Aug 30, 2024
e39740a
refactor: clean up screenshot menu
seankmartin Sep 2, 2024
3d2804b
feat: add minimal CSS styling for screenshot
seankmartin Sep 2, 2024
53b02e5
feat(ui): only show stats while in progress
seankmartin Sep 2, 2024
51e01c3
feat(ui): improve screenshot stats
seankmartin Sep 2, 2024
24b04a9
feat: hide screenshot controls when not in use and update stats with …
seankmartin Sep 3, 2024
d11dff2
feat(ui): improve table updating
seankmartin Sep 3, 2024
6bafc30
refactor: improve screenshot from viewer code
seankmartin Sep 3, 2024
81154b6
refactor: small rename for consistency
seankmartin Sep 3, 2024
aa4b419
feat: include state log for screenshot replication
seankmartin Sep 3, 2024
2d59788
refactor: change trackable screenshot from type to class
seankmartin Sep 3, 2024
f40c432
refactor: clarify force check for bool
seankmartin Sep 3, 2024
d666a3e
remove: is DataPanel flag in favour of checking instance
seankmartin Sep 3, 2024
7fbbf88
feat(ui): small UI improvements in screenshot menu
seankmartin Sep 3, 2024
c6dca6c
refactor: rename classes
seankmartin Sep 3, 2024
e0facf0
refactor: clarify interaction between screenshot objects
seankmartin Sep 3, 2024
f928d07
refactor: make viewer menu responsible for manipulating data from con…
seankmartin Sep 3, 2024
cf44402
refactor: rename screenshot manager file
seankmartin Sep 16, 2024
4fc91b8
feat: lock screenshot menu until cancelled or done
seankmartin Sep 16, 2024
a2d504b
feat: close tool menus before opening JSON state editor or screenshot…
seankmartin Sep 16, 2024
7f61396
feat: show indication of screenshot size, warning if big, don't hide …
seankmartin Sep 16, 2024
15bf297
feat: progress on image (slice and volume) res stats
seankmartin Sep 16, 2024
3e2afd8
feat: resolution from each layer type
seankmartin Sep 17, 2024
5d1a0ee
feat: add per panel resolution indicator
seankmartin Sep 17, 2024
7d2930b
feat: separate screenshot cancel button
seankmartin Sep 17, 2024
5f84eb6
feat: separate close button
seankmartin Sep 17, 2024
beeb355
feat(ui): show stats on menu even when screenshot not running
seankmartin Sep 17, 2024
949bcdf
feat: update resolution rounding for slices > 1px
seankmartin Sep 17, 2024
042ee62
feat: populate layer stats in menu as they laod
seankmartin Sep 19, 2024
b62fe06
feat: hide non-visible stats
seankmartin Sep 19, 2024
3289c2c
feat: reduce screenshot hang time
seankmartin Sep 19, 2024
bd91904
feat: improve stats display and checking for hanging screenshots
seankmartin Sep 20, 2024
bb07ae8
feat: detect ortographic view stats
seankmartin Sep 23, 2024
54a20d2
fix(ui): don't round resolution < 1 in display
seankmartin Sep 23, 2024
4230a4c
docs: note about why use debug close menu
seankmartin Sep 23, 2024
7f0d199
revert: don't grab JSON state with screenshot
seankmartin Sep 26, 2024
beab5f4
feat: include voxel resolution in screenshot
seankmartin Sep 26, 2024
681d923
feat: allow fixed 2D panel FOV in screenshots with checkbox
seankmartin Sep 26, 2024
7e5dda2
fix: formatting
seankmartin Sep 26, 2024
5862bf9
fix: possible race condition between screenshot taking and resetting …
seankmartin Sep 26, 2024
7ebf558
feat: add panel pixel sizes
seankmartin Sep 26, 2024
7e9404f
refactor: small changes for clarity
seankmartin Sep 27, 2024
461a79e
docs: add docstring for resolution functions
seankmartin Sep 27, 2024
970a3f7
docs, refactor: improve screenshot clarity
seankmartin Sep 27, 2024
0cb7ef2
docs: screenshot manager notes
seankmartin Sep 27, 2024
6c171df
feat: combine panel physical and pixel resolution in UI
seankmartin Sep 27, 2024
9b4c306
fix: handle correclty the pixel indicator on zoom in UI
seankmartin Sep 27, 2024
c9eb62a
feat(ui): initial version of tooltips
seankmartin Sep 27, 2024
ce618d1
#NA-356 Screenshot Dialog UI updates
vidhya-metacell Oct 10, 2024
937a553
#NA-356 Screenshot Modal UI
vidhya-metacell Oct 11, 2024
d1457d9
#NA-356 PR comments update
vidhya-metacell Oct 17, 2024
12ad19d
#NA-356 PR updates
vidhya-metacell Oct 18, 2024
71bb1a8
#NA-356 Screenshot UI pr updates
vidhya-metacell Oct 21, 2024
f045680
feat: flip pixel and physical resolution
seankmartin Oct 28, 2024
b992557
chore: run fix formatting command for merge
seankmartin Oct 28, 2024
9a72905
fix: apply styling to children of screenshot menu
seankmartin Oct 28, 2024
302c119
Revert "fix: apply styling to children of screenshot menu"
seankmartin Oct 28, 2024
28bfb99
refactor: remove all svg files in local folder
seankmartin Oct 28, 2024
f8f39df
fix: help close positioning after using ikonate
seankmartin Oct 28, 2024
9647bd9
fix: apply styling to children of screenshot menu
seankmartin Oct 28, 2024
460d4d7
Revert "fix: apply styling to children of screenshot menu"
seankmartin Oct 28, 2024
c561ea8
fix: remove left right padding after ikonate usage on close button
seankmartin Oct 28, 2024
e03af09
refactor: combine same selector into one
seankmartin Oct 28, 2024
836fceb
fix: remove border on panel resolution table
seankmartin Oct 28, 2024
3441be2
fix: Panel type text not offset
seankmartin Oct 28, 2024
10e5548
Revert "fix: apply styling to children of screenshot menu"
seankmartin Oct 28, 2024
aba9956
Reapply "fix: apply styling to children of screenshot menu"
seankmartin Oct 28, 2024
d711bcf
feat: move body content to new div to help scroll feat
seankmartin Oct 29, 2024
e30b07d
feat: color dimension in screenshot
seankmartin Oct 29, 2024
50e240f
refactor: rename screenshot button
seankmartin Oct 29, 2024
4515da1
feat: add copy to clipboard resolution function
seankmartin Oct 29, 2024
024be79
fix: disable UI elements during screenshot
seankmartin Oct 29, 2024
f0efea9
feat: show forcing as status message
seankmartin Oct 29, 2024
5a1f605
fix: correct user screenshot force handling
seankmartin Oct 29, 2024
dce43eb
feat(python): support resolution scale factor in CLI
seankmartin Oct 29, 2024
045d9cf
NA-362-screenshot scrollbar change style
Aiga115 Nov 1, 2024
e0d81bf
NA-362-screenshot fix tooltip ui and table ui
Aiga115 Nov 5, 2024
92af1f2
feat: small changes and revert scroll bar styling
seankmartin Nov 6, 2024
4b9b04e
Merge pull request #46 from MetaCell/feature/NA-362-screenshot
seankmartin Nov 6, 2024
cde708e
Merge pull request #44 from MetaCell/feature/screenshot-cli-scale
seankmartin Nov 6, 2024
e952d59
Merge branch 'feature/NA-362' into feature/NA-356
seankmartin Nov 6, 2024
34672e1
feat: use :is in css to restrict changes
seankmartin Nov 6, 2024
532f46f
Merge pull request #40 from MetaCell/feature/NA-356
seankmartin Nov 6, 2024
2be0ebb
feat(ui): small screenshot updates
seankmartin Nov 6, 2024
b2e4509
refactor: clearer separation of logic for resolution copy to table
seankmartin Nov 7, 2024
b3b8da7
fix: correct logic for flipping between fixed FOV and not
seankmartin Nov 8, 2024
eefbbc5
feat: improve resolution to clipboard copy
seankmartin Nov 8, 2024
33e3c3b
refactor: only call setup tooltips once
seankmartin Nov 11, 2024
940b8d6
feat: add layer tooltip
seankmartin Nov 11, 2024
f7edfef
refactor: move tooltip strings to const
seankmartin Nov 11, 2024
c4c5da9
fix: handle non-integer resolutions and clean up handling
seankmartin Nov 11, 2024
bf3e619
refactor: clean up css defs and formatting
seankmartin Nov 11, 2024
a415c0f
refactor: removed unused VR variables
seankmartin Nov 11, 2024
ca40e51
fix: remove accidental log
seankmartin Nov 11, 2024
2266dc3
Merge branch 'master' into feature/high-resolution-screenshot
seankmartin Nov 11, 2024
5bcfd9e
Merge branch 'master' into feature/high-resolution-screenshot
seankmartin Nov 14, 2024
817cf36
fix(ui): consistent formatting of pixel resolution
seankmartin Nov 19, 2024
353a128
refactor: include interfaces in viewer_resolution_stats for metadata
seankmartin Nov 19, 2024
f353aba
feat(python,ts): change to python screenshot integration to include p…
seankmartin Nov 19, 2024
dc50a09
fix(ui): make pixel res R1 x R2 px not R1 x R2px
seankmartin Nov 19, 2024
3f3431c
feat: actually resize canvas during preview. Also give message to use…
seankmartin Nov 20, 2024
3f19533
fix: remove manual increment to context display generation number
seankmartin Dec 16, 2024
e66bfde
feat: cap max scale factor based on pixel size
seankmartin Dec 16, 2024
3713da8
feat: fine tune num pixel limit on screenshot
seankmartin Dec 16, 2024
ee77c66
fix: remove accidental log
seankmartin Dec 16, 2024
bd73859
Merge branch 'master' into feature/high-resolution-screenshot
seankmartin Dec 16, 2024
f3e108c
chore: formatting
seankmartin Dec 18, 2024
e3b5625
feat: remove custom tooltip in favor of using "title"
seankmartin Jan 17, 2025
ccbf2ef
NA-377-fix delete neuroglancer-screenshot-tooltip classname and all i…
Aiga115 Jan 20, 2025
aa55002
NA-377-fix change width of tooltip and make changes to selectors
Aiga115 Jan 21, 2025
32f27f8
NA-377-fix make change to selectors
Aiga115 Jan 21, 2025
f2c6630
refactor: further clean CSS to remove complex selectors and unqualifi…
seankmartin Jan 22, 2025
25e9e73
refactor: set split into lines with default value
seankmartin Jan 22, 2025
5b1b30a
refactor: replace color strings by var
seankmartin Jan 22, 2025
48c9629
chore: format and lint
seankmartin Jan 22, 2025
f27872f
refactor: css favour td and th over specific class
seankmartin Jan 22, 2025
a29818d
feat: add proper wrapper for screenshot resolution metadata
seankmartin Jan 22, 2025
5a6d07c
Merge pull request #65 from MetaCell/feature/NA-377-fix
seankmartin Jan 27, 2025
c49150d
Merge branch 'master' into feature/high-resolution-screenshot
seankmartin Jan 27, 2025
fdb1758
chore: format and lint
seankmartin Jan 27, 2025
ad23c13
feat: change unloaded message from "Loading..." to "Data not loaded"
seankmartin Jan 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion python/neuroglancer/tool/screenshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,11 @@ def define_state_modification_args(ap: argparse.ArgumentParser):
type=float,
help="Multiply projection view scale by specified factor.",
)
ap.add_argument(
"--resolution-scale-factor",
type=float,
help="Divide cross section view scale by specified factor. E.g. a 2000x2000 output with a resolution scale factor of 2 will have the same FOV as a 1000x1000 output.",
)
ap.add_argument(
"--system-memory-limit",
type=int,
Expand All @@ -621,7 +626,6 @@ def define_state_modification_args(ap: argparse.ArgumentParser):
"--scale-bar-scale", type=float, help="Scale factor for scale bar", default=1
)


def apply_state_modifications(
state: neuroglancer.ViewerState, args: argparse.Namespace
):
Expand All @@ -635,6 +639,8 @@ def apply_state_modifications(
state.show_default_annotations = args.show_default_annotations
if args.projection_scale_multiplier is not None:
state.projection_scale *= args.projection_scale_multiplier
if args.resolution_scale_factor is not None:
state.cross_section_scale /= args.resolution_scale_factor
if args.cross_section_background_color is not None:
state.cross_section_background_color = args.cross_section_background_color

Expand Down
28 changes: 28 additions & 0 deletions python/neuroglancer/viewer_config_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,31 @@ class LayerSelectionState(JsonObjectWrapper):
class LayerSelectedValues(_LayerSelectedValuesBase):
"""Specifies the data values associated with the current mouse position."""

@export
class PanelResolutionData(JsonObjectWrapper):
__slots__ = ()
type = wrapped_property("type", str)
width = wrapped_property("width", int)
height = wrapped_property("height", int)
resolution = wrapped_property("resolution", str)

@export
class LayerResolutionData(JsonObjectWrapper):
__slots__ = ()
name = wrapped_property("name", str)
type = wrapped_property("type", str)
resolution = wrapped_property("resolution", str)

@export
class ScreenshotResolutionMetadata(JsonObjectWrapper):
__slots__ = ()
panel_resolution_data = panelResolutionData = wrapped_property(
"panelResolutionData", typed_list(PanelResolutionData)
)
layer_resolution_data = layerResolutionData = wrapped_property(
"layerResolutionData", typed_list(LayerResolutionData)
)


@export
class ScreenshotReply(JsonObjectWrapper):
Expand All @@ -106,6 +131,9 @@ class ScreenshotReply(JsonObjectWrapper):
height = wrapped_property("height", int)
image_type = imageType = wrapped_property("imageType", str)
depth_data = depthData = wrapped_property("depthData", optional(base64.b64decode))
resolution_metadata = resolutionMetadata = wrapped_property(
"resolutionMetadata", ScreenshotResolutionMetadata
)

@property
def image_pixels(self):
Expand Down
29 changes: 24 additions & 5 deletions src/display_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import { FramerateMonitor } from "#src/util/framerate.js";
import type { mat4 } from "#src/util/geom.js";
import { parseFixedLengthArray, verifyFloat01 } from "#src/util/json.js";
import { NullarySignal } from "#src/util/signal.js";
import {
TrackableScreenshotMode,
ScreenshotMode,
} from "#src/util/trackable_screenshot_mode.js";
import type { WatchableVisibilityPriority } from "#src/visibility_priority/frontend.js";
import type { GL } from "#src/webgl/context.js";
import { initializeWebGL } from "#src/webgl/context.js";
Expand Down Expand Up @@ -135,7 +139,7 @@ export abstract class RenderedPanel extends RefCounted {

abstract isReady(): boolean;

ensureBoundsUpdated() {
ensureBoundsUpdated(canScaleForScreenshot: boolean = false) {
const { context } = this;
context.ensureBoundsUpdated();
const { boundsGeneration } = context;
Expand Down Expand Up @@ -221,8 +225,18 @@ export abstract class RenderedPanel extends RefCounted {
0,
clippedBottom - clippedTop,
));
viewport.logicalWidth = logicalWidth;
viewport.logicalHeight = logicalHeight;
if (
this.context.screenshotMode.value !== ScreenshotMode.OFF &&
canScaleForScreenshot
) {
viewport.width = logicalWidth * screenToCanvasPixelScaleX;
viewport.height = logicalHeight * screenToCanvasPixelScaleY;
viewport.logicalWidth = logicalWidth * screenToCanvasPixelScaleX;
viewport.logicalHeight = logicalHeight * screenToCanvasPixelScaleY;
} else {
viewport.logicalWidth = logicalWidth;
viewport.logicalHeight = logicalHeight;
}
viewport.visibleLeftFraction = (clippedLeft - logicalLeft) / logicalWidth;
viewport.visibleTopFraction = (clippedTop - logicalTop) / logicalHeight;
viewport.visibleWidthFraction = clippedWidth / logicalWidth;
Expand Down Expand Up @@ -410,6 +424,9 @@ export class DisplayContext extends RefCounted implements FrameNumberCounter {
rootRect: DOMRect | undefined;
resizeGeneration = 0;
boundsGeneration = -1;
screenshotMode: TrackableScreenshotMode = new TrackableScreenshotMode(
ScreenshotMode.OFF,
);
force3DHistogramForAutoRange = false;
private framerateMonitor = new FramerateMonitor();

Expand Down Expand Up @@ -599,8 +616,10 @@ export class DisplayContext extends RefCounted implements FrameNumberCounter {
const { resizeGeneration } = this;
if (this.boundsGeneration === resizeGeneration) return;
const { canvas } = this;
canvas.width = canvas.offsetWidth;
canvas.height = canvas.offsetHeight;
if (this.screenshotMode.value === ScreenshotMode.OFF) {
canvas.width = canvas.offsetWidth;
canvas.height = canvas.offsetHeight;
}
this.canvasRect = canvas.getBoundingClientRect();
this.rootRect = this.container.getBoundingClientRect();
this.boundsGeneration = resizeGeneration;
Expand Down
6 changes: 5 additions & 1 deletion src/overlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,15 @@ export class Overlay extends RefCounted {
document.body.appendChild(container);
this.registerDisposer(new KeyboardEventBinder(this.container, this.keyMap));
this.registerEventListener(container, "action:close", () => {
this.dispose();
this.close();
});
content.focus();
}

close() {
this.dispose();
}

disposed() {
--overlaysOpen;
document.body.removeChild(this.container);
Expand Down
2 changes: 1 addition & 1 deletion src/perspective_view/panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ export class PerspectivePanel extends RenderedDataPanel {
}

ensureBoundsUpdated() {
super.ensureBoundsUpdated();
super.ensureBoundsUpdated(true /* canScaleForScreenshot */);
this.projectionParameters.setViewport(this.renderViewport);
}

Expand Down
55 changes: 51 additions & 4 deletions src/python_integration/screenshots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,54 @@ import { convertEndian32, Endianness } from "#src/util/endian.js";
import { verifyOptionalString } from "#src/util/json.js";
import { Signal } from "#src/util/signal.js";
import { getCachedJson } from "#src/util/trackable.js";
import { ScreenshotMode } from "#src/util/trackable_screenshot_mode.js";
import type { ResolutionMetadata } from "#src/util/viewer_resolution_stats.js";
import { getViewerResolutionMetadata } from "#src/util/viewer_resolution_stats.js";
import type { Viewer } from "#src/viewer.js";

export interface ScreenshotResult {
id: string;
image: string;
imageType: string;
depthData: string | undefined;
width: number;
height: number;
resolutionMetadata: ResolutionMetadata;
}

export interface ScreenshotActionState {
afonsobspinto marked this conversation as resolved.
Show resolved Hide resolved
viewerState: any;
selectedValues: any;
screenshot: ScreenshotResult;
}

export interface ScreenshotChunkStatistics {
downloadLatency: number;
visibleChunksDownloading: number;
visibleChunksFailed: number;
visibleChunksGpuMemory: number;
visibleChunksSystemMemory: number;
visibleChunksTotal: number;
visibleGpuMemory: number;
}

export interface StatisticsActionState {
viewerState: any;
selectedValues: any;
screenshotStatistics: {
id: string;
chunkSources: any[];
total: ScreenshotChunkStatistics;
};
}

export class ScreenshotHandler extends RefCounted {
sendScreenshotRequested = new Signal<(state: any) => void>();
sendStatisticsRequested = new Signal<(state: any) => void>();
sendScreenshotRequested = new Signal<
(state: ScreenshotActionState) => void
>();
sendStatisticsRequested = new Signal<
(state: StatisticsActionState) => void
>();
requestState = new TrackableValue<string | undefined>(
undefined,
verifyOptionalString,
Expand Down Expand Up @@ -124,12 +167,14 @@ export class ScreenshotHandler extends RefCounted {
return;
}
const { viewer } = this;
if (!viewer.isReady()) {
const shouldForceScreenshot =
this.viewer.display.screenshotMode.value === ScreenshotMode.FORCE;
if (!viewer.isReady() && !shouldForceScreenshot) {
this.wasAlreadyVisible = false;
this.throttledSendStatistics(requestState);
return;
}
if (!this.wasAlreadyVisible) {
if (!this.wasAlreadyVisible && !shouldForceScreenshot) {
this.throttledSendStatistics(requestState);
this.wasAlreadyVisible = true;
this.debouncedMaybeSendScreenshot();
Expand All @@ -140,6 +185,7 @@ export class ScreenshotHandler extends RefCounted {
this.throttledSendStatistics.cancel();
viewer.display.draw();
const screenshotData = viewer.display.canvas.toDataURL();
const resolutionMetadata = getViewerResolutionMetadata(viewer);
const { width, height } = viewer.display.canvas;
const prefix = "data:image/png;base64,";
let imageType: string;
Expand Down Expand Up @@ -169,6 +215,7 @@ export class ScreenshotHandler extends RefCounted {
depthData,
width,
height,
resolutionMetadata,
},
};

Expand Down
20 changes: 10 additions & 10 deletions src/single_mesh/frontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,18 @@ import {
ChunkSource,
WithParameters,
} from "#src/chunk_manager/frontend.js";
import {
makeCoordinateSpace,
makeIdentityTransform,
} from "#src/coordinate_transform.js";
import type {
DataSource,
GetKvStoreBasedDataSourceOptions,
KvStoreBasedDataSourceProvider,
} from "#src/datasource/index.js";
import { WithSharedKvStoreContext } from "#src/kvstore/chunk_source_frontend.js";
import type { SharedKvStoreContext } from "#src/kvstore/frontend.js";
import { ensureEmptyUrlSuffix } from "#src/kvstore/url.js";
import type { PickState, VisibleLayerInfo } from "#src/layer/index.js";
import type { PerspectivePanel } from "#src/perspective_view/panel.js";
import type { PerspectiveViewRenderContext } from "#src/perspective_view/render_layer.js";
Expand Down Expand Up @@ -85,16 +95,6 @@ import {
TextureFormat,
} from "#src/webgl/texture_access.js";
import { SharedObject } from "#src/worker_rpc.js";
import type {
DataSource,
GetKvStoreBasedDataSourceOptions,
KvStoreBasedDataSourceProvider,
} from "#src/datasource/index.js";
import { ensureEmptyUrlSuffix } from "#src/kvstore/url.js";
import {
makeCoordinateSpace,
makeIdentityTransform,
} from "#src/coordinate_transform.js";

const DEFAULT_FRAGMENT_MAIN = `void main() {
emitGray();
Expand Down
2 changes: 1 addition & 1 deletion src/sliceview/panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ export class SliceViewPanel extends RenderedDataPanel {
}

ensureBoundsUpdated() {
super.ensureBoundsUpdated();
super.ensureBoundsUpdated(true /* canScaleForScreenshot */);
this.sliceView.projectionParameters.setViewport(this.renderViewport);
}

Expand Down
14 changes: 14 additions & 0 deletions src/sliceview/volume/renderlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ export abstract class SliceViewVolumeRenderLayer<
>;
private tempChunkPosition: Float32Array;
shaderParameters: WatchableValueInterface<ShaderParameters>;
highestResolutionLoadedVoxelSize: Float32Array | undefined;
private vertexIdHelper: VertexIdHelper;

constructor(
Expand Down Expand Up @@ -570,6 +571,7 @@ void main() {
this.chunkManager.chunkQueueManager.frameNumberCounter.frameNumber,
);
}
this.highestResolutionLoadedVoxelSize = undefined;

let shaderResult: ParameterizedShaderGetterResult<
ShaderParameters,
Expand Down Expand Up @@ -692,6 +694,18 @@ void main() {
effectiveVoxelSize[1],
effectiveVoxelSize[2],
);
if (presentCount > 0) {
const medianStoredVoxelSize = this.highestResolutionLoadedVoxelSize
? medianOf3(
this.highestResolutionLoadedVoxelSize[0],
this.highestResolutionLoadedVoxelSize[1],
this.highestResolutionLoadedVoxelSize[2],
)
: Infinity;
if (medianVoxelSize <= medianStoredVoxelSize) {
this.highestResolutionLoadedVoxelSize = effectiveVoxelSize;
}
}
renderScaleHistogram.add(
medianVoxelSize,
medianVoxelSize / projectionParameters.pixelSize,
Expand Down
Loading
Loading