AbstractPicker

Introduction

vtkAbstractPicker is an abstract superclass that defines a minimal API for its concrete subclasses.
The minimum functionality of a picker is to return the x-y-z global coordinate position of a pick (the pick itself is defined in display coordinates).

The API to this class is to invoke the Pick() method with a selection point (in display coordinates - pixels)
and a renderer. Then get the resulting pick position in global coordinates with the GetPickPosition() method.

See Also

vtkPointPicker

Methods

addPickList

Argument Type Required Description
actor vtkActor Yes

deletePickList

Argument Type Required Description
actor vtkActor Yes

extend

Method used to decorate a given object (publicAPI+model) with vtkAbstractPicker 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 IAbstractPickerInitialValues No (default: {})

getPickFromList

getPickList

getPickPosition

Get the picked position

getPickPositionByReference

Get the picked position

getRenderer

getSelectionPoint

getSelectionPointByReference

initialize

initializePickList

Set pickList to empty array.

setPickFromList

Argument Type Required Description
pickFromList Number Yes

setPickList

Argument Type Required Description
pickList Array. Yes

Source

index.d.ts
import { vtkObject } from '../../../interfaces';
import { Vector3 } from '../../../types';
import vtkActor from '../Actor';
import vtkRenderer from '../Renderer';

/**
*
*/
export interface IAbstractPickerInitialValues {
renderer?: vtkRenderer;
selectionPoint?: Vector3;
pickPosition?: Vector3;
pickFromList?: number;
pickList?: vtkActor[];
}

/**
*
*/
export interface vtkAbstractPicker extends vtkObject {
/**
*
* @param {vtkActor} actor
*/
addPickList(actor: vtkActor): void;

/**
*
* @param {vtkActor} actor
*/
deletePickList(actor: vtkActor): void;

/**
*
*/
getPickFromList(): boolean;

/**
*
*/
getPickList(): boolean;

/**
* Get the picked position
* @default [0.0, 0.0, 0.0]
*/
getPickPosition(): Vector3;

/**
*
* Get the picked position
* @default [0.0, 0.0, 0.0]
*/
getPickPositionByReference(): Vector3;

/**
*
*/
getRenderer(): vtkRenderer;

/**
*
* @default [0.0, 0.0, 0.0]
*/
getSelectionPoint(): Vector3;

/**
*
* @default [0.0, 0.0, 0.0]
*/
getSelectionPointByReference(): Vector3;

/**
*
*/
initialize(): void;

/**
* Set pickList to empty array.
*/
initializePickList(): void;

/**
*
* @param {Number} pickFromList
* @default 0
*/
setPickFromList(pickFromList: number): boolean;

/**
*
* @param {vtkActor[]} pickList
* @default []
*/
setPickList(pickList: vtkActor[]): boolean;
}

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

/**
* vtkAbstractPicker is an abstract superclass that defines a minimal API for its concrete subclasses.
* The minimum functionality of a picker is to return the x-y-z global coordinate position of a pick (the pick itself is defined in display coordinates).
*
* The API to this class is to invoke the Pick() method with a selection point (in display coordinates - pixels)
* and a renderer. Then get the resulting pick position in global coordinates with the GetPickPosition() method.
* @see [vtkPointPicker](./Rendering_Core_PointPicker.html)
*/
export declare const vtkAbstractPicker: {
extend: typeof extend;
};
export default vtkAbstractPicker;
index.js
import macro from 'vtk.js/Sources/macros';

// ----------------------------------------------------------------------------
// vtkAbstractPicker methods
// ----------------------------------------------------------------------------

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

publicAPI.initialize = () => {
model.renderer = null;

model.selectionPoint[0] = 0.0;
model.selectionPoint[1] = 0.0;
model.selectionPoint[2] = 0.0;

model.pickPosition[0] = 0.0;
model.pickPosition[1] = 0.0;
model.pickPosition[2] = 0.0;
};

publicAPI.initializePickList = () => {
model.pickList = [];
};

publicAPI.addPickList = (actor) => {
model.pickList.push(actor);
};

publicAPI.deletePickList = (actor) => {
const i = model.pickList.indexOf(actor);
if (i !== -1) {
model.pickList.splice(i, 1);
}
};
}

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

const DEFAULT_VALUES = {
renderer: null,
selectionPoint: [0.0, 0.0, 0.0],
pickPosition: [0.0, 0.0, 0.0],
pickFromList: 0,
pickList: [],
};

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

export function extend(publicAPI, model, initialValues = {}) {
Object.assign(model, DEFAULT_VALUES, initialValues);

// Build VTK API
macro.obj(publicAPI, model);

macro.get(publicAPI, model, ['renderer']);
macro.getArray(publicAPI, model, ['selectionPoint', 'pickPosition']);
macro.setGet(publicAPI, model, ['pickFromList', 'pickList']);

vtkAbstractPicker(publicAPI, model);
}

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

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

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

export default { newInstance, extend };