import macro from 'vtk.js/Sources/macros'; import vtkAbstractWidgetFactory from 'vtk.js/Sources/Widgets/Core/AbstractWidgetFactory'; import vtkPlanePointManipulator from 'vtk.js/Sources/Widgets/Manipulators/PlaneManipulator'; import vtkSplineContextRepresentation from 'vtk.js/Sources/Widgets/Representations/SplineContextRepresentation'; import vtkSphereHandleRepresentation from 'vtk.js/Sources/Widgets/Representations/SphereHandleRepresentation';
import widgetBehavior from 'vtk.js/Sources/Widgets/Widgets3D/SplineWidget/behavior'; import stateGenerator from 'vtk.js/Sources/Widgets/Widgets3D/SplineWidget/state';
import { ViewTypes } from 'vtk.js/Sources/Widgets/Core/WidgetManager/Constants';
function vtkSplineWidget(publicAPI, model) { model.classHierarchy.push('vtkSplineWidget');
const superClass = { ...publicAPI };
model.methodsToLink = [ 'boundaryCondition', 'close', 'outputBorder', 'fill', 'borderColor', 'errorBorderColor', 'scaleInPixels', ];
publicAPI.getRepresentationsForViewType = (viewType) => { switch (viewType) { case ViewTypes.DEFAULT: case ViewTypes.GEOMETRY: case ViewTypes.SLICE: case ViewTypes.VOLUME: default: return [ { builder: vtkSphereHandleRepresentation, labels: ['handles', 'moveHandle'], }, { builder: vtkSplineContextRepresentation, labels: ['handles', 'moveHandle'], }, ]; } };
publicAPI.setManipulator = (manipulator) => { superClass.setManipulator(manipulator); model.widgetState.getMoveHandle().setManipulator(manipulator); model.widgetState.getHandleList().forEach((handle) => { handle.setManipulator(manipulator); }); };
publicAPI.setManipulator( model.manipulator || model.manipulator || vtkPlanePointManipulator.newInstance({ useCameraNormal: true }) ); }
const defaultValues = (initialValues) => ({ freehandMinDistance: 0.1, allowFreehand: true, resolution: 32, defaultCursor: 'pointer', handleSizeInPixels: 10, resetAfterPointPlacement: false, behavior: widgetBehavior, widgetState: stateGenerator(), ...initialValues, });
export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, defaultValues(initialValues));
vtkAbstractWidgetFactory.extend(publicAPI, model, initialValues); macro.setGet(publicAPI, model, [ 'manipulator', 'freehandMinDistance', 'allowFreehand', 'resolution', 'defaultCursor', 'handleSizeInPixels', 'resetAfterPointPlacement', ]);
vtkSplineWidget(publicAPI, model); }
export const newInstance = macro.newInstance(extend, 'vtkSplineWidget');
export default { newInstance, extend };
|