UNPKG

@kitware/vtk.js

Version:

Visualization Toolkit for the Web

84 lines (67 loc) 2.77 kB
import { m as macro } from '../../macros2.js'; import vtkAbstractWidgetFactory from '../Core/AbstractWidgetFactory.js'; import vtkSphereHandleRepresentation from '../Representations/SphereHandleRepresentation.js'; import vtkPlaneManipulator from '../Manipulators/PlaneManipulator.js'; import widgetBehavior from './LabelWidget/behavior.js'; import generateState from './LabelWidget/state.js'; import { ViewTypes } from '../Core/WidgetManager/Constants.js'; // ---------------------------------------------------------------------------- // Factory // ---------------------------------------------------------------------------- function vtkLabelWidget(publicAPI, model) { model.classHierarchy.push('vtkLabelWidget'); const superClass = { ...publicAPI }; // --- Widget Requirement --------------------------------------------------- model.methodsToLink = ['scaleInPixels']; publicAPI.getRepresentationsForViewType = viewType => { switch (viewType) { case ViewTypes.DEFAULT: case ViewTypes.GEOMETRY: case ViewTypes.SLICE: case ViewTypes.VOLUME: default: return [{ builder: vtkSphereHandleRepresentation, labels: ['moveHandle'] }]; } }; // --- Public methods ------------------------------------------------------- publicAPI.setManipulator = manipulator => { superClass.setManipulator(manipulator); model.widgetState.getMoveHandle().setManipulator(manipulator); model.widgetState.getText().setManipulator(manipulator); }; // -------------------------------------------------------------------------- // initialization // -------------------------------------------------------------------------- // Default manipulator publicAPI.setManipulator(model.manipulator || vtkPlaneManipulator.newInstance({ useCameraNormal: true })); } // ---------------------------------------------------------------------------- function defaultValues(initialValues) { return { behavior: widgetBehavior, widgetState: generateState(), ...initialValues }; } // ---------------------------------------------------------------------------- function extend(publicAPI, model, initialValues = {}) { Object.assign(model, defaultValues(initialValues)); vtkAbstractWidgetFactory.extend(publicAPI, model, initialValues); macro.setGet(publicAPI, model, ['manipulator']); vtkLabelWidget(publicAPI, model); } // ---------------------------------------------------------------------------- const newInstance = macro.newInstance(extend, 'vtkLabelWidget'); // ---------------------------------------------------------------------------- var vtkLabelWidget$1 = { newInstance, extend }; export { vtkLabelWidget$1 as default, extend, newInstance };