-
Notifications
You must be signed in to change notification settings - Fork 66
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
Geometry / Point selection #575
Comments
@PaulHax @thewtex :
Might try give it a go myself ... if I knew where to start. |
I don't think it would be too hard, but not trivial. Here is the place where the image voxel picker updates.
I would start there. |
@PaulHax However, I am noticing that the ID's returned by Note: (Points from I have ran the same code using Do we know of any reason why the point IDs returned on glyphs might be off like this? Code from notebook (stitched together) import numpy as np
from itkwidgets import view
import vtk
# Point View
gaussian_1_mean = [0.0, 0.0, 0.0]
gaussian_1_cov = [[1.0, 0.0, 0.0], [0.0, 2.0, 0.0], [0.0, 0.0, 0.5]]
point_set_1 = np.random.multivariate_normal(gaussian_1_mean, gaussian_1_cov, 3000)
view(point_sets=[point_set_1])
# Glyph View
point_data = vtk.vtkPoints()
polydata = vtk.vtkPolyData()
for ptId in range(point_set_1.shape[0]):
pt = point_set_1[ptId]
point_data.InsertNextPoint(pt[0], pt[1], pt[2])
polydata.SetPoints(point_data)
sphere_src = vtk.vtkSphereSource()
sphere_src.SetRadius(0.08)
glyphs = vtk.vtkGlyph3D()
glyphs.ScalingOff()
glyphs.SetSourceConnection(sphere_src.GetOutputPort())
glyphs.SetInputData(polydata)
glyphs.Update()
view(geometries=[glyphs.GetOutput()]) |
Wow, you figured things out! 👏 Off by constant factor eh? My understanding of the basic VTK datatypes are limited. Maybe when viewing geometries, this does it? Good source for VTK.js info: https://discourse.vtk.org/c/web/9 |
I have this working for my own usage where I am providing glyphs as input. However, due to my inability to be able to determine the data type being presented (vtk discource quesion) it would not be viable for me to create a pull request for this work into the master I have attached the changes I have made below in the hope that this could aid the incorporation of this ability to select data points in future revisions of this module. Bases of code changes made to ItkVtkViewProxy.js
const CursorCornerAnnotationPointID =
'<table class="corner-annotation" style="margin-left: 0;"><tr><td style="margin-left: auto; margin-right: 0;"">Point ID: </td><td style="text-align:center;" colspan="3">${pointID}</td></tr><tr><td style="margin-left: auto; margin-right: 0;"">(Selected): </td><td style="text-align:center;" colspan="3">${selected}</td></tr></table>'
...
} else if (model.pointRepresentation) {
publicAPI.setCornerAnnotation('se', CursorCornerAnnotationPointID)
// KTS: 20th March 2023: Glyphs are represented by 50 data points so to get the point ID for the selected
// data point we need to divide the pointID value by 50
publicAPI.updateCornerAnnotation({
pointID: Math.floor(model.annotationPicker.getPointId()/50),
selected: model.selectedId,
})
} else {
model.lastPickedValues = null
}
model.interactor.onLeftButtonPress(event => {
// KTS: 20th March 2023: Save the ID of the selected point
if (model.annotationPicker.getPointId() != -1) {
model.selectedId = Math.floor(model.annotationPicker.getPointId()/50)
}
if (model.clickCallback && model.lastPickedValues) {
model.clickCallback(model.lastPickedValues)
}
})
// KTS: 20th March 2023: Filter out the representations to only select the non-volume
const pointRepresentations = model.representations.filter(rep => {
const isNotVolumeRepresentation = !!!rep.getVolumes().length
return isNotVolumeRepresentation
})
// KTS: 20th March 2023: Determine the number of non-volume representations
var pointRepresentationsLength = pointRepresentations.length
...
} else if (!!pointRepresentationsLength) {
// KTS 16 Mar 2023: We want the glyph actor, which will be the last geometry added within the latent explorer tool
model.pointRepresentation = pointRepresentations[pointRepresentationsLength -1]
model.pointRepresentation
.getActors()
.forEach(model.annotationPicker.addPickList)
publicAPI.setAnnotationOpacity(1.0)
}
const DEFAULT_VALUES = {
...
selectedId: null, // KTS: 20th March 2023: Added to store the selected (clicked) Point ID information
} |
Thank your for pioneering this and sharing your results! |
It would be advantageous to be able to select points within itkwidgets. For example, while viewing a collection of 3D glyphs, to be able to select one and gather some information etc. This is currently supported in vtk.js using
vtkInteractorStyleTrackballCamera
.The text was updated successfully, but these errors were encountered: