-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1545 from xeokit/XEOK-36-edit-measurement
XEOK-36 Edit Measurement
- Loading branch information
Showing
13 changed files
with
1,965 additions
and
1,179 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,62 @@ | ||
export * from "./AngleMeasurementsPlugin.js"; | ||
export * from "./AngleMeasurementsControl.js"; | ||
export * from "./AngleMeasurementsMouseControl.js"; | ||
export * from "./AngleMeasurementsTouchControl.js"; | ||
export * from "./AngleMeasurementsTouchControl.js"; | ||
|
||
import {Component} from "../../viewer/scene/Component.js"; | ||
import {activateDraggableDots} from "../../../src/plugins/lib/ui/index.js"; | ||
|
||
class AngleMeasurementEditControl extends Component { | ||
|
||
/** | ||
* Edits {@link AngleMeasurement} with mouse and/or touch input. | ||
* | ||
* @param {AngleMeasurement} [measurement] The AngleMeasurement to edit. | ||
* @param [cfg] Configuration | ||
* @param {PointerLens} [cfg.pointerLens] A PointerLens to use to provide a magnified view of the cursor. | ||
* @param {boolean} [cfg.snapping] Whether to enable snap-to-vertex and snap-to-edge. | ||
* @param {boolean} [handleMouseEvents] Whether to hangle mouse input. | ||
* @param {boolean} [handleTouchEvents] Whether to hangle touch input. | ||
*/ | ||
constructor(measurement, cfg, handleMouseEvents, handleTouchEvents) { | ||
|
||
const viewer = measurement.plugin.viewer; | ||
|
||
super(viewer.scene); | ||
|
||
const cleanup = activateDraggableDots({ | ||
viewer: viewer, | ||
handleMouseEvents: handleMouseEvents, | ||
handleTouchEvents: handleTouchEvents, | ||
snapping: cfg.snapping, | ||
pointerLens: cfg.pointerLens, | ||
color: measurement.color, | ||
markers: [ measurement.origin, measurement.corner, measurement.target ], | ||
onEdit: () => this.fire("edited") | ||
}); | ||
|
||
const destroyCb = measurement.on("destroyed", cleanup); | ||
|
||
this._deactivate = function() { | ||
measurement.off("destroyed", destroyCb); | ||
cleanup(); | ||
}; | ||
} | ||
|
||
deactivate() { | ||
this._deactivate(); | ||
super.destroy(); | ||
} | ||
} | ||
|
||
export class AngleMeasurementEditMouseControl extends AngleMeasurementEditControl { | ||
constructor(zone, cfg) { | ||
super(zone, cfg, true, false); | ||
} | ||
} | ||
|
||
export class AngleMeasurementEditTouchControl extends AngleMeasurementEditControl { | ||
constructor(zone, cfg) { | ||
super(zone, cfg, false, true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,62 @@ | ||
export * from "./DistanceMeasurementsPlugin.js"; | ||
export * from "./DistanceMeasurementsControl.js"; | ||
export * from "./DistanceMeasurementsMouseControl.js"; | ||
export * from "./DistanceMeasurementsTouchControl.js"; | ||
export * from "./DistanceMeasurementsTouchControl.js"; | ||
|
||
import {Component} from "../../viewer/scene/Component.js"; | ||
import {activateDraggableDots} from "../../../src/plugins/lib/ui/index.js"; | ||
|
||
class DistanceMeasurementEditControl extends Component { | ||
|
||
/** | ||
* Edits {@link DistanceMeasurement} with mouse and/or touch input. | ||
* | ||
* @param {DistanceMeasurement} [measurement] The DistanceMeasurement to edit. | ||
* @param [cfg] Configuration | ||
* @param {PointerLens} [cfg.pointerLens] A PointerLens to use to provide a magnified view of the cursor. | ||
* @param {boolean} [cfg.snapping] Whether to enable snap-to-vertex and snap-to-edge. | ||
* @param {boolean} [handleMouseEvents] Whether to hangle mouse input. | ||
* @param {boolean} [handleTouchEvents] Whether to hangle touch input. | ||
*/ | ||
constructor(measurement, cfg, handleMouseEvents, handleTouchEvents) { | ||
|
||
const viewer = measurement.plugin.viewer; | ||
|
||
super(viewer.scene); | ||
|
||
const cleanup = activateDraggableDots({ | ||
viewer: viewer, | ||
handleMouseEvents: handleMouseEvents, | ||
handleTouchEvents: handleTouchEvents, | ||
snapping: cfg.snapping, | ||
pointerLens: cfg.pointerLens, | ||
color: measurement.color, | ||
markers: [ measurement.origin, measurement.target ], | ||
onEdit: () => this.fire("edited") | ||
}); | ||
|
||
const destroyCb = measurement.on("destroyed", cleanup); | ||
|
||
this._deactivate = function() { | ||
measurement.off("destroyed", destroyCb); | ||
cleanup(); | ||
}; | ||
} | ||
|
||
deactivate() { | ||
this._deactivate(); | ||
super.destroy(); | ||
} | ||
} | ||
|
||
export class DistanceMeasurementEditMouseControl extends DistanceMeasurementEditControl { | ||
constructor(zone, cfg) { | ||
super(zone, cfg, true, false); | ||
} | ||
} | ||
|
||
export class DistanceMeasurementEditTouchControl extends DistanceMeasurementEditControl { | ||
constructor(zone, cfg) { | ||
super(zone, cfg, false, true); | ||
} | ||
} |
Oops, something went wrong.