@vertexvis/viewer 0.18.1 → 0.18.2-testing.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/_commonjsHelpers.js +41 -0
- package/dist/components/_commonjsHelpers.js.map +1 -0
- package/dist/components/browser.esm.js +3173 -0
- package/dist/components/browser.esm.js.map +1 -0
- package/dist/components/bundle.esm.js +2250 -0
- package/dist/components/bundle.esm.js.map +1 -0
- package/dist/components/bundle.esm2.js +39740 -0
- package/dist/components/bundle.esm2.js.map +1 -0
- package/dist/components/config.js +81 -0
- package/dist/components/config.js.map +1 -0
- package/dist/components/controller.js +7627 -0
- package/dist/components/controller.js.map +1 -0
- package/dist/components/controller2.js +124 -0
- package/dist/components/controller2.js.map +1 -0
- package/dist/components/controller3.js +111 -0
- package/dist/components/controller3.js.map +1 -0
- package/dist/components/cursors.js +110 -0
- package/dist/components/cursors.js.map +1 -0
- package/dist/components/dom.js +43 -0
- package/dist/components/dom.js.map +1 -0
- package/dist/components/dom2.js +10 -0
- package/dist/components/dom2.js.map +1 -0
- package/dist/components/elementRectObserver.js +25 -0
- package/dist/components/elementRectObserver.js.map +1 -0
- package/dist/components/entities.js +179 -0
- package/dist/components/entities.js.map +1 -0
- package/dist/components/errors.js +80 -0
- package/dist/components/errors.js.map +1 -0
- package/dist/components/events.js +11 -0
- package/dist/components/events.js.map +1 -0
- package/dist/components/index.d.ts +26 -0
- package/dist/components/index.js +365 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index2.js +63 -0
- package/dist/components/index2.js.map +1 -0
- package/dist/components/interactions.js +236 -0
- package/dist/components/interactions.js.map +1 -0
- package/dist/components/mapper.js +9811 -0
- package/dist/components/mapper.js.map +1 -0
- package/dist/components/markup.js +33 -0
- package/dist/components/markup.js.map +1 -0
- package/dist/components/model.js +134 -0
- package/dist/components/model.js.map +1 -0
- package/dist/components/model2.js +157 -0
- package/dist/components/model2.js.map +1 -0
- package/dist/components/overlays.js +76 -0
- package/dist/components/overlays.js.map +1 -0
- package/dist/components/png-decoder.js +2405 -0
- package/dist/components/png-decoder.js.map +1 -0
- package/dist/components/regl-component.js +12582 -0
- package/dist/components/regl-component.js.map +1 -0
- package/dist/components/results.js +24 -0
- package/dist/components/results.js.map +1 -0
- package/dist/components/row.js +32 -0
- package/dist/components/row.js.map +1 -0
- package/dist/components/scene-tree-search.js +146 -0
- package/dist/components/scene-tree-search.js.map +1 -0
- package/dist/components/scene-tree-table-layout.js +928 -0
- package/dist/components/scene-tree-table-layout.js.map +1 -0
- package/dist/components/scene-tree-toolbar.js +35 -0
- package/dist/components/scene-tree-toolbar.js.map +1 -0
- package/dist/components/scene.js +1508 -0
- package/dist/components/scene.js.map +1 -0
- package/dist/components/stencil.js +25 -0
- package/dist/components/stencil.js.map +1 -0
- package/dist/components/streamAttributes.js +40833 -0
- package/dist/components/streamAttributes.js.map +1 -0
- package/dist/components/templates.js +36 -0
- package/dist/components/templates.js.map +1 -0
- package/dist/components/tslib.es6.js +125 -0
- package/dist/components/tslib.es6.js.map +1 -0
- package/dist/components/vertex-scene-tree-search.d.ts +11 -0
- package/dist/components/vertex-scene-tree-search.js +11 -0
- package/dist/components/vertex-scene-tree-search.js.map +1 -0
- package/dist/components/vertex-scene-tree-table-cell.d.ts +11 -0
- package/dist/components/vertex-scene-tree-table-cell.js +209 -0
- package/dist/components/vertex-scene-tree-table-cell.js.map +1 -0
- package/dist/components/vertex-scene-tree-table-column.d.ts +11 -0
- package/dist/components/vertex-scene-tree-table-column.js +42 -0
- package/dist/components/vertex-scene-tree-table-column.js.map +1 -0
- package/dist/components/vertex-scene-tree-table-header.d.ts +11 -0
- package/dist/components/vertex-scene-tree-table-header.js +38 -0
- package/dist/components/vertex-scene-tree-table-header.js.map +1 -0
- package/dist/components/vertex-scene-tree-table-layout.d.ts +11 -0
- package/dist/components/vertex-scene-tree-table-layout.js +11 -0
- package/dist/components/vertex-scene-tree-table-layout.js.map +1 -0
- package/dist/components/vertex-scene-tree-table-resize-divider.d.ts +11 -0
- package/dist/components/vertex-scene-tree-table-resize-divider.js +57 -0
- package/dist/components/vertex-scene-tree-table-resize-divider.js.map +1 -0
- package/dist/components/vertex-scene-tree-toolbar-group.d.ts +11 -0
- package/dist/components/vertex-scene-tree-toolbar-group.js +38 -0
- package/dist/components/vertex-scene-tree-toolbar-group.js.map +1 -0
- package/dist/components/vertex-scene-tree-toolbar.d.ts +11 -0
- package/dist/components/vertex-scene-tree-toolbar.js +11 -0
- package/dist/components/vertex-scene-tree-toolbar.js.map +1 -0
- package/dist/components/vertex-scene-tree.d.ts +11 -0
- package/dist/components/vertex-scene-tree.js +803 -0
- package/dist/components/vertex-scene-tree.js.map +1 -0
- package/dist/components/vertex-viewer-box-query-tool.d.ts +11 -0
- package/dist/components/vertex-viewer-box-query-tool.js +352 -0
- package/dist/components/vertex-viewer-box-query-tool.js.map +1 -0
- package/dist/components/vertex-viewer-button.d.ts +11 -0
- package/dist/components/vertex-viewer-button.js +11 -0
- package/dist/components/vertex-viewer-button.js.map +1 -0
- package/dist/components/vertex-viewer-default-toolbar.d.ts +11 -0
- package/dist/components/vertex-viewer-default-toolbar.js +99 -0
- package/dist/components/vertex-viewer-default-toolbar.js.map +1 -0
- package/dist/components/vertex-viewer-dom-element.d.ts +11 -0
- package/dist/components/vertex-viewer-dom-element.js +11 -0
- package/dist/components/vertex-viewer-dom-element.js.map +1 -0
- package/dist/components/vertex-viewer-dom-group.d.ts +11 -0
- package/dist/components/vertex-viewer-dom-group.js +11 -0
- package/dist/components/vertex-viewer-dom-group.js.map +1 -0
- package/dist/components/vertex-viewer-dom-renderer.d.ts +11 -0
- package/dist/components/vertex-viewer-dom-renderer.js +11 -0
- package/dist/components/vertex-viewer-dom-renderer.js.map +1 -0
- package/dist/components/vertex-viewer-hit-result-indicator.d.ts +11 -0
- package/dist/components/vertex-viewer-hit-result-indicator.js +335 -0
- package/dist/components/vertex-viewer-hit-result-indicator.js.map +1 -0
- package/dist/components/vertex-viewer-icon.d.ts +11 -0
- package/dist/components/vertex-viewer-icon.js +11 -0
- package/dist/components/vertex-viewer-icon.js.map +1 -0
- package/dist/components/vertex-viewer-layer.d.ts +11 -0
- package/dist/components/vertex-viewer-layer.js +11 -0
- package/dist/components/vertex-viewer-layer.js.map +1 -0
- package/dist/components/vertex-viewer-markup-arrow.d.ts +11 -0
- package/dist/components/vertex-viewer-markup-arrow.js +11 -0
- package/dist/components/vertex-viewer-markup-arrow.js.map +1 -0
- package/dist/components/vertex-viewer-markup-circle.d.ts +11 -0
- package/dist/components/vertex-viewer-markup-circle.js +11 -0
- package/dist/components/vertex-viewer-markup-circle.js.map +1 -0
- package/dist/components/vertex-viewer-markup-freeform.d.ts +11 -0
- package/dist/components/vertex-viewer-markup-freeform.js +11 -0
- package/dist/components/vertex-viewer-markup-freeform.js.map +1 -0
- package/dist/components/vertex-viewer-markup-tool.d.ts +11 -0
- package/dist/components/vertex-viewer-markup-tool.js +257 -0
- package/dist/components/vertex-viewer-markup-tool.js.map +1 -0
- package/dist/components/vertex-viewer-markup.d.ts +11 -0
- package/dist/components/vertex-viewer-markup.js +362 -0
- package/dist/components/vertex-viewer-markup.js.map +1 -0
- package/dist/components/vertex-viewer-measurement-details.d.ts +11 -0
- package/dist/components/vertex-viewer-measurement-details.js +307 -0
- package/dist/components/vertex-viewer-measurement-details.js.map +1 -0
- package/dist/components/vertex-viewer-measurement-distance.d.ts +11 -0
- package/dist/components/vertex-viewer-measurement-distance.js +1067 -0
- package/dist/components/vertex-viewer-measurement-distance.js.map +1 -0
- package/dist/components/vertex-viewer-measurement-line.d.ts +11 -0
- package/dist/components/vertex-viewer-measurement-line.js +11 -0
- package/dist/components/vertex-viewer-measurement-line.js.map +1 -0
- package/dist/components/vertex-viewer-measurement-overlays.d.ts +11 -0
- package/dist/components/vertex-viewer-measurement-overlays.js +11 -0
- package/dist/components/vertex-viewer-measurement-overlays.js.map +1 -0
- package/dist/components/vertex-viewer-measurement-precise.d.ts +11 -0
- package/dist/components/vertex-viewer-measurement-precise.js +362 -0
- package/dist/components/vertex-viewer-measurement-precise.js.map +1 -0
- package/dist/components/vertex-viewer-pin-group.d.ts +11 -0
- package/dist/components/vertex-viewer-pin-group.js +11 -0
- package/dist/components/vertex-viewer-pin-group.js.map +1 -0
- package/dist/components/vertex-viewer-pin-label-line.d.ts +11 -0
- package/dist/components/vertex-viewer-pin-label-line.js +11 -0
- package/dist/components/vertex-viewer-pin-label-line.js.map +1 -0
- package/dist/components/vertex-viewer-pin-label.d.ts +11 -0
- package/dist/components/vertex-viewer-pin-label.js +11 -0
- package/dist/components/vertex-viewer-pin-label.js.map +1 -0
- package/dist/components/vertex-viewer-pin-tool.d.ts +11 -0
- package/dist/components/vertex-viewer-pin-tool.js +430 -0
- package/dist/components/vertex-viewer-pin-tool.js.map +1 -0
- package/dist/components/vertex-viewer-spinner.d.ts +11 -0
- package/dist/components/vertex-viewer-spinner.js +11 -0
- package/dist/components/vertex-viewer-spinner.js.map +1 -0
- package/dist/components/vertex-viewer-toolbar-group.d.ts +11 -0
- package/dist/components/vertex-viewer-toolbar-group.js +11 -0
- package/dist/components/vertex-viewer-toolbar-group.js.map +1 -0
- package/dist/components/vertex-viewer-toolbar.d.ts +11 -0
- package/dist/components/vertex-viewer-toolbar.js +11 -0
- package/dist/components/vertex-viewer-toolbar.js.map +1 -0
- package/dist/components/vertex-viewer-transform-widget.d.ts +11 -0
- package/dist/components/vertex-viewer-transform-widget.js +838 -0
- package/dist/components/vertex-viewer-transform-widget.js.map +1 -0
- package/dist/components/vertex-viewer-view-cube.d.ts +11 -0
- package/dist/components/vertex-viewer-view-cube.js +270 -0
- package/dist/components/vertex-viewer-view-cube.js.map +1 -0
- package/dist/components/vertex-viewer.d.ts +11 -0
- package/dist/components/vertex-viewer.js +3543 -0
- package/dist/components/vertex-viewer.js.map +1 -0
- package/dist/components/viewer-button.js +35 -0
- package/dist/components/viewer-button.js.map +1 -0
- package/dist/components/viewer-dom-element.js +250 -0
- package/dist/components/viewer-dom-element.js.map +1 -0
- package/dist/components/viewer-dom-group.js +214 -0
- package/dist/components/viewer-dom-group.js.map +1 -0
- package/dist/components/viewer-dom-renderer.js +295 -0
- package/dist/components/viewer-dom-renderer.js.map +1 -0
- package/dist/components/viewer-icon.js +87 -0
- package/dist/components/viewer-icon.js.map +1 -0
- package/dist/components/viewer-layer.js +46 -0
- package/dist/components/viewer-layer.js.map +1 -0
- package/dist/components/viewer-markup-arrow.js +235 -0
- package/dist/components/viewer-markup-arrow.js.map +1 -0
- package/dist/components/viewer-markup-circle-components.js +42 -0
- package/dist/components/viewer-markup-circle-components.js.map +1 -0
- package/dist/components/viewer-markup-circle.js +201 -0
- package/dist/components/viewer-markup-circle.js.map +1 -0
- package/dist/components/viewer-markup-freeform.js +251 -0
- package/dist/components/viewer-markup-freeform.js.map +1 -0
- package/dist/components/viewer-measurement-line.js +77 -0
- package/dist/components/viewer-measurement-line.js.map +1 -0
- package/dist/components/viewer-measurement-overlays.js +184 -0
- package/dist/components/viewer-measurement-overlays.js.map +1 -0
- package/dist/components/viewer-pin-group.js +207 -0
- package/dist/components/viewer-pin-group.js.map +1 -0
- package/dist/components/viewer-pin-label-line.js +43 -0
- package/dist/components/viewer-pin-label-line.js.map +1 -0
- package/dist/components/viewer-pin-label.js +427 -0
- package/dist/components/viewer-pin-label.js.map +1 -0
- package/dist/components/viewer-spinner.js +53 -0
- package/dist/components/viewer-spinner.js.map +1 -0
- package/dist/components/viewer-toolbar-group.js +42 -0
- package/dist/components/viewer-toolbar-group.js.map +1 -0
- package/dist/components/viewer-toolbar.js +61 -0
- package/dist/components/viewer-toolbar.js.map +1 -0
- package/dist/components/viewport.js +188 -0
- package/dist/components/viewport.js.map +1 -0
- package/dist/components/wrappers_pb.js +1926 -0
- package/dist/components/wrappers_pb.js.map +1 -0
- package/package.json +7 -7
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2023 Vertex Software LLC. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
5
|
+
import { g as getMarkupBoundingClientRect } from './dom2.js';
|
|
6
|
+
import { M as MarkupInteractionHandler, t as translatePointToRelative, h as transformRectangle, l as translatePointsToBounds, d as isValidStartEvent, m as parsePoints, j as parseBounds, S as SvgShadow, k as translateRectToScreen, c as translatePointToScreen } from './interactions.js';
|
|
7
|
+
import { B as BoundingBox2d } from './viewer-markup-circle-components.js';
|
|
8
|
+
import { p as point, e as rectangle } from './bundle.esm.js';
|
|
9
|
+
import { g as getMouseClientPosition } from './dom.js';
|
|
10
|
+
|
|
11
|
+
class FreeformMarkupInteractionHandler extends MarkupInteractionHandler {
|
|
12
|
+
constructor(markupEl, editBegin, editEnd) {
|
|
13
|
+
super();
|
|
14
|
+
this.markupEl = markupEl;
|
|
15
|
+
this.editBegin = editBegin;
|
|
16
|
+
this.editEnd = editEnd;
|
|
17
|
+
this.anchor = 'bottom-right';
|
|
18
|
+
this.handleResizeInteractionMove = (event) => {
|
|
19
|
+
if (this.resizeStartPosition != null &&
|
|
20
|
+
this.elementBounds != null &&
|
|
21
|
+
this.resizeBounds != null &&
|
|
22
|
+
this.resizePoints != null) {
|
|
23
|
+
const position = translatePointToRelative(getMouseClientPosition(event, this.elementBounds), this.elementBounds);
|
|
24
|
+
const updatedBounds = transformRectangle(this.resizeBounds, this.resizeStartPosition, position, this.anchor, event.shiftKey);
|
|
25
|
+
this.markupEl.points = translatePointsToBounds(this.resizePoints, this.resizeBounds, updatedBounds);
|
|
26
|
+
this.markupEl.bounds = updatedBounds;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
this.handleResizeInteractionEnd = (event) => {
|
|
30
|
+
window.removeEventListener('pointermove', this.handleResizeInteractionMove);
|
|
31
|
+
window.removeEventListener('pointerup', this.handleResizeInteractionEnd);
|
|
32
|
+
this.resizeBounds = undefined;
|
|
33
|
+
this.editEnd.emit();
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
editAnchor(anchor, event) {
|
|
37
|
+
if (this.markupEl.mode === 'edit' && this.elementBounds != null) {
|
|
38
|
+
this.resizeBounds = this.markupEl.bounds;
|
|
39
|
+
this.resizePoints = this.markupEl.points;
|
|
40
|
+
this.anchor = anchor;
|
|
41
|
+
this.resizeStartPosition = translatePointToRelative(getMouseClientPosition(event, this.elementBounds), this.elementBounds);
|
|
42
|
+
window.addEventListener('pointermove', this.handleResizeInteractionMove);
|
|
43
|
+
window.addEventListener('pointerup', this.handleResizeInteractionEnd);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
startInteraction(event) {
|
|
47
|
+
this.handleInteractionAttempt(event);
|
|
48
|
+
}
|
|
49
|
+
computeBoundingRect() {
|
|
50
|
+
return getMarkupBoundingClientRect(this.markupEl);
|
|
51
|
+
}
|
|
52
|
+
handleInteractionAttempt(event) {
|
|
53
|
+
var _a;
|
|
54
|
+
if (this.markupEl.mode !== '' &&
|
|
55
|
+
this.pointerId == null &&
|
|
56
|
+
this.elementBounds != null) {
|
|
57
|
+
this.pointerId = event.pointerId;
|
|
58
|
+
const screenPosition = getMouseClientPosition(event, this.elementBounds);
|
|
59
|
+
const position = translatePointToRelative(screenPosition, this.elementBounds);
|
|
60
|
+
this.updateMinAndMax(position);
|
|
61
|
+
this.markupEl.points = (_a = this.markupEl.points) !== null && _a !== void 0 ? _a : [position];
|
|
62
|
+
this.editBegin.emit();
|
|
63
|
+
this.acceptInteraction();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
handleInteractionMove(event) {
|
|
67
|
+
if (this.pointerId === event.pointerId &&
|
|
68
|
+
this.markupEl.points != null &&
|
|
69
|
+
this.elementBounds != null) {
|
|
70
|
+
const screenPosition = getMouseClientPosition(event, this.elementBounds);
|
|
71
|
+
const position = translatePointToRelative(screenPosition, this.elementBounds);
|
|
72
|
+
this.updateMinAndMax(position);
|
|
73
|
+
this.markupEl.points = [...this.markupEl.points, position];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
handleInteractionEnd(event) {
|
|
77
|
+
if (this.pointerId === event.pointerId) {
|
|
78
|
+
if (this.markupEl.mode !== '' &&
|
|
79
|
+
this.markupEl.points != null &&
|
|
80
|
+
this.markupEl.points.length > 2 &&
|
|
81
|
+
this.elementBounds != null) {
|
|
82
|
+
const screenPosition = getMouseClientPosition(event, this.elementBounds);
|
|
83
|
+
const position = translatePointToRelative(screenPosition, this.elementBounds);
|
|
84
|
+
this.updateMinAndMax(position);
|
|
85
|
+
this.markupEl.points = [...this.markupEl.points, position];
|
|
86
|
+
this.editEnd.emit();
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
this.markupEl.points = undefined;
|
|
90
|
+
}
|
|
91
|
+
this.min = undefined;
|
|
92
|
+
this.max = undefined;
|
|
93
|
+
this.pointerId = undefined;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
updateMinAndMax(position) {
|
|
97
|
+
this.min =
|
|
98
|
+
this.min != null
|
|
99
|
+
? point.create(Math.min(this.min.x, position.x), Math.min(this.min.y, position.y))
|
|
100
|
+
: position;
|
|
101
|
+
this.max =
|
|
102
|
+
this.max != null
|
|
103
|
+
? point.create(Math.max(this.max.x, position.x), Math.max(this.max.y, position.y))
|
|
104
|
+
: position;
|
|
105
|
+
this.markupEl.bounds = rectangle.create(this.min.x, this.min.y, this.max.x - this.min.x, this.max.y - this.min.y);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const viewerMarkupFreeformCss = ":host{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;--viewer-markup-freeform-stroke-color:var(--red-800);--viewer-markup-freeform-stroke-width:4;--viewer-markup-freeform-line-join:round;--viewer-markup-freeform-line-cap:round;--viewer-markup-freeform-bounds-outline-border-color:var(--blue-400);--viewer-markup-freeform-bounds-outline-border-width:1px;--viewer-markup-freeform-bounds-edge-anchor-border-color:var(--blue-400);--viewer-markup-freeform-bounds-edge-anchor-border-width:1px;--viewer-markup-freeform-bounds-edge-anchor-background-color:white;--viewer-markup-freeform-bounds-center-anchor-border-color:white;--viewer-markup-freeform-bounds-center-anchor-border-width:1px;--viewer-markup-freeform-bounds-center-anchor-background-color:var(--blue-400);--viewer-markup-freeform-bounds-anchor-width:9px;--viewer-markup-freeform-bounds-anchor-height:9px}.svg{pointer-events:none;width:100%;height:100%;position:absolute;top:0;left:0}.path{pointer-events:auto;cursor:default;stroke:var(--viewer-markup-freeform-stroke-color);stroke-width:var(--viewer-markup-freeform-stroke-width);stroke-linejoin:var(--viewer-markup-freeform-line-join);stroke-linecap:var(--viewer-markup-freeform-line-cap)}.create-overlay{pointer-events:auto;position:absolute;left:0;top:0;width:100%;height:100%;cursor:crosshair}.bounds-container{pointer-events:none;position:absolute;width:100%;height:100%;top:0;left:0;overflow:hidden}.bounds-outline{position:absolute;border-width:var(--viewer-markup-freeform-bounds-outline-border-width);border-color:var(--viewer-markup-freeform-bounds-outline-border-color);border-style:solid;box-shadow:0 0 3px rgba(0, 0, 0, 0.3)}.bounds-anchor-position{position:absolute;transform:translate(-50%, -50%)}.bounds-anchor{pointer-events:auto;cursor:default;user-select:none}.bounds-default-anchor{width:var(--viewer-markup-freeform-bounds-anchor-width);height:var(--viewer-markup-freeform-bounds-anchor-height);box-sizing:border-box;box-shadow:0 0 2px rgba(0, 0, 0, 0.3)}.bounds-center-anchor{border-radius:100%;border-width:var(--viewer-markup-freeform-bounds-center-anchor-border-width);border-color:var(--viewer-markup-freeform-bounds-center-anchor-border-color);border-style:solid;background-color:var(--viewer-markup-freeform-bounds-center-anchor-background-color)}.bounds-edge-anchor{border-width:var(--viewer-markup-freeform-bounds-edge-anchor-border-width);border-color:var(--viewer-markup-freeform-bounds-edge-anchor-border-color);border-style:solid;background-color:var(--viewer-markup-freeform-bounds-edge-anchor-background-color)}";
|
|
110
|
+
|
|
111
|
+
const ViewerMarkupFreeform = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
112
|
+
constructor() {
|
|
113
|
+
super();
|
|
114
|
+
this.__registerHost();
|
|
115
|
+
this.__attachShadow();
|
|
116
|
+
this.editBegin = createEvent(this, "editBegin", 7);
|
|
117
|
+
this.editEnd = createEvent(this, "editEnd", 7);
|
|
118
|
+
this.viewRendered = createEvent(this, "viewRendered", 7);
|
|
119
|
+
/**
|
|
120
|
+
* A mode that specifies how the markup component should behave. When
|
|
121
|
+
* unset, the component will not respond to interactions with the handles.
|
|
122
|
+
* When `edit`, the markup anchors are interactive and the user is able
|
|
123
|
+
* to reposition them. When `create`, anytime the user clicks on the canvas,
|
|
124
|
+
* a new markup will be performed.
|
|
125
|
+
*/
|
|
126
|
+
this.mode = '';
|
|
127
|
+
this.screenPoints = [];
|
|
128
|
+
this.interactionHandler = new FreeformMarkupInteractionHandler(this.hostEl, this.editBegin, this.editEnd);
|
|
129
|
+
this.handleWindowPointerDown = (event) => {
|
|
130
|
+
if (isValidStartEvent(event)) {
|
|
131
|
+
this.interactionHandler.startInteraction(event);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
this.handleTouchStart = (event) => {
|
|
135
|
+
event.preventDefault();
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* @ignore
|
|
140
|
+
*/
|
|
141
|
+
componentWillLoad() {
|
|
142
|
+
this.updateViewport();
|
|
143
|
+
this.handleViewerChanged(this.viewer);
|
|
144
|
+
this.updatePointsFromProps();
|
|
145
|
+
}
|
|
146
|
+
componentDidLoad() {
|
|
147
|
+
const resize = new ResizeObserver(() => this.updateViewport());
|
|
148
|
+
resize.observe(this.hostEl);
|
|
149
|
+
if (this.mode === 'create') {
|
|
150
|
+
window.addEventListener('pointerdown', this.handleWindowPointerDown);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
componentDidRender() {
|
|
154
|
+
if (this.mode === '') {
|
|
155
|
+
this.viewRendered.emit();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
disconnectedCallback() {
|
|
159
|
+
this.dispose();
|
|
160
|
+
}
|
|
161
|
+
async dispose() {
|
|
162
|
+
var _a;
|
|
163
|
+
(_a = this.registeredInteraction) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
164
|
+
this.registeredInteraction = undefined;
|
|
165
|
+
window.removeEventListener('pointerdown', this.handleWindowPointerDown);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* @ignore
|
|
169
|
+
*/
|
|
170
|
+
async handleViewerChanged(newViewer) {
|
|
171
|
+
var _a;
|
|
172
|
+
(_a = this.registeredInteraction) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
173
|
+
this.registeredInteraction = undefined;
|
|
174
|
+
if (newViewer != null) {
|
|
175
|
+
this.registeredInteraction = await newViewer.registerInteractionHandler(this.interactionHandler);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
handlePointsChange() {
|
|
179
|
+
this.updatePointsFromProps();
|
|
180
|
+
}
|
|
181
|
+
handleBoundsChange() {
|
|
182
|
+
this.updatePointsFromProps();
|
|
183
|
+
}
|
|
184
|
+
handleModeChange() {
|
|
185
|
+
if (this.mode !== 'create') {
|
|
186
|
+
window.removeEventListener('pointerdown', this.handleWindowPointerDown);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
updateViewport() {
|
|
190
|
+
var _a;
|
|
191
|
+
const rect = getMarkupBoundingClientRect(this.hostEl);
|
|
192
|
+
this.elementBounds = rect;
|
|
193
|
+
this.screenPoints = (_a = this.convertPointsToScreen()) !== null && _a !== void 0 ? _a : this.screenPoints;
|
|
194
|
+
}
|
|
195
|
+
updatePointsFromProps() {
|
|
196
|
+
var _a, _b, _c;
|
|
197
|
+
this.points = (_a = this.points) !== null && _a !== void 0 ? _a : parsePoints(this.pointsJson);
|
|
198
|
+
this.screenPoints = (_b = this.convertPointsToScreen()) !== null && _b !== void 0 ? _b : [];
|
|
199
|
+
this.bounds = (_c = this.bounds) !== null && _c !== void 0 ? _c : parseBounds(this.boundsJson);
|
|
200
|
+
}
|
|
201
|
+
render() {
|
|
202
|
+
if (this.screenPoints.length > 0 && this.elementBounds != null) {
|
|
203
|
+
return (h(Host, null, h("svg", { class: "svg", onTouchStart: this.handleTouchStart }, h("defs", null, h(SvgShadow, { id: "freeform-markup-shadow" })), h("g", { filter: "url(#freeform-markup-shadow)" }, h("path", { class: "path", d: this.screenPoints.reduce((d, pt) => `${d}L${pt.x},${pt.y}`, `M${this.screenPoints[0].x},${this.screenPoints[0].y}`), fill: "none" }))), this.mode === 'edit' && this.bounds != null && (h(BoundingBox2d, { bounds: translateRectToScreen(this.bounds, this.elementBounds), onTopLeftAnchorPointerDown: (e) => this.interactionHandler.editAnchor('top-left', e), onTopRightAnchorPointerDown: (e) => this.interactionHandler.editAnchor('top-right', e), onTopAnchorPointerDown: (e) => this.interactionHandler.editAnchor('top', e), onBottomLeftAnchorPointerDown: (e) => this.interactionHandler.editAnchor('bottom-left', e), onBottomRightAnchorPointerDown: (e) => this.interactionHandler.editAnchor('bottom-right', e), onBottomAnchorPointerDown: (e) => this.interactionHandler.editAnchor('bottom', e), onLeftAnchorPointerDown: (e) => this.interactionHandler.editAnchor('left', e), onRightAnchorPointerDown: (e) => this.interactionHandler.editAnchor('right', e), onCenterAnchorPointerDown: (e) => this.interactionHandler.editAnchor('center', e) })), this.mode === 'create' && (h("div", { class: "create-overlay", onTouchStart: this.handleTouchStart }))));
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
return (h(Host, null, h("div", { class: "create-overlay", onTouchStart: this.handleTouchStart })));
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
convertPointsToScreen() {
|
|
210
|
+
var _a;
|
|
211
|
+
const elementBounds = this.elementBounds;
|
|
212
|
+
if (elementBounds != null) {
|
|
213
|
+
return (_a = this.points) === null || _a === void 0 ? void 0 : _a.map((pt) => translatePointToScreen(pt, elementBounds));
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
get hostEl() { return this; }
|
|
217
|
+
static get watchers() { return {
|
|
218
|
+
"viewer": ["handleViewerChanged"],
|
|
219
|
+
"points": ["handlePointsChange"],
|
|
220
|
+
"bounds": ["handleBoundsChange"],
|
|
221
|
+
"mode": ["handleModeChange"]
|
|
222
|
+
}; }
|
|
223
|
+
static get style() { return viewerMarkupFreeformCss; }
|
|
224
|
+
}, [1, "vertex-viewer-markup-freeform", {
|
|
225
|
+
"points": [1040],
|
|
226
|
+
"pointsJson": [1, "points"],
|
|
227
|
+
"bounds": [1040],
|
|
228
|
+
"boundsJson": [1, "bounds"],
|
|
229
|
+
"mode": [513],
|
|
230
|
+
"viewer": [16],
|
|
231
|
+
"elementBounds": [32],
|
|
232
|
+
"screenPoints": [32],
|
|
233
|
+
"dispose": [64]
|
|
234
|
+
}]);
|
|
235
|
+
function defineCustomElement() {
|
|
236
|
+
if (typeof customElements === "undefined") {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
const components = ["vertex-viewer-markup-freeform"];
|
|
240
|
+
components.forEach(tagName => { switch (tagName) {
|
|
241
|
+
case "vertex-viewer-markup-freeform":
|
|
242
|
+
if (!customElements.get(tagName)) {
|
|
243
|
+
customElements.define(tagName, ViewerMarkupFreeform);
|
|
244
|
+
}
|
|
245
|
+
break;
|
|
246
|
+
} });
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export { ViewerMarkupFreeform as V, defineCustomElement as d };
|
|
250
|
+
|
|
251
|
+
//# sourceMappingURL=viewer-markup-freeform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"viewer-markup-freeform.js","mappings":";;;;;;;;;;MAaa,gCAAiC,SAAQ,wBAAwB;EAW5E,YACmB,QAA+C,EAC/C,SAA6B,EAC7B,OAA2B;IAE5C,KAAK,EAAE,CAAC;IAJS,aAAQ,GAAR,QAAQ,CAAuC;IAC/C,cAAS,GAAT,SAAS,CAAoB;IAC7B,YAAO,GAAP,OAAO,CAAoB;IALtC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AC,kBAAkB,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,EAE/C,wBAAwB,EAAE,CAAC,CAAC,KAC1B,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,EAEhD,yBAAyB,EAAE,CAAC,CAAC,KAC3B,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC,GAEjD,CACH,EACA,IAAI,CAAC,IAAI,KAAK,QAAQ,KACrB,WACE,KAAK,EAAC,gBAAgB,EACtB,YAAY,EAAE,IAAI,CAAC,gBAAgB,GAC9B,CACR,CACI,EACP;KACH;SAAM;MACL,QACE,EAAC,IAAI,QACH,WACE,KAAK,EAAC,gBAAgB,EACtB,YAAY,EAAE,IAAI,CAAC,gBAAgB,GAC9B,CACF,EACP;KACH;GACF;EAYO,qBAAqB;;IAC3B,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;IACzC,IAAI,aAAa,IAAI,IAAI,EAAE;MACzB,OAAO,MAAA,IAAI,CAAC,MAAM,0CAAE,GAAG,CAAC,CAAC,EAAE,KACzB,sBAAsB,CAAC,EAAE,EAAE,aAAa,CAAC,CAC1C,CAAC;KACH;GACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["Point","Rectangle"],"sources":["./src/components/viewer-markup-freeform/interactions.ts","./src/components/viewer-markup-freeform/viewer-markup-freeform.css?tag=vertex-viewer-markup-freeform&encapsulation=shadow","./src/components/viewer-markup-freeform/viewer-markup-freeform.tsx"],"sourcesContent":["import type { EventEmitter } from '@stencil/core';\nimport { Point, Rectangle } from '@vertexvis/geometry';\n\nimport { getMouseClientPosition } from '../../lib/dom';\nimport { MarkupInteractionHandler } from '../../lib/markup/interactions';\nimport { getMarkupBoundingClientRect } from '../viewer-markup/dom';\nimport {\n BoundingBox2dAnchorPosition,\n transformRectangle,\n translatePointsToBounds,\n translatePointToRelative,\n} from '../viewer-markup/markup-utils';\n\nexport class FreeformMarkupInteractionHandler extends MarkupInteractionHandler {\n private pointerId?: number;\n private min?: Point.Point;\n private max?: Point.Point;\n\n private resizeBounds?: Rectangle.Rectangle;\n private resizePoints?: Point.Point[];\n private resizeStartPosition?: Point.Point;\n\n private anchor: BoundingBox2dAnchorPosition = 'bottom-right';\n\n public constructor(\n private readonly markupEl: HTMLVertexViewerMarkupFreeformElement,\n private readonly editBegin: EventEmitter<void>,\n private readonly editEnd: EventEmitter<void>\n ) {\n super();\n }\n\n public editAnchor(\n anchor: BoundingBox2dAnchorPosition,\n event: PointerEvent\n ): void {\n if (this.markupEl.mode === 'edit' && this.elementBounds != null) {\n this.resizeBounds = this.markupEl.bounds;\n this.resizePoints = this.markupEl.points;\n this.anchor = anchor;\n this.resizeStartPosition = translatePointToRelative(\n getMouseClientPosition(event, this.elementBounds),\n this.elementBounds\n );\n\n window.addEventListener('pointermove', this.handleResizeInteractionMove);\n window.addEventListener('pointerup', this.handleResizeInteractionEnd);\n }\n }\n\n public startInteraction(event: PointerEvent): void {\n this.handleInteractionAttempt(event);\n }\n\n protected computeBoundingRect(): DOMRect {\n return getMarkupBoundingClientRect(this.markupEl);\n }\n\n protected handleInteractionAttempt(event: PointerEvent): void {\n if (\n this.markupEl.mode !== '' &&\n this.pointerId == null &&\n this.elementBounds != null\n ) {\n this.pointerId = event.pointerId;\n const screenPosition = getMouseClientPosition(event, this.elementBounds);\n const position = translatePointToRelative(\n screenPosition,\n this.elementBounds\n );\n this.updateMinAndMax(position);\n this.markupEl.points = this.markupEl.points ?? [position];\n\n this.editBegin.emit();\n this.acceptInteraction();\n }\n }\n\n protected handleInteractionMove(event: PointerEvent): void {\n if (\n this.pointerId === event.pointerId &&\n this.markupEl.points != null &&\n this.elementBounds != null\n ) {\n const screenPosition = getMouseClientPosition(event, this.elementBounds);\n const position = translatePointToRelative(\n screenPosition,\n this.elementBounds\n );\n this.updateMinAndMax(position);\n this.markupEl.points = [...this.markupEl.points, position];\n }\n }\n\n protected handleInteractionEnd(event: PointerEvent): void {\n if (this.pointerId === event.pointerId) {\n if (\n this.markupEl.mode !== '' &&\n this.markupEl.points != null &&\n this.markupEl.points.length > 2 &&\n this.elementBounds != null\n ) {\n const screenPosition = getMouseClientPosition(\n event,\n this.elementBounds\n );\n const position = translatePointToRelative(\n screenPosition,\n this.elementBounds\n );\n\n this.updateMinAndMax(position);\n\n this.markupEl.points = [...this.markupEl.points, position];\n this.editEnd.emit();\n } else {\n this.markupEl.points = undefined;\n }\n\n this.min = undefined;\n this.max = undefined;\n this.pointerId = undefined;\n }\n }\n\n private handleResizeInteractionMove = (event: PointerEvent): void => {\n if (\n this.resizeStartPosition != null &&\n this.elementBounds != null &&\n this.resizeBounds != null &&\n this.resizePoints != null\n ) {\n const position = translatePointToRelative(\n getMouseClientPosition(event, this.elementBounds),\n this.elementBounds\n );\n\n const updatedBounds = transformRectangle(\n this.resizeBounds,\n this.resizeStartPosition,\n position,\n this.anchor,\n event.shiftKey\n );\n\n this.markupEl.points = translatePointsToBounds(\n this.resizePoints,\n this.resizeBounds,\n updatedBounds\n );\n this.markupEl.bounds = updatedBounds;\n }\n };\n\n private handleResizeInteractionEnd = (event: PointerEvent): void => {\n window.removeEventListener('pointermove', this.handleResizeInteractionMove);\n window.removeEventListener('pointerup', this.handleResizeInteractionEnd);\n\n this.resizeBounds = undefined;\n this.editEnd.emit();\n };\n\n private updateMinAndMax(position: Point.Point): void {\n this.min =\n this.min != null\n ? Point.create(\n Math.min(this.min.x, position.x),\n Math.min(this.min.y, position.y)\n )\n : position;\n this.max =\n this.max != null\n ? Point.create(\n Math.max(this.max.x, position.x),\n Math.max(this.max.y, position.y)\n )\n : position;\n this.markupEl.bounds = Rectangle.create(\n this.min.x,\n this.min.y,\n this.max.x - this.min.x,\n this.max.y - this.min.y\n );\n }\n}\n",":host {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n pointer-events: none;\n /**\n * @prop --viewer-markup-freeform-stroke-color: A CSS color that\n * specifies the color of the freeform line.\n */\n --viewer-markup-freeform-stroke-color: var(--red-800);\n /**\n * @prop --viewer-markup-freeform-stroke-width: A CSS length that\n * specifies the width of the freeform line.\n */\n --viewer-markup-freeform-stroke-width: 4;\n /**\n * @prop --viewer-markup-freeform-line-join: The join behavior between\n * the lines making up this freeform markup. Defaults to `round`.\n */\n --viewer-markup-freeform-line-join: round;\n /**\n * @prop --viewer-markup-freeform-line-cap: The cap behavior for\n * the lines making up this freeform markup. Defaults to `round`.\n */\n --viewer-markup-freeform-line-cap: round;\n /**\n * @prop --viewer-markup-freeform-bounds-outline-border-color: A CSS color that\n * specifies the color of the circle's selected bounding box border.\n */\n --viewer-markup-freeform-bounds-outline-border-color: var(--blue-400);\n /**\n * @prop --viewer-markup-freeform-bounds-outline-border-width: A CSS length that\n * specifies the width of the circle's selected bounding box border.\n */\n --viewer-markup-freeform-bounds-outline-border-width: 1px;\n /**\n * @prop --viewer-markup-freeform-bounds-edge-anchor-border-color: A CSS color that\n * specifies the color of the edge and corner resize anchors' borders.\n */\n --viewer-markup-freeform-bounds-edge-anchor-border-color: var(--blue-400);\n /**\n * @prop --viewer-markup-freeform-bounds-edge-anchor-border-width: A CSS length that\n * specifies the width of the edge and corner resize anchors' borders.\n */\n --viewer-markup-freeform-bounds-edge-anchor-border-width: 1px;\n /**\n * @prop --viewer-markup-freeform-bounds-edge-anchor-background-color: A CSS color that\n * specifies the background color of the edge and corner resize anchors.\n */\n --viewer-markup-freeform-bounds-edge-anchor-background-color: white;\n /**\n * @prop --viewer-markup-freeform-bounds-center-anchor-border-color: A CSS color that\n * specifies the color of the center reposition anchor's border.\n */\n --viewer-markup-freeform-bounds-center-anchor-border-color: white;\n /**\n * @prop --viewer-markup-freeform-bounds-center-anchor-border-width: A CSS length that\n * specifies the width of the center reposition anchor's border.\n */\n --viewer-markup-freeform-bounds-center-anchor-border-width: 1px;\n /**\n * @prop --viewer-markup-freeform-bounds-center-anchor-background-color: A CSS color that\n * specifies the background color of the center reposition anchor.\n */\n --viewer-markup-freeform-bounds-center-anchor-background-color: var(--blue-400);\n /**\n * @prop --viewer-markup-freeform-bounds-anchor-width: A CSS length that\n * specifies the width of the resize and reposition anchors.\n */\n --viewer-markup-freeform-bounds-anchor-width: 9px;\n /**\n * @prop --viewer-markup-freeform-bounds-anchor-height: A CSS length that\n * specifies the height of the resize and reposition anchors.\n */\n --viewer-markup-freeform-bounds-anchor-height: 9px;\n}\n\n.svg {\n pointer-events: none;\n width: 100%;\n height: 100%;\n position: absolute;\n top: 0;\n left: 0;\n}\n\n.path {\n pointer-events: auto;\n cursor: default;\n stroke: var(--viewer-markup-freeform-stroke-color);\n stroke-width: var(--viewer-markup-freeform-stroke-width);\n stroke-linejoin: var(--viewer-markup-freeform-line-join);\n stroke-linecap: var(--viewer-markup-freeform-line-cap);\n}\n\n.create-overlay {\n pointer-events: auto;\n position: absolute;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n cursor: crosshair;\n}\n\n.bounds-container {\n pointer-events: none;\n position: absolute;\n width: 100%;\n height: 100%;\n top: 0;\n left: 0;\n overflow: hidden;\n}\n\n.bounds-outline {\n position: absolute;\n border-width: var(--viewer-markup-freeform-bounds-outline-border-width);\n border-color: var(--viewer-markup-freeform-bounds-outline-border-color);\n border-style: solid;\n box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);\n}\n\n.bounds-anchor-position {\n position: absolute;\n transform: translate(-50%, -50%);\n}\n\n.bounds-anchor {\n pointer-events: auto;\n cursor: default;\n user-select: none;\n}\n\n.bounds-default-anchor {\n width: var(--viewer-markup-freeform-bounds-anchor-width);\n height: var(--viewer-markup-freeform-bounds-anchor-height);\n box-sizing: border-box;\n box-shadow: 0 0 2px rgba(0, 0, 0, 0.3);\n}\n\n.bounds-center-anchor {\n border-radius: 100%;\n border-width: var(--viewer-markup-freeform-bounds-center-anchor-border-width);\n border-color: var(--viewer-markup-freeform-bounds-center-anchor-border-color);\n border-style: solid;\n background-color: var(--viewer-markup-freeform-bounds-center-anchor-background-color);\n}\n\n.bounds-edge-anchor {\n border-width: var(--viewer-markup-freeform-bounds-edge-anchor-border-width);\n border-color: var(--viewer-markup-freeform-bounds-edge-anchor-border-color);\n border-style: solid;\n background-color: var(--viewer-markup-freeform-bounds-edge-anchor-background-color);\n}","import {\n Component,\n Element,\n Event,\n EventEmitter,\n h,\n Host,\n Method,\n Prop,\n State,\n Watch,\n} from '@stencil/core';\nimport { Point, Rectangle } from '@vertexvis/geometry';\nimport { Disposable } from '@vertexvis/utils';\n\nimport { getMarkupBoundingClientRect } from '../viewer-markup/dom';\nimport {\n isValidStartEvent,\n translatePointToScreen,\n translateRectToScreen,\n} from '../viewer-markup/markup-utils';\nimport { SvgShadow } from '../viewer-markup/viewer-markup-components';\nimport { parseBounds } from '../viewer-markup-circle/utils';\nimport { BoundingBox2d } from '../viewer-markup-circle/viewer-markup-circle-components';\nimport { FreeformMarkupInteractionHandler } from './interactions';\nimport { parsePoints } from './utils';\n\n/**\n * The supported markup modes.\n *\n * @see {@link ViewerMarkupFreeformMode.mode} - For more details about modes.\n */\nexport type ViewerMarkupFreeformMode = 'edit' | 'create' | '';\n\n@Component({\n tag: 'vertex-viewer-markup-freeform',\n styleUrl: 'viewer-markup-freeform.css',\n shadow: true,\n})\nexport class ViewerMarkupFreeform {\n /**\n * The positions of the various points of this freeform markup. Can either be an array of\n * `Point`s or a JSON string representation in the format of `[[x1, y1], [x2, y2]]` or\n * `[{\"x\": 0, \"y\": 0}, {\"x\": 0, \"y\": 0}]`.\n *\n * Points are expected to be relative coordinates from `[-0.5, 0.5]`,\n * e.g. `[0, 0]` corresponds to a point in the center of the viewport.\n */\n @Prop({ mutable: true, attribute: null })\n public points?: Point.Point[];\n\n /**\n * The positions of the various points of this freeform markup. Can either be an array of\n * `Point`s or a JSON string representation in the format of `[[x1, y1], [x2, y2]]` or\n * `[{\"x\": 0, \"y\": 0}, {\"x\": 0, \"y\": 0}]`.\n *\n * Points are expected to be relative coordinates from `[-0.5, 0.5]`,\n * e.g. `[0, 0]` corresponds to a point in the center of the viewport.\n */\n @Prop({ attribute: 'points' })\n public pointsJson?: string;\n\n /**\n * The bounds of the freeform. Can either be an instance of a `Rectangle` or\n * a JSON string representation in the format of `[x, y, width, height]` or\n * `{\"x\": 0, \"y\": 0, \"width\": 10, \"height\": 10}`.\n *\n * Bounds are expected to have relative coordinates, with `[x, y]` from `[-0.5, 0.5]`\n * and `[width, height]` from `[0, 1]`, e.g. `[0, 0, 0.25, 0.25]`corresponds to a freeform\n * with a diameter of one fourth the viewport's smallest size in the center of the viewport.\n */\n @Prop({ mutable: true, attribute: null })\n public bounds?: Rectangle.Rectangle;\n\n /**\n * The bounds of the freeform. Can either be an instance of a `Rectangle` or\n * a JSON string representation in the format of `[x, y, width, height]` or\n * `{\"x\": 0, \"y\": 0, \"width\": 0.1, \"height\": 0.1}`.\n *\n * Bounds are expected to have relative coordinates, with `[x, y]` from `[-0.5, 0.5]`\n * and `[width, height]` from `[0, 1]`, e.g. `[0, 0, 0.25, 0.25]`corresponds to a freeform\n * with a diameter of one fourth the viewport's smallest size in the center of the viewport.\n */\n @Prop({ attribute: 'bounds' })\n public boundsJson?: string;\n\n /**\n * A mode that specifies how the markup component should behave. When\n * unset, the component will not respond to interactions with the handles.\n * When `edit`, the markup anchors are interactive and the user is able\n * to reposition them. When `create`, anytime the user clicks on the canvas,\n * a new markup will be performed.\n */\n @Prop({ reflect: true })\n public mode: ViewerMarkupFreeformMode = '';\n\n /**\n * The viewer to connect to markups.\n *\n * This property will automatically be set when a child of a\n * `<vertex-viewer-markup>` or `<vertex-viewer>` element.\n */\n @Prop()\n public viewer?: HTMLVertexViewerElement;\n\n /**\n * An event that is dispatched anytime the user begins editing the\n * markup.\n */\n @Event({ bubbles: true })\n public editBegin!: EventEmitter<void>;\n\n /**\n * An event that is dispatched when the user has finished editing the\n * markup.\n */\n @Event({ bubbles: true })\n public editEnd!: EventEmitter<void>;\n\n /**\n * An event that is dispatched when this markup element is in view\n * mode (`this.mode === \"\"`), and it completes a rerender.\n */\n @Event({ bubbles: true })\n public viewRendered!: EventEmitter<void>;\n\n @Element()\n private hostEl!: HTMLVertexViewerMarkupFreeformElement;\n\n @State()\n private elementBounds?: DOMRect;\n\n @State()\n private screenPoints: Point.Point[] = [];\n\n private interactionHandler = new FreeformMarkupInteractionHandler(\n this.hostEl,\n this.editBegin,\n this.editEnd\n );\n\n private registeredInteraction?: Disposable;\n\n /**\n * @ignore\n */\n protected componentWillLoad(): void {\n this.updateViewport();\n this.handleViewerChanged(this.viewer);\n this.updatePointsFromProps();\n }\n\n protected componentDidLoad(): void {\n const resize = new ResizeObserver(() => this.updateViewport());\n resize.observe(this.hostEl);\n\n if (this.mode === 'create') {\n window.addEventListener('pointerdown', this.handleWindowPointerDown);\n }\n }\n\n protected componentDidRender(): void {\n if (this.mode === '') {\n this.viewRendered.emit();\n }\n }\n\n protected disconnectedCallback(): void {\n this.dispose();\n }\n\n @Method()\n public async dispose(): Promise<void> {\n this.registeredInteraction?.dispose();\n this.registeredInteraction = undefined;\n\n window.removeEventListener('pointerdown', this.handleWindowPointerDown);\n }\n\n /**\n * @ignore\n */\n @Watch('viewer')\n protected async handleViewerChanged(\n newViewer?: HTMLVertexViewerElement\n ): Promise<void> {\n this.registeredInteraction?.dispose();\n this.registeredInteraction = undefined;\n\n if (newViewer != null) {\n this.registeredInteraction = await newViewer.registerInteractionHandler(\n this.interactionHandler\n );\n }\n }\n\n @Watch('points')\n protected handlePointsChange(): void {\n this.updatePointsFromProps();\n }\n\n @Watch('bounds')\n protected handleBoundsChange(): void {\n this.updatePointsFromProps();\n }\n\n @Watch('mode')\n protected handleModeChange(): void {\n if (this.mode !== 'create') {\n window.removeEventListener('pointerdown', this.handleWindowPointerDown);\n }\n }\n\n private updateViewport(): void {\n const rect = getMarkupBoundingClientRect(this.hostEl);\n this.elementBounds = rect;\n this.screenPoints = this.convertPointsToScreen() ?? this.screenPoints;\n }\n\n private updatePointsFromProps(): void {\n this.points = this.points ?? parsePoints(this.pointsJson);\n this.screenPoints = this.convertPointsToScreen() ?? [];\n this.bounds = this.bounds ?? parseBounds(this.boundsJson);\n }\n\n public render(): h.JSX.IntrinsicElements {\n if (this.screenPoints.length > 0 && this.elementBounds != null) {\n return (\n <Host>\n <svg class=\"svg\" onTouchStart={this.handleTouchStart}>\n <defs>\n <SvgShadow id=\"freeform-markup-shadow\" />\n </defs>\n <g filter=\"url(#freeform-markup-shadow)\">\n <path\n class=\"path\"\n d={this.screenPoints.reduce(\n (d, pt) => `${d}L${pt.x},${pt.y}`,\n `M${this.screenPoints[0].x},${this.screenPoints[0].y}`\n )}\n fill=\"none\"\n />\n </g>\n </svg>\n {this.mode === 'edit' && this.bounds != null && (\n <BoundingBox2d\n bounds={translateRectToScreen(this.bounds, this.elementBounds)}\n onTopLeftAnchorPointerDown={(e) =>\n this.interactionHandler.editAnchor('top-left', e)\n }\n onTopRightAnchorPointerDown={(e) =>\n this.interactionHandler.editAnchor('top-right', e)\n }\n onTopAnchorPointerDown={(e) =>\n this.interactionHandler.editAnchor('top', e)\n }\n onBottomLeftAnchorPointerDown={(e) =>\n this.interactionHandler.editAnchor('bottom-left', e)\n }\n onBottomRightAnchorPointerDown={(e) =>\n this.interactionHandler.editAnchor('bottom-right', e)\n }\n onBottomAnchorPointerDown={(e) =>\n this.interactionHandler.editAnchor('bottom', e)\n }\n onLeftAnchorPointerDown={(e) =>\n this.interactionHandler.editAnchor('left', e)\n }\n onRightAnchorPointerDown={(e) =>\n this.interactionHandler.editAnchor('right', e)\n }\n onCenterAnchorPointerDown={(e) =>\n this.interactionHandler.editAnchor('center', e)\n }\n />\n )}\n {this.mode === 'create' && (\n <div\n class=\"create-overlay\"\n onTouchStart={this.handleTouchStart}\n ></div>\n )}\n </Host>\n );\n } else {\n return (\n <Host>\n <div\n class=\"create-overlay\"\n onTouchStart={this.handleTouchStart}\n ></div>\n </Host>\n );\n }\n }\n\n private handleWindowPointerDown = (event: PointerEvent): void => {\n if (isValidStartEvent(event)) {\n this.interactionHandler.startInteraction(event);\n }\n };\n\n private handleTouchStart = (event: TouchEvent): void => {\n event.preventDefault();\n };\n\n private convertPointsToScreen(): Point.Point[] | undefined {\n const elementBounds = this.elementBounds;\n if (elementBounds != null) {\n return this.points?.map((pt) =>\n translatePointToScreen(pt, elementBounds)\n );\n }\n }\n}\n"],"version":3}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2023 Vertex Software LLC. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
|
|
5
|
+
import { p as point, c as angle } from './bundle.esm.js';
|
|
6
|
+
|
|
7
|
+
const viewerMeasurementLineCss = ":host{display:block;--viewer-measurement-line-stroke:var(--white);--viewer-measurement-line-stroke-opacity:0.75;--viewer-measurement-line-stroke-width:1.25px;--viewer-measurement-line-fill:var(--neutral-900);--viewer-measurement-line-fill-width:2px;--viewer-measurement-line-start-cap-visibility:initial;--viewer-measurement-line-end-cap-visibility:initial}svg{width:100%;height:100%}.line-stroke{stroke-width:calc(\n var(--viewer-measurement-line-fill-width) +\n var(--viewer-measurement-line-stroke-width)\n );stroke:var(--viewer-measurement-line-stroke);opacity:var(--viewer-measurement-line-stroke-opacity)}.line-fill{stroke-width:var(--viewer-measurement-line-fill-width);stroke:var(--viewer-measurement-line-fill)}.start-cap{visibility:var(--viewer-measurement-line-start-cap-visibility)}.end-cap{visibility:var(--viewer-measurement-line-end-cap-visibility)}";
|
|
8
|
+
|
|
9
|
+
const ViewerMeasurementLine = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
10
|
+
constructor() {
|
|
11
|
+
super();
|
|
12
|
+
this.__registerHost();
|
|
13
|
+
this.__attachShadow();
|
|
14
|
+
/**
|
|
15
|
+
* A point that specifies the starting point of the line.
|
|
16
|
+
*/
|
|
17
|
+
this.start = point.create();
|
|
18
|
+
/**
|
|
19
|
+
* A point that specifies the ending point of the line.
|
|
20
|
+
*/
|
|
21
|
+
this.end = point.create();
|
|
22
|
+
/**
|
|
23
|
+
* A length of the line cap. The line cap is a line at each end of a line.
|
|
24
|
+
*/
|
|
25
|
+
this.capLength = 0;
|
|
26
|
+
/**
|
|
27
|
+
* The type of [SVG pointer
|
|
28
|
+
* events](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/pointer-events)
|
|
29
|
+
* that the line should respond to.
|
|
30
|
+
*/
|
|
31
|
+
this.pointerEvents = 'none';
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @ignore
|
|
35
|
+
*/
|
|
36
|
+
render() {
|
|
37
|
+
const angle$1 = angle.fromPoints(this.start, this.end);
|
|
38
|
+
const lineFillEndCaps = getEndCapPoints(this.start, this.end, angle$1, this.capLength);
|
|
39
|
+
const lineStrokeEndCaps = getEndCapPoints(this.start, this.end, angle$1, this.capLength + 1);
|
|
40
|
+
return (h("svg", null, h("g", { class: "line-stroke", "pointer-events": this.pointerEvents }, h("line", { class: "line", x1: this.start.x, y1: this.start.y, x2: this.end.x, y2: this.end.y }), h("line", { class: "start-cap", x1: lineStrokeEndCaps.startEndCap.start.x, y1: lineStrokeEndCaps.startEndCap.start.y, x2: lineStrokeEndCaps.startEndCap.end.x, y2: lineStrokeEndCaps.startEndCap.end.y }), h("line", { class: "end-cap", x1: lineStrokeEndCaps.endEndCap.start.x, y1: lineStrokeEndCaps.endEndCap.start.y, x2: lineStrokeEndCaps.endEndCap.end.x, y2: lineStrokeEndCaps.endEndCap.end.y })), h("g", { class: "line-fill", "pointer-events": this.pointerEvents }, h("line", { class: "line", x1: this.start.x, y1: this.start.y, x2: this.end.x, y2: this.end.y }), h("line", { class: "start-cap", x1: lineFillEndCaps.startEndCap.start.x, y1: lineFillEndCaps.startEndCap.start.y, x2: lineFillEndCaps.startEndCap.end.x, y2: lineFillEndCaps.startEndCap.end.y }), h("line", { class: "end-cap", x1: lineFillEndCaps.endEndCap.start.x, y1: lineFillEndCaps.endEndCap.start.y, x2: lineFillEndCaps.endEndCap.end.x, y2: lineFillEndCaps.endEndCap.end.y }))));
|
|
41
|
+
}
|
|
42
|
+
static get style() { return viewerMeasurementLineCss; }
|
|
43
|
+
}, [1, "vertex-viewer-measurement-line", {
|
|
44
|
+
"start": [16],
|
|
45
|
+
"end": [16],
|
|
46
|
+
"capLength": [2, "cap-length"],
|
|
47
|
+
"pointerEvents": [1, "pointer-events"]
|
|
48
|
+
}]);
|
|
49
|
+
function getEndCapPoints(start, end, angle, length) {
|
|
50
|
+
return {
|
|
51
|
+
startEndCap: getPerpendicularLine(start, angle, length),
|
|
52
|
+
endEndCap: getPerpendicularLine(end, angle, length),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function getPerpendicularLine(pt, angle, length) {
|
|
56
|
+
const perpAngle = angle + Math.PI / 2;
|
|
57
|
+
const start = point.add(pt, point.polar(length / 2, perpAngle));
|
|
58
|
+
const end = point.add(pt, point.polar(length / 2, perpAngle + Math.PI));
|
|
59
|
+
return { start, end };
|
|
60
|
+
}
|
|
61
|
+
function defineCustomElement() {
|
|
62
|
+
if (typeof customElements === "undefined") {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const components = ["vertex-viewer-measurement-line"];
|
|
66
|
+
components.forEach(tagName => { switch (tagName) {
|
|
67
|
+
case "vertex-viewer-measurement-line":
|
|
68
|
+
if (!customElements.get(tagName)) {
|
|
69
|
+
customElements.define(tagName, ViewerMeasurementLine);
|
|
70
|
+
}
|
|
71
|
+
break;
|
|
72
|
+
} });
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { ViewerMeasurementLine as V, defineCustomElement as d };
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=viewer-measurement-line.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"viewer-measurement-line.js","mappings":";;;;;;AAAA,MAAM,wBAAwB,GAAG,22BAA22B;;MCQ/3B,qBAAqB;EALlC;;;;;;;IAU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AC,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC;GACpD,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAC3B,EAAe,EACf,KAAa,EACb,MAAc;EAEd,MAAM,SAAS,GAAG,KAAK,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;EACtC,MAAM,KAAK,GAAGD,KAAK,CAAC,GAAG,CAAC,EAAE,EAAEA,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;EAChE,MAAM,GAAG,GAAGA,KAAK,CAAC,GAAG,CAAC,EAAE,EAAEA,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;EACxE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;AACxB,CAAC;;;;;;;;;;;;;;;;;","names":["Point","angle","Angle"],"sources":["./src/components/viewer-measurement-line/viewer-measurement-line.css?tag=vertex-viewer-measurement-line&encapsulation=shadow","./src/components/viewer-measurement-line/viewer-measurement-line.tsx"],"sourcesContent":[":host {\n display: block;\n\n /**\n * @prop --viewer-measurement-line-stroke: An SVG stroke that specifies the\n * color stroke of the line.\n */\n --viewer-measurement-line-stroke: var(--white);\n\n /**\n * @prop --viewer-measurement-line-stroke-opacity: An SVG stroke that\n * specifies the stroke opacity of the line.\n */\n --viewer-measurement-line-stroke-opacity: 0.75;\n\n /**\n * @prop --viewer-measurement-line-stroke-width: A CSS length that specifies\n * the width of the stroke.\n */\n --viewer-measurement-line-stroke-width: 1.25px;\n\n /**\n * @prop --viewer-measurement-line-fill: An SVG stroke that specifies the\n * color fill of the line.\n */\n --viewer-measurement-line-fill: var(--neutral-900);\n\n /**\n * @prop --viewer-measurement-line-fill-width: A CSS length that specifies\n * the width of the fill.\n */\n --viewer-measurement-line-fill-width: 2px;\n\n /**\n * @prop --viewer-measurement-line-start-cap-visibility: An CSS visibility\n * value for the cap at the start of the line.\n */\n --viewer-measurement-line-start-cap-visibility: initial;\n\n /**\n * @prop --viewer-measurement-line-end-cap-visibility: An CSS visibility value\n * for the cap at the end of the line.\n */\n --viewer-measurement-line-end-cap-visibility: initial;\n}\n\nsvg {\n width: 100%;\n height: 100%;\n}\n\n.line-stroke {\n stroke-width: calc(\n var(--viewer-measurement-line-fill-width) +\n var(--viewer-measurement-line-stroke-width)\n );\n stroke: var(--viewer-measurement-line-stroke);\n opacity: var(--viewer-measurement-line-stroke-opacity);\n}\n\n.line-fill {\n stroke-width: var(--viewer-measurement-line-fill-width);\n stroke: var(--viewer-measurement-line-fill);\n}\n\n.start-cap {\n visibility: var(--viewer-measurement-line-start-cap-visibility);\n}\n\n.end-cap {\n visibility: var(--viewer-measurement-line-end-cap-visibility);\n}\n","import { Component, h, Prop } from '@stencil/core';\nimport { Angle, Point } from '@vertexvis/geometry';\n\n@Component({\n tag: 'vertex-viewer-measurement-line',\n styleUrl: 'viewer-measurement-line.css',\n shadow: true,\n})\nexport class ViewerMeasurementLine {\n /**\n * A point that specifies the starting point of the line.\n */\n @Prop()\n public start: Point.Point = Point.create();\n\n /**\n * A point that specifies the ending point of the line.\n */\n @Prop()\n public end: Point.Point = Point.create();\n\n /**\n * A length of the line cap. The line cap is a line at each end of a line.\n */\n @Prop()\n public capLength = 0;\n\n /**\n * The type of [SVG pointer\n * events](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/pointer-events)\n * that the line should respond to.\n */\n @Prop()\n public pointerEvents = 'none';\n\n /**\n * @ignore\n */\n protected render(): h.JSX.IntrinsicElements {\n const angle = Angle.fromPoints(this.start, this.end);\n const lineFillEndCaps = getEndCapPoints(\n this.start,\n this.end,\n angle,\n this.capLength\n );\n const lineStrokeEndCaps = getEndCapPoints(\n this.start,\n this.end,\n angle,\n this.capLength + 1\n );\n\n return (\n <svg>\n <g class=\"line-stroke\" pointer-events={this.pointerEvents}>\n <line\n class=\"line\"\n x1={this.start.x}\n y1={this.start.y}\n x2={this.end.x}\n y2={this.end.y}\n />\n\n <line\n class=\"start-cap\"\n x1={lineStrokeEndCaps.startEndCap.start.x}\n y1={lineStrokeEndCaps.startEndCap.start.y}\n x2={lineStrokeEndCaps.startEndCap.end.x}\n y2={lineStrokeEndCaps.startEndCap.end.y}\n />\n\n <line\n class=\"end-cap\"\n x1={lineStrokeEndCaps.endEndCap.start.x}\n y1={lineStrokeEndCaps.endEndCap.start.y}\n x2={lineStrokeEndCaps.endEndCap.end.x}\n y2={lineStrokeEndCaps.endEndCap.end.y}\n />\n </g>\n\n <g class=\"line-fill\" pointer-events={this.pointerEvents}>\n <line\n class=\"line\"\n x1={this.start.x}\n y1={this.start.y}\n x2={this.end.x}\n y2={this.end.y}\n />\n\n <line\n class=\"start-cap\"\n x1={lineFillEndCaps.startEndCap.start.x}\n y1={lineFillEndCaps.startEndCap.start.y}\n x2={lineFillEndCaps.startEndCap.end.x}\n y2={lineFillEndCaps.startEndCap.end.y}\n />\n\n <line\n class=\"end-cap\"\n x1={lineFillEndCaps.endEndCap.start.x}\n y1={lineFillEndCaps.endEndCap.start.y}\n x2={lineFillEndCaps.endEndCap.end.x}\n y2={lineFillEndCaps.endEndCap.end.y}\n />\n </g>\n </svg>\n );\n }\n}\n\ninterface EndCapPoints {\n start: Point.Point;\n end: Point.Point;\n}\n\ninterface LinePoints {\n startEndCap: EndCapPoints;\n endEndCap: EndCapPoints;\n}\n\nfunction getEndCapPoints(\n start: Point.Point,\n end: Point.Point,\n angle: number,\n length: number\n): LinePoints {\n return {\n startEndCap: getPerpendicularLine(start, angle, length),\n endEndCap: getPerpendicularLine(end, angle, length),\n };\n}\n\nfunction getPerpendicularLine(\n pt: Point.Point,\n angle: number,\n length: number\n): { start: Point.Point; end: Point.Point } {\n const perpAngle = angle + Math.PI / 2;\n const start = Point.add(pt, Point.polar(length / 2, perpAngle));\n const end = Point.add(pt, Point.polar(length / 2, perpAngle + Math.PI));\n return { start, end };\n}\n"],"version":3}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2023 Vertex Software LLC. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { h, Fragment, proxyCustomElement, HTMLElement as HTMLElement$1, Host } from '@stencil/core/internal/client';
|
|
5
|
+
import './mapper.js';
|
|
6
|
+
import './wrappers_pb.js';
|
|
7
|
+
import './streamAttributes.js';
|
|
8
|
+
import { M as MeasurementOverlayManager } from './overlays.js';
|
|
9
|
+
import { p as point, l as line3 } from './bundle.esm.js';
|
|
10
|
+
import { d as defineCustomElement$1 } from './viewer-measurement-line.js';
|
|
11
|
+
|
|
12
|
+
function translateWorldLineToViewport(line, params) {
|
|
13
|
+
const { camera, viewport } = params;
|
|
14
|
+
const isStartBehindCamera = camera.isPointBehindNear(line.start);
|
|
15
|
+
const isEndBehindCamera = camera.isPointBehindNear(line.end);
|
|
16
|
+
// If either the start or end of the line is behind the camera, then we need
|
|
17
|
+
// to truncate the line so it can be presented correctly. You cannot use a
|
|
18
|
+
// projection matrix to compute a point behind the near plane.
|
|
19
|
+
if (isStartBehindCamera || isEndBehindCamera) {
|
|
20
|
+
const pt = camera.intersectLineWithNear(line);
|
|
21
|
+
const newLine = line3.create({
|
|
22
|
+
start: isStartBehindCamera && pt != null ? pt : line.start,
|
|
23
|
+
end: isEndBehindCamera && pt != null ? pt : line.end,
|
|
24
|
+
});
|
|
25
|
+
const ndc = line3.transformMatrix(newLine, camera.projectionViewMatrix);
|
|
26
|
+
return {
|
|
27
|
+
start: viewport.transformVectorToViewport(ndc.start),
|
|
28
|
+
end: viewport.transformVectorToViewport(ndc.end),
|
|
29
|
+
hideStart: isStartBehindCamera,
|
|
30
|
+
hideEnd: isEndBehindCamera,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
const ndc = line3.transformMatrix(line, camera.projectionViewMatrix);
|
|
35
|
+
return {
|
|
36
|
+
start: viewport.transformVectorToViewport(ndc.start),
|
|
37
|
+
end: viewport.transformVectorToViewport(ndc.end),
|
|
38
|
+
hideStart: false,
|
|
39
|
+
hideEnd: false,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function getViewingElementPositions(line, interactingAnchor, params) {
|
|
44
|
+
const { start: startPt, end: endPt, hideStart, hideEnd, } = translateWorldLineToViewport(line, params);
|
|
45
|
+
const labelPt = point.lerp(startPt, endPt, 0.5);
|
|
46
|
+
const indicatorPt = interactingAnchor !== 'none'
|
|
47
|
+
? getIndicatorPtForAnchor(line, interactingAnchor, params)
|
|
48
|
+
: undefined;
|
|
49
|
+
return { startPt, endPt, labelPt, indicatorPt, hideStart, hideEnd };
|
|
50
|
+
}
|
|
51
|
+
function getIndicatorPtForAnchor(line, anchor, params) {
|
|
52
|
+
return params.viewport.transformWorldToViewport(anchor === 'start' ? line.start : line.end, params.camera.projectionViewMatrix);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
56
|
+
const MeasurementOverlayView = ({ overlay, viewport, camera }) => {
|
|
57
|
+
if (overlay.type === 'line') {
|
|
58
|
+
return (h(LineOverlayView, { overlay: overlay, viewport: viewport, camera: camera }));
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
return (h(DistanceVectorOverlayView, { overlay: overlay, viewport: viewport, camera: camera }));
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const LineOverlayView = ({ overlay, camera, viewport }) => {
|
|
65
|
+
const { start, end } = translateWorldLineToViewport(overlay, {
|
|
66
|
+
camera,
|
|
67
|
+
viewport,
|
|
68
|
+
});
|
|
69
|
+
return (h("vertex-viewer-measurement-line", { class: "measurement-line", start: start, end: end }));
|
|
70
|
+
};
|
|
71
|
+
const DistanceVectorOverlayView = ({ overlay: { x, y, z }, camera, viewport }) => {
|
|
72
|
+
const params = { camera, viewport };
|
|
73
|
+
const { start: xs, end: xe } = translateWorldLineToViewport(x, params);
|
|
74
|
+
const { start: ys, end: ye } = translateWorldLineToViewport(y, params);
|
|
75
|
+
const { start: zs, end: ze } = translateWorldLineToViewport(z, params);
|
|
76
|
+
return (h(Fragment, null,
|
|
77
|
+
h("vertex-viewer-measurement-line", { class: "measurement-line distance-vector-x", start: xs, end: xe }),
|
|
78
|
+
h("vertex-viewer-measurement-line", { class: "measurement-line distance-vector-y", start: ys, end: ye }),
|
|
79
|
+
h("vertex-viewer-measurement-line", { class: "measurement-line distance-vector-z", start: zs, end: ze })));
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const viewerMeasurementOverlaysCss = ":host{display:block;position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none;--viewer-measurement-overlays-x-axis-color:var(--x-axis-color);--viewer-measurement-overlays-y-axis-color:var(--y-axis-color);--viewer-measurement-overlays-z-axis-color:var(--z-axis-color)}.measurement-line{position:absolute;width:100%;height:100%}.measurement-line.distance-vector-x{--viewer-measurement-line-fill:var(\n --viewer-measurement-overlays-x-axis-color\n )}.measurement-line.distance-vector-y{--viewer-measurement-line-fill:var(\n --viewer-measurement-overlays-y-axis-color\n )}.measurement-line.distance-vector-z{--viewer-measurement-line-fill:var(\n --viewer-measurement-overlays-z-axis-color\n )}";
|
|
83
|
+
|
|
84
|
+
const ViewerMeasurementOverlays = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement$1 {
|
|
85
|
+
constructor() {
|
|
86
|
+
super();
|
|
87
|
+
this.__registerHost();
|
|
88
|
+
this.__attachShadow();
|
|
89
|
+
/**
|
|
90
|
+
* The model that contains the overlays to present.
|
|
91
|
+
*/
|
|
92
|
+
this.measurementOverlays = new MeasurementOverlayManager();
|
|
93
|
+
this.overlays = [];
|
|
94
|
+
this.updateCamera = () => {
|
|
95
|
+
var _a, _b;
|
|
96
|
+
this.camera = (_b = (_a = this.viewer) === null || _a === void 0 ? void 0 : _a.frame) === null || _b === void 0 ? void 0 : _b.scene.camera;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* @ignore
|
|
101
|
+
*/
|
|
102
|
+
handleMeasurementOverlaysChanged() {
|
|
103
|
+
this.removeModelListeners();
|
|
104
|
+
this.addModelListeners();
|
|
105
|
+
this.updateOverlays();
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* @ignore
|
|
109
|
+
*/
|
|
110
|
+
handleViewerChanged(newViewer, oldViewer) {
|
|
111
|
+
this.removeViewerListeners(oldViewer);
|
|
112
|
+
this.addViewerListeners();
|
|
113
|
+
this.updateCamera();
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* @ignore
|
|
117
|
+
*/
|
|
118
|
+
componentWillLoad() {
|
|
119
|
+
this.addModelListeners();
|
|
120
|
+
this.addViewerListeners();
|
|
121
|
+
this.updateOverlays();
|
|
122
|
+
this.updateCamera();
|
|
123
|
+
}
|
|
124
|
+
addModelListeners() {
|
|
125
|
+
this.onOverlaysChangedListener = this.measurementOverlays.onOverlaysChanged(() => this.updateOverlays());
|
|
126
|
+
}
|
|
127
|
+
removeModelListeners() {
|
|
128
|
+
var _a;
|
|
129
|
+
(_a = this.onOverlaysChangedListener) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
130
|
+
this.onOverlaysChangedListener = undefined;
|
|
131
|
+
}
|
|
132
|
+
addViewerListeners() {
|
|
133
|
+
var _a;
|
|
134
|
+
(_a = this.viewer) === null || _a === void 0 ? void 0 : _a.addEventListener('frameReceived', this.updateCamera);
|
|
135
|
+
}
|
|
136
|
+
removeViewerListeners(viewer) {
|
|
137
|
+
viewer === null || viewer === void 0 ? void 0 : viewer.removeEventListener('frameReceived', this.updateCamera);
|
|
138
|
+
}
|
|
139
|
+
updateOverlays() {
|
|
140
|
+
this.overlays = this.measurementOverlays.getOverlays();
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* @ignore
|
|
144
|
+
*/
|
|
145
|
+
render() {
|
|
146
|
+
return (h(Host, null, this.overlays.map((overlay) => {
|
|
147
|
+
if (this.camera != null && this.viewer != null) {
|
|
148
|
+
return (h(MeasurementOverlayView, { overlay: overlay, viewport: this.viewer.viewport, camera: this.camera }));
|
|
149
|
+
}
|
|
150
|
+
})));
|
|
151
|
+
}
|
|
152
|
+
static get watchers() { return {
|
|
153
|
+
"measurementOverlays": ["handleMeasurementOverlaysChanged"],
|
|
154
|
+
"viewer": ["handleViewerChanged"]
|
|
155
|
+
}; }
|
|
156
|
+
static get style() { return viewerMeasurementOverlaysCss; }
|
|
157
|
+
}, [1, "vertex-viewer-measurement-overlays", {
|
|
158
|
+
"measurementOverlays": [16],
|
|
159
|
+
"camera": [1040],
|
|
160
|
+
"viewer": [16],
|
|
161
|
+
"overlays": [32]
|
|
162
|
+
}]);
|
|
163
|
+
function defineCustomElement() {
|
|
164
|
+
if (typeof customElements === "undefined") {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
const components = ["vertex-viewer-measurement-overlays", "vertex-viewer-measurement-line"];
|
|
168
|
+
components.forEach(tagName => { switch (tagName) {
|
|
169
|
+
case "vertex-viewer-measurement-overlays":
|
|
170
|
+
if (!customElements.get(tagName)) {
|
|
171
|
+
customElements.define(tagName, ViewerMeasurementOverlays);
|
|
172
|
+
}
|
|
173
|
+
break;
|
|
174
|
+
case "vertex-viewer-measurement-line":
|
|
175
|
+
if (!customElements.get(tagName)) {
|
|
176
|
+
defineCustomElement$1();
|
|
177
|
+
}
|
|
178
|
+
break;
|
|
179
|
+
} });
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export { ViewerMeasurementOverlays as V, defineCustomElement as d, getViewingElementPositions as g };
|
|
183
|
+
|
|
184
|
+
//# sourceMappingURL=viewer-measurement-overlays.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"viewer-measurement-overlays.js","mappings":";;;;;;;;;;;SAoBgB,4BAA4B,CAC1C,IAAiB,EACjB,MAAoB;EAOpB,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;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C,CAAC,OAAO;MACzB,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,EAAE;QAC9C,QACE,EAAC,sBAAsB,IACrB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,EAC9B,MAAM,EAAE,IAAI,CAAC,MAAM,GACnB,EACF;OACH;KACF,CAAC,CACG,EACP;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["Line3","Point"],"sources":["./src/components/viewer-measurement-distance/utils.ts","./src/components/viewer-measurement-overlays/viewer-measurement-overlays-components.tsx","./src/components/viewer-measurement-overlays/viewer-measurement-overlays.css?tag=vertex-viewer-measurement-overlays&encapsulation=shadow","./src/components/viewer-measurement-overlays/viewer-measurement-overlays.tsx"],"sourcesContent":["import { Line3, Point } from '@vertexvis/geometry';\n\nimport { FrameCameraBase, Viewport } from '../../lib/types';\n\nexport type Anchor = 'start' | 'end';\n\nexport interface MeasurementElementPositions {\n startPt?: Point.Point;\n endPt?: Point.Point;\n labelPt?: Point.Point;\n indicatorPt?: Point.Point;\n hideStart?: boolean;\n hideEnd?: boolean;\n}\n\nexport interface RenderParams {\n viewport: Viewport;\n camera: FrameCameraBase;\n}\n\nexport function translateWorldLineToViewport(\n line: Line3.Line3,\n params: RenderParams\n): {\n start: Point.Point;\n end: Point.Point;\n hideStart: boolean;\n hideEnd: boolean;\n} {\n const { camera, viewport } = params;\n\n const isStartBehindCamera = camera.isPointBehindNear(line.start);\n const isEndBehindCamera = camera.isPointBehindNear(line.end);\n\n // If either the start or end of the line is behind the camera, then we need\n // to truncate the line so it can be presented correctly. You cannot use a\n // projection matrix to compute a point behind the near plane.\n if (isStartBehindCamera || isEndBehindCamera) {\n const pt = camera.intersectLineWithNear(line);\n const newLine = Line3.create({\n start: isStartBehindCamera && pt != null ? pt : line.start,\n end: isEndBehindCamera && pt != null ? pt : line.end,\n });\n\n const ndc = Line3.transformMatrix(newLine, camera.projectionViewMatrix);\n return {\n start: viewport.transformVectorToViewport(ndc.start),\n end: viewport.transformVectorToViewport(ndc.end),\n hideStart: isStartBehindCamera,\n hideEnd: isEndBehindCamera,\n };\n } else {\n const ndc = Line3.transformMatrix(line, camera.projectionViewMatrix);\n return {\n start: viewport.transformVectorToViewport(ndc.start),\n end: viewport.transformVectorToViewport(ndc.end),\n hideStart: false,\n hideEnd: false,\n };\n }\n}\n\nexport function getViewingElementPositions(\n line: Line3.Line3,\n interactingAnchor: Anchor | 'none',\n params: RenderParams\n): MeasurementElementPositions {\n const {\n start: startPt,\n end: endPt,\n hideStart,\n hideEnd,\n } = translateWorldLineToViewport(line, params);\n const labelPt = Point.lerp(startPt, endPt, 0.5);\n const indicatorPt =\n interactingAnchor !== 'none'\n ? getIndicatorPtForAnchor(line, interactingAnchor, params)\n : undefined;\n\n return { startPt, endPt, labelPt, indicatorPt, hideStart, hideEnd };\n}\n\nexport function isVertexViewerDistanceMeasurement(\n el: unknown\n): el is HTMLVertexViewerMeasurementDistanceElement {\n return (\n el instanceof HTMLElement &&\n el.nodeName === 'VERTEX-VIEWER-MEASUREMENT-DISTANCE'\n );\n}\n\nfunction getIndicatorPtForAnchor(\n line: Line3.Line3,\n anchor: Anchor,\n params: RenderParams\n): Point.Point {\n return params.viewport.transformWorldToViewport(\n anchor === 'start' ? line.start : line.end,\n params.camera.projectionViewMatrix\n );\n}\n","// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { Fragment, FunctionalComponent, h } from '@stencil/core';\n\nimport {\n DistanceVectorOverlay,\n LineOverlay,\n MeasurementOverlay,\n} from '../../lib/measurement';\nimport { FrameCameraBase, Viewport } from '../../lib/types';\nimport {\n RenderParams,\n translateWorldLineToViewport,\n} from '../viewer-measurement-distance/utils';\n\ninterface MeasurementOverlayViewProps<O extends MeasurementOverlay> {\n overlay: O;\n viewport: Viewport;\n camera: FrameCameraBase;\n}\n\nexport const MeasurementOverlayView: FunctionalComponent<\n MeasurementOverlayViewProps<MeasurementOverlay>\n> = ({ overlay, viewport, camera }) => {\n if (overlay.type === 'line') {\n return (\n <LineOverlayView overlay={overlay} viewport={viewport} camera={camera} />\n );\n } else {\n return (\n <DistanceVectorOverlayView\n overlay={overlay}\n viewport={viewport}\n camera={camera}\n />\n );\n }\n};\n\nconst LineOverlayView: FunctionalComponent<\n MeasurementOverlayViewProps<LineOverlay>\n> = ({ overlay, camera, viewport }) => {\n const { start, end } = translateWorldLineToViewport(overlay, {\n camera,\n viewport,\n });\n\n return (\n <vertex-viewer-measurement-line\n class=\"measurement-line\"\n start={start}\n end={end}\n />\n );\n};\n\nconst DistanceVectorOverlayView: FunctionalComponent<\n MeasurementOverlayViewProps<DistanceVectorOverlay>\n> = ({ overlay: { x, y, z }, camera, viewport }) => {\n const params: RenderParams = { camera, viewport };\n\n const { start: xs, end: xe } = translateWorldLineToViewport(x, params);\n const { start: ys, end: ye } = translateWorldLineToViewport(y, params);\n const { start: zs, end: ze } = translateWorldLineToViewport(z, params);\n\n return (\n <Fragment>\n <vertex-viewer-measurement-line\n class=\"measurement-line distance-vector-x\"\n start={xs}\n end={xe}\n />\n <vertex-viewer-measurement-line\n class=\"measurement-line distance-vector-y\"\n start={ys}\n end={ye}\n />\n <vertex-viewer-measurement-line\n class=\"measurement-line distance-vector-z\"\n start={zs}\n end={ze}\n />\n </Fragment>\n );\n};\n",":host {\n display: block;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n pointer-events: none;\n\n /**\n * @prop --viewer-measurement-overlays-x-axis-color: A CSS color for overlays\n * representing the X axis.\n */\n --viewer-measurement-overlays-x-axis-color: var(--x-axis-color);\n\n /**\n * @prop --viewer-measurement-overlays-y-axis-color: A CSS color for overlays\n * representing the Y axis.\n */\n --viewer-measurement-overlays-y-axis-color: var(--y-axis-color);\n\n /**\n * @prop --viewer-measurement-overlays-z-axis-color: A CSS color for overlays\n * representing the Z axis.\n */\n --viewer-measurement-overlays-z-axis-color: var(--z-axis-color);\n}\n\n.measurement-line {\n position: absolute;\n width: 100%;\n height: 100%;\n}\n\n.measurement-line.distance-vector-x {\n --viewer-measurement-line-fill: var(\n --viewer-measurement-overlays-x-axis-color\n );\n}\n\n.measurement-line.distance-vector-y {\n --viewer-measurement-line-fill: var(\n --viewer-measurement-overlays-y-axis-color\n );\n}\n\n.measurement-line.distance-vector-z {\n --viewer-measurement-line-fill: var(\n --viewer-measurement-overlays-z-axis-color\n );\n}\n","/* eslint-disable @typescript-eslint/member-ordering */\nimport { Component, h, Host, Prop, State, Watch } from '@stencil/core';\nimport { Disposable } from '@vertexvis/utils';\n\nimport {\n MeasurementOverlay,\n MeasurementOverlayManager,\n} from '../../lib/measurement';\nimport { FrameCameraBase } from '../../lib/types';\nimport { MeasurementOverlayView } from './viewer-measurement-overlays-components';\n\n@Component({\n tag: 'vertex-viewer-measurement-overlays',\n styleUrl: 'viewer-measurement-overlays.css',\n shadow: true,\n})\nexport class ViewerMeasurementOverlays {\n /**\n * The model that contains the overlays to present.\n */\n @Prop()\n public measurementOverlays = new MeasurementOverlayManager();\n\n private onOverlaysChangedListener?: Disposable;\n\n /**\n * @ignore\n */\n @Watch('measurementOverlays')\n protected handleMeasurementOverlaysChanged(): void {\n this.removeModelListeners();\n this.addModelListeners();\n\n this.updateOverlays();\n }\n\n /**\n * @internal\n */\n @Prop({ mutable: true })\n public camera?: FrameCameraBase;\n\n /**\n * The viewer that this component is bound to.\n */\n @Prop()\n public viewer?: HTMLVertexViewerElement;\n\n /**\n * @ignore\n */\n @Watch('viewer')\n protected handleViewerChanged(\n newViewer?: HTMLVertexViewerElement,\n oldViewer?: HTMLVertexViewerElement\n ): void {\n this.removeViewerListeners(oldViewer);\n this.addViewerListeners();\n\n this.updateCamera();\n }\n\n @State()\n private overlays: MeasurementOverlay[] = [];\n\n /**\n * @ignore\n */\n protected componentWillLoad(): void {\n this.addModelListeners();\n this.addViewerListeners();\n\n this.updateOverlays();\n this.updateCamera();\n }\n\n private addModelListeners(): void {\n this.onOverlaysChangedListener = this.measurementOverlays.onOverlaysChanged(\n () => this.updateOverlays()\n );\n }\n\n private removeModelListeners(): void {\n this.onOverlaysChangedListener?.dispose();\n this.onOverlaysChangedListener = undefined;\n }\n\n private addViewerListeners(): void {\n this.viewer?.addEventListener('frameReceived', this.updateCamera);\n }\n\n private removeViewerListeners(viewer?: HTMLVertexViewerElement): void {\n viewer?.removeEventListener('frameReceived', this.updateCamera);\n }\n\n private updateCamera = (): void => {\n this.camera = this.viewer?.frame?.scene.camera;\n };\n\n private updateOverlays(): void {\n this.overlays = this.measurementOverlays.getOverlays();\n }\n\n /**\n * @ignore\n */\n protected render(): h.JSX.IntrinsicElements {\n return (\n <Host>\n {this.overlays.map((overlay) => {\n if (this.camera != null && this.viewer != null) {\n return (\n <MeasurementOverlayView\n overlay={overlay}\n viewport={this.viewer.viewport}\n camera={this.camera}\n />\n );\n }\n })}\n </Host>\n );\n }\n}\n"],"version":3}
|