HardwareSelector

Methods

getCaptureZValues

Gets whether to capture Z values.

getFieldAssociation

Gets the field association.

getSourceDataAsync

Get the picking source data.

Argument Type Required Description
renderer vtkRenderer Yes
fx1 number Yes top left x coord
fy1 number Yes top left y coord
fx2 number Yes bottom right x coord
fy2 number Yes bottom right y coord

selectAsync

Generates a selection.

Argument Type Required Description
renderer vtkRenderer Yes
fx1 number Yes top left x coord
fy1 number Yes top left y coord
fx2 number Yes bottom right x coord
fy2 number Yes bottom right y coord

setCaptureZValues

Sets whether to capture Z values.

Argument Type Required Description
capture boolean Yes

setFieldAssociation

Sets the field association.

Argument Type Required Description
assoc FieldAssociations Yes

Source

index.d.ts
import { FieldAssociations } from '../../../Common/DataModel/DataSet/Constants';
import vtkSelectionNode from '../../../Common/DataModel/SelectionNode';
import { vtkObject } from '../../../interfaces';
import vtkRenderer from '../../../Rendering/Core/Renderer';

export interface vtkHardwareSelector extends vtkObject {
/**
* Get the picking source data.
*
* @param {vtkRenderer} renderer
* @param {number} fx1 top left x coord
* @param {number} fy1 top left y coord
* @param {number} fx2 bottom right x coord
* @param {number} fy2 bottom right y coord
*/
getSourceDataAsync(
renderer: vtkRenderer,
fx1: number,
fy1: number,
fx2: number,
fy2: number
): Promise<unknown>;

/**
* Generates a selection.
*
* @param {vtkRenderer} renderer
* @param {number} fx1 top left x coord
* @param {number} fy1 top left y coord
* @param {number} fx2 bottom right x coord
* @param {number} fy2 bottom right y coord
*/
selectAsync(
renderer: vtkRenderer,
fx1: number,
fy1: number,
fx2: number,
fy2: number
): Promise<vtkSelectionNode[]>;

/**
* Sets the field association.
* @param {FieldAssociations} assoc
*/
setFieldAssociation(assoc: FieldAssociations): boolean;

/**
* Gets the field association.
*/
getFieldAssociation(): FieldAssociations;

/**
* Sets whether to capture Z values.
* @param {boolean} capture
*/
setCaptureZValues(capture: boolean): boolean;

/**
* Gets whether to capture Z values.
*/
getCaptureZValues(): boolean;
}

export interface IHardwareSelectorInitialValues {
fieldAssociation?: FieldAssociations;
captureZValues?: boolean;
}

export function newInstance(
initialValues?: IHardwareSelectorInitialValues
): vtkHardwareSelector;

export function extend(
publicAPI: object,
model: object,
initialValues?: IHardwareSelectorInitialValues
): void;

export const vtkHardwareSelector: {
newInstance: typeof newInstance;
extend: typeof extend;
};

export default vtkHardwareSelector;
index.js
import macro from 'vtk.js/Sources/macros';
import vtkDataSet from 'vtk.js/Sources/Common/DataModel/DataSet';

const { FieldAssociations } = vtkDataSet;

// ----------------------------------------------------------------------------
// vtkHardwareSelector methods
// ----------------------------------------------------------------------------

function vtkHardwareSelector(publicAPI, model) {
model.classHierarchy.push('vtkHardwareSelector');

// get the source data that is used for generating a selection. This
// must be called at least once before calling generateSelection. In
// raster based backends this method will capture the buffers. You can
// call this once and then make multiple calls to generateSelection.
publicAPI.getSourceDataAsync = async (renderer, fx1, fy1, fx2, fy2) => {};

publicAPI.selectAsync = async (renderer, fx1, fy1, fx2, fy2) => {
const srcData = await publicAPI.getSourceDataAsync(
renderer,
fx1,
fy1,
fx2,
fy2
);
if (srcData) {
return srcData.generateSelection(fx1, fy1, fx2, fy2);
}
return [];
};
}

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

const DEFAULT_VALUES = {
fieldAssociation: FieldAssociations.FIELD_ASSOCIATION_CELLS,
captureZValues: false,
};

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

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

// Inheritance
macro.obj(publicAPI, model);

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

// Object methods
vtkHardwareSelector(publicAPI, model);
}

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

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

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

export default { newInstance, extend };