widget.setCenter() is not updating Reslices unless hover

Hey,

I’m really stuck, I’m updating the center of a vtkResliceCursorWidget after a button click but the center of the widget is not updated unless I hover in each view, I need to update views right after update the center,

ezgif-4-b2aae76241

I’m using same code as the official example, and I’m storing the widget object in a useRef():

reader.setUrl("/Patient/volume.vti").then(() => {
  reader.loadData().then(() => {
    const image = reader.getOutputData();
    widget.setImage(image);
      widgetRef.current = {
        widget: widget
      }
...

in my button onAction method:

() => {
      const wid = widgetRef.current.widget;
      wid.setCenter( [13.9, -73.7, -55.8]);
      // I tried to call updateViews() like in the example but it doesn't work
    }

Just a guess: does calling view3D.widgetManager.renderWidgets() in updateViews() work?

No as I deleted the view3D, (I tried obj.widgetManager.renderWidgets()) it doesn’t work

function updateViews() {
  viewAttributes.forEach((obj, i) => {
    updateReslice({
      viewType: xyzToViewType[i],
      reslice: obj.reslice,
      actor: obj.resliceActor,
      renderer: obj.renderer,
      resetFocalPoint: true,
      keepFocalPointPosition: false,
      computeFocalPointOffset: false,
      sphereSources: obj.sphereSources,
    });
    obj.widgetManager.renderWidgets();
    obj.renderer.getActiveCamera().zoom(1.5);
    obj.renderWindow.render();
  });
}

The example works fine with the “reset” button/function. So I would investiguate the difference between the example and your code.

Hth,
J.

1 Like