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 vtkPolyLineRepresentation from 'vtk.js/Sources/Widgets/Representations/PolyLineRepresentation'; import vtkSphereHandleRepresentation from 'vtk.js/Sources/Widgets/Representations/SphereHandleRepresentation';
import widgetBehavior from 'vtk.js/Sources/Widgets/Widgets3D/PolyLineWidget/behavior'; import stateGenerator from 'vtk.js/Sources/Widgets/Widgets3D/PolyLineWidget/state';
import { ViewTypes } from 'vtk.js/Sources/Widgets/Core/WidgetManager/Constants';
function vtkPolyLineWidget(publicAPI, model) { model.classHierarchy.push('vtkPolyLineWidget');
const superClass = { ...publicAPI };
model.methodsToLink = [ 'activeColor', 'activeScaleFactor', 'closePolyLine', 'defaultScale', 'glyphResolution', 'lineThickness', 'useActiveColor', 'scaleInPixels', ];
publicAPI.getRepresentationsForViewType = (viewType) => { switch (viewType) { case ViewTypes.DEFAULT: case ViewTypes.GEOMETRY: case ViewTypes.SLICE: case ViewTypes.VOLUME: default: return [ { builder: vtkSphereHandleRepresentation, labels: ['handles'], }, { builder: vtkSphereHandleRepresentation, labels: ['moveHandle'], }, { builder: vtkPolyLineRepresentation, 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 || vtkPlanePointManipulator.newInstance({ useCameraFocalPoint: true, useCameraNormal: true, }) ); }
const defaultValues = (initialValues) => ({ manipulator: null, 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']);
vtkPolyLineWidget(publicAPI, model); }
export const newInstance = macro.newInstance(extend, 'vtkPolyLineWidget');
export default { newInstance, extend };
|