Class: MeasurementTool
@cognite/reveal/tools.MeasurementTool
Enables @see {@link Cognite3DViewer} to perform a point to point measurement. This can be achieved by selecting a point on the 3D Object and drag the pointer to required point to get measurement of the distance. The tools default measurement is in "Meters" as supported in Reveal, but it also provides user to customise the measuring units based on their convinience with the callback.
example
const measurementTool = new MeasurementTool(viewer);
measurementTool.enterMeasurementMode();
// ...
measurementTool.exitMeasurementMode();
// detach the tool from the viewer
measurementTool.dispose();
example
Hierarchy
-
↳
MeasurementTool
Constructors
constructor
• new MeasurementTool(viewer
, options?
)
Parameters
Name | Type |
---|---|
viewer | Cognite3DViewer |
options? | MeasurementOptions |
Overrides
Cognite3DViewerToolBase.constructor
Defined in
packages/tools/src/Measurement/MeasurementTool.ts:87
Accessors
isInMeasurementMode
• get
isInMeasurementMode(): boolean
Returns measurement mode state, is measurement mode started or ended.
Returns
boolean
Defined in
packages/tools/src/Measurement/MeasurementTool.ts:53
Methods
dispose
▸ dispose(): void
Dispose Measurement Tool.
Returns
void
Overrides
Cognite3DViewerToolBase.dispose
Defined in
packages/tools/src/Measurement/MeasurementTool.ts:340
enterMeasurementMode
▸ enterMeasurementMode(): void
Enter into point to point measurement mode.
Returns
void
Defined in
packages/tools/src/Measurement/MeasurementTool.ts:228
exitMeasurementMode
▸ exitMeasurementMode(): void
Exit measurement mode.
Returns
void
Defined in
packages/tools/src/Measurement/MeasurementTool.ts:240
getAllMeasurements
▸ getAllMeasurements(): Measurement
[]
Get all measurements from Cognite3DViewer.
Returns
Array of Measurements containing Id, start point, end point & measured distance.
Defined in
packages/tools/src/Measurement/MeasurementTool.ts:333
off
▸ off(event
, callback
): void
Unsubscribe to the Measurement event
example
measurementTool.off('disposed', onMeasurementDispose);
Parameters
Name | Type | Description |
---|---|---|
event | "disposed" | MeasurementEvents event |
callback | DisposedDelegate | Callback to measurements events |
Returns
void
Overrides
Defined in
packages/tools/src/Measurement/MeasurementTool.ts:172
▸ off(event
, callback
): void
Unsubscribe to the Measurement event
example
measurementTool.off('added', onMeasurementAdded);
Parameters
Name | Type | Description |
---|---|---|
event | "added" | MeasurementEvents event |
callback | MeasurementAddedDelegate | Callback to measurements events |
Returns
void
Overrides
Cognite3DViewerToolBase.off
Defined in
packages/tools/src/Measurement/MeasurementTool.ts:180
▸ off(event
, callback
): void
Unsubscribe to the Measurement event
example
measurementTool.off('started', onMeasurementStarted);
Parameters
Name | Type | Description |
---|---|---|
event | "started" | MeasurementEvents event |
callback | MeasurementStartedDelegate | Callback to measurements events |
Returns
void
Overrides
Cognite3DViewerToolBase.off
Defined in
packages/tools/src/Measurement/MeasurementTool.ts:188
▸ off(event
, callback
): void
Unsubscribe to the Measurement event
example
measurementTool.off('ended', onMeasurementEnded);
Parameters
Name | Type | Description |
---|---|---|
event | "ended" | MeasurementEvents event |
callback | MeasurementEndedDelegate | Callback to measurements events |
Returns
void
Overrides
Cognite3DViewerToolBase.off
Defined in
packages/tools/src/Measurement/MeasurementTool.ts:196
on
▸ on(event
, callback
): void
Triggered when the tool is disposed. Listeners should clean up any resources held and remove the reference to the tool.
example
measurementTool.on('disposed', onMeasurementDispose);
Parameters
Name | Type | Description |
---|---|---|
event | "disposed" | MeasurementEvents event |
callback | DisposedDelegate | Callback to measurements events |
Returns
void
Overrides
Cognite3DViewerToolBase.on
Defined in
packages/tools/src/Measurement/MeasurementTool.ts:110
▸ on(event
, callback
): void
Triggered when a measurement is added into the Cognite3DViewer.
example
measurementTool.on('added', onMeasurementAdded);
Parameters
Name | Type | Description |
---|---|---|
event | "added" | MeasurementEvents event |
callback | MeasurementAddedDelegate | Callback to measurements events |
Returns
void
Overrides
Cognite3DViewerToolBase.on
Defined in
packages/tools/src/Measurement/MeasurementTool.ts:119
▸ on(event
, callback
): void
Triggered when a measurement mode is started.
example
measurementTool.on('started', onMeasurementStarted);
Parameters
Name | Type | Description |
---|---|---|
event | "started" | MeasurementEvents event |
callback | MeasurementStartedDelegate | Callback to measurements events |
Returns
void
Overrides
Cognite3DViewerToolBase.on
Defined in
packages/tools/src/Measurement/MeasurementTool.ts:128
▸ on(event
, callback
): void
Triggered when measurement mode is ended.
example
measurementTool.on('ended', onMeasurementEnded);
Parameters
Name | Type | Description |
---|---|---|
event | "ended" | MeasurementEvents event |
callback | MeasurementEndedDelegate | Callback to measurements events |
Returns
void
Overrides
Cognite3DViewerToolBase.on
Defined in
packages/tools/src/Measurement/MeasurementTool.ts:137
removeAllMeasurements
▸ removeAllMeasurements(): void
Removes all measurements from the Cognite3DViewer.
Returns
void
Defined in
packages/tools/src/Measurement/MeasurementTool.ts:269
removeMeasurement
▸ removeMeasurement(measurement
): void
Removes a measurement from the Cognite3DViewer.
Parameters
Name | Type | Description |
---|---|---|
measurement | Measurement | Measurement to be removed from Cognite3DViewer. |
Returns
void
Defined in
packages/tools/src/Measurement/MeasurementTool.ts:254
setLineOptions
▸ setLineOptions(options
): void
Sets Measurement line width, color and label units value for the next measurment.
Parameters
Name | Type | Description |
---|---|---|
options | MeasurementOptions | MeasurementOptions to set line width, color and callback for custom operation on measurement labels. |
Returns
void
Defined in
packages/tools/src/Measurement/MeasurementTool.ts:290
setMeasurementLabelsVisible
▸ setMeasurementLabelsVisible(enable
): void
Sets the visiblity of labels in the Measurement.
Parameters
Name | Type |
---|---|
enable | boolean |
Returns
void
Defined in
packages/tools/src/Measurement/MeasurementTool.ts:282
updateLineColor
▸ updateLineColor(measurement
, color
): void
Update selected line color.
Parameters
Name | Type | Description |
---|---|---|
measurement | Measurement | Measurement to be updated. |
color | Color | Color of the measuring line. |
Returns
void
Defined in
packages/tools/src/Measurement/MeasurementTool.ts:318
updateLineWidth
▸ updateLineWidth(measurement
, lineWidth
): void
Update selected line width.
Parameters
Name | Type | Description |
---|---|---|
measurement | Measurement | Measurement to be updated. |
lineWidth | number | Width of the measuring line. |
Returns
void