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

Fetch roi info #724

Merged
merged 4 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
12 changes: 12 additions & 0 deletions src/ImJoyPluginAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,18 @@ class ImJoyPluginAPI {
getCompareImages(name) {
return this.viewer.getCompareImages(name)
}

getloadedScale(scale) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getLoadedScale, l -> L

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and calls

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh my 🙃 Fixed!

return this.viewer.getloadedScale(scale)
}

getCroppedImageWorldBounds() {
return this.viewer.getCroppedImageWorldBounds()
}

async getCroppedIndexBounds(scale) {
return await this.viewer.getCroppedIndexBounds(scale)
}
}

export default ImJoyPluginAPI
34 changes: 34 additions & 0 deletions src/createViewer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { mat4 } from 'gl-matrix'
import { inspect } from '@xstate/inspect'
import { interpret } from 'xstate'

Expand All @@ -13,11 +14,13 @@ import hex2rgb from './UserInterface/hex2rgb'
import ViewerStore from './ViewerStore'

import toMultiscaleSpatialImage from './IO/toMultiscaleSpatialImage'
import { worldBoundsToIndexBounds } from './IO/MultiscaleSpatialImage'
import viewerMachineOptions from './viewerMachineOptions'
import createViewerMachine from './createViewerMachine'
import ViewerMachineContext from './Context/ViewerMachineContext'
import {
addCroppingPlanes,
getCropWidgetBounds,
updateCroppingParameters,
} from './Rendering/VTKJS/Main/croppingPlanes'

Expand Down Expand Up @@ -1254,6 +1257,37 @@ const createViewer = async (
return context.maxConcurrency
}

publicAPI.getloadedScale = name => {
if (typeof name === 'undefined') {
name = context.images.selectedName
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (typeof name === 'undefined') {
name = context.images.selectedName
}
const imageName = name ?? context.images.selectedName

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

const actorContext = context.images.actorContext.get(name)
return actorContext.loadedScale
}

publicAPI.getCroppedImageWorldBounds = () => {
return getCropWidgetBounds(context)
}

publicAPI.getCroppedIndexBounds = async (scale, name) => {
if (typeof name === 'undefined') {
name = context.images.selectedName
}
const actorContext = context.images.actorContext.get(name)
if (typeof scale === 'undefined' || scale < 0) {
scale = actorContext.loadedScale
}
const image = actorContext.image
const bounds = getCropWidgetBounds(context)
const indexToWorld = await image.scaleIndexToWorld(scale)
const fullIndexBounds = image.getIndexBounds(scale)
return worldBoundsToIndexBounds({
bounds,
fullIndexBounds,
worldToIndex: mat4.invert([], indexToWorld),
})
}

addKeyboardShortcuts(context.uiContainer, service)

// must come before moving/main image
Expand Down
Loading