Skip to content

Commit

Permalink
wip default view setup
Browse files Browse the repository at this point in the history
  • Loading branch information
jinhan committed Aug 24, 2024
1 parent 8fb2e52 commit 7bd863f
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 31 deletions.
38 changes: 38 additions & 0 deletions config/default-settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"h01_c3_flat": {
"dimensions": [8e-9, 8e-9, 3.3e-8],
"position": [313521.25, 181787.21875, 4311.5],
"crossSectionScale": 8.031913463326639,
"projectionOrientation": [
-0.24557209014892578,
0.17511530220508575,
0.5259231328964233,
0.7952570915222168
],
"projectionScale": 23218.557071742558
},
"fish1_full_v240509": {
"dimensions": [8e-9, 8e-9, 3e-8],
"position": [36012.56640625, 31434.515625, 4344.5],
"crossSectionScale": 3.244521169873426,
"projectionOrientation": [
-0.9953426122665405,
-0.00016468977264594287,
0.012358397245407104,
-0.09560522437095642
],
"projectionScale": 32237.35182935765
},
"fish1_full": {
"dimensions": [8e-9, 8e-9, 3e-8],
"position": [36012.56640625, 31434.515625, 4344.5],
"crossSectionScale": 3.244521169873426,
"projectionOrientation": [
-0.9953426122665405,
-0.00016468977264594287,
0.012358397245407104,
-0.09560522437095642
],
"projectionScale": 32237.35182935765
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"build-min": "node ./node_modules/neuroglancer/config/esbuild-cli.js --config=min",
"build": "node ./node_modules/neuroglancer/config/esbuild-cli.js --config=min",
"build:watch": "node ./node_modules/neuroglancer/config/esbuild-cli.js --config=dev --serve --watch",
"dev-server": "node ./node_modules/neuroglancer/config/esbuild-cli.js --define CONFIG=$(cat config/ng-extend.json | tr -d ' \t\n\r') --define STATE_SERVERS=$(cat config/state_servers.json | tr -d ' \t\n\r') --define CUSTOM_BINDINGS=$(cat config/custom-keybinds.json | tr -d ' \t\n\r') --define DATASETS=$(cat config/datastack-dataset.json | tr -d ' \t\n\n') --config=dev --serve --watch",
"dev-server": "node ./node_modules/neuroglancer/config/esbuild-cli.js --define CONFIG=$(cat config/ng-extend.json | tr -d ' \t\n\r') --define STATE_SERVERS=$(cat config/state_servers.json | tr -d ' \t\n\r') --define CUSTOM_BINDINGS=$(cat config/custom-keybinds.json | tr -d ' \t\n\r') --define DATASETS=$(cat config/datastack-dataset.json | tr -d ' \t\n\n') --define DEFAULT_SETTINGS=$(cat config/default-settings.json | tr -d ' \t\n\n') --config=dev --serve --watch",
"dev-server-python": "node ./node_modules/neuroglancer/config/esbuild-cli.js --config=python-dev --serve --watch",
"build-module": "node ./node_modules/neuroglancer/config/esbuild-cli.js --config=module",
"build-python": "node ./node_modules/neuroglancer/config/esbuild-cli.js --config=python-min",
Expand Down
52 changes: 22 additions & 30 deletions src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ import {cancellableFetchSpecialOk, parseSpecialUrl} from 'neuroglancer/util/spec
import {responseJson} from 'neuroglancer/util/http_request';

import {Config} from './config';
import {SegmentationUserLayer} from "neuroglancer/segmentation_user_layer";
import {parsePositionString} from "neuroglancer/ui/default_clipboard_handling";

declare const CONFIG: Config|undefined;
declare const DEFAULT_SETTINGS: { [key: string]: any }

export const useDropdownListStore = defineStore('dropdownlist', () => {
let dropdownCount = 0;
Expand Down Expand Up @@ -151,15 +154,7 @@ export const useLayersStore = defineStore('layers', () => {
// set default values in settings
viewer.chunkQueueManager.capacities.gpuMemory.sizeLimit.value = 2e9;
viewer.chunkQueueManager.capacities.systemMemory.sizeLimit.value = 3e9;
// viewer.showPerspectiveSliceViews.value = false;
// viewer.position.assign(313521.25, 181787.21875, 4311.5);
// viewer.position.value = { "x":313521.25, "y":181787.21875, "z":4311.5};
// viewer.crossSectionScale.value = 8.031913463326639;
// viewer.projectionOrientation = [-0.24557209014892578, 0.17511530220508575, 0.5259231328964233, 0.7952570915222168];
// viewer.projectionScale.value = 23218.557071742558;
// viewer.layerManager.getLayerByName("segmentation").
// viewer.layout.container.setSpecification('xy-3d');

viewer.layout.restoreState('xy-3d');
viewer.layerManager.layersChanged.add(refreshLayers);
refreshLayers();
}
Expand All @@ -168,29 +163,26 @@ export const useLayersStore = defineStore('layers', () => {
if (!viewer) return;
viewer.layerSpecification.restoreState(layers);
viewer.navigationState.reset();
const imageLayer = viewer.layerManager.managedLayers.filter(
(x) => x.name === "img"

const segmentationLayer = viewer.layerManager.managedLayers.filter(
(x) => x.layer instanceof SegmentationUserLayer
)[0];
if (imageLayer) {
const stopListening = imageLayer.readyStateChanged.add(() => {
if (imageLayer.isReady() && imageLayer.layer) {
const { dataSources } = imageLayer.layer;
stopListening();
if (dataSources.length) {
const { loadState } = dataSources[0];
if (loadState && !loadState.error) {
const { scales } = loadState.transform.outputSpace.value;
viewer!.coordinateSpace.restoreState({
// x: [scales[0], "m"],
// y: [scales[1], "m"],
x: [8e-9, 'm'],
y: [8e-9, 'm'],
z: [scales[2], "m"],
});
}
}
}
if (segmentationLayer) {
const segmentationLayerName = segmentationLayer.name;
const SETTINGS = DEFAULT_SETTINGS[segmentationLayerName]
viewer!.coordinateSpace.restoreState({
x: [SETTINGS.dimensions[0], "m"],
y: [SETTINGS.dimensions[1], "m"],
z: [SETTINGS.dimensions[2], "m"],
});

const position = parsePositionString(SETTINGS.position, 3);
if (position !== undefined) {
viewer!.navigationState.position.value = position;
}
viewer!.crossSectionScale.value = SETTINGS.crossSectionScale;
viewer!.projectionScale.value = SETTINGS.projectionScale;
viewer!.projectionOrientation.restoreState(SETTINGS.projectionOrientation);
}
}

Expand Down

0 comments on commit 7bd863f

Please sign in to comment.