Skip to content

Commit 9237ba2

Browse files
committed
feat(LineGlyphRepresentation): use scale1 value and add forceLineThickness
1 parent 37acd7d commit 9237ba2

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const points = [
4242
points.forEach((point) => {
4343
const handle = compositeState.addHandle();
4444
handle.setOrigin(point);
45-
handle.setScale1(1);
45+
handle.setScale1(1.5);
4646
});
4747

4848
// -----------------------------------------------------------
@@ -51,7 +51,6 @@ points.forEach((point) => {
5151

5252
const widgetRep = vtkLineGlyphRepresentation.newInstance({
5353
scaleInPixels: false,
54-
lineThickness: 0.5, // radius of the cylinder
5554
});
5655
widgetRep.setInputData(compositeState);
5756
widgetRep.setLabels(['handles']);

Sources/Widgets/Representations/LineGlyphRepresentation/index.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ function cylinderScale(publicAPI, model) {
4949
model.displayScaleParams
5050
);
5151
}
52+
if (!model.forceLineThickness) {
53+
scaleFactor *= state.getScale1?.() ?? 1;
54+
}
5255
const scale = [1, model.lineThickness, model.lineThickness];
5356
scales[j++] = length * scale[0];
5457
scales[j++] = scaleFactor * scale[1];
@@ -95,14 +98,15 @@ function defaultValues(publicAPI, model, initialValues) {
9598
return {
9699
behavior: Behavior.CONTEXT,
97100
glyphResolution: 32,
98-
lineThickness: 1,
101+
lineThickness: 0.5, // radius of the cylinder
102+
forceLineThickness: false,
99103
...initialValues,
100104
_pipeline: {
101105
glyph:
102106
initialValues?.pipeline?.glyph ??
103107
vtkCylinderSource.newInstance({
104108
direction: [1, 0, 0],
105-
center: [0.5, 0, 0],
109+
center: [0.5, 0, 0], // origin of cylinder at end, not center
106110
capping: false,
107111
}),
108112
...initialValues?.pipeline,
@@ -123,7 +127,11 @@ export function extend(publicAPI, model, initialValues = {}) {
123127
model,
124128
defaultValues(publicAPI, model, initialValues)
125129
);
126-
macro.setGet(publicAPI, model, ['glyphResolution', 'lineThickness']);
130+
macro.setGet(publicAPI, model, [
131+
'glyphResolution',
132+
'lineThickness',
133+
'forceLineThickness',
134+
]);
127135
macro.get(publicAPI, model._pipeline, ['glyph', 'mapper', 'actor']);
128136

129137
vtkLineGlyphRepresentation(publicAPI, model);

0 commit comments

Comments
 (0)