PlaneManipulator

Introduction

vtkPlaneManipulator.

Methods

extend

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

intersectDisplayWithPlane

Argument Type Required Description
x Number Yes
y Number Yes
planeOrigin Vector3 Yes
planeNormal Vector3 Yes
renderer Yes
glRenderWindow Yes

newInstance

Method use to create a new instance of vtkPlaneManipulator

Source

index.d.ts
import { IAbstractManipulatorInitialValues, vtkAbstractManipulator } from "../AbstractManipulator";
import { Vector3 } from "../../../types";

/**
*
*/
export interface IPlaneManipulatorInitialValues extends IAbstractManipulatorInitialValues {

}

export interface vtkPlaneManipulator extends vtkAbstractManipulator {

}


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

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

/**
*
* @param {Number} x
* @param {Number} y
* @param {Vector3} planeOrigin
* @param {Vector3} planeNormal
* @param renderer
* @param glRenderWindow
*/
export function intersectDisplayWithPlane(x: number, y: number, planeOrigin: Vector3, planeNormal: Vector3, renderer: any, glRenderWindow: any): Vector3;


/**
* vtkPlaneManipulator.
*/
export declare const vtkPlaneManipulator: {
newInstance: typeof newInstance,
extend: typeof extend,
intersectDisplayWithPlane: typeof intersectDisplayWithPlane;
};
export default vtkPlaneManipulator;
index.js
import macro from 'vtk.js/Sources/macros';
import vtkPlane from 'vtk.js/Sources/Common/DataModel/Plane';

import vtkAbstractManipulator from 'vtk.js/Sources/Widgets/Manipulators/AbstractManipulator';

export function intersectDisplayWithPlane(
x,
y,
planeOrigin,
planeNormal,
renderer,
glRenderWindow
) {
const near = glRenderWindow.displayToWorld(x, y, 0, renderer);
const far = glRenderWindow.displayToWorld(x, y, 1, renderer);

return vtkPlane.intersectWithLine(near, far, planeOrigin, planeNormal).x;
}

// ----------------------------------------------------------------------------
// vtkPlaneManipulator methods
// ----------------------------------------------------------------------------

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

publicAPI.handleEvent = (callData, glRenderWindow) =>
intersectDisplayWithPlane(
callData.position.x,
callData.position.y,
publicAPI.getOrigin(callData),
publicAPI.getNormal(callData),
callData.pokedRenderer,
glRenderWindow
);
}

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

function defaultValues(initialValues) {
return {
...initialValues,
};
}

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

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

vtkPlaneManipulator(publicAPI, model);
}

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

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

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

export default { intersectDisplayWithPlane, extend, newInstance };