@vertexvis/viewer 0.10.2-canary.7 → 0.11.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/cjs/{browser.esm-ae55f058.js → browser.esm-17419694.js} +25 -25
- package/dist/cjs/{bundle.esm-c457ad4d.js → bundle.esm-b79513ef.js} +231 -207
- package/dist/cjs/{constants-4277684a.js → constants-1d65ed39.js} +1 -1
- package/dist/cjs/{cursors-b93b43ef.js → cursors-8aaf500f.js} +1 -1
- package/dist/cjs/{dom-cdb50ebc.js → dom-40804039.js} +1 -1
- package/dist/cjs/index.cjs.js +8 -7
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{markup-3dac4cef.js → markup-e84a143f.js} +11 -2
- package/dist/cjs/{measurement-b494bf55.js → measurement-4579193b.js} +2 -2
- package/dist/cjs/{orientation-42cc9e8d.js → orientation-09d0f3ef.js} +14 -7
- package/dist/cjs/{png-decoder-2add73dd.js → png-decoder-97ea96ba.js} +3 -3
- package/dist/cjs/{scene-23a0a330.js → scene-4397373a.js} +28524 -2446
- package/dist/cjs/{utils-6933381f.js → utils-414e6cfe.js} +2 -2
- package/dist/cjs/utils-440f0f7d.js +61 -0
- package/dist/cjs/vertex-scene-tree.cjs.entry.js +6 -5
- package/dist/cjs/vertex-viewer-dom-element_3.cjs.entry.js +4 -4
- package/dist/cjs/{vertex-viewer-markup-arrow_2.cjs.entry.js → vertex-viewer-markup-arrow_3.cjs.entry.js} +267 -4
- package/dist/cjs/vertex-viewer-markup-tool.cjs.entry.js +43 -9
- package/dist/cjs/vertex-viewer-markup.cjs.entry.js +25 -5
- package/dist/cjs/vertex-viewer-measurement-distance_2.cjs.entry.js +8 -8
- package/dist/cjs/vertex-viewer-measurement-tool.cjs.entry.js +5 -5
- package/dist/cjs/vertex-viewer-measurements.cjs.entry.js +5 -5
- package/dist/cjs/vertex-viewer-view-cube.cjs.entry.js +3 -3
- package/dist/cjs/vertex-viewer.cjs.entry.js +141 -48
- package/dist/cjs/viewer.cjs.js +1 -1
- package/dist/cjs/{viewport-e69f8223.js → viewport-fc405a48.js} +31 -7
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/scene-tree/scene-tree.js +3 -2
- package/dist/collection/components/viewer/viewer.js +28 -3
- package/dist/collection/components/viewer-markup/utils.js +65 -1
- package/dist/collection/components/viewer-markup/viewer-markup.js +72 -16
- package/dist/collection/components/viewer-markup-circle/utils.js +2 -55
- package/dist/collection/components/viewer-markup-circle/viewer-markup-circle.js +4 -4
- package/dist/collection/components/viewer-markup-freeform.tsx/utils.js +10 -0
- package/dist/collection/components/viewer-markup-freeform.tsx/viewer-markup-freeform.css +157 -0
- package/dist/collection/components/viewer-markup-freeform.tsx/viewer-markup-freeform.js +413 -0
- package/dist/collection/components/viewer-markup-tool/viewer-markup-tool.js +63 -9
- package/dist/collection/components/viewer-measurement-distance/viewer-measurement-distance-components.js +1 -1
- package/dist/collection/components/viewer-measurement-distance/viewer-measurement-distance.js +2 -2
- package/dist/collection/lib/cursors.js +1 -1
- package/dist/collection/lib/interactions/baseInteractionHandler.js +5 -4
- package/dist/collection/lib/interactions/flyToPartKeyInteraction.js +1 -1
- package/dist/collection/lib/interactions/interactionApi.js +101 -22
- package/dist/collection/lib/interactions/mouseInteractions.js +17 -15
- package/dist/collection/lib/interactions/multiTouchInteractionHandler.js +2 -2
- package/dist/collection/lib/mappers.js +4 -3
- package/dist/collection/lib/scenes/camera.js +8 -2
- package/dist/collection/lib/scenes/operations.js +1 -1
- package/dist/collection/lib/scenes/scene.js +5 -2
- package/dist/collection/lib/types/frame.js +8 -2
- package/dist/collection/lib/types/markup.js +9 -1
- package/dist/collection/lib/types/stencilBuffer.js +2 -2
- package/dist/collection/lib/types/viewport.js +32 -8
- package/dist/collection/testing/fixtures.js +2 -1
- package/dist/esm/{browser.esm-7dbdf78a.js → browser.esm-e4fb17dc.js} +25 -25
- package/dist/esm/{bundle.esm-590d2273.js → bundle.esm-d891316f.js} +232 -208
- package/dist/esm/{constants-083f6b2c.js → constants-037e417f.js} +1 -1
- package/dist/esm/{cursors-39294365.js → cursors-00835249.js} +1 -1
- package/dist/esm/{dom-43682375.js → dom-d0877f90.js} +1 -1
- package/dist/esm/index.js +7 -7
- package/dist/esm/index.mjs +7 -7
- package/dist/esm/loader.js +1 -1
- package/dist/esm/loader.mjs +1 -1
- package/dist/esm/{markup-3ce3dccd.js → markup-9b29aa94.js} +11 -3
- package/dist/esm/{measurement-78bd27fc.js → measurement-8430d5d6.js} +2 -2
- package/dist/esm/{orientation-c3e2af18.js → orientation-bb34b652.js} +14 -7
- package/dist/esm/{png-decoder-dfb97536.js → png-decoder-c4745070.js} +3 -3
- package/dist/esm/{scene-30ac6229.js → scene-72760305.js} +28532 -2454
- package/dist/esm/utils-5fe43b8a.js +52 -0
- package/dist/esm/{utils-b857bd7c.js → utils-f8e0baf7.js} +2 -2
- package/dist/esm/vertex-scene-tree.entry.js +6 -5
- package/dist/esm/vertex-viewer-dom-element_3.entry.js +4 -4
- package/dist/esm/{vertex-viewer-markup-arrow_2.entry.js → vertex-viewer-markup-arrow_3.entry.js} +267 -5
- package/dist/esm/vertex-viewer-markup-tool.entry.js +43 -9
- package/dist/esm/vertex-viewer-markup.entry.js +25 -5
- package/dist/esm/vertex-viewer-measurement-distance_2.entry.js +8 -8
- package/dist/esm/vertex-viewer-measurement-tool.entry.js +5 -5
- package/dist/esm/vertex-viewer-measurements.entry.js +5 -5
- package/dist/esm/vertex-viewer-view-cube.entry.js +3 -3
- package/dist/esm/vertex-viewer.entry.js +141 -48
- package/dist/esm/viewer.js +1 -1
- package/dist/esm/{viewport-8fea0743.js → viewport-d6f5cd7b.js} +31 -7
- package/dist/types/components/viewer/viewer.d.ts +4 -0
- package/dist/types/components/viewer-markup/utils.d.ts +8 -0
- package/dist/types/components/viewer-markup/viewer-markup.d.ts +13 -6
- package/dist/types/components/viewer-markup-circle/utils.d.ts +1 -4
- package/dist/types/components/viewer-markup-freeform.tsx/utils.d.ts +3 -0
- package/dist/types/components/viewer-markup-freeform.tsx/viewer-markup-freeform.d.ts +116 -0
- package/dist/types/components/viewer-markup-tool/viewer-markup-tool.d.ts +13 -1
- package/dist/types/components.d.ts +107 -10
- package/dist/types/lib/interactions/interactionApi.d.ts +22 -6
- package/dist/types/lib/interactions/mouseInteractions.d.ts +7 -6
- package/dist/types/lib/scenes/camera.d.ts +5 -1
- package/dist/types/lib/scenes/scene.d.ts +1 -1
- package/dist/types/lib/types/frame.d.ts +4 -1
- package/dist/types/lib/types/markup.d.ts +12 -1
- package/dist/types/lib/types/viewport.d.ts +17 -0
- package/dist/viewer/index.esm.js +1 -1
- package/dist/viewer/p-012fb54f.js +4 -0
- package/dist/viewer/{p-3dc15d99.entry.js → p-117324c0.entry.js} +1 -1
- package/dist/viewer/{p-1ee75110.entry.js → p-1c772ec1.entry.js} +1 -1
- package/dist/viewer/p-1f8a238b.js +4 -0
- package/dist/viewer/p-21e8510d.js +4 -0
- package/dist/viewer/{p-e3105f9a.entry.js → p-3c2aff67.entry.js} +1 -1
- package/dist/viewer/p-5389e9d4.js +4 -0
- package/dist/viewer/p-59d075d4.js +17 -0
- package/dist/viewer/{p-5b078339.js → p-62c6f482.js} +1 -1
- package/dist/viewer/p-640cb5f8.js +18 -0
- package/dist/viewer/p-68aaf1f8.entry.js +4 -0
- package/dist/viewer/{p-05b2444e.js → p-75682963.js} +1 -1
- package/dist/viewer/{p-4183c421.entry.js → p-79c45c02.entry.js} +1 -1
- package/dist/viewer/p-835e158e.js +4 -0
- package/dist/viewer/p-8c255868.entry.js +4 -0
- package/dist/viewer/{p-f4a492e1.js → p-9faabd97.js} +1 -1
- package/dist/viewer/p-b122ee39.js +4 -0
- package/dist/viewer/p-b36b3d1a.js +4 -0
- package/dist/viewer/{p-7c71db57.entry.js → p-bc9e6919.entry.js} +1 -1
- package/dist/viewer/{p-f090a3f3.entry.js → p-c818c80e.entry.js} +1 -1
- package/dist/viewer/{p-e96bc9a2.js → p-d42a482c.js} +1 -1
- package/dist/viewer/p-f43e8cc2.entry.js +4 -0
- package/dist/viewer/p-f75436be.entry.js +4 -0
- package/dist/viewer/viewer.esm.js +1 -1
- package/package.json +18 -16
- package/readme.md +6 -6
- package/dist/cjs/utils-96f244e1.js +0 -104
- package/dist/esm/utils-a550c58f.js +0 -96
- package/dist/viewer/p-11bdd2c4.js +0 -4
- package/dist/viewer/p-14182324.entry.js +0 -4
- package/dist/viewer/p-2768474e.js +0 -4
- package/dist/viewer/p-2e11803d.js +0 -4
- package/dist/viewer/p-6d4ab5fc.js +0 -17
- package/dist/viewer/p-964642c6.js +0 -4
- package/dist/viewer/p-9e856d0a.entry.js +0 -4
- package/dist/viewer/p-a717d9ff.js +0 -4
- package/dist/viewer/p-a9434d8e.entry.js +0 -4
- package/dist/viewer/p-af806858.js +0 -4
- package/dist/viewer/p-b5c350a7.js +0 -4
- package/dist/viewer/p-d912dd24.js +0 -18
- package/dist/viewer/p-f6d75616.entry.js +0 -4
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**!
|
|
2
|
+
* Copyright (c) 2021 Vertex Software LLC. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { p as point, n as matrix, k as angle, g as rectangle } from './bundle.esm-d891316f.js';
|
|
5
|
+
|
|
6
|
+
function createArrowheadPoints(start, end, arrowAngle = 60) {
|
|
7
|
+
const distance = point.distance(start, end);
|
|
8
|
+
const angle$1 = angle.normalize(angle.toDegrees(angle.fromPoints(start, end)) - 270);
|
|
9
|
+
// Adjust the arrow height in relation to the distance between the to and from
|
|
10
|
+
// points. Uses a min and max size so the arrow doesn't become cartoonish.
|
|
11
|
+
const height = Math.max(4, Math.min(16, distance * 0.25));
|
|
12
|
+
const sideLength = height / Math.cos(angle.toRadians(90 - arrowAngle));
|
|
13
|
+
const rotation = matrix.rotation(angle$1);
|
|
14
|
+
const arrowLeft = point.polar(sideLength, angle.toRadians(arrowAngle * 2));
|
|
15
|
+
const arrowRight = point.polar(sideLength, angle.toRadians(arrowAngle));
|
|
16
|
+
const arrowBase = point.polar(height, angle.toRadians(90));
|
|
17
|
+
return {
|
|
18
|
+
tip: end,
|
|
19
|
+
left: point.add(end, matrix.transformPoint(rotation, arrowLeft)),
|
|
20
|
+
right: point.add(end, matrix.transformPoint(rotation, arrowRight)),
|
|
21
|
+
base: point.add(end, matrix.transformPoint(rotation, arrowBase)),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function arrowheadPointsToPolygonPoints(points) {
|
|
25
|
+
return [points.tip, points.right, points.base, points.left]
|
|
26
|
+
.map((pt) => `${pt.x},${pt.y}`)
|
|
27
|
+
.join(' ');
|
|
28
|
+
}
|
|
29
|
+
function isVertexViewerArrowMarkup(el) {
|
|
30
|
+
return (el instanceof HTMLElement && el.nodeName === 'VERTEX-VIEWER-MARKUP-ARROW');
|
|
31
|
+
}
|
|
32
|
+
function parsePoint(value) {
|
|
33
|
+
return typeof value === 'string' ? point.fromJson(value) : value;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function isVertexViewerCircleMarkup(el) {
|
|
37
|
+
return (el instanceof HTMLElement && el.nodeName === 'VERTEX-VIEWER-MARKUP-CIRCLE');
|
|
38
|
+
}
|
|
39
|
+
function parseBounds(value) {
|
|
40
|
+
return typeof value === 'string' ? rectangle.fromJson(value) : value;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function parsePoints(value) {
|
|
44
|
+
return typeof value === 'string'
|
|
45
|
+
? JSON.parse(value).map((values) => point.fromJson(JSON.stringify(values)))
|
|
46
|
+
: value;
|
|
47
|
+
}
|
|
48
|
+
function isVertexViewerFreeformMarkup(el) {
|
|
49
|
+
return (el instanceof HTMLElement && el.nodeName === 'VERTEX-VIEWER-MARKUP-FREEFORM');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { isVertexViewerCircleMarkup as a, isVertexViewerFreeformMarkup as b, createArrowheadPoints as c, arrowheadPointsToPolygonPoints as d, parseBounds as e, parsePoints as f, isVertexViewerArrowMarkup as i, parsePoint as p };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**!
|
|
2
2
|
* Copyright (c) 2021 Vertex Software LLC. All rights reserved.
|
|
3
3
|
*/
|
|
4
|
-
import { o as objects, c as color } from './browser.esm-
|
|
5
|
-
import './orientation-
|
|
4
|
+
import { o as objects, c as color } from './browser.esm-e4fb17dc.js';
|
|
5
|
+
import './orientation-bb34b652.js';
|
|
6
6
|
|
|
7
7
|
const defaultFlags = {
|
|
8
8
|
throttleFrameDelivery: true,
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* Copyright (c) 2021 Vertex Software LLC. All rights reserved.
|
|
3
3
|
*/
|
|
4
4
|
import { r as registerInstance, c as createEvent, f as forceUpdate, h, H as Host, g as getElement } from './index-8d7400a7.js';
|
|
5
|
-
import {
|
|
5
|
+
import { j as __rest } from './bundle.esm-d891316f.js';
|
|
6
6
|
import { a as commonjsGlobal, c as createCommonjsModule } from './_commonjsHelpers-9943807e.js';
|
|
7
|
-
import { E as EventDispatcher } from './browser.esm-
|
|
8
|
-
import { g as getElementBoundingClientRect, p as parseConfig } from './utils-
|
|
7
|
+
import { E as EventDispatcher } from './browser.esm-e4fb17dc.js';
|
|
8
|
+
import { g as getElementBoundingClientRect, p as parseConfig } from './utils-f8e0baf7.js';
|
|
9
9
|
import { w as writeDOM, r as readDOM } from './stencil-540d92eb.js';
|
|
10
|
-
import './orientation-
|
|
10
|
+
import './orientation-bb34b652.js';
|
|
11
11
|
|
|
12
12
|
window.requestIdleCallback =
|
|
13
13
|
window.requestIdleCallback ||
|
|
@@ -9392,7 +9392,8 @@ const SceneTree = class {
|
|
|
9392
9392
|
(_a = this.stateMap.viewerDisposable) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
9393
9393
|
}
|
|
9394
9394
|
if (newViewer != null) {
|
|
9395
|
-
this.stateMap.viewerDisposable =
|
|
9395
|
+
this.stateMap.viewerDisposable =
|
|
9396
|
+
(_b = this.controller) === null || _b === void 0 ? void 0 : _b.connectToViewer(newViewer);
|
|
9396
9397
|
}
|
|
9397
9398
|
}
|
|
9398
9399
|
/**
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Copyright (c) 2021 Vertex Software LLC. All rights reserved.
|
|
3
3
|
*/
|
|
4
4
|
import { r as registerInstance, h, H as Host, g as getElement } from './index-8d7400a7.js';
|
|
5
|
-
import { v as vector3, q as quaternion, m as matrix4, s as euler } from './bundle.esm-
|
|
6
|
-
import './orientation-
|
|
7
|
-
import { V as Viewport } from './viewport-
|
|
8
|
-
import './browser.esm-
|
|
5
|
+
import { v as vector3, q as quaternion, m as matrix4, s as euler } from './bundle.esm-d891316f.js';
|
|
6
|
+
import './orientation-bb34b652.js';
|
|
7
|
+
import { V as Viewport } from './viewport-d6f5cd7b.js';
|
|
8
|
+
import './browser.esm-e4fb17dc.js';
|
|
9
9
|
|
|
10
10
|
const viewerDomElementCss = ":host{position:absolute;pointer-events:none}:host(:not([interactions-off]))>*{pointer-events:auto}";
|
|
11
11
|
|
package/dist/esm/{vertex-viewer-markup-arrow_2.entry.js → vertex-viewer-markup-arrow_3.entry.js}
RENAMED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Copyright (c) 2021 Vertex Software LLC. All rights reserved.
|
|
3
3
|
*/
|
|
4
4
|
import { h, r as registerInstance, c as createEvent, H as Host, g as getElement } from './index-8d7400a7.js';
|
|
5
|
-
import {
|
|
6
|
-
import { g as getMouseClientPosition } from './dom-
|
|
7
|
-
import { p as parsePoint, c as createArrowheadPoints,
|
|
5
|
+
import { k as angle, p as point, f as dimensions, g as rectangle } from './bundle.esm-d891316f.js';
|
|
6
|
+
import { g as getMouseClientPosition } from './dom-d0877f90.js';
|
|
7
|
+
import { p as parsePoint, c as createArrowheadPoints, d as arrowheadPointsToPolygonPoints, e as parseBounds, f as parsePoints } from './utils-5fe43b8a.js';
|
|
8
8
|
import { c as classnames } from './index-455380d0.js';
|
|
9
9
|
import './_commonjsHelpers-9943807e.js';
|
|
10
10
|
|
|
@@ -115,6 +115,66 @@ function translatePointToRelative(pt, canvasDimensions) {
|
|
|
115
115
|
const scaleFactor = toRelativeScaleFactor(canvasDimensions);
|
|
116
116
|
return point.scale(point.subtract(pt, dimensions.center(canvasDimensions)), scaleFactor, scaleFactor);
|
|
117
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Translates a set of points in relative `original` units to
|
|
120
|
+
* points in relative `bounds` units.
|
|
121
|
+
*/
|
|
122
|
+
function translatePointsToBounds(points, original, bounds) {
|
|
123
|
+
return points.map((pt) => point.add(point.scale(point.subtract(pt, original), bounds.width / (original.width || 1), bounds.height / (original.height || 1)), bounds));
|
|
124
|
+
}
|
|
125
|
+
function createRectangle(initialPoint, currentPoint, maintainAspectRatio) {
|
|
126
|
+
const bounds = rectangle.fromPoints(initialPoint, currentPoint);
|
|
127
|
+
if (maintainAspectRatio) {
|
|
128
|
+
const fitBoundsSize = Math.max(bounds.width, bounds.height);
|
|
129
|
+
const isPortrait = bounds.height > bounds.width;
|
|
130
|
+
const currentIsLeftOfInitial = currentPoint.x <= initialPoint.x;
|
|
131
|
+
const currentIsAboveInitial = currentPoint.y <= initialPoint.y;
|
|
132
|
+
const fitBoundsX = currentIsLeftOfInitial
|
|
133
|
+
? isPortrait
|
|
134
|
+
? initialPoint.x - fitBoundsSize
|
|
135
|
+
: currentPoint.x
|
|
136
|
+
: initialPoint.x;
|
|
137
|
+
const fitBoundsY = currentIsAboveInitial
|
|
138
|
+
? isPortrait
|
|
139
|
+
? currentPoint.y
|
|
140
|
+
: initialPoint.y - fitBoundsSize
|
|
141
|
+
: initialPoint.y;
|
|
142
|
+
return rectangle.create(fitBoundsX, fitBoundsY, fitBoundsSize, fitBoundsSize);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
return bounds;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function transformRectangle(bounds, start, current, anchor, maintainAspectRatio) {
|
|
149
|
+
const delta = point.subtract(current, start);
|
|
150
|
+
const { x: left, y: top, width: w, height: h } = bounds;
|
|
151
|
+
const right = left + w;
|
|
152
|
+
const bottom = top + h;
|
|
153
|
+
const topLeft = point.create(left, top);
|
|
154
|
+
const bottomLeft = point.create(left, bottom);
|
|
155
|
+
const topRight = point.create(right, top);
|
|
156
|
+
const bottomRight = point.create(right, bottom);
|
|
157
|
+
switch (anchor) {
|
|
158
|
+
case 'top-left':
|
|
159
|
+
return createRectangle(bottomRight, current, !!maintainAspectRatio);
|
|
160
|
+
case 'top':
|
|
161
|
+
return createRectangle(bottomRight, point.create(left, current.y), !!maintainAspectRatio);
|
|
162
|
+
case 'top-right':
|
|
163
|
+
return createRectangle(bottomLeft, current, !!maintainAspectRatio);
|
|
164
|
+
case 'right':
|
|
165
|
+
return createRectangle(bottomLeft, point.create(current.x, top), !!maintainAspectRatio);
|
|
166
|
+
case 'bottom-right':
|
|
167
|
+
return createRectangle(topLeft, current, !!maintainAspectRatio);
|
|
168
|
+
case 'bottom':
|
|
169
|
+
return createRectangle(topLeft, point.create(right, current.y), !!maintainAspectRatio);
|
|
170
|
+
case 'bottom-left':
|
|
171
|
+
return createRectangle(topRight, current, !!maintainAspectRatio);
|
|
172
|
+
case 'left':
|
|
173
|
+
return createRectangle(bottomRight, point.create(current.x, top), !!maintainAspectRatio);
|
|
174
|
+
case 'center':
|
|
175
|
+
return rectangle.create(bounds.x + delta.x, bounds.y + delta.y, bounds.width, bounds.height);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
118
178
|
|
|
119
179
|
function getMarkupBoundingClientRect(element) {
|
|
120
180
|
return element.getBoundingClientRect();
|
|
@@ -330,7 +390,7 @@ const ViewerMarkupCircle = class {
|
|
|
330
390
|
this.startPosition != null &&
|
|
331
391
|
this.elementBounds != null) {
|
|
332
392
|
const position = translatePointToRelative(getMouseClientPosition(event, this.elementBounds), this.elementBounds);
|
|
333
|
-
this.bounds =
|
|
393
|
+
this.bounds = transformRectangle((_a = this.resizeBounds) !== null && _a !== void 0 ? _a : this.bounds, this.startPosition, position, this.editAnchor, event.shiftKey);
|
|
334
394
|
}
|
|
335
395
|
};
|
|
336
396
|
this.startMarkup = (event) => {
|
|
@@ -440,4 +500,206 @@ const ViewerMarkupCircle = class {
|
|
|
440
500
|
};
|
|
441
501
|
ViewerMarkupCircle.style = viewerMarkupCircleCss;
|
|
442
502
|
|
|
443
|
-
|
|
503
|
+
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)}";
|
|
504
|
+
|
|
505
|
+
const ViewerMarkupFreeform = class {
|
|
506
|
+
constructor(hostRef) {
|
|
507
|
+
registerInstance(this, hostRef);
|
|
508
|
+
this.editBegin = createEvent(this, "editBegin", 7);
|
|
509
|
+
this.editEnd = createEvent(this, "editEnd", 7);
|
|
510
|
+
this.editCancel = createEvent(this, "editCancel", 7);
|
|
511
|
+
/**
|
|
512
|
+
* A mode that specifies how the markup component should behave. When
|
|
513
|
+
* unset, the component will not respond to interactions with the handles.
|
|
514
|
+
* When `edit`, the markup anchors are interactive and the user is able
|
|
515
|
+
* to reposition them. When `create`, anytime the user clicks on the canvas,
|
|
516
|
+
* a new markup will be performed.
|
|
517
|
+
*/
|
|
518
|
+
this.mode = '';
|
|
519
|
+
this.editAnchor = 'bottom-right';
|
|
520
|
+
this.screenPoints = [];
|
|
521
|
+
this.updateEditAnchor = (event, anchor) => {
|
|
522
|
+
if (this.elementBounds != null) {
|
|
523
|
+
this.resizeBounds = this.bounds;
|
|
524
|
+
this.resizePoints = this.points;
|
|
525
|
+
this.editAnchor = anchor;
|
|
526
|
+
this.resizeStartPosition = translatePointToRelative(getMouseClientPosition(event, this.elementBounds), this.elementBounds);
|
|
527
|
+
this.addEditingInteractionListeners();
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
this.updateBounds = (event) => {
|
|
531
|
+
var _a;
|
|
532
|
+
if (this.resizeStartPosition != null &&
|
|
533
|
+
this.elementBounds != null &&
|
|
534
|
+
this.resizeBounds != null &&
|
|
535
|
+
this.resizePoints != null) {
|
|
536
|
+
const position = translatePointToRelative(getMouseClientPosition(event, this.elementBounds), this.elementBounds);
|
|
537
|
+
const updatedBounds = transformRectangle(this.resizeBounds, this.resizeStartPosition, position, this.editAnchor, event.shiftKey);
|
|
538
|
+
this.points = translatePointsToBounds(this.resizePoints, this.resizeBounds, updatedBounds);
|
|
539
|
+
this.screenPoints = (_a = this.convertPointsToScreen()) !== null && _a !== void 0 ? _a : this.screenPoints;
|
|
540
|
+
this.bounds = updatedBounds;
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
this.updatePoints = (event) => {
|
|
544
|
+
if (this.points != null && this.elementBounds != null) {
|
|
545
|
+
const screenPosition = getMouseClientPosition(event, this.elementBounds);
|
|
546
|
+
const position = translatePointToRelative(screenPosition, this.elementBounds);
|
|
547
|
+
this.updateMinAndMax(position);
|
|
548
|
+
this.points = [...this.points, position];
|
|
549
|
+
this.screenPoints = [...this.screenPoints, screenPosition];
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
this.startMarkup = (event) => {
|
|
553
|
+
var _a, _b;
|
|
554
|
+
if (this.mode !== '' && this.elementBounds != null) {
|
|
555
|
+
const screenPosition = getMouseClientPosition(event, this.elementBounds);
|
|
556
|
+
const position = translatePointToRelative(screenPosition, this.elementBounds);
|
|
557
|
+
this.updateMinAndMax(position);
|
|
558
|
+
this.points = (_a = this.points) !== null && _a !== void 0 ? _a : [position];
|
|
559
|
+
this.screenPoints = (_b = this.screenPoints) !== null && _b !== void 0 ? _b : [screenPosition];
|
|
560
|
+
this.editBegin.emit();
|
|
561
|
+
this.addDrawingInteractionListeners();
|
|
562
|
+
}
|
|
563
|
+
};
|
|
564
|
+
this.endMarkup = (event) => {
|
|
565
|
+
if (this.mode !== '' &&
|
|
566
|
+
this.points != null &&
|
|
567
|
+
this.points.length > 1 &&
|
|
568
|
+
this.elementBounds != null) {
|
|
569
|
+
const screenPosition = getMouseClientPosition(event, this.elementBounds);
|
|
570
|
+
const position = translatePointToRelative(screenPosition, this.elementBounds);
|
|
571
|
+
this.updateMinAndMax(position);
|
|
572
|
+
this.points = [...this.points, position];
|
|
573
|
+
this.screenPoints = [...this.screenPoints, screenPosition];
|
|
574
|
+
this.editEnd.emit();
|
|
575
|
+
}
|
|
576
|
+
else {
|
|
577
|
+
this.points = undefined;
|
|
578
|
+
this.editCancel.emit();
|
|
579
|
+
}
|
|
580
|
+
this.min = undefined;
|
|
581
|
+
this.max = undefined;
|
|
582
|
+
this.removeDrawingInteractionListeners();
|
|
583
|
+
};
|
|
584
|
+
this.endEdit = () => {
|
|
585
|
+
this.resizeBounds = undefined;
|
|
586
|
+
this.removeEditingInteractionListeners();
|
|
587
|
+
this.editEnd.emit();
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* @ignore
|
|
592
|
+
*/
|
|
593
|
+
componentWillLoad() {
|
|
594
|
+
this.updateViewport();
|
|
595
|
+
this.handleViewerChanged(this.viewer);
|
|
596
|
+
this.updatePointsFromProps();
|
|
597
|
+
}
|
|
598
|
+
componentDidLoad() {
|
|
599
|
+
this.updatePointsFromProps();
|
|
600
|
+
const resize = new ResizeObserver(() => this.updateViewport());
|
|
601
|
+
resize.observe(this.hostEl);
|
|
602
|
+
}
|
|
603
|
+
async dispose() {
|
|
604
|
+
if (this.viewer != null) {
|
|
605
|
+
this.removeInteractionListeners(this.viewer);
|
|
606
|
+
}
|
|
607
|
+
this.removeDrawingInteractionListeners();
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* @ignore
|
|
611
|
+
*/
|
|
612
|
+
handleViewerChanged(newViewer, oldViewer) {
|
|
613
|
+
if (oldViewer != null) {
|
|
614
|
+
this.removeInteractionListeners(oldViewer);
|
|
615
|
+
}
|
|
616
|
+
if (newViewer != null) {
|
|
617
|
+
this.addInteractionListeners(newViewer);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
handlePointsJsonChange() {
|
|
621
|
+
this.updatePointsFromProps();
|
|
622
|
+
}
|
|
623
|
+
handleBoundsJsonChange() {
|
|
624
|
+
this.updatePointsFromProps();
|
|
625
|
+
}
|
|
626
|
+
updateViewport() {
|
|
627
|
+
var _a;
|
|
628
|
+
const rect = getMarkupBoundingClientRect(this.hostEl);
|
|
629
|
+
this.elementBounds = rect;
|
|
630
|
+
this.screenPoints = (_a = this.convertPointsToScreen()) !== null && _a !== void 0 ? _a : this.screenPoints;
|
|
631
|
+
}
|
|
632
|
+
updatePointsFromProps() {
|
|
633
|
+
var _a, _b, _c;
|
|
634
|
+
this.points = (_a = this.points) !== null && _a !== void 0 ? _a : parsePoints(this.pointsJson);
|
|
635
|
+
this.screenPoints = (_b = this.convertPointsToScreen()) !== null && _b !== void 0 ? _b : [];
|
|
636
|
+
this.bounds = (_c = this.bounds) !== null && _c !== void 0 ? _c : parseBounds(this.boundsJson);
|
|
637
|
+
}
|
|
638
|
+
render() {
|
|
639
|
+
if (this.screenPoints.length > 0 && this.elementBounds != null) {
|
|
640
|
+
return (h(Host, null, h("svg", { class: "svg" }, 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.updateEditAnchor(e, 'top-left'), onTopRightAnchorPointerDown: (e) => this.updateEditAnchor(e, 'top-right'), onTopAnchorPointerDown: (e) => this.updateEditAnchor(e, 'top'), onBottomLeftAnchorPointerDown: (e) => this.updateEditAnchor(e, 'bottom-left'), onBottomRightAnchorPointerDown: (e) => this.updateEditAnchor(e, 'bottom-right'), onBottomAnchorPointerDown: (e) => this.updateEditAnchor(e, 'bottom'), onLeftAnchorPointerDown: (e) => this.updateEditAnchor(e, 'left'), onRightAnchorPointerDown: (e) => this.updateEditAnchor(e, 'right'), onCenterAnchorPointerDown: (e) => this.updateEditAnchor(e, 'center') }))));
|
|
641
|
+
}
|
|
642
|
+
else {
|
|
643
|
+
return (h(Host, null, h("div", { class: "create-overlay", onPointerDown: (event) => this.startMarkup(event) })));
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
async addInteractionListeners(viewer) {
|
|
647
|
+
const interactionTarget = await viewer.getInteractionTarget();
|
|
648
|
+
if (this.mode === 'create') {
|
|
649
|
+
interactionTarget.addEventListener('pointerdown', this.startMarkup);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
async addDrawingInteractionListeners() {
|
|
653
|
+
if (this.mode !== '') {
|
|
654
|
+
window.addEventListener('pointermove', this.updatePoints);
|
|
655
|
+
window.addEventListener('pointerup', this.endMarkup);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
async addEditingInteractionListeners() {
|
|
659
|
+
if (this.mode === 'edit') {
|
|
660
|
+
window.addEventListener('pointermove', this.updateBounds);
|
|
661
|
+
window.addEventListener('pointerup', this.endEdit);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
async removeInteractionListeners(viewer) {
|
|
665
|
+
const interactionTarget = await viewer.getInteractionTarget();
|
|
666
|
+
interactionTarget.removeEventListener('pointerdown', this.startMarkup);
|
|
667
|
+
}
|
|
668
|
+
async removeDrawingInteractionListeners() {
|
|
669
|
+
window.removeEventListener('pointermove', this.updatePoints);
|
|
670
|
+
window.removeEventListener('pointerup', this.endMarkup);
|
|
671
|
+
}
|
|
672
|
+
async removeEditingInteractionListeners() {
|
|
673
|
+
if (this.mode === 'edit') {
|
|
674
|
+
window.removeEventListener('pointermove', this.updateBounds);
|
|
675
|
+
window.removeEventListener('pointerup', this.endEdit);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
updateMinAndMax(position) {
|
|
679
|
+
this.min =
|
|
680
|
+
this.min != null
|
|
681
|
+
? point.create(Math.min(this.min.x, position.x), Math.min(this.min.y, position.y))
|
|
682
|
+
: position;
|
|
683
|
+
this.max =
|
|
684
|
+
this.max != null
|
|
685
|
+
? point.create(Math.max(this.max.x, position.x), Math.max(this.max.y, position.y))
|
|
686
|
+
: position;
|
|
687
|
+
this.bounds = rectangle.create(this.min.x, this.min.y, this.max.x - this.min.x, this.max.y - this.min.y);
|
|
688
|
+
}
|
|
689
|
+
convertPointsToScreen() {
|
|
690
|
+
var _a;
|
|
691
|
+
const elementBounds = this.elementBounds;
|
|
692
|
+
if (elementBounds != null) {
|
|
693
|
+
return (_a = this.points) === null || _a === void 0 ? void 0 : _a.map((pt) => translatePointToScreen(pt, elementBounds));
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
get hostEl() { return getElement(this); }
|
|
697
|
+
static get watchers() { return {
|
|
698
|
+
"viewer": ["handleViewerChanged"],
|
|
699
|
+
"points": ["handlePointsJsonChange"],
|
|
700
|
+
"bounds": ["handleBoundsJsonChange"]
|
|
701
|
+
}; }
|
|
702
|
+
};
|
|
703
|
+
ViewerMarkupFreeform.style = viewerMarkupFreeformCss;
|
|
704
|
+
|
|
705
|
+
export { ViewerMarkupArrow as vertex_viewer_markup_arrow, ViewerMarkupCircle as vertex_viewer_markup_circle, ViewerMarkupFreeform as vertex_viewer_markup_freeform };
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-8d7400a7.js';
|
|
5
5
|
import { s as stampTemplateWithId } from './templates-022199c1.js';
|
|
6
|
-
import { a as isVertexViewerCircleMarkup, i as isVertexViewerArrowMarkup } from './utils-
|
|
7
|
-
import { C as CircleMarkup, A as ArrowMarkup } from './markup-
|
|
8
|
-
import './bundle.esm-
|
|
9
|
-
import './browser.esm-
|
|
6
|
+
import { b as isVertexViewerFreeformMarkup, a as isVertexViewerCircleMarkup, i as isVertexViewerArrowMarkup } from './utils-5fe43b8a.js';
|
|
7
|
+
import { F as FreeformMarkup, C as CircleMarkup, A as ArrowMarkup } from './markup-9b29aa94.js';
|
|
8
|
+
import './bundle.esm-d891316f.js';
|
|
9
|
+
import './browser.esm-e4fb17dc.js';
|
|
10
10
|
|
|
11
11
|
const viewerMarkupToolCss = ":host{position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none}";
|
|
12
12
|
|
|
@@ -40,7 +40,15 @@ const ViewerMarkupTool = class {
|
|
|
40
40
|
};
|
|
41
41
|
this.handleMarkupEditEnd = () => {
|
|
42
42
|
const { markupElement } = this.stateMap;
|
|
43
|
-
if (
|
|
43
|
+
if (isVertexViewerFreeformMarkup(markupElement)) {
|
|
44
|
+
const { points, bounds } = markupElement;
|
|
45
|
+
markupElement.points = undefined;
|
|
46
|
+
markupElement.bounds = undefined;
|
|
47
|
+
if (points != null && points.length > 0 && bounds != null) {
|
|
48
|
+
this.markupEnd.emit(new FreeformMarkup({ points, bounds }));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else if (isVertexViewerCircleMarkup(markupElement)) {
|
|
44
52
|
const { bounds } = markupElement;
|
|
45
53
|
markupElement.bounds = undefined;
|
|
46
54
|
if (bounds != null) {
|
|
@@ -84,6 +92,12 @@ const ViewerMarkupTool = class {
|
|
|
84
92
|
handleCircleTemplateIdChanged() {
|
|
85
93
|
this.updateMarkupElement();
|
|
86
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* @ignore
|
|
97
|
+
*/
|
|
98
|
+
handleFreeformTemplateIdChanged() {
|
|
99
|
+
this.updateMarkupElement();
|
|
100
|
+
}
|
|
87
101
|
/**
|
|
88
102
|
* @ignore
|
|
89
103
|
*/
|
|
@@ -101,7 +115,9 @@ const ViewerMarkupTool = class {
|
|
|
101
115
|
*/
|
|
102
116
|
render() {
|
|
103
117
|
if (!this.disabled) {
|
|
104
|
-
if (this.tool === 'arrow' ||
|
|
118
|
+
if (this.tool === 'arrow' ||
|
|
119
|
+
this.tool === 'circle' ||
|
|
120
|
+
this.tool === 'freeform') {
|
|
105
121
|
return (h(Host, null, h("slot", null)));
|
|
106
122
|
}
|
|
107
123
|
else {
|
|
@@ -130,6 +146,25 @@ const ViewerMarkupTool = class {
|
|
|
130
146
|
}
|
|
131
147
|
return document.createElement('vertex-viewer-markup-circle');
|
|
132
148
|
}
|
|
149
|
+
createFreeformMarkupElement() {
|
|
150
|
+
if (this.freeformTemplateId != null) {
|
|
151
|
+
const element = stampTemplateWithId(window.document.body, this.freeformTemplateId, isVertexViewerFreeformMarkup, () => console.warn(`Freeform template with ID ${this.freeformTemplateId} not found. Using default freeform element.`), () => console.warn(`Freeform template does not contain a vertex-viewer-markup-freeform. Using default freeform element.`));
|
|
152
|
+
if (element != null) {
|
|
153
|
+
return element;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return document.createElement('vertex-viewer-markup-freeform');
|
|
157
|
+
}
|
|
158
|
+
createNewMarkupElement() {
|
|
159
|
+
switch (this.tool) {
|
|
160
|
+
case 'arrow':
|
|
161
|
+
return this.createArrowMarkupElement();
|
|
162
|
+
case 'circle':
|
|
163
|
+
return this.createCircleMarkupElement();
|
|
164
|
+
case 'freeform':
|
|
165
|
+
return this.createFreeformMarkupElement();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
133
168
|
updateMarkupElement() {
|
|
134
169
|
const { markupElement } = this.stateMap;
|
|
135
170
|
if (markupElement != null) {
|
|
@@ -141,9 +176,7 @@ const ViewerMarkupTool = class {
|
|
|
141
176
|
markupElement.removeEventListener('editCancel', this.handleMarkupEditCancel);
|
|
142
177
|
}
|
|
143
178
|
if (!this.disabled) {
|
|
144
|
-
const newMarkupElement = this.
|
|
145
|
-
? this.createArrowMarkupElement()
|
|
146
|
-
: this.createCircleMarkupElement();
|
|
179
|
+
const newMarkupElement = this.createNewMarkupElement();
|
|
147
180
|
newMarkupElement.mode = 'create';
|
|
148
181
|
newMarkupElement.viewer = this.viewer;
|
|
149
182
|
newMarkupElement.addEventListener('editBegin', this.handleMarkupEditBegin);
|
|
@@ -159,6 +192,7 @@ const ViewerMarkupTool = class {
|
|
|
159
192
|
"tool": ["handleToolChanged"],
|
|
160
193
|
"arrowTemplateId": ["handleArrowTemplateIdChanged"],
|
|
161
194
|
"circleTemplateId": ["handleCircleTemplateIdChanged"],
|
|
195
|
+
"freeformTemplateId": ["handleFreeformTemplateIdChanged"],
|
|
162
196
|
"disabled": ["handleDisabledChanged"]
|
|
163
197
|
}; }
|
|
164
198
|
};
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-8d7400a7.js';
|
|
5
5
|
import { s as stampTemplateWithId } from './templates-022199c1.js';
|
|
6
|
-
import { A as ArrowMarkup, C as CircleMarkup } from './markup-
|
|
7
|
-
import { i as isVertexViewerArrowMarkup, a as isVertexViewerCircleMarkup } from './utils-
|
|
8
|
-
import './bundle.esm-
|
|
9
|
-
import './browser.esm-
|
|
6
|
+
import { A as ArrowMarkup, C as CircleMarkup, F as FreeformMarkup } from './markup-9b29aa94.js';
|
|
7
|
+
import { i as isVertexViewerArrowMarkup, a as isVertexViewerCircleMarkup, b as isVertexViewerFreeformMarkup } from './utils-5fe43b8a.js';
|
|
8
|
+
import './bundle.esm-d891316f.js';
|
|
9
|
+
import './browser.esm-e4fb17dc.js';
|
|
10
10
|
|
|
11
11
|
const viewerMarkupCss = ":host{display:block;position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none}";
|
|
12
12
|
|
|
@@ -52,6 +52,14 @@ const ViewerMarkup = class {
|
|
|
52
52
|
el.bounds = bounds;
|
|
53
53
|
return this.appendMarkupElement(el);
|
|
54
54
|
}
|
|
55
|
+
else if (markup instanceof FreeformMarkup) {
|
|
56
|
+
const { bounds, points, id } = markup;
|
|
57
|
+
const el = this.createFreeformMarkupElement();
|
|
58
|
+
el.id = id;
|
|
59
|
+
el.points = points;
|
|
60
|
+
el.bounds = bounds;
|
|
61
|
+
return this.appendMarkupElement(el);
|
|
62
|
+
}
|
|
55
63
|
else {
|
|
56
64
|
throw new Error(`Cannot add markup. Unknown type '${markup}'.`);
|
|
57
65
|
}
|
|
@@ -79,7 +87,9 @@ const ViewerMarkup = class {
|
|
|
79
87
|
* @see {@link ViewerMarkup.getMarkupElement}
|
|
80
88
|
*/
|
|
81
89
|
async getMarkupElements() {
|
|
82
|
-
return Array.from(this.hostEl.children).filter((e) => isVertexViewerArrowMarkup(e) ||
|
|
90
|
+
return Array.from(this.hostEl.children).filter((e) => isVertexViewerArrowMarkup(e) ||
|
|
91
|
+
isVertexViewerCircleMarkup(e) ||
|
|
92
|
+
isVertexViewerFreeformMarkup(e));
|
|
83
93
|
}
|
|
84
94
|
/**
|
|
85
95
|
* Returns the markup element associated to the given ID.
|
|
@@ -195,6 +205,15 @@ const ViewerMarkup = class {
|
|
|
195
205
|
}
|
|
196
206
|
return document.createElement('vertex-viewer-markup-circle');
|
|
197
207
|
}
|
|
208
|
+
createFreeformMarkupElement() {
|
|
209
|
+
if (this.freeformTemplateId != null) {
|
|
210
|
+
const element = stampTemplateWithId(window.document.body, this.freeformTemplateId, isVertexViewerFreeformMarkup, () => console.warn(`Freeform template with ID ${this.freeformTemplateId} not found. Using default freeform element.`), () => console.warn(`Freeform template does not contain a vertex-viewer-markup-freeform. Using default freeform element.`));
|
|
211
|
+
if (element != null) {
|
|
212
|
+
return element;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return document.createElement('vertex-viewer-markup-freeform');
|
|
216
|
+
}
|
|
198
217
|
async updatePropsOnMarkups() {
|
|
199
218
|
const markup = await this.getMarkupElements();
|
|
200
219
|
markup.forEach((m) => this.updatePropsOnMarkup(m));
|
|
@@ -209,6 +228,7 @@ const ViewerMarkup = class {
|
|
|
209
228
|
tool.disabled = this.disabled;
|
|
210
229
|
tool.arrowTemplateId = this.arrowTemplateId;
|
|
211
230
|
tool.circleTemplateId = this.circleTemplateId;
|
|
231
|
+
tool.freeformTemplateId = this.freeformTemplateId;
|
|
212
232
|
tool.tool = this.tool;
|
|
213
233
|
tool.viewer = this.viewer;
|
|
214
234
|
}
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
* Copyright (c) 2021 Vertex Software LLC. All rights reserved.
|
|
3
3
|
*/
|
|
4
4
|
import { h, r as registerInstance, c as createEvent, H as Host, g as getElement } from './index-8d7400a7.js';
|
|
5
|
-
import {
|
|
6
|
-
import { M as MeasurementUnits } from './orientation-
|
|
7
|
-
import { V as Viewport } from './viewport-
|
|
8
|
-
import { M as MEASUREMENT_SNAP_DISTANCE, a as MEASUREMENT_LINE_CAP_LENGTH, t as translatePointToWorld, b as translateWorldPtToViewport, g as getViewingElementPositions } from './constants-
|
|
9
|
-
import { a as cssTransformCenterAt, g as getMouseClientPosition } from './dom-
|
|
5
|
+
import { k as angle, p as point, v as vector3, o as line3 } from './bundle.esm-d891316f.js';
|
|
6
|
+
import { M as MeasurementUnits } from './orientation-bb34b652.js';
|
|
7
|
+
import { V as Viewport } from './viewport-d6f5cd7b.js';
|
|
8
|
+
import { M as MEASUREMENT_SNAP_DISTANCE, a as MEASUREMENT_LINE_CAP_LENGTH, t as translatePointToWorld, b as translateWorldPtToViewport, g as getViewingElementPositions } from './constants-037e417f.js';
|
|
9
|
+
import { a as cssTransformCenterAt, g as getMouseClientPosition } from './dom-d0877f90.js';
|
|
10
10
|
import { c as classnames } from './index-455380d0.js';
|
|
11
|
-
import { m as measurementCursor } from './cursors-
|
|
12
|
-
import './browser.esm-
|
|
11
|
+
import { m as measurementCursor } from './cursors-00835249.js';
|
|
12
|
+
import './browser.esm-e4fb17dc.js';
|
|
13
13
|
import './_commonjsHelpers-9943807e.js';
|
|
14
14
|
|
|
15
15
|
function getMeasurementBoundingClientRect(el) {
|
|
@@ -232,7 +232,7 @@ const ViewerMeasurementDistance = class {
|
|
|
232
232
|
*/
|
|
233
233
|
render() {
|
|
234
234
|
const positions = this.computeElementPositions();
|
|
235
|
-
const { startPt, endPt, labelPt, indicatorPt, hideStart, hideEnd
|
|
235
|
+
const { startPt, endPt, labelPt, indicatorPt, hideStart, hideEnd } = positions;
|
|
236
236
|
const distance = this.formatDistance(this.distance);
|
|
237
237
|
if (this.mode === 'edit') {
|
|
238
238
|
return (h(Host, null, h("div", { class: "measurement" }, h(DistanceMeasurementRenderer, { startPt: startPt, endPt: endPt, centerPt: labelPt, indicatorPt: indicatorPt, distance: distance, anchorLabelOffset: this.anchorLabelOffset, lineCapLength: this.lineCapLength, hideStartAnchor: hideStart, hideEndAnchor: hideEnd, onStartAnchorPointerDown: this.handleEditAnchor('start'), onEndAnchorPointerDown: this.handleEditAnchor('end') }))));
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-8d7400a7.js';
|
|
5
5
|
import { s as stampTemplateWithId } from './templates-022199c1.js';
|
|
6
|
-
import './orientation-
|
|
7
|
-
import { D as DistanceMeasurement } from './measurement-
|
|
8
|
-
import { M as MEASUREMENT_SNAP_DISTANCE, i as isVertexViewerDistanceMeasurement } from './constants-
|
|
9
|
-
import './browser.esm-
|
|
10
|
-
import './bundle.esm-
|
|
6
|
+
import './orientation-bb34b652.js';
|
|
7
|
+
import { D as DistanceMeasurement } from './measurement-8430d5d6.js';
|
|
8
|
+
import { M as MEASUREMENT_SNAP_DISTANCE, i as isVertexViewerDistanceMeasurement } from './constants-037e417f.js';
|
|
9
|
+
import './browser.esm-e4fb17dc.js';
|
|
10
|
+
import './bundle.esm-d891316f.js';
|
|
11
11
|
|
|
12
12
|
const viewerMeasurementToolCss = ":host{position:absolute;top:0;bottom:0;left:0;right:0}";
|
|
13
13
|
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* Copyright (c) 2021 Vertex Software LLC. All rights reserved.
|
|
3
3
|
*/
|
|
4
4
|
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-8d7400a7.js';
|
|
5
|
-
import { M as MEASUREMENT_SNAP_DISTANCE, i as isVertexViewerDistanceMeasurement } from './constants-
|
|
5
|
+
import { M as MEASUREMENT_SNAP_DISTANCE, i as isVertexViewerDistanceMeasurement } from './constants-037e417f.js';
|
|
6
6
|
import { s as stampTemplateWithId } from './templates-022199c1.js';
|
|
7
|
-
import './orientation-
|
|
8
|
-
import { D as DistanceMeasurement } from './measurement-
|
|
9
|
-
import './bundle.esm-
|
|
10
|
-
import './browser.esm-
|
|
7
|
+
import './orientation-bb34b652.js';
|
|
8
|
+
import { D as DistanceMeasurement } from './measurement-8430d5d6.js';
|
|
9
|
+
import './bundle.esm-d891316f.js';
|
|
10
|
+
import './browser.esm-e4fb17dc.js';
|
|
11
11
|
|
|
12
12
|
const viewerMeasurementsCss = ":host{display:block;position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none}::slotted(.viewer-measurements__measurement[mode='']){cursor:pointer}::slotted(.viewer-measurements__measurement[mode='edit']){z-index:1}::slotted(.viewer-measurements__measurement[interacting-anchor='start']),::slotted(.viewer-measurements__measurement[interacting-anchor='end']),::slotted(vertex-viewer-measurement-tool[is-measuring]){z-index:2}";
|
|
13
13
|
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* Copyright (c) 2021 Vertex Software LLC. All rights reserved.
|
|
3
3
|
*/
|
|
4
4
|
import { h, F as Fragment, r as registerInstance, H as Host } from './index-8d7400a7.js';
|
|
5
|
-
import { v as vector3, q as quaternion, s as euler } from './bundle.esm-
|
|
5
|
+
import { v as vector3, q as quaternion, s as euler } from './bundle.esm-d891316f.js';
|
|
6
6
|
import { r as readDOM } from './stencil-540d92eb.js';
|
|
7
|
-
import { O as Orientation, c as FramePerspectiveCamera, e as StandardView } from './orientation-
|
|
7
|
+
import { O as Orientation, c as FramePerspectiveCamera, e as StandardView } from './orientation-bb34b652.js';
|
|
8
8
|
import { c as classnames } from './index-455380d0.js';
|
|
9
|
-
import './browser.esm-
|
|
9
|
+
import './browser.esm-e4fb17dc.js';
|
|
10
10
|
import './_commonjsHelpers-9943807e.js';
|
|
11
11
|
|
|
12
12
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|