Skip to content

Commit b5a456f

Browse files
authored
Release v34
Major changes: - #3239 - #3224 - #3171 - #3159 - #3158 - #3157
2 parents 3247463 + b7f9c1e commit b5a456f

File tree

63 files changed

+4100
-4006
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+4100
-4006
lines changed

BREAKING_CHANGES.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## From 33.x to 34
2+
3+
- **vtkMapper**: many properties have moved to `vtkVolumeProperty`. The full list of changed methods is: `getAnisotropy`, `getComputeNormalFromOpacity`, `getFilterMode`, `getFilterModeAsString`, `getGlobalIlluminationReach`, `getIpScalarRange`, `getIpScalarRangeByReference`, `getLAOKernelRadius`, `getLAOKernelSize`, `getLocalAmbientOcclusion`, `getPreferSizeOverAccuracy`, `getVolumetricScatteringBlending`, `setAnisotropy`, `setAverageIPScalarRange`, `setComputeNormalFromOpacity`, `setFilterMode`, `setFilterModeToNormalized`, `setFilterModeToOff`, `setFilterModeToRaw`, `setGlobalIlluminationReach`, `setIpScalarRange`, `setIpScalarRangeFrom`, `setLAOKernelRadius`, `setLAOKernelSize`, `setLocalAmbientOcclusion`, `setPreferSizeOverAccuracy`, `setVolumetricScatteringBlending`.
4+
- **vtkRenderWindowInteractor**: KeyPress, KeyDown and KeyUp events are now observed on the container and no longer on the document. "tabIndex=0" is now automatically added on RWI containers to give focus on your render windows and catch key events. Check the KeyPressEvents example for usage.
5+
- **vtkOpenGLTexture**: The public `create2D*` and `create3D*` methods used to have positional parameters. These methods now use named parameters via passing in an object record.
6+
7+
## From 32.x to 33
8+
9+
- **vtkColorTransferFunction**, **vtkMapper**: Previous log scaling was disabled but functionality is now quite different from what it maybe was before it was disabled. ColorTransfer function now maps the model.nodes in logarithmic scales so there's an even spacing between powers of ten.
10+
111
## From 31.x to 32
212

313
- **vtkMapper**: remove `mapScalarsToTexture` from the public API. The function becomes protected and its API changes. This shouldn't cause any issue in most cases.
17.7 KB
Loading

Documentation/content/examples/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ This will allow you to see the some live code running in your browser. Just pick
326326
[![InteractorStyleTrackballCamera Example][InteractorStyleTrackballCamera]](./InteractorStyleTrackballCamera.html "InteractorStyleTrackballCamera")
327327
[![InteractorStyleUnicam Example][InteractorStyleUnicam]](./InteractorStyleUnicam.html "InteractorStyleUnicam")
328328
[![KeyboardCameraManipulator Example][KeyboardCameraManipulator]](./KeyboardCameraManipulator.html "KeyboardCameraManipulator")
329+
[![KeyPressEvents Example][KeyPressEvents]](./KeyPressEvents.html "KeyPressEvents")
329330
[![MouseRangeManipulator Example][MouseRangeManipulator]](./MouseRangeManipulator.html "MouseRangeManipulator")
330331
[![PiecewiseGaussianWidget Example][PiecewiseGaussianWidget]](./PiecewiseGaussianWidget.html "PiecewiseGaussianWidget")
331332
[![TimeStepBasedAnimationHandler Example][TimeStepBasedAnimationHandler]](./TimeStepBasedAnimationHandler.html "TimeStepBasedAnimationHandler")
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<style>
2+
#view-1:focus {
3+
outline: none; /* remove default */
4+
box-shadow: 0 0 20px 10px rgba(0, 255, 0, 0.6); /* red glow */
5+
z-index: 1; /* move forward (works only if position!=static) */
6+
position: relative;
7+
}
8+
#view-2:focus, #view-2:focus-visible {
9+
outline: none; /* remove default */
10+
}
11+
12+
input:focus {
13+
outline: none;
14+
border: 2px solid teal;
15+
box-shadow: 0 0 4px teal;
16+
}
17+
18+
/* Optional: Use focus-visible for keyboard-only styling */
19+
select:focus-visible {
20+
outline: 3px dashed orange;
21+
}
22+
</style>
23+
<h3>Click or press tab until you "focus" a render window, then type keys (e.g. r, w, s)</h3>
24+
<table>
25+
<tr>
26+
<td>Click with mouse then press space key:</td>
27+
<td>
28+
<input type="checkbox" id="checkboxTranslation" checked>
29+
</td>
30+
</tr>
31+
<tr>
32+
<td>Click then key up and down :</td>
33+
<td><input id='slider' type="range" min="0" max="255" step="1" value="255" style="width: 100px;"/></td>
34+
</tr>
35+
<tr>
36+
<td>Use key up and down to browse through:</td>
37+
<td>
38+
<select id="select">
39+
<option>One</option>
40+
<option>Two</option>
41+
<option selected="selected">Three</option>
42+
<option>Four</option>
43+
</select>
44+
</td>
45+
</tr>
46+
<tr>
47+
<td>
48+
<button id="buttonReset">Click and press space key</button>
49+
</td>
50+
</tr>
51+
</table>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import '@kitware/vtk.js/favicon';
2+
3+
// Load the rendering pieces we want to use (for both WebGL and WebGPU)
4+
import '@kitware/vtk.js/Rendering/Profiles/Geometry';
5+
6+
import vtkActor from '@kitware/vtk.js/Rendering/Core/Actor';
7+
import vtkConeSource from '@kitware/vtk.js/Filters/Sources/ConeSource';
8+
import vtkGenericRenderWindow from '@kitware/vtk.js/Rendering/Misc/GenericRenderWindow';
9+
import vtkMapper from '@kitware/vtk.js/Rendering/Core/Mapper';
10+
11+
import controlPanel from './controlPanel.html';
12+
13+
// ----------------------------------------------------------------------------
14+
// Standard rendering code setup
15+
// ----------------------------------------------------------------------------
16+
17+
const container = document.querySelector('body');
18+
const controlContainer = document.createElement('div');
19+
controlContainer.innerHTML = controlPanel;
20+
container.appendChild(controlContainer);
21+
22+
global.RWIs = [];
23+
24+
const logs = document.createElement('pre');
25+
26+
const cone = vtkConeSource.newInstance();
27+
28+
for (let i = 0; i < 3; ++i) {
29+
const elementParent = document.createElement('div');
30+
elementParent.style.width = '33%';
31+
elementParent.style.height = '300px';
32+
elementParent.style.display = 'inline-block';
33+
34+
const element = document.createElement('div');
35+
element.setAttribute('id', `view-${i}`);
36+
element.style.width = '100%';
37+
element.style.height = '100%';
38+
element.tabIndex = 0;
39+
elementParent.appendChild(element);
40+
41+
container.appendChild(elementParent);
42+
43+
const grw = vtkGenericRenderWindow.newInstance();
44+
45+
const color = [0, 0, 0];
46+
color[i % 3] = 1;
47+
grw.getRenderer().setBackground(color);
48+
49+
const mapper = vtkMapper.newInstance();
50+
mapper.setInputConnection(cone.getOutputPort());
51+
const actor = vtkActor.newInstance();
52+
actor.setMapper(mapper);
53+
grw.getRenderer().addActor(actor);
54+
grw.getRenderer().resetCamera();
55+
56+
grw.setContainer(element);
57+
grw.resize();
58+
59+
global.RWIs.push(grw.getInteractor());
60+
// Pick on mouse right click
61+
grw.getInteractor().onKeyDown((callData) => {
62+
logs.textContent += `Pressed ${callData.key} on RWI #${i}\n`;
63+
});
64+
}
65+
container.appendChild(logs);

Examples/Rendering/ManyRenderWindows/index.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,24 @@ function createVolumeActor(imageData) {
4444
// Create and setup the mapper
4545
const mapper = vtkVolumeMapper.newInstance();
4646
mapper.setSampleDistance(0.7);
47-
mapper.setVolumetricScatteringBlending(0);
48-
mapper.setLocalAmbientOcclusion(0);
49-
mapper.setLAOKernelSize(10);
50-
mapper.setLAOKernelRadius(5);
51-
mapper.setComputeNormalFromOpacity(true);
5247
mapper.setInputData(imageData);
5348

5449
// Create and setup the actor
5550
const actor = vtkVolume.newInstance();
56-
actor
57-
.getProperty()
58-
.setRGBTransferFunction(0, getRandomColorTransferFunction());
59-
actor.getProperty().setScalarOpacity(0, sharedOpacityFunction);
60-
actor.getProperty().setInterpolationTypeToLinear();
61-
actor.getProperty().setShade(true);
62-
actor.getProperty().setAmbient(0.3);
63-
actor.getProperty().setDiffuse(0.8);
64-
actor.getProperty().setSpecular(1);
65-
actor.getProperty().setSpecularPower(8);
51+
const actorProperty = actor.getProperty();
52+
actorProperty.setComputeNormalFromOpacity(true);
53+
actorProperty.setLAOKernelRadius(5);
54+
actorProperty.setLAOKernelSize(10);
55+
actorProperty.setLocalAmbientOcclusion(0);
56+
actorProperty.setVolumetricScatteringBlending(0);
57+
actorProperty.setRGBTransferFunction(0, getRandomColorTransferFunction());
58+
actorProperty.setScalarOpacity(0, sharedOpacityFunction);
59+
actorProperty.setInterpolationTypeToLinear();
60+
actorProperty.setShade(true);
61+
actorProperty.setAmbient(0.3);
62+
actorProperty.setDiffuse(0.8);
63+
actorProperty.setSpecular(1);
64+
actorProperty.setSpecularPower(8);
6665
actor.setMapper(mapper);
6766

6867
return actor;

Examples/Rendering/QuadView/index.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -158,28 +158,27 @@ function createVolumeView(renderer, source) {
158158
.reduce((a, b) => a + b, 0)
159159
);
160160
mapper.setSampleDistance(sampleDistance / 2.5);
161-
mapper.setComputeNormalFromOpacity(false);
162-
mapper.setGlobalIlluminationReach(0.0);
163-
mapper.setVolumetricScatteringBlending(0.5);
164161
mapper.setVolumeShadowSamplingDistFactor(5.0);
165162

166163
// Set volume properties
167164
const volProp = vtkVolumeProperty.newInstance();
165+
volProp.setComputeNormalFromOpacity(false);
166+
volProp.setGlobalIlluminationReach(0.0);
167+
volProp.setVolumetricScatteringBlending(0.5);
168168
volProp.setInterpolationTypeToLinear();
169-
volume
170-
.getProperty()
171-
.setScalarOpacityUnitDistance(
172-
0,
173-
vtkBoundingBox.getDiagonalLength(source.getBounds()) /
174-
Math.max(...source.getDimensions())
175-
);
169+
volProp.setScalarOpacityUnitDistance(
170+
0,
171+
vtkBoundingBox.getDiagonalLength(source.getBounds()) /
172+
Math.max(...source.getDimensions())
173+
);
176174
volProp.setGradientOpacityMinimumValue(0, 0);
177175
const dataArray =
178176
source.getPointData().getScalars() || source.getPointData().getArrays()[0];
179177
const dataRange = dataArray.getRange();
180-
volume
181-
.getProperty()
182-
.setGradientOpacityMaximumValue(0, (dataRange[1] - dataRange[0]) * 0.05);
178+
volProp.setGradientOpacityMaximumValue(
179+
0,
180+
(dataRange[1] - dataRange[0]) * 0.05
181+
);
183182
volProp.setShade(true);
184183
volProp.setUseGradientOpacity(0, false);
185184
volProp.setGradientOpacityMinimumOpacity(0, 0.0);

Examples/Volume/VolumeMapperBlendModes/index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,12 @@ const reader = vtkHttpDataSetReader.newInstance({ fetchGzip: true });
4040
const initialSampleDistance = 1.3;
4141

4242
const actor = vtkVolume.newInstance();
43+
const actorProperty = actor.getProperty();
4344
const mapper = vtkVolumeMapper.newInstance();
4445
mapper.setSampleDistance(initialSampleDistance);
4546

4647
// use half float at the cost of precision to save memory
47-
mapper.setPreferSizeOverAccuracy(true);
48+
actorProperty.setPreferSizeOverAccuracy(true);
4849

4950
actor.setMapper(mapper);
5051

@@ -125,16 +126,16 @@ function updateSampleDistance(event) {
125126
}
126127

127128
function updateScalarMin(event) {
128-
mapper.setIpScalarRange(
129+
actorProperty.setIpScalarRange(
129130
event.target.valueAsNumber,
130-
mapper.getIpScalarRange()[1]
131+
actorProperty.getIpScalarRange()[1]
131132
);
132133
renderWindow.render();
133134
}
134135

135136
function updateScalarMax(event) {
136-
mapper.setIpScalarRange(
137-
mapper.getIpScalarRange()[0],
137+
actorProperty.setIpScalarRange(
138+
actorProperty.getIpScalarRange()[0],
138139
event.target.valueAsNumber
139140
);
140141
renderWindow.render();
@@ -146,7 +147,7 @@ function updateBlendMode(event) {
146147
const radonScalars = document.querySelectorAll('.radonScalar');
147148

148149
mapper.setBlendMode(currentBlendMode);
149-
mapper.setIpScalarRange(0.0, 1.0);
150+
actorProperty.setIpScalarRange(0.0, 1.0);
150151

151152
// if average or additive blend mode
152153
for (let i = 0; i < ipScalarEls.length; i += 1) {

0 commit comments

Comments
 (0)