# How to update contrast in all image slices in ResliceCursorWidget simoustanly

**URL:** https://discourse.vtk.org/t/how-to-update-contrast-in-all-image-slices-in-reslicecursorwidget-simoustanly/7957
**Category:** Web
**Created:** [March 2, 2022, 10:06am UTC](https://discourse.vtk.org/t/how-to-update-contrast-in-all-image-slices-in-reslicecursorwidget-simoustanly/7957 "2022-03-02T10:06:40Z")
**Posts on this page:** 1
**Showing post:** 7

<div class="post-metadata">

### Author: ![rajajms](https://discourse.vtk.org/user_avatar/discourse.vtk.org/rajajms/32/7476_2.png) [@rajajms](https://discourse.vtk.org/u/rajajms)
#### Post date: [July 24, 2023, 4:45am UTC](https://discourse.vtk.org/t/how-to-update-contrast-in-all-image-slices-in-reslicecursorwidget-simoustanly/7957/7 "2023-07-24T04:45:32Z")

</div>

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](https://kitware.github.io/vtk-js/examples/ResliceCursorWidget.html) example for the following code snippets.

```auto
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();
			}
		}
	});
}

```

---

_[View the full topic](https://discourse.vtk.org/t/how-to-update-contrast-in-all-image-slices-in-reslicecursorwidget-simoustanly/7957)._
