import macro from 'vtk.js/Sources/macro'; 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 vtkSVGLandmarkRepresentation from 'vtk.js/Sources/Widgets/SVG/SVGLandmarkRepresentation';
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');
model.methodsToLink = [ 'closePolyLine', 'activeScaleFactor', 'activeColor', 'useActiveColor', 'glyphResolution', 'defaultScale', ]; model.behavior = widgetBehavior; model.widgetState = stateGenerator();
publicAPI.getRepresentationsForViewType = (viewType) => { switch (viewType) { case ViewTypes.DEFAULT: case ViewTypes.GEOMETRY: case ViewTypes.SLICE: case ViewTypes.VOLUME: default: return [ { builder: vtkSphereHandleRepresentation, labels: ['handles'], initialValues: { scaleInPixels: true, }, }, { builder: vtkSphereHandleRepresentation, labels: ['moveHandle'], initialValues: { scaleInPixels: true, }, }, { builder: vtkSVGLandmarkRepresentation, labels: ['handles'] }, { builder: vtkPolyLineRepresentation, labels: ['handles', 'moveHandle'], }, ]; } };
model.widgetState.onBoundsChange((bounds) => { const center = [ (bounds[0] + bounds[1]) * 0.5, (bounds[2] + bounds[3]) * 0.5, (bounds[4] + bounds[5]) * 0.5, ]; model.widgetState.getMoveHandle().setOrigin(center); });
model.manipulator = vtkPlanePointManipulator.newInstance(); }
const DEFAULT_VALUES = { };
export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, 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 };
|