Skip to content

Commit

Permalink
fix(shapewidget): improve ShapeWidget example
Browse files Browse the repository at this point in the history
  • Loading branch information
finetjul authored and floryst committed Dec 5, 2024
1 parent ba39aae commit 2d7ce0f
Show file tree
Hide file tree
Showing 3 changed files with 222 additions and 78 deletions.
22 changes: 22 additions & 0 deletions Sources/Widgets/Widgets3D/ResliceCursorWidget/behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,28 @@ export default function widgetBehavior(publicAPI, model) {
};
};

/**
* Rotate a line by a specified angle
* @param {string} lineName The line name to rotate (e.g. YinX, ZinX, XinY, ZinY, XinZ, YinZ)
* @param {Number} radianAngle Applied angle in radian
*/
publicAPI.setViewPlane = (viewType, normal, viewUp) => {
let newViewUp = viewUp;
if (newViewUp == null) {
newViewUp = model.widgetState.getPlanes()[viewType].viewUp;
}
model.widgetState.getPlanes()[viewType] = {
normal,
viewUp: newViewUp,
};

updateState(
model.widgetState,
model._factory.getScaleInPixels(),
model._factory.getRotationHandlePosition()
);
};

// --------------------------------------------------------------------------
// initialization
// --------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions Sources/Widgets/Widgets3D/ResliceCursorWidget/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ export function rotateVector(vectorToBeRotated, axis, angle) {
}

/**
* Return ['X'] if there are only 1 plane defined in the widget state.
* Return ['X', 'Y'] if there are only 2 planes defined in the widget state.
* Return ['X', 'Y', 'Z'] if there are 3 planes defined in the widget state.
* @param {object} widgetState the state of the widget
Expand Down
Loading

0 comments on commit 2d7ce0f

Please sign in to comment.