PickerManipulator

Introduction

vtkPickerManipulator.

Methods

extend

Method use to decorate a given object (publicAPI+model) with vtkPickerManipulator characteristics.

Argument Type Required Description
publicAPI Yes object on which methods will be bounds (public)
model Yes object on which data structure will be bounds (protected)
initialValues IPickerManipulatorInitialValues No (default: {})

getPicker

newInstance

Method use to create a new instance of vtkPickerManipulator

setPicker

Source

index.d.ts
import { IAbstractManipulatorInitialValues, vtkAbstractManipulator } from "../AbstractManipulator";
import vtkPicker from '../../../Rendering/Core/Picker';

/**
*
*/
export interface IPickerManipulatorInitialValues extends IAbstractManipulatorInitialValues {

}

export interface vtkPickerManipulator extends vtkAbstractManipulator {

/**
*
*/
getPicker(): vtkPicker;

/**
*
*/
setPicker(picker: vtkPicker): void;

}


/**
* Method use to decorate a given object (publicAPI+model) with vtkPickerManipulator characteristics.
*
* @param publicAPI object on which methods will be bounds (public)
* @param model object on which data structure will be bounds (protected)
* @param {IPickerManipulatorInitialValues} [initialValues] (default: {})
*/
export function extend(publicAPI: object, model: object, initialValues?: IPickerManipulatorInitialValues): void;

/**
* Method use to create a new instance of vtkPickerManipulator
*/
export function newInstance(initialValues?: IPickerManipulatorInitialValues): vtkPickerManipulator;


/**
* vtkPickerManipulator.
*/
export declare const vtkPickerManipulator: {
newInstance: typeof newInstance,
extend: typeof extend,
};
export default vtkPickerManipulator;
index.js
import macro from 'vtk.js/Sources/macros';
import vtkCellPicker from 'vtk.js/Sources/Rendering/Core/CellPicker';
import vtkAbstractManipulator from 'vtk.js/Sources/Widgets/Manipulators/AbstractManipulator';

// ----------------------------------------------------------------------------
// vtkPickerManipulator methods
// ----------------------------------------------------------------------------

function vtkPickerManipulator(publicAPI, model) {
// Set our className
model.classHierarchy.push('vtkPickerManipulator');

publicAPI.handleEvent = (callData) => {
const { position, pokedRenderer } = callData;

model.picker.pick([position.x, position.y, 0.0], pokedRenderer);
if (model.picker.getPickedPositions().length > 0) {
model.position = model.picker.getPickedPositions()[0];
} else {
model.position = null;
}
return {
worldCoords: model.position,
};
};
}

// ----------------------------------------------------------------------------
// Object factory
// ----------------------------------------------------------------------------

function defaultValues(initialValues) {
if (!initialValues.picker) {
// Default picker
const picker = vtkCellPicker.newInstance();
picker.initializePickList();
picker.setPickFromList(true);
picker.setTolerance(0);

initialValues.picker = picker;
}
return {
...initialValues,
};
}

// ----------------------------------------------------------------------------

export function extend(publicAPI, model, initialValues = {}) {
vtkAbstractManipulator.extend(publicAPI, model, defaultValues(initialValues));

macro.setGet(publicAPI, model, ['picker']);

vtkPickerManipulator(publicAPI, model);
}

// ----------------------------------------------------------------------------

export const newInstance = macro.newInstance(extend, 'vtkPickerManipulator');

// ----------------------------------------------------------------------------

export default { extend, newInstance };