All files / Sources/Widgets/Core/StateBuilder manipulatorMixin.js

27.77% Statements 5/18
0% Branches 0/24
66.66% Functions 2/3
27.77% Lines 5/18

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50          125x                                                         1x             125x 125x 125x            
import macro from 'vtk.js/Sources/macros';
 
// ----------------------------------------------------------------------------
 
function vtkManipulatorMixin(publicAPI, model) {
  publicAPI.updateManipulator = () => {
    if (model.manipulator) {
      const { origin, normal, direction } = model;
      const {
        setHandleOrigin,
        setHandleCenter,
        setHandleNormal,
        setHandleDirection,
      } = model.manipulator;
 
      if (origin && setHandleOrigin) {
        setHandleOrigin(origin);
      } else if (origin && setHandleCenter) {
        setHandleCenter(origin);
      }
 
      if (direction && setHandleDirection) {
        setHandleDirection(direction);
      } else if (direction && !normal && setHandleNormal) {
        setHandleNormal(direction);
      } else if (normal && setHandleDirection) {
        setHandleDirection(normal);
      }
    }
  };
}
 
// ----------------------------------------------------------------------------
 
const DEFAULT_VALUES = {
  manipulator: null,
};
 
// ----------------------------------------------------------------------------
 
export function extend(publicAPI, model, initialValues = {}) {
  Object.assign(model, DEFAULT_VALUES, initialValues);
  macro.setGet(publicAPI, model, ['manipulator']);
  vtkManipulatorMixin(publicAPI, model);
}
 
// ----------------------------------------------------------------------------
 
export default { extend };