Skip to content

Commit

Permalink
refactor(code): add slider in VolumePicker example
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigobasilio2022 committed Nov 1, 2023
1 parent 1f48bdc commit 24dd369
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Examples/Volume/VolumePicker/controlPanel.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@
</td>
</tr>
</tr>
<tr>
<label id="opacityLabel">Opacity (0.0001)</label>
<input id='opacity' type="range" min="0.001" max="0.8" step="0.005" value="0.001" />
</tr>
</table>
12 changes: 12 additions & 0 deletions Examples/Volume/VolumePicker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,18 @@ renderWindow.getInteractor().onRightButtonPress((callData) => {
renderWindow.render();
});

function setOpacityFromSlider(opacityValue) {
picker.setOpacityThreshold(opacityValue);
}

const opacity = document.getElementById('opacity');
const opacityLabel = document.getElementById('opacityLabel');

opacity.addEventListener('input', () => {
setOpacityFromSlider(Number.parseFloat(opacity.value, 10));
opacityLabel.innerHTML = `Opacity ( ${opacity.value} )`;
});

// -----------------------------------------------------------
// Make some variables global so that you can inspect and
// modify objects in your browser's developer console:
Expand Down
7 changes: 6 additions & 1 deletion Sources/Rendering/Core/CellPicker/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ export interface vtkCellPicker extends vtkPicker {
/**
* Get the opacity threshold for volume picking
*/
getOpacityThreshold(): number[];
getOpacityThreshold(): number;

/**
* Get the opacity threshold for volume picking
*/
setOpacityThreshold(value: number);

/**
* Get the parametric coordinates of the picked cell.
Expand Down
4 changes: 3 additions & 1 deletion Sources/Rendering/Core/CellPicker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -571,8 +571,10 @@ export function extend(publicAPI, model, initialValues = {}) {
'mapperNormal',
'pCoords',
'cellIJK',
'opacityThreshold',
]);

macro.setGet(publicAPI, model, ['opacityThreshold']);

macro.get(publicAPI, model, ['cellId']);

// Object methods
Expand Down

0 comments on commit 24dd369

Please sign in to comment.