@vertexvis/viewer 0.20.1-testing.0 → 0.20.1
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/index.cjs.js +3 -2
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/{controller-0155a10a.js → model-2105e63b.js} +85 -1
- package/dist/cjs/model-2105e63b.js.map +1 -0
- package/dist/cjs/vertex-viewer-box-query-tool.cjs.entry.js +7 -87
- package/dist/cjs/vertex-viewer-box-query-tool.cjs.entry.js.map +1 -1
- package/dist/cjs/vertex-viewer.cjs.entry.js +90 -24
- package/dist/cjs/vertex-viewer.cjs.entry.js.map +1 -1
- package/dist/collection/components/viewer-box-query-tool/viewer-box-query-tool.js +23 -1
- package/dist/collection/components/viewer-box-query-tool/viewer-box-query-tool.js.map +1 -1
- package/dist/collection/lib/interactions/multiPointerInteractionHandler.js +4 -2
- package/dist/collection/lib/interactions/multiPointerInteractionHandler.js.map +1 -1
- package/dist/collection/lib/interactions/multiTouchInteractionHandler.js +79 -17
- package/dist/collection/lib/interactions/multiTouchInteractionHandler.js.map +1 -1
- package/dist/collection/lib/interactions/touchInteractionHandler.js +4 -5
- package/dist/collection/lib/interactions/touchInteractionHandler.js.map +1 -1
- package/dist/collection/lib/volume-intersection/index.js +1 -0
- package/dist/collection/lib/volume-intersection/index.js.map +1 -1
- package/dist/collection/lib/window.js +7 -0
- package/dist/collection/lib/window.js.map +1 -0
- package/dist/components/index.js +1 -1
- package/dist/components/model2.js +165 -128
- package/dist/components/model2.js.map +1 -1
- package/dist/components/model3.js +157 -0
- package/dist/components/model3.js.map +1 -0
- package/dist/components/vertex-viewer-box-query-tool.js +4 -86
- package/dist/components/vertex-viewer-box-query-tool.js.map +1 -1
- package/dist/components/vertex-viewer-pin-tool.js +1 -1
- package/dist/components/vertex-viewer.js +91 -25
- package/dist/components/vertex-viewer.js.map +1 -1
- package/dist/components/viewer-pin-group.js +1 -1
- package/dist/components/viewer-pin-label-line.js +1 -1
- package/dist/components/viewer-pin-label.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/{controller-f0d7a836.js → model-4ba9fc30.js} +85 -2
- package/dist/esm/model-4ba9fc30.js.map +1 -0
- package/dist/esm/vertex-viewer-box-query-tool.entry.js +6 -86
- package/dist/esm/vertex-viewer-box-query-tool.entry.js.map +1 -1
- package/dist/esm/vertex-viewer.entry.js +91 -25
- package/dist/esm/vertex-viewer.entry.js.map +1 -1
- package/dist/types/components/viewer-box-query-tool/viewer-box-query-tool.d.ts +5 -1
- package/dist/types/components.d.ts +8 -0
- package/dist/types/lib/interactions/multiTouchInteractionHandler.d.ts +7 -2
- package/dist/types/lib/interactions/touchInteractionHandler.d.ts +1 -0
- package/dist/types/lib/volume-intersection/index.d.ts +1 -0
- package/dist/types/lib/window.d.ts +1 -0
- package/dist/viewer/index.esm.js +1 -1
- package/dist/viewer/index.esm.js.map +1 -1
- package/dist/viewer/p-12a301e0.entry.js +5 -0
- package/dist/viewer/p-12a301e0.entry.js.map +1 -0
- package/dist/viewer/p-4c4019b2.entry.js +5 -0
- package/dist/viewer/p-4c4019b2.entry.js.map +1 -0
- package/dist/viewer/p-ee0c9d33.js +5 -0
- package/dist/viewer/p-ee0c9d33.js.map +1 -0
- package/dist/viewer/viewer.esm.js +1 -1
- package/package.json +7 -7
- package/readme.md +4 -4
- package/dist/cjs/controller-0155a10a.js.map +0 -1
- package/dist/components/controller3.js +0 -111
- package/dist/components/controller3.js.map +0 -1
- package/dist/esm/controller-f0d7a836.js.map +0 -1
- package/dist/viewer/p-b50678f0.js +0 -5
- package/dist/viewer/p-b50678f0.js.map +0 -1
- package/dist/viewer/p-c6e12cf7.entry.js +0 -5
- package/dist/viewer/p-c6e12cf7.entry.js.map +0 -1
- package/dist/viewer/p-cfa05845.entry.js +0 -5
- package/dist/viewer/p-cfa05845.entry.js.map +0 -1
|
@@ -1,157 +1,194 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Copyright (c) 2024 Vertex Software LLC. All rights reserved.
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { S as StreamRequestError } from './bundle.esm2.js';
|
|
5
|
+
import { E as EventDispatcher } from './browser.esm.js';
|
|
6
|
+
import { p as point, e as rectangle } from './bundle.esm.js';
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
primaryColor: ((_b = (_a = pin === null || pin === void 0 ? void 0 : pin.attributes) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.primaryColor) == null
|
|
19
|
-
? undefined
|
|
20
|
-
: convertColorToString((_d = (_c = pin === null || pin === void 0 ? void 0 : pin.attributes) === null || _c === void 0 ? void 0 : _c.style) === null || _d === void 0 ? void 0 : _d.primaryColor),
|
|
21
|
-
accentColor: ((_f = (_e = pin === null || pin === void 0 ? void 0 : pin.attributes) === null || _e === void 0 ? void 0 : _e.style) === null || _f === void 0 ? void 0 : _f.accentColor) == null
|
|
22
|
-
? undefined
|
|
23
|
-
: convertColorToString((_h = (_g = pin === null || pin === void 0 ? void 0 : pin.attributes) === null || _g === void 0 ? void 0 : _g.style) === null || _h === void 0 ? void 0 : _h.accentColor),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
class PinModel {
|
|
27
|
-
constructor() {
|
|
28
|
-
this.entities = {};
|
|
29
|
-
this.entitiesChanged = new EventDispatcher();
|
|
30
|
-
this.selectionChanged = new EventDispatcher();
|
|
8
|
+
class VolumeIntersectionQueryController {
|
|
9
|
+
constructor(model, viewer) {
|
|
10
|
+
this.model = model;
|
|
11
|
+
this.viewer = viewer;
|
|
12
|
+
this.additionalTransforms = [];
|
|
13
|
+
this.operationInFlight = false;
|
|
14
|
+
this.operationAborted = false;
|
|
15
|
+
this.executeStarted = new EventDispatcher();
|
|
16
|
+
this.executeComplete = new EventDispatcher();
|
|
17
|
+
this.executeAborted = new EventDispatcher();
|
|
18
|
+
this.additionalTransforms = [(op) => op.where((q) => q.all()).deselect()];
|
|
19
|
+
this.operationTransform = (builder) => builder.select();
|
|
31
20
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
* @returns `true` if the entity has been added.
|
|
37
|
-
*/
|
|
38
|
-
addPin(pin, suppressEvent = false) {
|
|
39
|
-
if (this.entities[pin.id] == null) {
|
|
40
|
-
this.entities = Object.assign(Object.assign({}, this.entities), { [pin.id]: pin });
|
|
41
|
-
if (!suppressEvent) {
|
|
42
|
-
this.entitiesChanged.emit(this.getPins());
|
|
43
|
-
}
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
21
|
+
setStartPoint(point) {
|
|
22
|
+
this.previousViewerCameraControls = this.viewer.cameraControls;
|
|
23
|
+
this.viewer.cameraControls = false;
|
|
24
|
+
this.model.setStartPoint(point);
|
|
49
25
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
*/
|
|
53
|
-
clearPins() {
|
|
54
|
-
this.getPins().forEach((e) => this.removePin(e));
|
|
26
|
+
setEndPoint(point) {
|
|
27
|
+
this.model.setEndPoint(point);
|
|
55
28
|
}
|
|
56
29
|
/**
|
|
57
|
-
*
|
|
30
|
+
* Updates the operation that will be applied based on the volume intersection
|
|
31
|
+
* query. Defaults to `(builder) => builder.select()`, which will select any
|
|
32
|
+
* of the results of the query.
|
|
58
33
|
*/
|
|
59
|
-
|
|
60
|
-
|
|
34
|
+
setOperationTransform(operationTransform) {
|
|
35
|
+
this.operationTransform = operationTransform;
|
|
61
36
|
}
|
|
62
37
|
/**
|
|
63
|
-
*
|
|
38
|
+
* Updates any additional operations that should be performed independent of
|
|
39
|
+
* the volume intersection query. This can be used to perform an operation on
|
|
40
|
+
* the entirety of the scene prior to the operation on the result of the
|
|
41
|
+
* volume intersection query.
|
|
42
|
+
* Defaults to `[(op) => op.where((q) => q.all()).deselect()]`, which will
|
|
43
|
+
* clear any prior selection before the default selection.
|
|
64
44
|
*/
|
|
65
|
-
|
|
66
|
-
|
|
45
|
+
setAdditionalTransforms(additionalTransforms) {
|
|
46
|
+
this.additionalTransforms = additionalTransforms;
|
|
67
47
|
}
|
|
68
|
-
|
|
69
|
-
return this.
|
|
48
|
+
onExecuteStarted(listener) {
|
|
49
|
+
return this.executeStarted.on(listener);
|
|
70
50
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
51
|
+
onExecuteComplete(listener) {
|
|
52
|
+
return this.executeComplete.on(listener);
|
|
53
|
+
}
|
|
54
|
+
onExecuteAborted(listener) {
|
|
55
|
+
return this.executeAborted.on(listener);
|
|
56
|
+
}
|
|
57
|
+
async execute() {
|
|
58
|
+
var _a, _b, _c;
|
|
59
|
+
const screenBounds = this.model.getScreenBounds();
|
|
60
|
+
const type = this.model.getType();
|
|
61
|
+
if (screenBounds != null && !this.operationInFlight) {
|
|
62
|
+
this.model.complete();
|
|
63
|
+
try {
|
|
64
|
+
this.operationInFlight = true;
|
|
65
|
+
this.executeStarted.emit();
|
|
66
|
+
const additionalTransforms = (op) => this.additionalTransforms.map((t) => t(op)).flat();
|
|
67
|
+
const operationTransforms = (op) => [
|
|
68
|
+
this.operationTransform(op.where((q) => q.withVolumeIntersection(screenBounds, type === 'exclusive'))),
|
|
69
|
+
].flat();
|
|
70
|
+
const scene = await this.viewer.scene();
|
|
71
|
+
await scene
|
|
72
|
+
.items((op) => [
|
|
73
|
+
...additionalTransforms(op),
|
|
74
|
+
...operationTransforms(op),
|
|
75
|
+
])
|
|
76
|
+
.execute();
|
|
77
|
+
}
|
|
78
|
+
catch (e) {
|
|
79
|
+
if (e instanceof StreamRequestError &&
|
|
80
|
+
((_a = e.summary) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase().includes('operation aborted'))) {
|
|
81
|
+
this.executeAborted.emit(e);
|
|
82
|
+
this.operationAborted = true;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
console.error('Failed to perform volume intersection query', e);
|
|
86
|
+
throw e;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
this.viewer.cameraControls = (_b = this.previousViewerCameraControls) !== null && _b !== void 0 ? _b : true;
|
|
91
|
+
this.previousViewerCameraControls = undefined;
|
|
92
|
+
this.operationInFlight = false;
|
|
93
|
+
this.executeComplete.emit({
|
|
94
|
+
aborted: this.operationAborted,
|
|
95
|
+
});
|
|
96
|
+
this.operationAborted = false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else if (this.operationInFlight) {
|
|
100
|
+
this.model.cancel();
|
|
101
|
+
throw new Error(`Unable to perform volume intersection query as there is already one in-flight.`);
|
|
82
102
|
}
|
|
83
103
|
else {
|
|
84
|
-
|
|
104
|
+
this.model.cancel();
|
|
105
|
+
this.viewer.cameraControls = (_c = this.previousViewerCameraControls) !== null && _c !== void 0 ? _c : true;
|
|
85
106
|
}
|
|
86
107
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
this.
|
|
95
|
-
|
|
96
|
-
this.entitiesChanged.emit(this.getPins());
|
|
97
|
-
return true;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
class VolumeIntersectionQueryModel {
|
|
111
|
+
constructor(mode) {
|
|
112
|
+
this.mode = mode;
|
|
113
|
+
this.dragStarted = new EventDispatcher();
|
|
114
|
+
this.dragComplete = new EventDispatcher();
|
|
115
|
+
this.dragCancelled = new EventDispatcher();
|
|
116
|
+
this.screenBoundsChanged = new EventDispatcher();
|
|
98
117
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
* @param pin A pin to set
|
|
103
|
-
* @returns `true` if the entity has been set
|
|
104
|
-
*/
|
|
105
|
-
setPin(pin) {
|
|
106
|
-
this.entities = Object.assign(Object.assign({}, this.entities), { [pin.id]: pin });
|
|
107
|
-
this.entitiesChanged.emit(this.getPins());
|
|
108
|
-
return true;
|
|
118
|
+
setStartPoint(point) {
|
|
119
|
+
this.startPoint = point;
|
|
120
|
+
this.dragStarted.emit();
|
|
109
121
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
updatePin(pin) {
|
|
117
|
-
const pinById = this.getPinById(pin.id);
|
|
118
|
-
if (pinById != null) {
|
|
119
|
-
this.entities = Object.assign(Object.assign({}, this.entities), { [pin.id]: pin });
|
|
120
|
-
this.entitiesChanged.emit(this.getPins());
|
|
121
|
-
return true;
|
|
122
|
+
setEndPoint(point$1) {
|
|
123
|
+
if (this.startPoint != null &&
|
|
124
|
+
point.distance(this.startPoint, point$1) >= 2) {
|
|
125
|
+
this.endPoint = point$1;
|
|
126
|
+
this.updateQueryType();
|
|
127
|
+
this.screenBoundsChanged.emit(this.getQueryDetails());
|
|
122
128
|
}
|
|
123
|
-
return false;
|
|
124
129
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
* pin entities change.
|
|
128
|
-
*
|
|
129
|
-
* @param listener The listener to add.
|
|
130
|
-
* @returns A disposable that can be used to remove the listener.
|
|
131
|
-
*/
|
|
132
|
-
onEntitiesChanged(listener) {
|
|
133
|
-
return this.entitiesChanged.on(listener);
|
|
130
|
+
setMode(mode) {
|
|
131
|
+
this.mode = mode;
|
|
134
132
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
*/
|
|
142
|
-
onSelectionChange(listener) {
|
|
143
|
-
return this.selectionChanged.on(listener);
|
|
133
|
+
complete() {
|
|
134
|
+
if (this.startPoint != null && this.endPoint != null) {
|
|
135
|
+
this.screenBoundsChanged.emit(undefined);
|
|
136
|
+
this.dragComplete.emit(this.getQueryDetails());
|
|
137
|
+
this.reset();
|
|
138
|
+
}
|
|
144
139
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
this.
|
|
140
|
+
cancel() {
|
|
141
|
+
this.screenBoundsChanged.emit(undefined);
|
|
142
|
+
this.dragCancelled.emit();
|
|
143
|
+
this.reset();
|
|
144
|
+
}
|
|
145
|
+
reset() {
|
|
146
|
+
this.startPoint = undefined;
|
|
147
|
+
this.endPoint = undefined;
|
|
148
|
+
this.type = undefined;
|
|
149
|
+
}
|
|
150
|
+
getScreenBounds() {
|
|
151
|
+
return this.startPoint != null && this.endPoint != null
|
|
152
|
+
? rectangle.fromPoints(this.startPoint, this.endPoint)
|
|
153
|
+
: undefined;
|
|
154
|
+
}
|
|
155
|
+
getType() {
|
|
156
|
+
return this.type;
|
|
157
|
+
}
|
|
158
|
+
onScreenBoundsChanged(listener) {
|
|
159
|
+
return this.screenBoundsChanged.on(listener);
|
|
160
|
+
}
|
|
161
|
+
onDragStarted(listener) {
|
|
162
|
+
return this.dragStarted.on(listener);
|
|
163
|
+
}
|
|
164
|
+
onDragComplete(listener) {
|
|
165
|
+
return this.dragComplete.on(listener);
|
|
166
|
+
}
|
|
167
|
+
onDragCancelled(listener) {
|
|
168
|
+
return this.dragCancelled.on(listener);
|
|
169
|
+
}
|
|
170
|
+
getQueryDetails() {
|
|
171
|
+
if (this.startPoint != null && this.endPoint != null && this.type != null) {
|
|
172
|
+
return {
|
|
173
|
+
screenBounds: rectangle.fromPoints(this.startPoint, this.endPoint),
|
|
174
|
+
type: this.type,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
throw new Error('Failed to create query details, the start and end points must be set.');
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
updateQueryType() {
|
|
182
|
+
var _a;
|
|
183
|
+
if (this.startPoint != null && this.endPoint != null) {
|
|
184
|
+
const directionalType = point.subtract(this.endPoint, this.startPoint).x > 0
|
|
185
|
+
? 'exclusive'
|
|
186
|
+
: 'inclusive';
|
|
187
|
+
this.type = (_a = this.mode) !== null && _a !== void 0 ? _a : directionalType;
|
|
188
|
+
}
|
|
152
189
|
}
|
|
153
190
|
}
|
|
154
191
|
|
|
155
|
-
export {
|
|
192
|
+
export { VolumeIntersectionQueryController as V, VolumeIntersectionQueryModel as a };
|
|
156
193
|
|
|
157
194
|
//# sourceMappingURL=model2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"model2.js","mappings":";;;;;SA+CgB,SAAS,CAAC,GAAS;EACjC,OAAO,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,MAAK,MAAM,CAAC;AAC9B,CAAC;SAOe,SAAS,CAAC,GAAS;EACjC,OAAO,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,MAAK,MAAM,CAAC;AAC9B,CAAC;AAED,SAAS,oBAAoB,CAACA,OAA2B;EACvD,OAAO,OAAOA,OAAK,KAAK,QAAQ,GAAGA,OAAK,GAAGC,KAAK,CAAC,WAAW,CAACD,OAAK,CAAC,CAAC;AACtE,CAAC;SACe,YAAY,CAAC,GAAS;;EAIpC,OAAO;IACL,YAAY,EACV,CAAA,MAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,0CAAE,KAAK,0CAAE,YAAY,KAAI,IAAI;QACxC,SAAS;QACT,oBAAoB,CAAC,MAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,0CAAE,KAAK,0CAAE,YAAY,CAAC;IAChE,WAAW,EACT,CAAA,MAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,0CAAE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,CAAC,QAAyB;IAChD,OAAO,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;GAC1C;;;;;;;;EASM,iBAAiB,CAAC,QAAsC;IAC7D,OAAO,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;GAC3C;;;;;EAMM,cAAc,CAAC,KAAc;IAClC,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;IAC3B,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;GAChD;;;;;","names":["color","Color"],"sources":["./src/lib/pins/model.ts"],"sourcesContent":["import { Color, Disposable, EventDispatcher, Listener } from '@vertexvis/utils';\n\n/**\n * The types of pins that can be performed by this tool.\n */\nexport type ViewerPinToolType = 'pin-icon' | 'pin-text';\n\n/**\n * The mode of the pin tool\n */\nexport type ViewerPinToolMode = 'edit' | 'view';\n\n/**\n * A model representing the state of pins.\n *\n */\n\nimport { Point, Vector3 } from '@vertexvis/geometry';\n\ninterface BasePinAttributes {\n style?: PinStyleAttributes;\n}\n\ninterface BasePin {\n id: string;\n worldPosition: Vector3.Vector3;\n partId?: string;\n attributes?: BasePinAttributes;\n}\n\nexport interface TextPin extends BasePin {\n type: 'text';\n label: PinLabel;\n}\n\n// Future: Support custom icons.\nexport interface IconPin extends BasePin {\n type: 'icon';\n}\n\nexport type Pin = IconPin | TextPin;\n\nexport interface PinLabel {\n point: Point.Point;\n text?: string;\n}\n\nexport function isTextPin(pin?: Pin): pin is TextPin {\n return pin?.type === 'text';\n}\n\nexport interface PinStyleAttributes {\n primaryColor?: Color.Color | string;\n accentColor?: Color.Color | string;\n}\n\nexport function isIconPin(pin?: Pin): pin is Pin {\n return pin?.type === 'icon';\n}\n\nfunction convertColorToString(color: Color.Color | string): string {\n return typeof color === 'string' ? color : Color.toHexString(color);\n}\nexport function getPinColors(pin?: Pin): {\n primaryColor?: string;\n accentColor?: string;\n} {\n return {\n primaryColor:\n pin?.attributes?.style?.primaryColor == null\n ? undefined\n : convertColorToString(pin?.attributes?.style?.primaryColor),\n accentColor:\n pin?.attributes?.style?.accentColor == null\n ? undefined\n : convertColorToString(pin?.attributes?.style?.accentColor),\n };\n}\n\nexport class PinModel {\n private entities: Record<string, Pin> = {};\n private selectedPinId?: string;\n\n private entitiesChanged = new EventDispatcher<Pin[]>();\n private selectionChanged = new EventDispatcher<string | undefined>();\n\n /**\n * Registers an entity to be drawn in the canvas\n *\n * @param pin A pin entity to draw.\n * @returns `true` if the entity has been added.\n */\n public addPin(pin: Pin, suppressEvent = false): boolean {\n if (this.entities[pin.id] == null) {\n this.entities = {\n ...this.entities,\n [pin.id]: pin,\n };\n\n if (!suppressEvent) {\n this.entitiesChanged.emit(this.getPins());\n }\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Clears all registered entities from the model.\n */\n public clearPins(): void {\n this.getPins().forEach((e) => this.removePin(e));\n }\n\n /**\n * Returns all the entities registered with the model.\n */\n public getPins(): Pin[] {\n return Object.keys(this.entities).map((key) => this.entities[key]);\n }\n\n /**\n * Returns single entity by id if present in the model.\n */\n public getPinById(id: string): Pin | undefined {\n return this.entities[id];\n }\n\n public getSelectedPinId(): string | undefined {\n return this.selectedPinId;\n }\n\n /**\n * Unregisters an entity from the model.\n *\n * @param entity The entity to remove.\n * @returns `true` if the entity was removed.\n */\n public removePin(entity: Pin): boolean {\n if (this.entities[entity.id] != null) {\n delete this.entities[entity.id];\n this.entitiesChanged.emit(this.getPins());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Sets the set of entities to be placed with the model.\n *\n * @param entities A set of entities to draw.\n * @returns `true` if the entity has been added.\n */\n public setPins(pins: Set<Pin>): boolean {\n this.clearPins();\n pins.forEach((e) => this.addPin(e, true));\n this.entitiesChanged.emit(this.getPins());\n\n return true;\n }\n\n /**\n * Sets the set of entities to be placed with the model.\n *\n * @param pin A pin to set\n * @returns `true` if the entity has been set\n */\n public setPin(pin: Pin): boolean {\n this.entities = {\n ...this.entities,\n [pin.id]: pin,\n };\n this.entitiesChanged.emit(this.getPins());\n\n return true;\n }\n\n /**\n * Sets the set of entities to be placed with the model.\n *\n * @param pin A pin to set\n * @returns `true` if the entity has been set\n */\n public updatePin(pin: Pin): boolean {\n const pinById = this.getPinById(pin.id);\n if (pinById != null) {\n this.entities = {\n ...this.entities,\n [pin.id]: pin,\n };\n this.entitiesChanged.emit(this.getPins());\n\n return true;\n }\n return false;\n }\n\n /**\n * Registers an event listener that will be invoked when the model's\n * pin entities change.\n *\n * @param listener The listener to add.\n * @returns A disposable that can be used to remove the listener.\n */\n public onEntitiesChanged(listener: Listener<Pin[]>): Disposable {\n return this.entitiesChanged.on(listener);\n }\n\n /**\n * Registers an event listener that will be invoked when the model's\n * pin selection changes\n *\n * @param listener The listener to add.\n * @returns A disposable that can be used to remove the listener.\n */\n public onSelectionChange(listener: Listener<string | undefined>): Disposable {\n return this.selectionChanged.on(listener);\n }\n\n /**\n * Sets the selected pin Id\n * @param pinId\n */\n public setSelectedPin(pinId?: string): void {\n this.selectedPinId = pinId;\n this.selectionChanged.emit(this.selectedPinId);\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"model2.js","mappings":";;;;;;;MAsBa,iCAAiC;EAW5C,YACU,KAAmC,EACnC,MAA+B;IAD/B,UAAK,GAAL,KAAK,CAA8B;IACnC,WAAM,GAAN,MAAM,CAAyB;IAVjC,yBAAoB,GAA0B,EAAE,CAAC;IACjD,sBAAiB,GAAG,KAAK,CAAC;IAC1B,qBAAgB,GAAG,KAAK,CAAC;IAEzB,mBAAc,GAAG,IAAI,eAAe,EAAQ,CAAC;IAC7C,oBAAe,GAAG,IAAI,eAAe,EAA4B,CAAC;IAClE,mBAAc,GAAG,IAAI,eAAe,EAAsB,CAAC;IAMjE,IAAI,CAAC,oBAAoB,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC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AAQ,CAAC,CAAC;GACxC;EAEO,eAAe;IACrB,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,EAAE;MACzE,OAAO;QACL,YAAY,EAAEA,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC;QAClE,IAAI,EAAE,IAAI,CAAC,IAAI;OAChB,CAAC;KACH;SAAM;MACL,MAAM,IAAI,KAAK,CACb,uEAAuE,CACxE,CAAC;KACH;GACF;EAEO,eAAe;;IACrB,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,EAAE;MACpD,MAAM,eAAe,GACnBD,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC;UAChD,WAAW;UACX,WAAW,CAAC;MAElB,IAAI,CAAC,IAAI,GAAG,MAAA,IAAI,CAAC,IAAI,mCAAI,eAAe,CAAC;KAC1C;GACF;;;;;","names":["point","Point","Rectangle"],"sources":["./src/lib/volume-intersection/controller.ts","./src/lib/volume-intersection/model.ts"],"sourcesContent":["import { Point } from '@vertexvis/geometry';\nimport { StreamRequestError } from '@vertexvis/stream-api';\nimport { Disposable, EventDispatcher, Listener } from '@vertexvis/utils';\n\nimport {\n SceneItemOperationsBuilder,\n TerminalItemOperationBuilder,\n} from '../scenes';\nimport { SceneItemQueryExecutor } from '../scenes/queries';\nimport { VolumeIntersectionQueryModel } from './model';\n\nexport type OperationTransform = (\n builder: SceneItemOperationsBuilder\n) => TerminalItemOperationBuilder;\nexport type AdditionalTransform = (\n executor: SceneItemQueryExecutor\n) => TerminalItemOperationBuilder;\n\nexport interface CompleteExecutionDetails {\n aborted: boolean;\n}\n\nexport class VolumeIntersectionQueryController {\n private previousViewerCameraControls?: boolean;\n private operationTransform: OperationTransform;\n private additionalTransforms: AdditionalTransform[] = [];\n private operationInFlight = false;\n private operationAborted = false;\n\n private executeStarted = new EventDispatcher<void>();\n private executeComplete = new EventDispatcher<CompleteExecutionDetails>();\n private executeAborted = new EventDispatcher<StreamRequestError>();\n\n public constructor(\n private model: VolumeIntersectionQueryModel,\n private viewer: HTMLVertexViewerElement\n ) {\n this.additionalTransforms = [(op) => op.where((q) => q.all()).deselect()];\n this.operationTransform = (builder) => builder.select();\n }\n\n public setStartPoint(point: Point.Point): void {\n this.previousViewerCameraControls = this.viewer.cameraControls;\n this.viewer.cameraControls = false;\n\n this.model.setStartPoint(point);\n }\n\n public setEndPoint(point: Point.Point): void {\n this.model.setEndPoint(point);\n }\n\n /**\n * Updates the operation that will be applied based on the volume intersection\n * query. Defaults to `(builder) => builder.select()`, which will select any\n * of the results of the query.\n */\n public setOperationTransform(operationTransform: OperationTransform): void {\n this.operationTransform = operationTransform;\n }\n\n /**\n * Updates any additional operations that should be performed independent of\n * the volume intersection query. This can be used to perform an operation on\n * the entirety of the scene prior to the operation on the result of the\n * volume intersection query.\n * Defaults to `[(op) => op.where((q) => q.all()).deselect()]`, which will\n * clear any prior selection before the default selection.\n */\n public setAdditionalTransforms(\n additionalTransforms: AdditionalTransform[]\n ): void {\n this.additionalTransforms = additionalTransforms;\n }\n\n public onExecuteStarted(listener: Listener<void>): Disposable {\n return this.executeStarted.on(listener);\n }\n\n public onExecuteComplete(\n listener: Listener<CompleteExecutionDetails>\n ): Disposable {\n return this.executeComplete.on(listener);\n }\n\n public onExecuteAborted(listener: Listener<StreamRequestError>): Disposable {\n return this.executeAborted.on(listener);\n }\n\n public async execute(): Promise<void> {\n const screenBounds = this.model.getScreenBounds();\n const type = this.model.getType();\n\n if (screenBounds != null && !this.operationInFlight) {\n this.model.complete();\n\n try {\n this.operationInFlight = true;\n this.executeStarted.emit();\n\n const additionalTransforms = (\n op: SceneItemQueryExecutor\n ): SceneItemOperationsBuilder[] =>\n this.additionalTransforms.map((t) => t(op)).flat();\n const operationTransforms = (\n op: SceneItemQueryExecutor\n ): SceneItemOperationsBuilder[] =>\n [\n this.operationTransform(\n op.where((q) =>\n q.withVolumeIntersection(screenBounds, type === 'exclusive')\n )\n ),\n ].flat();\n\n const scene = await this.viewer.scene();\n await scene\n .items((op) => [\n ...additionalTransforms(op),\n ...operationTransforms(op),\n ])\n .execute();\n } catch (e) {\n if (\n e instanceof StreamRequestError &&\n e.summary?.toLocaleLowerCase().includes('operation aborted')\n ) {\n this.executeAborted.emit(e);\n this.operationAborted = true;\n } else {\n console.error('Failed to perform volume intersection query', e);\n throw e;\n }\n } finally {\n this.viewer.cameraControls = this.previousViewerCameraControls ?? true;\n this.previousViewerCameraControls = undefined;\n this.operationInFlight = false;\n this.executeComplete.emit({\n aborted: this.operationAborted,\n });\n this.operationAborted = false;\n }\n } else if (this.operationInFlight) {\n this.model.cancel();\n\n throw new Error(\n `Unable to perform volume intersection query as there is already one in-flight.`\n );\n } else {\n this.model.cancel();\n\n this.viewer.cameraControls = this.previousViewerCameraControls ?? true;\n }\n }\n}\n","import { Point, Rectangle } from '@vertexvis/geometry';\nimport { Disposable, EventDispatcher, Listener } from '@vertexvis/utils';\n\nimport { VolumeIntersectionQueryMode } from '../../components/viewer-box-query-tool/types';\n\nexport type QueryType = 'inclusive' | 'exclusive';\n\nexport interface VolumeIntersectionQueryDetails {\n screenBounds: Rectangle.Rectangle;\n type: QueryType;\n}\n\nexport class VolumeIntersectionQueryModel {\n private startPoint?: Point.Point;\n private endPoint?: Point.Point;\n private type?: QueryType;\n\n private dragStarted = new EventDispatcher<void>();\n private dragComplete = new EventDispatcher<VolumeIntersectionQueryDetails>();\n private dragCancelled = new EventDispatcher<void>();\n\n private screenBoundsChanged = new EventDispatcher<\n VolumeIntersectionQueryDetails | undefined\n >();\n\n public constructor(private mode?: VolumeIntersectionQueryMode) {}\n\n public setStartPoint(point: Point.Point): void {\n this.startPoint = point;\n\n this.dragStarted.emit();\n }\n\n public setEndPoint(point: Point.Point): void {\n if (\n this.startPoint != null &&\n Point.distance(this.startPoint, point) >= 2\n ) {\n this.endPoint = point;\n\n this.updateQueryType();\n this.screenBoundsChanged.emit(this.getQueryDetails());\n }\n }\n\n public setMode(mode?: VolumeIntersectionQueryMode): void {\n this.mode = mode;\n }\n\n public complete(): void {\n if (this.startPoint != null && this.endPoint != null) {\n this.screenBoundsChanged.emit(undefined);\n this.dragComplete.emit(this.getQueryDetails());\n this.reset();\n }\n }\n\n public cancel(): void {\n this.screenBoundsChanged.emit(undefined);\n this.dragCancelled.emit();\n this.reset();\n }\n\n public reset(): void {\n this.startPoint = undefined;\n this.endPoint = undefined;\n this.type = undefined;\n }\n\n public getScreenBounds(): Rectangle.Rectangle | undefined {\n return this.startPoint != null && this.endPoint != null\n ? Rectangle.fromPoints(this.startPoint, this.endPoint)\n : undefined;\n }\n\n public getType(): QueryType | undefined {\n return this.type;\n }\n\n public onScreenBoundsChanged(\n listener: Listener<VolumeIntersectionQueryDetails | undefined>\n ): Disposable {\n return this.screenBoundsChanged.on(listener);\n }\n\n public onDragStarted(listener: Listener<void>): Disposable {\n return this.dragStarted.on(listener);\n }\n\n public onDragComplete(\n listener: Listener<VolumeIntersectionQueryDetails>\n ): Disposable {\n return this.dragComplete.on(listener);\n }\n\n public onDragCancelled(listener: Listener<void>): Disposable {\n return this.dragCancelled.on(listener);\n }\n\n private getQueryDetails(): VolumeIntersectionQueryDetails {\n if (this.startPoint != null && this.endPoint != null && this.type != null) {\n return {\n screenBounds: Rectangle.fromPoints(this.startPoint, this.endPoint),\n type: this.type,\n };\n } else {\n throw new Error(\n 'Failed to create query details, the start and end points must be set.'\n );\n }\n }\n\n private updateQueryType(): void {\n if (this.startPoint != null && this.endPoint != null) {\n const directionalType =\n Point.subtract(this.endPoint, this.startPoint).x > 0\n ? 'exclusive'\n : 'inclusive';\n\n this.type = this.mode ?? directionalType;\n }\n }\n}\n"],"version":3}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2024 Vertex Software LLC. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { c as color, E as EventDispatcher } from './browser.esm.js';
|
|
5
|
+
|
|
6
|
+
function isTextPin(pin) {
|
|
7
|
+
return (pin === null || pin === void 0 ? void 0 : pin.type) === 'text';
|
|
8
|
+
}
|
|
9
|
+
function isIconPin(pin) {
|
|
10
|
+
return (pin === null || pin === void 0 ? void 0 : pin.type) === 'icon';
|
|
11
|
+
}
|
|
12
|
+
function convertColorToString(color$1) {
|
|
13
|
+
return typeof color$1 === 'string' ? color$1 : color.toHexString(color$1);
|
|
14
|
+
}
|
|
15
|
+
function getPinColors(pin) {
|
|
16
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
17
|
+
return {
|
|
18
|
+
primaryColor: ((_b = (_a = pin === null || pin === void 0 ? void 0 : pin.attributes) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.primaryColor) == null
|
|
19
|
+
? undefined
|
|
20
|
+
: convertColorToString((_d = (_c = pin === null || pin === void 0 ? void 0 : pin.attributes) === null || _c === void 0 ? void 0 : _c.style) === null || _d === void 0 ? void 0 : _d.primaryColor),
|
|
21
|
+
accentColor: ((_f = (_e = pin === null || pin === void 0 ? void 0 : pin.attributes) === null || _e === void 0 ? void 0 : _e.style) === null || _f === void 0 ? void 0 : _f.accentColor) == null
|
|
22
|
+
? undefined
|
|
23
|
+
: convertColorToString((_h = (_g = pin === null || pin === void 0 ? void 0 : pin.attributes) === null || _g === void 0 ? void 0 : _g.style) === null || _h === void 0 ? void 0 : _h.accentColor),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
class PinModel {
|
|
27
|
+
constructor() {
|
|
28
|
+
this.entities = {};
|
|
29
|
+
this.entitiesChanged = new EventDispatcher();
|
|
30
|
+
this.selectionChanged = new EventDispatcher();
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Registers an entity to be drawn in the canvas
|
|
34
|
+
*
|
|
35
|
+
* @param pin A pin entity to draw.
|
|
36
|
+
* @returns `true` if the entity has been added.
|
|
37
|
+
*/
|
|
38
|
+
addPin(pin, suppressEvent = false) {
|
|
39
|
+
if (this.entities[pin.id] == null) {
|
|
40
|
+
this.entities = Object.assign(Object.assign({}, this.entities), { [pin.id]: pin });
|
|
41
|
+
if (!suppressEvent) {
|
|
42
|
+
this.entitiesChanged.emit(this.getPins());
|
|
43
|
+
}
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Clears all registered entities from the model.
|
|
52
|
+
*/
|
|
53
|
+
clearPins() {
|
|
54
|
+
this.getPins().forEach((e) => this.removePin(e));
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Returns all the entities registered with the model.
|
|
58
|
+
*/
|
|
59
|
+
getPins() {
|
|
60
|
+
return Object.keys(this.entities).map((key) => this.entities[key]);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Returns single entity by id if present in the model.
|
|
64
|
+
*/
|
|
65
|
+
getPinById(id) {
|
|
66
|
+
return this.entities[id];
|
|
67
|
+
}
|
|
68
|
+
getSelectedPinId() {
|
|
69
|
+
return this.selectedPinId;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Unregisters an entity from the model.
|
|
73
|
+
*
|
|
74
|
+
* @param entity The entity to remove.
|
|
75
|
+
* @returns `true` if the entity was removed.
|
|
76
|
+
*/
|
|
77
|
+
removePin(entity) {
|
|
78
|
+
if (this.entities[entity.id] != null) {
|
|
79
|
+
delete this.entities[entity.id];
|
|
80
|
+
this.entitiesChanged.emit(this.getPins());
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Sets the set of entities to be placed with the model.
|
|
89
|
+
*
|
|
90
|
+
* @param entities A set of entities to draw.
|
|
91
|
+
* @returns `true` if the entity has been added.
|
|
92
|
+
*/
|
|
93
|
+
setPins(pins) {
|
|
94
|
+
this.clearPins();
|
|
95
|
+
pins.forEach((e) => this.addPin(e, true));
|
|
96
|
+
this.entitiesChanged.emit(this.getPins());
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Sets the set of entities to be placed with the model.
|
|
101
|
+
*
|
|
102
|
+
* @param pin A pin to set
|
|
103
|
+
* @returns `true` if the entity has been set
|
|
104
|
+
*/
|
|
105
|
+
setPin(pin) {
|
|
106
|
+
this.entities = Object.assign(Object.assign({}, this.entities), { [pin.id]: pin });
|
|
107
|
+
this.entitiesChanged.emit(this.getPins());
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Sets the set of entities to be placed with the model.
|
|
112
|
+
*
|
|
113
|
+
* @param pin A pin to set
|
|
114
|
+
* @returns `true` if the entity has been set
|
|
115
|
+
*/
|
|
116
|
+
updatePin(pin) {
|
|
117
|
+
const pinById = this.getPinById(pin.id);
|
|
118
|
+
if (pinById != null) {
|
|
119
|
+
this.entities = Object.assign(Object.assign({}, this.entities), { [pin.id]: pin });
|
|
120
|
+
this.entitiesChanged.emit(this.getPins());
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Registers an event listener that will be invoked when the model's
|
|
127
|
+
* pin entities change.
|
|
128
|
+
*
|
|
129
|
+
* @param listener The listener to add.
|
|
130
|
+
* @returns A disposable that can be used to remove the listener.
|
|
131
|
+
*/
|
|
132
|
+
onEntitiesChanged(listener) {
|
|
133
|
+
return this.entitiesChanged.on(listener);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Registers an event listener that will be invoked when the model's
|
|
137
|
+
* pin selection changes
|
|
138
|
+
*
|
|
139
|
+
* @param listener The listener to add.
|
|
140
|
+
* @returns A disposable that can be used to remove the listener.
|
|
141
|
+
*/
|
|
142
|
+
onSelectionChange(listener) {
|
|
143
|
+
return this.selectionChanged.on(listener);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Sets the selected pin Id
|
|
147
|
+
* @param pinId
|
|
148
|
+
*/
|
|
149
|
+
setSelectedPin(pinId) {
|
|
150
|
+
this.selectedPinId = pinId;
|
|
151
|
+
this.selectionChanged.emit(this.selectedPinId);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export { PinModel as P, isIconPin as a, getPinColors as g, isTextPin as i };
|
|
156
|
+
|
|
157
|
+
//# sourceMappingURL=model3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"model3.js","mappings":";;;;;SA+CgB,SAAS,CAAC,GAAS;EACjC,OAAO,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,MAAK,MAAM,CAAC;AAC9B,CAAC;SAOe,SAAS,CAAC,GAAS;EACjC,OAAO,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,MAAK,MAAM,CAAC;AAC9B,CAAC;AAED,SAAS,oBAAoB,CAACA,OAA2B;EACvD,OAAO,OAAOA,OAAK,KAAK,QAAQ,GAAGA,OAAK,GAAGC,KAAK,CAAC,WAAW,CAACD,OAAK,CAAC,CAAC;AACtE,CAAC;SACe,YAAY,CAAC,GAAS;;EAIpC,OAAO;IACL,YAAY,EACV,CAAA,MAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,0CAAE,KAAK,0CAAE,YAAY,KAAI,IAAI;QACxC,SAAS;QACT,oBAAoB,CAAC,MAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,0CAAE,KAAK,0CAAE,YAAY,CAAC;IAChE,WAAW,EACT,CAAA,MAAA,MAAA,GAAG,aAAH,GAAG,uB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AC;GACd;;;;;;;;EASM,iBAAiB,CAAC,QAAyB;IAChD,OAAO,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;GAC1C;;;;;;;;EASM,iBAAiB,CAAC,QAAsC;IAC7D,OAAO,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;GAC3C;;;;;EAMM,cAAc,CAAC,KAAc;IAClC,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;IAC3B,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;GAChD;;;;;","names":["color","Color"],"sources":["./src/lib/pins/model.ts"],"sourcesContent":["import { Color, Disposable, EventDispatcher, Listener } from '@vertexvis/utils';\n\n/**\n * The types of pins that can be performed by this tool.\n */\nexport type ViewerPinToolType = 'pin-icon' | 'pin-text';\n\n/**\n * The mode of the pin tool\n */\nexport type ViewerPinToolMode = 'edit' | 'view';\n\n/**\n * A model representing the state of pins.\n *\n */\n\nimport { Point, Vector3 } from '@vertexvis/geometry';\n\ninterface BasePinAttributes {\n style?: PinStyleAttributes;\n}\n\ninterface BasePin {\n id: string;\n worldPosition: Vector3.Vector3;\n partId?: string;\n attributes?: BasePinAttributes;\n}\n\nexport interface TextPin extends BasePin {\n type: 'text';\n label: PinLabel;\n}\n\n// Future: Support custom icons.\nexport interface IconPin extends BasePin {\n type: 'icon';\n}\n\nexport type Pin = IconPin | TextPin;\n\nexport interface PinLabel {\n point: Point.Point;\n text?: string;\n}\n\nexport function isTextPin(pin?: Pin): pin is TextPin {\n return pin?.type === 'text';\n}\n\nexport interface PinStyleAttributes {\n primaryColor?: Color.Color | string;\n accentColor?: Color.Color | string;\n}\n\nexport function isIconPin(pin?: Pin): pin is Pin {\n return pin?.type === 'icon';\n}\n\nfunction convertColorToString(color: Color.Color | string): string {\n return typeof color === 'string' ? color : Color.toHexString(color);\n}\nexport function getPinColors(pin?: Pin): {\n primaryColor?: string;\n accentColor?: string;\n} {\n return {\n primaryColor:\n pin?.attributes?.style?.primaryColor == null\n ? undefined\n : convertColorToString(pin?.attributes?.style?.primaryColor),\n accentColor:\n pin?.attributes?.style?.accentColor == null\n ? undefined\n : convertColorToString(pin?.attributes?.style?.accentColor),\n };\n}\n\nexport class PinModel {\n private entities: Record<string, Pin> = {};\n private selectedPinId?: string;\n\n private entitiesChanged = new EventDispatcher<Pin[]>();\n private selectionChanged = new EventDispatcher<string | undefined>();\n\n /**\n * Registers an entity to be drawn in the canvas\n *\n * @param pin A pin entity to draw.\n * @returns `true` if the entity has been added.\n */\n public addPin(pin: Pin, suppressEvent = false): boolean {\n if (this.entities[pin.id] == null) {\n this.entities = {\n ...this.entities,\n [pin.id]: pin,\n };\n\n if (!suppressEvent) {\n this.entitiesChanged.emit(this.getPins());\n }\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Clears all registered entities from the model.\n */\n public clearPins(): void {\n this.getPins().forEach((e) => this.removePin(e));\n }\n\n /**\n * Returns all the entities registered with the model.\n */\n public getPins(): Pin[] {\n return Object.keys(this.entities).map((key) => this.entities[key]);\n }\n\n /**\n * Returns single entity by id if present in the model.\n */\n public getPinById(id: string): Pin | undefined {\n return this.entities[id];\n }\n\n public getSelectedPinId(): string | undefined {\n return this.selectedPinId;\n }\n\n /**\n * Unregisters an entity from the model.\n *\n * @param entity The entity to remove.\n * @returns `true` if the entity was removed.\n */\n public removePin(entity: Pin): boolean {\n if (this.entities[entity.id] != null) {\n delete this.entities[entity.id];\n this.entitiesChanged.emit(this.getPins());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Sets the set of entities to be placed with the model.\n *\n * @param entities A set of entities to draw.\n * @returns `true` if the entity has been added.\n */\n public setPins(pins: Set<Pin>): boolean {\n this.clearPins();\n pins.forEach((e) => this.addPin(e, true));\n this.entitiesChanged.emit(this.getPins());\n\n return true;\n }\n\n /**\n * Sets the set of entities to be placed with the model.\n *\n * @param pin A pin to set\n * @returns `true` if the entity has been set\n */\n public setPin(pin: Pin): boolean {\n this.entities = {\n ...this.entities,\n [pin.id]: pin,\n };\n this.entitiesChanged.emit(this.getPins());\n\n return true;\n }\n\n /**\n * Sets the set of entities to be placed with the model.\n *\n * @param pin A pin to set\n * @returns `true` if the entity has been set\n */\n public updatePin(pin: Pin): boolean {\n const pinById = this.getPinById(pin.id);\n if (pinById != null) {\n this.entities = {\n ...this.entities,\n [pin.id]: pin,\n };\n this.entitiesChanged.emit(this.getPins());\n\n return true;\n }\n return false;\n }\n\n /**\n * Registers an event listener that will be invoked when the model's\n * pin entities change.\n *\n * @param listener The listener to add.\n * @returns A disposable that can be used to remove the listener.\n */\n public onEntitiesChanged(listener: Listener<Pin[]>): Disposable {\n return this.entitiesChanged.on(listener);\n }\n\n /**\n * Registers an event listener that will be invoked when the model's\n * pin selection changes\n *\n * @param listener The listener to add.\n * @returns A disposable that can be used to remove the listener.\n */\n public onSelectionChange(listener: Listener<string | undefined>): Disposable {\n return this.selectionChanged.on(listener);\n }\n\n /**\n * Sets the selected pin Id\n * @param pinId\n */\n public setSelectedPin(pinId?: string): void {\n this.selectedPinId = pinId;\n this.selectionChanged.emit(this.selectedPinId);\n }\n}\n"],"version":3}
|