Skip to content

Commit 8b3c380

Browse files
committed
feat(LineGlyphRepresentation): support scale1 state mixin
Add handle representations to example.
1 parent 42e8fca commit 8b3c380

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

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

+11-2
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

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ function cylinderScale(publicAPI, model) {
5050
);
5151
}
5252
const scale = state.getScale3?.() ?? [
53+
1,
5354
model.lineThickness,
5455
model.lineThickness,
55-
1,
5656
];
5757
scales[j++] = length * scale[0];
5858
scales[j++] = scaleFactor * scale[1];
@@ -113,6 +113,7 @@ function defaultValues(publicAPI, model, initialValues) {
113113
},
114114
applyMixin: {
115115
noScale: cylinderScale(publicAPI, model),
116+
scale1: cylinderScale(publicAPI, model),
116117
noOrientation: cylinderDirection(publicAPI, model),
117118
},
118119
};

0 commit comments

Comments
 (0)