You need to change level and window color of the actor on mouse drag. You can use interactorStyle.onInteractionEvent
to detect the drag on image.
I have used vtk.js example for the following code snippets.
for (let i = 0; i < 3; i++) {
// This sets up an event listener for the 'onInteractionEvent' of each view's interactor style.
this.viewAttributes[i].interactorStyle.onInteractionEvent(() => {
// When the 'onInteractionEvent' occurs for a view, the following code block is executed.
// Get the current color level and window settings of the view's reslice actor.
const level = this.viewAttributes[i].resliceActor.getProperty().getColorLevel();
const window = this.viewAttributes[i].resliceActor.getProperty().getColorWindow();
for (let j = 0; j < 3; j++) {
// Check if the current view (indexed by 'j') is not the same as the one that triggered the event (indexed by 'i').
if (j !== i) {
// If 'j' is different from 'i', update the color level and window of the current view (indexed by 'j')
// to match the values of the view that triggered the event (indexed by 'i').
this.viewAttributes[j].resliceActor.getProperty().setColorLevel(level);
this.viewAttributes[j].resliceActor.getProperty().setColorWindow(window);
// Finally, render the changes in the current view (indexed by 'j').
this.viewAttributes[j].renderWindow.getInteractor().render();
}
}
});
}