8000 fix(shapewidget): improve ShapeWidget example · Kitware/vtk-js@2d7ce0f · GitHub
[go: up one dir, main page]

Skip to content

Commit 2d7ce0f

Browse files
finetjulfloryst
authored andcommitted
fix(shapewidget): improve ShapeWidget example
1 parent ba39aae commit 2d7ce0f

File tree

3 files changed

+222
-78
lines changed

3 files changed

+222
-78
lines changed

Sources/Widgets/Widgets3D/ResliceCursorWidget/behavior.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,28 @@ export default function widgetBehavior(publicAPI, model) {
499499
};
500500
};
501501

502+
/**
503+
* Rotate a line by a specified angle
504+
* @param {string} lineName The line name to rotate (e.g. YinX, ZinX, XinY, ZinY, XinZ, YinZ)
505+
* @param {Number} radianAngle Applied angle in radian
506+
*/
507+
publicAPI.setViewPlane = (viewType, normal, viewUp) => {
508+
let newViewUp = viewUp;
509+
if (newViewUp == null) {
510+
newViewUp = model.widgetState.getPlanes()[viewType].viewUp;
511+
}
512+
model.widgetState.getPlanes()[viewType] = {
513+
normal,
514+
viewUp: newViewUp,
515+
};
516+
517+
updateState(
518+
model.widgetState,
519+
model._factory.getScaleInPixels(),
520+
model._factory.getRotationHandlePosition()
521+
);
522+
};
523+
502524
// --------------------------------------------------------------------------
503525
// initialization
504526
// --------------------------------------------------------------------------

Sources/Widgets/Widgets3D/ResliceCursorWidget/helpers.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ export function rotateVector(vectorToBeRotated, axis, angle) {
161161
}
162162

163163
/**
164+
* Return ['X'] if there are only 1 plane defined in the widget state.
164165
* Return ['X', 'Y'] if there are only 2 planes defined in the widget state.
165166
* Return ['X', 'Y', 'Z'] if there are 3 planes defined in the widget state.
166167
* @param {object} widgetState the state of the widget

0 commit comments

Comments
 (0)
0