Skip to content

Commit f5ec0be

Browse files
rodrigobasilio2022finetjul
authored andcommitted
refactor(code): add slider in VolumePicker example
1 parent 412fd43 commit f5ec0be

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

Examples/Volume/VolumePicker/controlPanel.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,8 @@
2525
</td>
2626
</tr>
2727
</tr>
28+
<tr>
29+
<label id="opacityLabel">Opacity (0.0001)</label>
30+
<input id='opacity' type="range" min="0.001" max="0.8" step="0.005" value="0.001" />
31+
</tr>
2832
</table>

Examples/Volume/VolumePicker/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,18 @@ renderWindow.getInteractor().onRightButtonPress((callData) => {
219219
renderWindow.render();
220220
});
221221

222+
function setOpacityFromSlider(opacityValue) {
223+
picker.setOpacityThreshold(opacityValue);
224+
}
225+
226+
const opacity = document.getElementById('opacity');
227+
const opacityLabel = document.getElementById('opacityLabel');
228+
229+
opacity.addEventListener('input', () => {
230+
setOpacityFromSlider(Number.parseFloat(opacity.value, 10));
231+
opacityLabel.innerHTML = `Opacity ( ${opacity.value} )`;
232+
});
233+
222234
// -----------------------------------------------------------
223235
// Make some variables global so that you can inspect and
224236
// modify objects in your browser's developer console:

Sources/Rendering/Core/CellPicker/index.d.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,12 @@ export interface vtkCellPicker extends vtkPicker {
4646
/**
4747
* Get the opacity threshold for volume picking
4848
*/
49-
getOpacityThreshold(): number[];
49+
getOpacityThreshold(): number;
50+
51+
/**
52+
* Get the opacity threshold for volume picking
53+
*/
54+
setOpacityThreshold(value: number);
5055

5156
/**
5257
* Get the parametric coordinates of the picked cell.

Sources/Rendering/Core/CellPicker/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,10 @@ export function extend(publicAPI, model, initialValues = {}) {
571571
'mapperNormal',
572572
'pCoords',
573573
'cellIJK',
574-
'opacityThreshold',
575574
]);
575+
576+
macro.setGet(publicAPI, model, ['opacityThreshold']);
577+
576578
macro.get(publicAPI, model, ['cellId']);
577579

578580
// Object methods

0 commit comments

Comments
 (0)