diff --git a/Sources/Interaction/Manipulators/RangeManipulator/example/index.js b/Sources/Interaction/Manipulators/RangeManipulator/example/index.js index d3992cc08ab..f340a8baedb 100644 --- a/Sources/Interaction/Manipulators/RangeManipulator/example/index.js +++ b/Sources/Interaction/Manipulators/RangeManipulator/example/index.js @@ -40,25 +40,25 @@ const range = data .getRange(); const wMin = 1; const wMax = range[1] - range[0]; -const wCurrent = actor.getProperty().getColorWindow(); -const wCallback = actor.getProperty().setColorWindow; +const wGet = actor.getProperty().getColorWindow; +const wSet = actor.getProperty().setColorWindow; const lMin = range[0]; const lMax = range[1]; -const lCurrent = actor.getProperty().getColorLevel(); -const lCallback = actor.getProperty().setColorLevel; +const lGet = actor.getProperty().getColorLevel; +const lSet = actor.getProperty().setColorLevel; const bounds = data.getBounds(); const zMin = bounds[4]; const zMax = bounds[5]; -const zCurrent = mapper.getZSlice(); -const zCallback = mapper.setZSlice; +const zGet = mapper.getZSlice; +const zSet = mapper.setZSlice; const rangeManipulator = Manipulators.vtkRangeManipulator.newInstance({ button: 1, pinch: true, }); -rangeManipulator.setVerticalListener(wMin, wMax, wCurrent, 1, wCallback); -rangeManipulator.setHorizontalListener(lMin, lMax, lCurrent, 1, lCallback); -rangeManipulator.setScrollListener(zMin, zMax, zCurrent, 1, zCallback); +rangeManipulator.setVerticalListener(wMin, wMax, 1, wGet, wSet); +rangeManipulator.setHorizontalListener(lMin, lMax, 1, lGet, lSet); +rangeManipulator.setScrollListener(zMin, zMax, 1, zGet, zSet); const iStyle = vtkInteractorStyleManipulator.newInstance(); iStyle.addManipulator(rangeManipulator); diff --git a/Sources/Interaction/Manipulators/RangeManipulator/index.js b/Sources/Interaction/Manipulators/RangeManipulator/index.js index b8375df99fc..a4f00296a46 100644 --- a/Sources/Interaction/Manipulators/RangeManipulator/index.js +++ b/Sources/Interaction/Manipulators/RangeManipulator/index.js @@ -13,7 +13,7 @@ function vtkRangeManipulator(publicAPI, model) { function processDelta(listener, delta) { let normDelta = delta; normDelta *= (listener.max - listener.min) / listener.step + 1; - let value = listener.value + normDelta; + let value = listener.getValue() + normDelta; const difference = value - listener.min; const stepsToDifference = Math.round(difference / listener.step); @@ -21,25 +21,27 @@ function vtkRangeManipulator(publicAPI, model) { value = Math.max(value, listener.min); value = Math.min(value, listener.max); - listener.callback(value); - listener.value = value; + listener.setValue(value); } //------------------------------------------------------------------------- - publicAPI.setHorizontalListener = (min, max, value, step, callback) => { - model.horizontalListener = { min, max, value, step, callback }; + publicAPI.setHorizontalListener = (min, max, step, getValue, setValue) => { + const getFn = Number.isFinite(getValue) ? () => getValue : getValue; + model.horizontalListener = { min, max, step, getValue: getFn, setValue }; publicAPI.modified(); }; //------------------------------------------------------------------------- - publicAPI.setVerticalListener = (min, max, value, step, callback) => { - model.verticalListener = { min, max, value, step, callback }; + publicAPI.setVerticalListener = (min, max, step, getValue, setValue) => { + const getFn = Number.isFinite(getValue) ? () => getValue : getValue; + model.verticalListener = { min, max, step, getValue: getFn, setValue }; publicAPI.modified(); }; //------------------------------------------------------------------------- - publicAPI.setScrollListener = (min, max, value, step, callback) => { - model.scrollListener = { min, max, value, step, callback }; + publicAPI.setScrollListener = (min, max, step, getValue, setValue) => { + const getFn = Number.isFinite(getValue) ? () => getValue : getValue; + model.scrollListener = { min, max, step, getValue: getFn, setValue }; publicAPI.modified(); };