Skip to content
Merged
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion app/stores/hybrid_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,52 +25,52 @@
];
const WHEEL_TIME_OUT_MS = 600;

export const useHybridViewerStore = defineStore("hybridViewer", () => {
const dataStore = useDataStore();
const viewerStore = useViewerStore();
const hybridDb = reactive({});
const status = ref(Status.NOT_CREATED);
const camera_options = reactive({});
const genericRenderWindow = reactive({});
const is_moving = ref(false);
const zScale = ref(1);
let viewStream = undefined;
const gridActor = undefined;

async function initHybridViewer() {
if (status.value !== Status.NOT_CREATED) {
return;
}
status.value = Status.CREATING;
genericRenderWindow.value = vtkGenericRenderWindow({
background: BACKGROUND_COLOR,
listenWindowResize: false,
});

const webGLRenderWindow = genericRenderWindow.value.getApiSpecificRenderWindow();
const imageStyle = webGLRenderWindow.getReferenceByName("bgImage").style;
imageStyle.transition = "opacity 0.1s ease-in";
imageStyle.zIndex = 1;

await viewerStore.ws_connect();
viewStream = viewerStore.client.getImageStream().createViewStream("-1");
viewStream.onImageReady((event) => {
if (is_moving.value) {
return;
}
webGLRenderWindow.setBackgroundImage(event.image);
imageStyle.opacity = 1;
});

status.value = Status.CREATED;
}

async function addItem(id) {
if (!genericRenderWindow.value) {
return;
}
const value = await dataStore.item(id);
console.log("hybridViewerStore.addItem", { value });

Check warning on line 73 in app/stores/hybrid_viewer.js

View workflow job for this annotation

GitHub Actions / test / oxlint

eslint(no-console)

Unexpected console statement.
const reader = vtkXMLPolyDataReader();
const textEncoder = new TextEncoder();
await reader.parseAsArrayBuffer(textEncoder.encode(value.binary_light_viewable));
Expand All @@ -82,8 +82,11 @@
actor.setMapper(mapper);
const renderer = genericRenderWindow.value.getRenderer();
const renderWindow = genericRenderWindow.value.getRenderWindow();
const isFirst = renderer.getActors().length === 0;
renderer.addActor(actor);
renderer.resetCamera();
if (isFirst) {
renderer.resetCamera();
}
renderWindow.render();
hybridDb[id] = { actor, polydata, mapper };
}

Check warning on line 92 in app/stores/hybrid_viewer.js

View workflow job for this annotation

GitHub Actions / test / oxlint

eslint(max-statements)

function `addItem` has too many statements (21). Maximum allowed is 20.
Expand Down Expand Up @@ -129,7 +132,7 @@
}

function syncRemoteCamera() {
console.log("syncRemoteCamera");

Check warning on line 135 in app/stores/hybrid_viewer.js

View workflow job for this annotation

GitHub Actions / test / oxlint

eslint(no-console)

Unexpected console statement.
const renderer = genericRenderWindow.value.getRenderer();
const camera = renderer.getActiveCamera();
const params = {
Expand Down Expand Up @@ -166,12 +169,12 @@
imageStyle.transition = "opacity 0.1s ease-in";
imageStyle.zIndex = 1;
resize(container.value.$el.offsetWidth, container.value.$el.offsetHeight);
console.log("setContainer", container.value.$el);

Check warning on line 172 in app/stores/hybrid_viewer.js

View workflow job for this annotation

GitHub Actions / test / oxlint

eslint(no-console)

Unexpected console statement.

useMousePressed({
target: container,
onPressed: (event) => {
console.log("onPressed");

Check warning on line 177 in app/stores/hybrid_viewer.js

View workflow job for this annotation

GitHub Actions / test / oxlint

eslint(no-console)

Unexpected console statement.
if (event.button === 0) {
is_moving.value = true;
event.stopPropagation();
Expand All @@ -183,7 +186,7 @@
return;
}
is_moving.value = false;
console.log("onReleased");

Check warning on line 189 in app/stores/hybrid_viewer.js

View workflow job for this annotation

GitHub Actions / test / oxlint

eslint(no-console)

Unexpected console statement.
syncRemoteCamera();
},
});
Expand Down Expand Up @@ -234,7 +237,7 @@

async function importStores(snapshot) {
if (!snapshot) {
console.warn("importStores called with undefined snapshot");

Check warning on line 240 in app/stores/hybrid_viewer.js

View workflow job for this annotation

GitHub Actions / test / oxlint

eslint(no-console)

Unexpected console statement.
return;
}
const z_scale = snapshot.zScale;
Expand Down
Loading