vtkCursor3D is an object that generates a 3D representation of a cursor. The cursor consists of a wireframe bounding box, three intersecting axes lines that meet at the cursor focus, and “shadows” or projections of the axes against the sides of the bounding box. Each of these components can be turned on/off.
Method used to decorate a given object (publicAPI+model) with vtkCursor3D 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
ICursor3DInitialValues
No
(default: {})
getAxes
getFocalPoint
Get the position of cursor focus.
getFocalPointByReference
getFocus
getModelBounds
Set the boundary of the 3D cursor.
getModelBoundsByReference
getOutline
getTranslationMode
Get the translation mode.
getWrap
Get the state of the cursor wrapping.
getXShadows
Get the state of the wireframe x-shadows.
getYShadows
Get the state of the wireframe y-shadows.
getZShadows
Get the state of the wireframe z-shadows.
newInstance
Method used to create a new instance of vtkCursor3D.
Argument
Type
Required
Description
initialValues
ICursor3DInitialValues
No
for pre-setting some of its content
requestData
Expose methods
Argument
Type
Required
Description
inData
Yes
outData
Yes
setAll
Argument
Type
Required
Description
flag
Boolean
Yes
setAxes
Turn on/off the wireframe axes.
Argument
Type
Required
Description
axes
Boolean
Yes
setFocalPoint
Set the position of cursor focus. If translation mode is on, then the entire cursor (including bounding box, cursor, and shadows) is translated. Otherwise, the focal point will either be clamped to the bounding box, or wrapped, if Wrap is on. (Note: this behavior requires that the bounding box is set prior to the focal point.)
Argument
Type
Required
Description
points
Vector3
Yes
setModelBounds
Set the boundary of the 3D cursor.
Argument
Type
Required
Description
bounds
Bounds
Yes
The bounds of the 3D cursor.
setTranslationMode
Enable/disable the translation mode. If on, changes in cursor position cause the entire widget to translate along with the cursor.
Argument
Type
Required
Description
translationMode
Boolean
Yes
setWrap
Turn on/off cursor wrapping. If the cursor focus moves outside the specified bounds, the cursor will either be restrained against the nearest “wall” (Wrap=off), or it will wrap around (Wrap=on).
/** * Set the position of cursor focus. * If translation mode is on, then the entire cursor (including bounding * box, cursor, and shadows) is translated. Otherwise, the focal point will * either be clamped to the bounding box, or wrapped, if Wrap is on. (Note: * this behavior requires that the bounding box is set prior to the focal * point.) * @param {Vector3} points */ setFocalPoint(points: Vector3): boolean;
/** * Set the boundary of the 3D cursor. * @param {Bounds} bounds The bounds of the 3D cursor. */ setModelBounds(bounds: Bounds): boolean;
/** * Enable/disable the translation mode. * If on, changes in cursor position cause the entire widget to translate * along with the cursor. * @param {Boolean} translationMode */ setTranslationMode(translationMode: boolean): boolean;
/** * Turn on/off cursor wrapping. * If the cursor focus moves outside the specified bounds, * the cursor will either be restrained against the nearest "wall" (Wrap=off), * or it will wrap around (Wrap=on). * @param {Number} wrap */ setWrap(wrap: number): boolean;
/** * Method used to decorate a given object (publicAPI+model) with vtkCursor3D characteristics. * * @param publicAPI object on which methods will be bounds (public) * @param model object on which data structure will be bounds (protected) * @param {ICursor3DInitialValues} [initialValues] (default: {}) */ exportfunctionextend( publicAPI: object, model: object, initialValues?: ICursor3DInitialValues ): void;
/** * Method used to create a new instance of vtkCursor3D. * @param {ICursor3DInitialValues} [initialValues] for pre-setting some of its content */ exportfunctionnewInstance( initialValues?: ICursor3DInitialValues ): vtkCursor3D;
/** * vtkCursor3D is an object that generates a 3D representation of a cursor. The * cursor consists of a wireframe bounding box, three intersecting axes lines * that meet at the cursor focus, and "shadows" or projections of the axes * against the sides of the bounding box. Each of these components can be turned * on/off. * * @example * ```js * import vtkCursor3D from '@kitware/vtk.js/Filters/Sources/vtkCursor3D'; * * const cursor = vtkCursor3D.newInstance({focalPoint: [0, 0, 0], modelBounds: [-100, 100, -100, 100, -100, 100]}); * const polyData = cursor.getOutputData(); * ``` */ export declare constvtkCursor3D: { newInstance: typeof newInstance; extend: typeof extend; }; exportdefault vtkCursor3D;
functionvtkCursor3D(publicAPI, model) { // Set our className model.classHierarchy.push('vtkCursor3D'); // Public API methods publicAPI.setModelBounds = (bounds) => { if (!Array.isArray(bounds) || bounds.length < 6) { return; } if ( model.modelBounds[0] === bounds[0] && model.modelBounds[1] === bounds[1] && model.modelBounds[2] === bounds[2] && model.modelBounds[3] === bounds[3] && model.modelBounds[4] === bounds[4] && model.modelBounds[5] === bounds[5] ) { return; } publicAPI.modified(); // Doing type convert, make sure it is a number array. // Without correct coversion, the array may contains string which cause // the wrapping and clampping works incorrectly. model.modelBounds = bounds.map((v) =>Number(v)); for (let i = 0; i < 3; ++i) { model.modelBounds[2 * i] = Math.min( model.modelBounds[2 * i], model.modelBounds[2 * i + 1] ); } };
publicAPI.setFocalPoint = (points) => { if (!Array.isArray(points) || points.length < 3) { return; } if ( points[0] === model.focalPoint[0] && points[1] === model.focalPoint[1] && points[2] === model.focalPoint[2] ) { return; } publicAPI.modified(); const v = []; for (let i = 0; i < 3; i++) { v[i] = points[i] - model.focalPoint[i]; model.focalPoint[i] = Number(points[i]);