# Forcing vtlResliceCursorWidget to change on slider move

**URL:** https://discourse.vtk.org/t/forcing-vtlreslicecursorwidget-to-change-on-slider-move/8737
**Category:** Web
**Created:** [June 15, 2022, 2:06pm UTC](https://discourse.vtk.org/t/forcing-vtlreslicecursorwidget-to-change-on-slider-move/8737 "2022-06-15T14:06:14Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![olry](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/o/0ea827/32.png) [@olry](https://discourse.vtk.org/u/olry)
#### Post date: [June 15, 2022, 2:06pm UTC](https://discourse.vtk.org/t/forcing-vtlreslicecursorwidget-to-change-on-slider-move/8737/1 "2022-06-15T14:06:14Z")

</div>

Dear VTK team,

could you please help me with vtlResliceCursorWidget, I would like to render reslice changes not only when I do mouse scrolling but also when I move a slider manually created by me for the purpose of slice changing. How can I pass slice number to the widget and cause it to update views? I’m using this example in my project [vtk.js](https://kitware.github.io/vtk-js/examples/ResliceCursorWidget.html)

Olga.

---

<div class="post-metadata">

### Author: ![Forrest](https://discourse.vtk.org/user_avatar/discourse.vtk.org/forrest/32/300_2.png) [@Forrest](https://discourse.vtk.org/u/Forrest)
#### Post date: [June 15, 2022, 3:30pm UTC](https://discourse.vtk.org/t/forcing-vtlreslicecursorwidget-to-change-on-slider-move/8737/2 "2022-06-15T15:30:27Z")

</div>

I’d start with looking at [the code that calls `updateReslice`](https://github.com/Kitware/vtk-js/blob/master/Sources/Widgets/Widgets3D/ResliceCursorWidget/example/index.js#L333). It should give you an idea of how to programmatically invoke the reslice from your slider.

---

<div class="post-metadata">

### Author: ![zhangzhi93](https://discourse.vtk.org/user_avatar/discourse.vtk.org/zhangzhi93/32/4954_2.png) [@zhangzhi93](https://discourse.vtk.org/u/zhangzhi93)
#### Post date: [June 27, 2022, 9:31am UTC](https://discourse.vtk.org/t/forcing-vtlreslicecursorwidget-to-change-on-slider-move/8737/3 "2022-06-27T09:31:37Z")

</div>

Hello, I tried to control the position of the slice through the slider by reading the source code ([vtk-js/behavior.js at ee863d1d08dc846c904526385e3d24335db16cb9 · Kitware/vtk-js · GitHub](https://github.com/Kitware/vtk-js/blob/ee863d1d08dc846c904526385e3d24335db16cb9/Sources/Widgets/Widgets3D/ResliceCursorWidget/behavior.js#L228)), and found that I need to get the origin, but I don’t know how to calculate the origin through the current position of the slider, can you help me? For example, I slide to the 50th layer, how can I get the origin of the 50th layer?

---

<div class="post-metadata">

### Author: ![Forrest](https://discourse.vtk.org/user_avatar/discourse.vtk.org/forrest/32/300_2.png) [@Forrest](https://discourse.vtk.org/u/Forrest)
#### Post date: [June 28, 2022, 9:59pm UTC](https://discourse.vtk.org/t/forcing-vtlreslicecursorwidget-to-change-on-slider-move/8737/4 "2022-06-28T21:59:15Z")

</div>

If you have access to the underlying `vtkImageSlice` actor, you can call `imageSliceActor.getBoundsForSlice()`, and then get the center of that bounding box. If you would rather get the origin without going through the actor, you will need to transform the slice point to world point via the image position. For example, if you are slicing along the K axis, you would do `imageData.indexToWorld([0, 0, kSliceValue])`.
