diff --git a/src/neuroglancer/sliceview/chunked_graph/frontend.ts b/src/neuroglancer/sliceview/chunked_graph/frontend.ts index 437c5696f..034a5bec2 100644 --- a/src/neuroglancer/sliceview/chunked_graph/frontend.ts +++ b/src/neuroglancer/sliceview/chunked_graph/frontend.ts @@ -14,19 +14,19 @@ * limitations under the License. */ -import {authFetch, responseIdentity} from 'neuroglancer/authentication/frontend.ts'; -import {ChunkManager} from 'neuroglancer/chunk_manager/frontend'; -import {VisibleSegmentsState} from 'neuroglancer/segmentation_display_state/base'; -import {CHUNKED_GRAPH_LAYER_RPC_ID, CHUNKED_GRAPH_SOURCE_UPDATE_ROOT_SEGMENTS_RPC_ID, ChunkedGraphChunkSource as ChunkedGraphChunkSourceInterface, ChunkedGraphChunkSpecification, RENDER_RATIO_LIMIT} from 'neuroglancer/sliceview/chunked_graph/base'; -import {SliceViewChunkSource} from 'neuroglancer/sliceview/frontend'; -import {RenderLayer as GenericSliceViewRenderLayer, RenderLayerOptions} from 'neuroglancer/sliceview/renderlayer'; -import {StatusMessage} from 'neuroglancer/status'; -import {TrackableBoolean} from 'neuroglancer/trackable_boolean'; -import {Uint64Set} from 'neuroglancer/uint64_set'; -import {vec3} from 'neuroglancer/util/geom'; -import {verify3dVec, verifyObjectProperty} from 'neuroglancer/util/json'; -import {Uint64} from 'neuroglancer/util/uint64'; -import {RPC} from 'neuroglancer/worker_rpc'; +import { authFetch, responseIdentity } from 'neuroglancer/authentication/frontend.ts'; +import { ChunkManager } from 'neuroglancer/chunk_manager/frontend'; +import { VisibleSegmentsState } from 'neuroglancer/segmentation_display_state/base'; +import { CHUNKED_GRAPH_LAYER_RPC_ID, CHUNKED_GRAPH_SOURCE_UPDATE_ROOT_SEGMENTS_RPC_ID, ChunkedGraphChunkSource as ChunkedGraphChunkSourceInterface, ChunkedGraphChunkSpecification, RENDER_RATIO_LIMIT } from 'neuroglancer/sliceview/chunked_graph/base'; +import { SliceViewChunkSource } from 'neuroglancer/sliceview/frontend'; +import { RenderLayer as GenericSliceViewRenderLayer, RenderLayerOptions } from 'neuroglancer/sliceview/renderlayer'; +import { StatusMessage } from 'neuroglancer/status'; +import { TrackableBoolean } from 'neuroglancer/trackable_boolean'; +import { Uint64Set } from 'neuroglancer/uint64_set'; +import { vec3 } from 'neuroglancer/util/geom'; +import { verify3dVec, verifyObjectProperty } from 'neuroglancer/util/json'; +import { Uint64 } from 'neuroglancer/util/uint64'; +import { RPC } from 'neuroglancer/worker_rpc'; export const GRAPH_SERVER_NOT_SPECIFIED = Symbol('Graph Server Not Specified.'); @@ -49,7 +49,7 @@ export function restoreSegmentSelection(x: any): SegmentSelection { } export class ChunkedGraphChunkSource extends SliceViewChunkSource implements - ChunkedGraphChunkSourceInterface { + ChunkedGraphChunkSourceInterface { rootSegments: Uint64Set; spec: ChunkedGraphChunkSpecification; @@ -69,19 +69,19 @@ export class ChunkedGraphChunkSource extends SliceViewChunkSource implements updateRootSegments(rpc: RPC, rootSegments: Uint64Set) { this.rootSegments = rootSegments; rpc.invoke( - CHUNKED_GRAPH_SOURCE_UPDATE_ROOT_SEGMENTS_RPC_ID, - {'id': this.rpcId, 'rootSegments': this.rootSegments.rpcId}); + CHUNKED_GRAPH_SOURCE_UPDATE_ROOT_SEGMENTS_RPC_ID, + { 'id': this.rpcId, 'rootSegments': this.rootSegments.rpcId }); } } export class ChunkedGraphLayer extends GenericSliceViewRenderLayer { private graphurl: string; - private leafRequestsStatusMessage: StatusMessage|undefined; + private leafRequestsStatusMessage: StatusMessage | undefined; leafRequestsActive = new TrackableBoolean(true, true); constructor( - chunkManager: ChunkManager, url: string, public sources: ChunkedGraphChunkSource[][], - displayState: VisibleSegmentsState&RenderLayerOptions) { + chunkManager: ChunkManager, url: string, public sources: ChunkedGraphChunkSource[][], + displayState: VisibleSegmentsState & RenderLayerOptions) { super(chunkManager, sources, { rpcTransfer: { 'chunkManager': chunkManager.rpcId, @@ -108,15 +108,14 @@ export class ChunkedGraphLayer extends GenericSliceViewRenderLayer { } async getRoot(selection: SegmentSelection, timestamp?: string): Promise { - const {url} = this; + const { url } = this; if (url === '') { return Promise.resolve(selection.segmentId); } const promise = authFetch( - `${url}/node/${String(selection.segmentId)}/root?int64_as_str=1${ - timestamp ? `×tamp=${timestamp}` : ``}`, - {}, responseIdentity, undefined, false); + `${url}/node/${String(selection.segmentId)}/root?stop_layer=6&int64_as_str=1${timestamp ? `×tamp=${timestamp}` : ``}`, + {}, responseIdentity, undefined, false); const response = await this.withErrorMessage(promise, { initialMessage: `Retrieving root for segment ${selection.segmentId}`, @@ -127,20 +126,20 @@ export class ChunkedGraphLayer extends GenericSliceViewRenderLayer { } async mergeSegments(first: SegmentSelection, second: SegmentSelection): Promise { - const {url} = this; + const { url } = this; if (url === '') { return Promise.reject(GRAPH_SERVER_NOT_SPECIFIED); } const promise = authFetch( - `${url}/merge?int64_as_str=1`, { - method: 'POST', - body: JSON.stringify([ - [String(first.segmentId), ...first.position.values()], - [String(second.segmentId), ...second.position.values()] - ]) - }, - responseIdentity, undefined, false); + `${url}/merge?int64_as_str=1`, { + method: 'POST', + body: JSON.stringify([ + [String(first.segmentId), ...first.position.values()], + [String(second.segmentId), ...second.position.values()] + ]) + }, + responseIdentity, undefined, false); const response = await this.withErrorMessage(promise, { initialMessage: `Merging ${first.segmentId} and ${second.segmentId}`, @@ -151,20 +150,20 @@ export class ChunkedGraphLayer extends GenericSliceViewRenderLayer { } async splitSegments(first: SegmentSelection[], second: SegmentSelection[]): Promise { - const {url} = this; + const { url } = this; if (url === '') { return Promise.reject(GRAPH_SERVER_NOT_SPECIFIED); } const promise = authFetch( - `${url}/split?int64_as_str=1`, { - method: 'POST', - body: JSON.stringify({ - 'sources': first.map(x => [String(x.segmentId), ...x.position.values()]), - 'sinks': second.map(x => [String(x.segmentId), ...x.position.values()]) - }) - }, - responseIdentity, undefined, false); + `${url}/split?int64_as_str=1`, { + method: 'POST', + body: JSON.stringify({ + 'sources': first.map(x => [String(x.segmentId), ...x.position.values()]), + 'sinks': second.map(x => [String(x.segmentId), ...x.position.values()]) + }) + }, + responseIdentity, undefined, false); const response = await this.withErrorMessage(promise, { initialMessage: `Splitting ${first.length} sources from ${second.length} sinks`, @@ -179,25 +178,25 @@ export class ChunkedGraphLayer extends GenericSliceViewRenderLayer { } async splitPreview(first: SegmentSelection[], second: SegmentSelection[]): - Promise<{supervoxelConnectedComponents: Uint64Set[], isSplitIllegal: boolean}> { - const {url} = this; + Promise<{ supervoxelConnectedComponents: Uint64Set[], isSplitIllegal: boolean }> { + const { url } = this; if (url === '') { return Promise.reject(GRAPH_SERVER_NOT_SPECIFIED); } const promise = authFetch( - `${url}/graph/split_preview?int64_as_str=1`, { - method: 'POST', - body: JSON.stringify({ - 'sources': first.map(x => [String(x.segmentId), ...x.position.values()]), - 'sinks': second.map(x => [String(x.segmentId), ...x.position.values()]) - }) - }, - responseIdentity, undefined, false); + `${url}/graph/split_preview?int64_as_str=1`, { + method: 'POST', + body: JSON.stringify({ + 'sources': first.map(x => [String(x.segmentId), ...x.position.values()]), + 'sinks': second.map(x => [String(x.segmentId), ...x.position.values()]) + }) + }, + responseIdentity, undefined, false); const response = await this.withErrorMessage(promise, { initialMessage: - `Calculating split preview: ${first.length} sources, and ${second.length} sinks`, + `Calculating split preview: ${first.length} sources, and ${second.length} sinks`, errorPrefix: 'Split preview failed: ' }); const jsonResp = await response.json(); @@ -213,24 +212,24 @@ export class ChunkedGraphLayer extends GenericSliceViewRenderLayer { supervoxelConnectedComponents[i] = connectedComponentSet; } const jsonIllegalSplitKey = 'illegal_split'; - return {supervoxelConnectedComponents, isSplitIllegal: jsonResp[jsonIllegalSplitKey]}; + return { supervoxelConnectedComponents, isSplitIllegal: jsonResp[jsonIllegalSplitKey] }; } async findPath(first: SegmentSelection, second: SegmentSelection, precisionMode: boolean): - Promise { - const {url} = this; + Promise { + const { url } = this; if (url === '') { return Promise.reject(GRAPH_SERVER_NOT_SPECIFIED); } const promise = - authFetch(`${url}/graph/find_path?int64_as_str=1&precision_mode=${Number(precisionMode)}`, { - method: 'POST', - body: JSON.stringify([ - [String(first.rootId), ...first.position.values()], - [String(second.rootId), ...second.position.values()] - ]) - }); + authFetch(`${url}/graph/find_path?int64_as_str=1&precision_mode=${Number(precisionMode)}`, { + method: 'POST', + body: JSON.stringify([ + [String(first.rootId), ...first.position.values()], + [String(second.rootId), ...second.position.values()] + ]) + }); const response = await this.withErrorMessage(promise, { initialMessage: `Finding path between ${first.segmentId} and ${second.segmentId}`, @@ -243,12 +242,12 @@ export class ChunkedGraphLayer extends GenericSliceViewRenderLayer { const missingL2Ids = jsonResponse[missingL2IdsKey]; if (missingL2Ids && missingL2Ids.length > 0) { StatusMessage.showTemporaryMessage( - 'Some level 2 meshes are missing, so the path shown may have a poor level of detail.'); + 'Some level 2 meshes are missing, so the path shown may have a poor level of detail.'); } return centroids; } - draw() {} + draw() { } async withErrorMessage(promise: Promise, options: { initialMessage: string, @@ -271,7 +270,7 @@ export class ChunkedGraphLayer extends GenericSliceViewRenderLayer { } catch { msg = await response.text(); } - const {errorPrefix = ''} = options; + const { errorPrefix = '' } = options; status.setErrorMessage(errorPrefix + msg); status.setVisible(true); throw new Error(`[${response.status}] ${errorPrefix}${msg}`);