How to get the center value of a GLWindow interactor position in ResliceCursorWidget

Hey,
I want to set the center of my reslice widget cursor, using the position where we clicked with the mouse in a reslice actor (one of the three views in the ResliceCursorWidget ),
I did this

obj.interactor.onLeftButtonPress(async (callData) => {
const pos = callData.position;
const arr = [pos[0], pos[1], pos[2]];
widget.setCenter(arr);
})

I figured out that we can’t do a setCenter using the position value, because the widget center value is different from the click position at certain location.
I don’t know how to setCenter the widget correctly thank you for your help

callData.position is in pixel coordinate system. setCenter() expects world coordinate. You need to map from display coordinate to world coordinate. I believe there are convenient functions in the render window , render window interactor or renderer classes.

1 Like

Yes thank you so much, I did it using:

const pos = callData.position;
    const arr = obj.interactor
      .getView()
      .displayToWorld(pos.x, pos.y, pos.z, obj.renderer);