Skip to content

Commit 37acd7d

Browse files
committed
feat(LineGlyphRepresentation): support scale1 state mixin
Add handle representations to example.
1 parent fa89694 commit 37acd7d

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

Sources/Widgets/Representations/LineGlyphRepresentation/example/index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import '@kitware/vtk.js/Rendering/Profiles/All';
66
import vtkFullScreenRenderWindow from '@kitware/vtk.js/Rendering/Misc/FullScreenRenderWindow';
77
import vtkStateBuilder from '@kitware/vtk.js/Widgets/Core/StateBuilder';
88

9+
import vtkSphereHandleRepresentation from '@kitware/vtk.js/Widgets/Representations/SphereHandleRepresentation';
910
import vtkLineGlyphRepresentation from '@kitware/vtk.js/Widgets/Representations/LineGlyphRepresentation';
1011

1112
// ----------------------------------------------------------------------------
@@ -26,7 +27,7 @@ const compositeState = vtkStateBuilder
2627
.createBuilder()
2728
.addDynamicMixinState({
2829
labels: ['handles'],
29-
mixins: ['origin'],
30+
mixins: ['origin', 'scale1'],
3031
name: 'handle',
3132
})
3233
.build();
@@ -41,6 +42,7 @@ const points = [
4142
points.forEach((point) => {
4243
const handle = compositeState.addHandle();
4344
handle.setOrigin(point);
45+
handle.setScale1(1);
4446
});
4547

4648
// -----------------------------------------------------------
@@ -49,11 +51,18 @@ points.forEach((point) => {
4951

5052
const widgetRep = vtkLineGlyphRepresentation.newInstance({
5153
scaleInPixels: false,
52-
close: true,
54+
lineThickness: 0.5, // radius of the cylinder
5355
});
5456
widgetRep.setInputData(compositeState);
5557
widgetRep.setLabels(['handles']);
5658
widgetRep.getActors().forEach(renderer.addActor);
5759

60+
const handleRep = vtkSphereHandleRepresentation.newInstance({
61+
scaleInPixels: false,
62+
});
63+
handleRep.setInputData(compositeState);
64+
handleRep.setLabels(['handles']);
65+
handleRep.getActors().forEach(renderer.addActor);
66+
5867
renderer.resetCamera();
5968
renderWindow.render();

Sources/Widgets/Representations/LineGlyphRepresentation/index.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ function cylinderScale(publicAPI, model) {
4949
model.displayScaleParams
5050
);
5151
}
52-
const scale = state.getScale3?.() ?? [
53-
model.lineThickness,
54-
model.lineThickness,
55-
1,
56-
];
52+
const scale = [1, model.lineThickness, model.lineThickness];
5753
scales[j++] = length * scale[0];
5854
scales[j++] = scaleFactor * scale[1];
5955
scales[j++] = scaleFactor * scale[2];
@@ -113,6 +109,7 @@ function defaultValues(publicAPI, model, initialValues) {
113109
},
114110
applyMixin: {
115111
noScale: cylinderScale(publicAPI, model),
112+
scale1: cylinderScale(publicAPI, model),
116113
noOrientation: cylinderDirection(publicAPI, model),
117114
},
118115
};

0 commit comments

Comments
 (0)