AbstractManipulator

Introduction

vtkAbstractManipulator.

Methods

extend

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

getNormal

Get the normal of the line

getOrigin

Get the origin of the line

getUseCameraFocalPoint

Get the value of useCameraFocalPoint

getUseCameraNormal

Get the value of useCameraNormal

handleEvent

Argument Type Required Description
callData Yes
glRenderWindow Yes

newInstance

Method use to create a new instance of vtkAbstractManipulator

setHandleNormal

Set the handle normal (see setHandleNormal).

Argument Type Required Description
x Number Yes The x coordinate.
y Number Yes The y coordinate.
z Number Yes The z coordinate.

setHandleNormal

Set the handle normal.
This normal is used after the userNormal and before the widgetNormal.
This normal is automatically set by any state having a manipulatorMixin,
and can be overridden in the widget code.

Argument Type Required Description
normal Vector3 Yes The normal coordinate.

setHandleNormalFrom

Set the handle normal (see setHandleNormal).

Argument Type Required Description
normal Vector3 Yes The normal coordinate.

setHandleOrigin

Set the handle origin (see setHandleOrigin).

Argument Type Required Description
x Number Yes The x coordinate of the origin point.
y Number Yes The y coordinate of the origin point.
z Number Yes The z coordinate of the origin point.

setHandleOrigin

Set the handle origin.
This origin is used after the userOrigin and before the widgetOrigin.
This origin is automatically set by any state having a manipulatorMixin,
and can be overridden in the widget code.

Argument Type Required Description
origin Vector3 Yes The coordinate of the origin point.

setHandleOriginFrom

Set the handle origin (see setHandleOrigin).

Argument Type Required Description
origin Vector3 Yes The coordinate of the origin point.

setUseCameraFocalPoint

Set the value of useCameraFocalPoint

Argument Type Required Description
useCameraFocalPoint Yes if true, the focal point of the camera will be used if userOrigin is not set.

setUseCameraNormal

Set the value of useCameraNormal

Argument Type Required Description
useCameraNormal Yes if true, the normal of the camera will be used if userNormal is not set.

setUserNormal

Set the user normal (see setUserNormal).

Argument Type Required Description
x Number Yes The x coordinate.
y Number Yes The y coordinate.
z Number Yes The z coordinate.

setUserNormal

Set the user normal.
This normal take precedence on the handleNormal and the widgetNormal.
This normal should not be set within the widget internal code.

Argument Type Required Description
normal Vector3 Yes The normal coordinate.

setUserNormalFrom

Set the user normal (see setUserNormal).

Argument Type Required Description
normal Vector3 Yes The normal coordinate.

setUserOrigin

Set the user origin (see setUserOrigin).

Argument Type Required Description
x Number Yes The x coordinate of the origin point.
y Number Yes The y coordinate of the origin point.
z Number Yes The z coordinate of the origin point.

setUserOrigin

Set the user origin.
This origin take precedence on the handleOrigin and the widgetOrigin.
This origin should not be set within the widget internal code.

Argument Type Required Description
origin Vector3 Yes The coordinate of the origin point.

setUserOriginFrom

Set the user origin (see setUserOrigin).

Argument Type Required Description
origin Vector3 Yes The coordinate of the origin point.

setWidgetNormal

Set the widget normal (see setWidgetNormal).

Argument Type Required Description
x Number Yes The x coordinate.
y Number Yes The y coordinate.
z Number Yes The z coordinate.

setWidgetNormal

Set the widget normal.
This normal is used if no other normals are set.
It can be used to define a normal global to the whole widget.

Argument Type Required Description
normal Vector3 Yes The normal coordinate.

setWidgetNormalFrom

Set the widget normal (see setWidgetNormal).

Argument Type Required Description
normal Vector3 Yes The normal coordinate.

setWidgetOrigin

Set the widget origin (see setWidgetOrigin).

Argument Type Required Description
x Number Yes The x coordinate of the origin point.
y Number Yes The y coordinate of the origin point.
z Number Yes The z coordinate of the origin point.

setWidgetOrigin

Set the widget origin.
This origin is used if no other origins are set.
It can be used to define an origin global to the whole widget.

Argument Type Required Description
origin Vector3 Yes The coordinate of the origin point.

setWidgetOriginFrom

Set the widget origin (see setWidgetOrigin).

Argument Type Required Description
origin Vector3 Yes The coordinate of the origin point.

Source

index.d.ts
import { vtkObject } from "../../../interfaces";
import { vtkOpenGLRenderWindow } from "../../../Rendering/OpenGL/RenderWindow"
import { Vector3 } from "../../../types";

/**
*
*/
export interface IAbstractManipulatorInitialValues {
userOrigin?: Vector3;
handleOrigin?: Vector3;
widgetOrigin?: Vector3;
userNormal?: Vector3;
handleNormal?: Vector3;
widgetNormal?: Vector3;
}

export interface vtkAbstractManipulator extends vtkObject {

/**
* Get the normal of the line
*/
getNormal(callData: any): Vector3;

/**
* Get the origin of the line
*/
getOrigin(callData: any): Vector3;

/**
* Get the value of useCameraFocalPoint
*/
getUseCameraFocalPoint(): boolean;

/**
* Set the value of useCameraFocalPoint
* @param useCameraFocalPoint if true, the focal point of the camera will be used if userOrigin is not set.
*/
setUseCameraFocalPoint(useCameraFocalPoint: boolean): boolean;

/**
* Get the value of useCameraNormal
*/
getUseCameraNormal(): boolean;

/**
* Set the value of useCameraNormal
* @param useCameraNormal if true, the normal of the camera will be used if userNormal is not set.
*/
setUseCameraNormal(useCameraNormal: boolean): boolean;

/**
*
* @param callData
* @param glRenderWindow
*/
handleEvent(callData: any, glRenderWindow: vtkOpenGLRenderWindow): Vector3;

/* ------------------------------------------------------------------- */

/**
* Set the user normal.
* This normal take precedence on the handleNormal and the widgetNormal.
* This normal should not be set within the widget internal code.
* @param {Vector3} normal The normal coordinate.
*/
setUserNormal(normal: Vector3): boolean;

/**
* Set the user normal (see setUserNormal).
* @param {Number} x The x coordinate.
* @param {Number} y The y coordinate.
* @param {Number} z The z coordinate.
*/
setUserNormal(x: number, y: number, z: number): boolean;

/**
* Set the user normal (see setUserNormal).
* @param {Vector3} normal The normal coordinate.
*/
setUserNormalFrom(normal: Vector3): boolean;

/**
* Set the user origin.
* This origin take precedence on the handleOrigin and the widgetOrigin.
* This origin should not be set within the widget internal code.
* @param {Vector3} origin The coordinate of the origin point.
*/
setUserOrigin(origin: Vector3): boolean;

/**
* Set the user origin (see setUserOrigin).
* @param {Number} x The x coordinate of the origin point.
* @param {Number} y The y coordinate of the origin point.
* @param {Number} z The z coordinate of the origin point.
*/
setUserOrigin(x: number, y: number, z: number): boolean;

/**
* Set the user origin (see setUserOrigin).
* @param {Vector3} origin The coordinate of the origin point.
*/
setUserOriginFrom(origin: Vector3): boolean;

/* ------------------------------------------------------------------- */

/**
* Set the handle normal.
* This normal is used after the userNormal and before the widgetNormal.
* This normal is automatically set by any state having a manipulatorMixin,
* and can be overridden in the widget code.
* @param {Vector3} normal The normal coordinate.
*/
setHandleNormal(normal: Vector3): boolean;

/**
* Set the handle normal (see setHandleNormal).
* @param {Number} x The x coordinate.
* @param {Number} y The y coordinate.
* @param {Number} z The z coordinate.
*/
setHandleNormal(x: number, y: number, z: number): boolean;

/**
* Set the handle normal (see setHandleNormal).
* @param {Vector3} normal The normal coordinate.
*/
setHandleNormalFrom(normal: Vector3): boolean;

/**
* Set the handle origin.
* This origin is used after the userOrigin and before the widgetOrigin.
* This origin is automatically set by any state having a manipulatorMixin,
* and can be overridden in the widget code.
* @param {Vector3} origin The coordinate of the origin point.
*/
setHandleOrigin(origin: Vector3): boolean;

/**
* Set the handle origin (see setHandleOrigin).
* @param {Number} x The x coordinate of the origin point.
* @param {Number} y The y coordinate of the origin point.
* @param {Number} z The z coordinate of the origin point.
*/
setHandleOrigin(x: number, y: number, z: number): boolean;

/**
* Set the handle origin (see setHandleOrigin).
* @param {Vector3} origin The coordinate of the origin point.
*/
setHandleOriginFrom(origin: Vector3): boolean;

/* ------------------------------------------------------------------- */

/**
* Set the widget normal.
* This normal is used if no other normals are set.
* It can be used to define a normal global to the whole widget.
* @param {Vector3} normal The normal coordinate.
*/
setWidgetNormal(normal: Vector3): boolean;

/**
* Set the widget normal (see setWidgetNormal).
* @param {Number} x The x coordinate.
* @param {Number} y The y coordinate.
* @param {Number} z The z coordinate.
*/
setWidgetNormal(x: number, y: number, z: number): boolean;

/**
* Set the widget normal (see setWidgetNormal).
* @param {Vector3} normal The normal coordinate.
*/
setWidgetNormalFrom(normal: Vector3): boolean;

/**
* Set the widget origin.
* This origin is used if no other origins are set.
* It can be used to define an origin global to the whole widget.
* @param {Vector3} origin The coordinate of the origin point.
*/
setWidgetOrigin(origin: Vector3): boolean;

/**
* Set the widget origin (see setWidgetOrigin).
* @param {Number} x The x coordinate of the origin point.
* @param {Number} y The y coordinate of the origin point.
* @param {Number} z The z coordinate of the origin point.
*/
setWidgetOrigin(x: number, y: number, z: number): boolean;

/**
* Set the widget origin (see setWidgetOrigin).
* @param {Vector3} origin The coordinate of the origin point.
*/
setWidgetOriginFrom(origin: Vector3): boolean;
}


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

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

/**
* vtkAbstractManipulator.
*/
export declare const vtkAbstractManipulator: {
newInstance: typeof newInstance,
extend: typeof extend,
};
export default vtkAbstractManipulator;
index.js
import macro from 'vtk.js/Sources/macros';

// ----------------------------------------------------------------------------
// vtkAbstractManipulator methods
// ----------------------------------------------------------------------------

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

publicAPI.getOrigin = (callData) => {
if (model.userOrigin) return model.userOrigin;
if (model.useCameraFocalPoint)
return callData.pokedRenderer.getActiveCamera().getFocalPoint();
if (model.handleOrigin) return model.handleOrigin;
if (model.widgetOrigin) return model.widgetOrigin;
return [0, 0, 0];
};

publicAPI.getNormal = (callData) => {
if (model.userNormal) return model.userNormal;
if (model.useCameraNormal)
return callData.pokedRenderer
.getActiveCamera()
.getDirectionOfProjection();
if (model.handleNormal) return model.handleNormal;
if (model.widgetNormal) return model.widgetNormal;
return [0, 0, 1];
};
}

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

const DEFAULT_VALUES = {
// userOrigin: null,
// handleOrigin: null,
// widgetOrigin: null,
// userNormal: null,
// handleNormal: null,
// widgetNormal: null
useCameraFocalPoint: false,
useCameraNormal: false,
};

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

export function extend(publicAPI, model, initialValues = {}) {
Object.assign(model, DEFAULT_VALUES, initialValues);
macro.obj(publicAPI, model);
macro.setGet(publicAPI, model, ['useCameraFocalPoint', 'useCameraNormal']);
macro.setGetArray(
publicAPI,
model,
[
'userOrigin',
'handleOrigin',
'widgetOrigin',
'userNormal',
'handleNormal',
'widgetNormal',
],
3
);

vtkAbstractManipulator(publicAPI, model);
}

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

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

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

export default { extend, newInstance };