@itwin/unified-selection 0.1.0 → 0.3.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/CHANGELOG.md +129 -0
- package/README.md +104 -6
- package/lib/cjs/unified-selection/CachingHiliteSetProvider.d.ts +33 -0
- package/lib/cjs/unified-selection/CachingHiliteSetProvider.d.ts.map +1 -0
- package/lib/cjs/unified-selection/CachingHiliteSetProvider.js +62 -0
- package/lib/cjs/unified-selection/CachingHiliteSetProvider.js.map +1 -0
- package/lib/cjs/unified-selection/EnableUnifiedSelectionSyncWithIModel.d.ts +90 -0
- package/lib/cjs/unified-selection/EnableUnifiedSelectionSyncWithIModel.d.ts.map +1 -0
- package/lib/cjs/unified-selection/EnableUnifiedSelectionSyncWithIModel.js +205 -0
- package/lib/cjs/unified-selection/EnableUnifiedSelectionSyncWithIModel.js.map +1 -0
- package/lib/cjs/unified-selection/HiliteSetProvider.d.ts +37 -0
- package/lib/cjs/unified-selection/HiliteSetProvider.d.ts.map +1 -0
- package/lib/cjs/unified-selection/HiliteSetProvider.js +344 -0
- package/lib/cjs/unified-selection/HiliteSetProvider.js.map +1 -0
- package/lib/cjs/unified-selection/Selectable.d.ts +0 -3
- package/lib/cjs/unified-selection/Selectable.d.ts.map +1 -1
- package/lib/cjs/unified-selection/Selectable.js +2 -2
- package/lib/cjs/unified-selection/Selectable.js.map +1 -1
- package/lib/cjs/unified-selection/SelectionChangeEvent.d.ts +11 -7
- package/lib/cjs/unified-selection/SelectionChangeEvent.d.ts.map +1 -1
- package/lib/cjs/unified-selection/SelectionChangeEvent.js +1 -1
- package/lib/cjs/unified-selection/SelectionChangeEvent.js.map +1 -1
- package/lib/cjs/unified-selection/SelectionScope.d.ts +44 -0
- package/lib/cjs/unified-selection/SelectionScope.d.ts.map +1 -0
- package/lib/cjs/unified-selection/SelectionScope.js +193 -0
- package/lib/cjs/unified-selection/SelectionScope.js.map +1 -0
- package/lib/cjs/unified-selection/SelectionStorage.d.ts +34 -29
- package/lib/cjs/unified-selection/SelectionStorage.d.ts.map +1 -1
- package/lib/cjs/unified-selection/SelectionStorage.js +32 -18
- package/lib/cjs/unified-selection/SelectionStorage.js.map +1 -1
- package/lib/cjs/unified-selection/Utils.d.ts +7 -0
- package/lib/cjs/unified-selection/Utils.d.ts.map +1 -0
- package/lib/cjs/unified-selection/Utils.js +24 -0
- package/lib/cjs/unified-selection/Utils.js.map +1 -0
- package/lib/cjs/unified-selection/types/IModel.d.ts +84 -0
- package/lib/cjs/unified-selection/types/IModel.d.ts.map +1 -0
- package/lib/cjs/unified-selection/types/IModel.js +24 -0
- package/lib/cjs/unified-selection/types/IModel.js.map +1 -0
- package/lib/cjs/unified-selection.d.ts +5 -7
- package/lib/cjs/unified-selection.d.ts.map +1 -1
- package/lib/cjs/unified-selection.js +11 -7
- package/lib/cjs/unified-selection.js.map +1 -1
- package/lib/esm/unified-selection/CachingHiliteSetProvider.d.ts +33 -0
- package/lib/esm/unified-selection/CachingHiliteSetProvider.d.ts.map +1 -0
- package/lib/esm/unified-selection/CachingHiliteSetProvider.js +58 -0
- package/lib/esm/unified-selection/CachingHiliteSetProvider.js.map +1 -0
- package/lib/esm/unified-selection/EnableUnifiedSelectionSyncWithIModel.d.ts +90 -0
- package/lib/esm/unified-selection/EnableUnifiedSelectionSyncWithIModel.d.ts.map +1 -0
- package/lib/esm/unified-selection/EnableUnifiedSelectionSyncWithIModel.js +200 -0
- package/lib/esm/unified-selection/EnableUnifiedSelectionSyncWithIModel.js.map +1 -0
- package/lib/esm/unified-selection/HiliteSetProvider.d.ts +37 -0
- package/lib/esm/unified-selection/HiliteSetProvider.d.ts.map +1 -0
- package/lib/esm/unified-selection/HiliteSetProvider.js +340 -0
- package/lib/esm/unified-selection/HiliteSetProvider.js.map +1 -0
- package/lib/esm/unified-selection/Selectable.d.ts +0 -3
- package/lib/esm/unified-selection/Selectable.d.ts.map +1 -1
- package/lib/esm/unified-selection/Selectable.js.map +1 -1
- package/lib/esm/unified-selection/SelectionChangeEvent.d.ts +11 -7
- package/lib/esm/unified-selection/SelectionChangeEvent.d.ts.map +1 -1
- package/lib/esm/unified-selection/SelectionChangeEvent.js +1 -1
- package/lib/esm/unified-selection/SelectionChangeEvent.js.map +1 -1
- package/lib/esm/unified-selection/SelectionScope.d.ts +44 -0
- package/lib/esm/unified-selection/SelectionScope.d.ts.map +1 -0
- package/lib/esm/unified-selection/SelectionScope.js +189 -0
- package/lib/esm/unified-selection/SelectionScope.js.map +1 -0
- package/lib/esm/unified-selection/SelectionStorage.d.ts +34 -29
- package/lib/esm/unified-selection/SelectionStorage.d.ts.map +1 -1
- package/lib/esm/unified-selection/SelectionStorage.js +31 -17
- package/lib/esm/unified-selection/SelectionStorage.js.map +1 -1
- package/lib/esm/unified-selection/Utils.d.ts +7 -0
- package/lib/esm/unified-selection/Utils.d.ts.map +1 -0
- package/lib/esm/unified-selection/Utils.js +20 -0
- package/lib/esm/unified-selection/Utils.js.map +1 -0
- package/lib/esm/unified-selection/types/IModel.d.ts +84 -0
- package/lib/esm/unified-selection/types/IModel.d.ts.map +1 -0
- package/lib/esm/unified-selection/types/IModel.js +21 -0
- package/lib/esm/unified-selection/types/IModel.js.map +1 -0
- package/lib/esm/unified-selection.d.ts +5 -7
- package/lib/esm/unified-selection.d.ts.map +1 -1
- package/lib/esm/unified-selection.js +5 -7
- package/lib/esm/unified-selection.js.map +1 -1
- package/package.json +28 -15
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.IModelSelectionHandler = exports.enableUnifiedSelectionSyncWithIModel = void 0;
|
|
8
|
+
const rxjs_1 = require("rxjs");
|
|
9
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
10
|
+
const CachingHiliteSetProvider_1 = require("./CachingHiliteSetProvider");
|
|
11
|
+
const HiliteSetProvider_1 = require("./HiliteSetProvider");
|
|
12
|
+
const SelectionScope_1 = require("./SelectionScope");
|
|
13
|
+
const IModel_1 = require("./types/IModel");
|
|
14
|
+
/**
|
|
15
|
+
* Enables synchronization between iModel selection and unified selection.
|
|
16
|
+
* @returns function for disposing the synchronization.
|
|
17
|
+
* @beta
|
|
18
|
+
*/
|
|
19
|
+
function enableUnifiedSelectionSyncWithIModel(props) {
|
|
20
|
+
const selectionHandler = new IModelSelectionHandler(props);
|
|
21
|
+
return () => selectionHandler.dispose();
|
|
22
|
+
}
|
|
23
|
+
exports.enableUnifiedSelectionSyncWithIModel = enableUnifiedSelectionSyncWithIModel;
|
|
24
|
+
/**
|
|
25
|
+
* A handler that syncs selection between unified selection storage
|
|
26
|
+
* (`SelectionStorage`) and an iModel (`iModel.selectionSet`, `iModel.hilited`).
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
class IModelSelectionHandler {
|
|
30
|
+
_selectionSourceName = "Tool";
|
|
31
|
+
_imodelAccess;
|
|
32
|
+
_selectionStorage;
|
|
33
|
+
_hiliteSetProvider;
|
|
34
|
+
_cachingHiliteSetProvider;
|
|
35
|
+
_activeScopeProvider;
|
|
36
|
+
_isSuspended;
|
|
37
|
+
_cancelOngoingChanges = new rxjs_1.Subject();
|
|
38
|
+
_unifiedSelectionListenerDisposeFunc;
|
|
39
|
+
_imodelListenerDisposeFunc;
|
|
40
|
+
_hasCustomCachingHiliteSetProvider;
|
|
41
|
+
constructor(props) {
|
|
42
|
+
this._imodelAccess = props.imodelAccess;
|
|
43
|
+
this._selectionStorage = props.selectionStorage;
|
|
44
|
+
this._activeScopeProvider = props.activeScopeProvider;
|
|
45
|
+
this._isSuspended = false;
|
|
46
|
+
this._hasCustomCachingHiliteSetProvider = !!props.cachingHiliteSetProvider;
|
|
47
|
+
this._cachingHiliteSetProvider =
|
|
48
|
+
props.cachingHiliteSetProvider ??
|
|
49
|
+
(0, CachingHiliteSetProvider_1.createCachingHiliteSetProvider)({
|
|
50
|
+
selectionStorage: this._selectionStorage,
|
|
51
|
+
imodelProvider: () => this._imodelAccess,
|
|
52
|
+
});
|
|
53
|
+
this._hiliteSetProvider = (0, HiliteSetProvider_1.createHiliteSetProvider)({ imodelAccess: this._imodelAccess });
|
|
54
|
+
this._imodelListenerDisposeFunc = this._imodelAccess.selectionSet.onChanged.addListener(this.onIModelSelectionChanged);
|
|
55
|
+
this._unifiedSelectionListenerDisposeFunc = this._selectionStorage.selectionChangeEvent.addListener(this.onUnifiedSelectionChanged);
|
|
56
|
+
// stop imodel from syncing tool selection with hilited list - we want to override that behavior
|
|
57
|
+
this._imodelAccess.hiliteSet.wantSyncWithSelectionSet = false;
|
|
58
|
+
this.applyCurrentHiliteSet({ activeSelectionAction: "clearAll" });
|
|
59
|
+
}
|
|
60
|
+
dispose() {
|
|
61
|
+
this._cancelOngoingChanges.next();
|
|
62
|
+
this._imodelListenerDisposeFunc();
|
|
63
|
+
this._unifiedSelectionListenerDisposeFunc();
|
|
64
|
+
if (!this._hasCustomCachingHiliteSetProvider) {
|
|
65
|
+
this._cachingHiliteSetProvider.dispose();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/** Temporarily suspends tool selection synchronization until the returned `IDisposable` is disposed. */
|
|
69
|
+
suspendIModelToolSelectionSync() {
|
|
70
|
+
const wasSuspended = this._isSuspended;
|
|
71
|
+
this._isSuspended = true;
|
|
72
|
+
return {
|
|
73
|
+
dispose: () => (this._isSuspended = wasSuspended),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
handleUnifiedSelectionChange(changeType, selectables, source) {
|
|
77
|
+
if (changeType === "clear" || changeType === "replace") {
|
|
78
|
+
this.applyCurrentHiliteSet({ activeSelectionAction: changeType === "replace" && source === "Tool" ? "clearHilited" : "clearAll" });
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (changeType === "add") {
|
|
82
|
+
(0, rxjs_1.from)(this._hiliteSetProvider.getHiliteSet({ selectables }))
|
|
83
|
+
.pipe((0, rxjs_1.takeUntil)(this._cancelOngoingChanges))
|
|
84
|
+
.subscribe({
|
|
85
|
+
next: (set) => {
|
|
86
|
+
this.addHiliteSet(set);
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
(0, rxjs_1.from)(this._hiliteSetProvider.getHiliteSet({ selectables }))
|
|
92
|
+
.pipe((0, rxjs_1.takeUntil)(this._cancelOngoingChanges))
|
|
93
|
+
.subscribe({
|
|
94
|
+
next: (set) => {
|
|
95
|
+
this.removeHiliteSet(set);
|
|
96
|
+
},
|
|
97
|
+
complete: () => {
|
|
98
|
+
this.applyCurrentHiliteSet({ activeSelectionAction: "keep" });
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
onUnifiedSelectionChanged = (args) => {
|
|
103
|
+
// iModels are only interested in top-level selection changes
|
|
104
|
+
if (args.imodelKey !== this._imodelAccess.key || args.level !== 0) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (args.changeType === "replace" || args.changeType === "clear") {
|
|
108
|
+
this._cancelOngoingChanges.next();
|
|
109
|
+
}
|
|
110
|
+
this.handleUnifiedSelectionChange(args.changeType, args.selectables, args.source);
|
|
111
|
+
};
|
|
112
|
+
applyCurrentHiliteSet({ activeSelectionAction }) {
|
|
113
|
+
if (activeSelectionAction !== "keep") {
|
|
114
|
+
(0, core_bentley_1.using)(this.suspendIModelToolSelectionSync(), (_) => {
|
|
115
|
+
this._imodelAccess.hiliteSet.clear();
|
|
116
|
+
if (activeSelectionAction === "clearAll") {
|
|
117
|
+
this._imodelAccess.selectionSet.emptyAll();
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
(0, rxjs_1.from)(this._cachingHiliteSetProvider.getHiliteSet({ imodelKey: this._imodelAccess.key }))
|
|
122
|
+
.pipe((0, rxjs_1.takeUntil)(this._cancelOngoingChanges))
|
|
123
|
+
.subscribe({
|
|
124
|
+
next: (ids) => {
|
|
125
|
+
this.addHiliteSet(ids);
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
addHiliteSet(set) {
|
|
130
|
+
(0, core_bentley_1.using)(this.suspendIModelToolSelectionSync(), (_) => {
|
|
131
|
+
if (set.models && set.models.length) {
|
|
132
|
+
this._imodelAccess.hiliteSet.models.addIds(set.models);
|
|
133
|
+
}
|
|
134
|
+
if (set.subCategories && set.subCategories.length) {
|
|
135
|
+
this._imodelAccess.hiliteSet.subcategories.addIds(set.subCategories);
|
|
136
|
+
}
|
|
137
|
+
if (set.elements && set.elements.length) {
|
|
138
|
+
this._imodelAccess.hiliteSet.elements.addIds(set.elements);
|
|
139
|
+
this._imodelAccess.selectionSet.add(set.elements);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
removeHiliteSet(set) {
|
|
144
|
+
(0, core_bentley_1.using)(this.suspendIModelToolSelectionSync(), (_) => {
|
|
145
|
+
if (set.models.length) {
|
|
146
|
+
this._imodelAccess.hiliteSet.models.deleteIds(set.models);
|
|
147
|
+
}
|
|
148
|
+
if (set.subCategories.length) {
|
|
149
|
+
this._imodelAccess.hiliteSet.subcategories.deleteIds(set.subCategories);
|
|
150
|
+
}
|
|
151
|
+
if (set.elements.length) {
|
|
152
|
+
this._imodelAccess.hiliteSet.elements.deleteIds(set.elements);
|
|
153
|
+
this._imodelAccess.selectionSet.remove(set.elements);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
onIModelSelectionChanged = async (event) => {
|
|
158
|
+
if (this._isSuspended) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (IModel_1.CoreSelectionSetEventType.Clear === event.type) {
|
|
162
|
+
this._selectionStorage.clearSelection({ imodelKey: this._imodelAccess.key, source: this._selectionSourceName });
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const elementIds = this.getSelectionSetChangeIds(event);
|
|
166
|
+
const scopedSelection = (0, SelectionScope_1.computeSelection)({ queryExecutor: this._imodelAccess, elementIds, scope: this._activeScopeProvider() });
|
|
167
|
+
await this.handleIModelSelectionChange(event.type, scopedSelection);
|
|
168
|
+
};
|
|
169
|
+
async handleIModelSelectionChange(type, iterator) {
|
|
170
|
+
if (type === IModel_1.CoreSelectionSetEventType.Remove) {
|
|
171
|
+
for await (const selectable of iterator) {
|
|
172
|
+
this._selectionStorage.removeFromSelection({ imodelKey: this._imodelAccess.key, source: this._selectionSourceName, selectables: [selectable] });
|
|
173
|
+
}
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (type === IModel_1.CoreSelectionSetEventType.Replace) {
|
|
177
|
+
this._selectionStorage.clearSelection({ imodelKey: this._imodelAccess.key, source: this._selectionSourceName });
|
|
178
|
+
}
|
|
179
|
+
for await (const selectable of iterator) {
|
|
180
|
+
this._selectionStorage.addToSelection({ imodelKey: this._imodelAccess.key, source: this._selectionSourceName, selectables: [selectable] });
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
getSelectionSetChangeIds(event) {
|
|
184
|
+
switch (event.type) {
|
|
185
|
+
case IModel_1.CoreSelectionSetEventType.Add:
|
|
186
|
+
case IModel_1.CoreSelectionSetEventType.Replace:
|
|
187
|
+
(0, core_bentley_1.assert)(!!event.added);
|
|
188
|
+
return this.idArgToIds(event.added);
|
|
189
|
+
default:
|
|
190
|
+
(0, core_bentley_1.assert)(!!event.removed);
|
|
191
|
+
return this.idArgToIds(event.removed);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
idArgToIds(ids) {
|
|
195
|
+
if (typeof ids === "string") {
|
|
196
|
+
return [ids];
|
|
197
|
+
}
|
|
198
|
+
if (ids instanceof Set) {
|
|
199
|
+
return [...ids];
|
|
200
|
+
}
|
|
201
|
+
return ids;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
exports.IModelSelectionHandler = IModelSelectionHandler;
|
|
205
|
+
//# sourceMappingURL=EnableUnifiedSelectionSyncWithIModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnableUnifiedSelectionSyncWithIModel.js","sourceRoot":"","sources":["../../../src/unified-selection/EnableUnifiedSelectionSyncWithIModel.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,+BAAgD;AAChD,sDAA6D;AAE7D,yEAAsG;AACtG,2DAA4F;AAG5F,qDAA2E;AAE3E,2CAAqI;AAoDrI;;;;GAIG;AACH,SAAgB,oCAAoC,CAAC,KAAgD;IACnG,MAAM,gBAAgB,GAAG,IAAI,sBAAsB,CAAC,KAAK,CAAC,CAAC;IAC3D,OAAO,GAAG,EAAE,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC;AAC1C,CAAC;AAHD,oFAGC;AAED;;;;GAIG;AACH,MAAa,sBAAsB;IACzB,oBAAoB,GAAG,MAAM,CAAC;IAE9B,aAAa,CAA4D;IACzE,iBAAiB,CAAmB;IACpC,kBAAkB,CAAoB;IACtC,yBAAyB,CAA2B;IACpD,oBAAoB,CAAuC;IAE3D,YAAY,CAAU;IACtB,qBAAqB,GAAG,IAAI,cAAO,EAAQ,CAAC;IAC5C,oCAAoC,CAAa;IACjD,0BAA0B,CAAa;IACvC,kCAAkC,CAAU;IAEpD,YAAmB,KAAgD;QACjE,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,YAAY,CAAC;QACxC,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC,gBAAgB,CAAC;QAChD,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC,mBAAmB,CAAC;QACtD,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAC1B,IAAI,CAAC,kCAAkC,GAAG,CAAC,CAAC,KAAK,CAAC,wBA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AAK,kCAAyB,CAAC,OAAO,EAAE,CAAC;YAC/C,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAC;QAClH,CAAC;QAED,IAAI,KAAK,EAAE,MAAM,UAAU,IAAI,QAAQ,EAAE,CAAC;YACxC,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,oBAAoB,EAAE,WAAW,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QAC7I,CAAC;IACH,CAAC;IAEO,wBAAwB,CAAC,KAAkC;QACjE,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;YACnB,KAAK,kCAAyB,CAAC,GAAG,CAAC;YACnC,KAAK,kCAAyB,CAAC,OAAO;gBACpC,IAAA,qBAAM,EAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBACtB,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACtC;gBACE,IAAA,qBAAM,EAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBACxB,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;IAEO,UAAU,CAAC,GAAY;QAC7B,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YAC5B,OAAO,CAAC,GAAG,CAAC,CAAC;QACf,CAAC;QACD,IAAI,GAAG,YAAY,GAAG,EAAE,CAAC;YACvB,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC;QAClB,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AAvMD,wDAuMC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { from, Subject, takeUntil } from \"rxjs\";\nimport { assert, Id64Arg, using } from \"@itwin/core-bentley\";\nimport { ECSchemaProvider, ECSqlQueryExecutor } from \"@itwin/presentation-shared\";\nimport { CachingHiliteSetProvider, createCachingHiliteSetProvider } from \"./CachingHiliteSetProvider\";\nimport { createHiliteSetProvider, HiliteSet, HiliteSetProvider } from \"./HiliteSetProvider\";\nimport { SelectableInstanceKey, Selectables } from \"./Selectable\";\nimport { StorageSelectionChangeEventArgs, StorageSelectionChangeType } from \"./SelectionChangeEvent\";\nimport { computeSelection, ComputeSelectionProps } from \"./SelectionScope\";\nimport { SelectionStorage } from \"./SelectionStorage\";\nimport { CoreIModelHiliteSet, CoreIModelSelectionSet, CoreSelectionSetEventType, CoreSelectionSetEventUnsafe } from \"./types/IModel\";\n\n/**\n * Props for `enableUnifiedSelectionSyncWithIModel`.\n * @internal Not exported through barrel, but used in public API as an argument. May be supplemented with optional attributes any time.\n */\nexport interface EnableUnifiedSelectionSyncWithIModelProps {\n /**\n * Provides access to different iModel's features: query executing, metadata access, selection and hilite sets.\n * It's recommended to use `@itwin/presentation-core-interop` to create `ECSqlQueryExecutor` and `ECSchemaProvider` from\n * [IModelConnection](https://www.itwinjs.org/reference/core-frontend/imodelconnection/imodelconnection/) and map its `key`,\n * `hilited` and `selectionSet` attributes like this:\n *\n * ```ts\n * import { createECSqlQueryExecutor, createECSchemaProvider } from \"@itwin/presentation-core-interop\";\n * import { IModelConnection } from \"@itwin/core-frontend\";\n *\n * const imodel: IModelConnection = ...\n * const imodelAccess = {\n * ...createECSqlQueryExecutor(imodel),\n * ...createECSchemaProvider(MyAppFrontend.getSchemaContext(imodel)),\n * key: imodel.key,\n * hiliteSet: imodel.hilited,\n * selectionSet: imodel.selectionSet,\n * };\n * ```.\n */\n imodelAccess: ECSqlQueryExecutor &\n ECSchemaProvider & {\n /** Key of the iModel. Generally taken from `IModelConnection.key`. */\n readonly key: string;\n /** The set of currently hilited elements taken from `IModelConnection.hilited`. */\n readonly hiliteSet: CoreIModelHiliteSet;\n /** The set of currently selected elements taken from `IModelConnection.selectionSet`. */\n readonly selectionSet: CoreIModelSelectionSet;\n };\n\n /** Selection storage to synchronize IModel's tool selection with. */\n selectionStorage: SelectionStorage;\n\n /** Active scope provider. */\n activeScopeProvider: () => ComputeSelectionProps[\"scope\"];\n\n /**\n * A caching hilite set provider used to retrieve hilite sets for an iModel. If not provided, a new `CachingHiliteSetProvider`\n * will be created for the given iModel using the provided `imodelAccess`.\n * If the consuming application already has a `CachingHiliteSetProvider` defined, it should be provided instead\n * to reuse the cache and avoid creating new providers for each iModel.\n */\n cachingHiliteSetProvider?: CachingHiliteSetProvider;\n}\n\n/**\n * Enables synchronization between iModel selection and unified selection.\n * @returns function for disposing the synchronization.\n * @beta\n */\nexport function enableUnifiedSelectionSyncWithIModel(props: EnableUnifiedSelectionSyncWithIModelProps): () => void {\n const selectionHandler = new IModelSelectionHandler(props);\n return () => selectionHandler.dispose();\n}\n\n/**\n * A handler that syncs selection between unified selection storage\n * (`SelectionStorage`) and an iModel (`iModel.selectionSet`, `iModel.hilited`).\n * @internal\n */\nexport class IModelSelectionHandler {\n private _selectionSourceName = \"Tool\";\n\n private _imodelAccess: EnableUnifiedSelectionSyncWithIModelProps[\"imodelAccess\"];\n private _selectionStorage: SelectionStorage;\n private _hiliteSetProvider: HiliteSetProvider;\n private _cachingHiliteSetProvider: CachingHiliteSetProvider;\n private _activeScopeProvider: () => ComputeSelectionProps[\"scope\"];\n\n private _isSuspended: boolean;\n private _cancelOngoingChanges = new Subject<void>();\n private _unifiedSelectionListenerDisposeFunc: () => void;\n private _imodelListenerDisposeFunc: () => void;\n private _hasCustomCachingHiliteSetProvider: boolean;\n\n public constructor(props: EnableUnifiedSelectionSyncWithIModelProps) {\n this._imodelAccess = props.imodelAccess;\n this._selectionStorage = props.selectionStorage;\n this._activeScopeProvider = props.activeScopeProvider;\n this._isSuspended = false;\n this._hasCustomCachingHiliteSetProvider = !!props.cachingHiliteSetProvider;\n\n this._cachingHiliteSetProvider =\n props.cachingHiliteSetProvider ??\n createCachingHiliteSetProvider({\n selectionStorage: this._selectionStorage,\n imodelProvider: () => this._imodelAccess,\n });\n\n this._hiliteSetProvider = createHiliteSetProvider({ imodelAccess: this._imodelAccess });\n this._imodelListenerDisposeFunc = this._imodelAccess.selectionSet.onChanged.addListener(this.onIModelSelectionChanged);\n this._unifiedSelectionListenerDisposeFunc = this._selectionStorage.selectionChangeEvent.addListener(this.onUnifiedSelectionChanged);\n\n // stop imodel from syncing tool selection with hilited list - we want to override that behavior\n this._imodelAccess.hiliteSet.wantSyncWithSelectionSet = false;\n this.applyCurrentHiliteSet({ activeSelectionAction: \"clearAll\" });\n }\n\n public dispose() {\n this._cancelOngoingChanges.next();\n this._imodelListenerDisposeFunc();\n this._unifiedSelectionListenerDisposeFunc();\n if (!this._hasCustomCachingHiliteSetProvider) {\n this._cachingHiliteSetProvider.dispose();\n }\n }\n\n /** Temporarily suspends tool selection synchronization until the returned `IDisposable` is disposed. */\n public suspendIModelToolSelectionSync() {\n const wasSuspended = this._isSuspended;\n this._isSuspended = true;\n return {\n dispose: () => (this._isSuspended = wasSuspended),\n };\n }\n\n private handleUnifiedSelectionChange(changeType: StorageSelectionChangeType, selectables: Selectables, source: string) {\n if (changeType === \"clear\" || changeType === \"replace\") {\n this.applyCurrentHiliteSet({ activeSelectionAction: changeType === \"replace\" && source === \"Tool\" ? \"clearHilited\" : \"clearAll\" });\n return;\n }\n\n if (changeType === \"add\") {\n from(this._hiliteSetProvider.getHiliteSet({ selectables }))\n .pipe(takeUntil(this._cancelOngoingChanges))\n .subscribe({\n next: (set) => {\n this.addHiliteSet(set);\n },\n });\n return;\n }\n\n from(this._hiliteSetProvider.getHiliteSet({ selectables }))\n .pipe(takeUntil(this._cancelOngoingChanges))\n .subscribe({\n next: (set) => {\n this.removeHiliteSet(set);\n },\n complete: () => {\n this.applyCurrentHiliteSet({ activeSelectionAction: \"keep\" });\n },\n });\n }\n\n private onUnifiedSelectionChanged = (args: StorageSelectionChangeEventArgs) => {\n // iModels are only interested in top-level selection changes\n if (args.imodelKey !== this._imodelAccess.key || args.level !== 0) {\n return;\n }\n\n if (args.changeType === \"replace\" || args.changeType === \"clear\") {\n this._cancelOngoingChanges.next();\n }\n this.handleUnifiedSelectionChange(args.changeType, args.selectables, args.source);\n };\n\n private applyCurrentHiliteSet({ activeSelectionAction }: { activeSelectionAction: \"clearAll\" | \"clearHilited\" | \"keep\" }) {\n if (activeSelectionAction !== \"keep\") {\n using(this.suspendIModelToolSelectionSync(), (_) => {\n this._imodelAccess.hiliteSet.clear();\n if (activeSelectionAction === \"clearAll\") {\n this._imodelAccess.selectionSet.emptyAll();\n }\n });\n }\n\n from(this._cachingHiliteSetProvider.getHiliteSet({ imodelKey: this._imodelAccess.key }))\n .pipe(takeUntil(this._cancelOngoingChanges))\n .subscribe({\n next: (ids) => {\n this.addHiliteSet(ids);\n },\n });\n }\n\n private addHiliteSet(set: HiliteSet) {\n using(this.suspendIModelToolSelectionSync(), (_) => {\n if (set.models && set.models.length) {\n this._imodelAccess.hiliteSet.models.addIds(set.models);\n }\n if (set.subCategories && set.subCategories.length) {\n this._imodelAccess.hiliteSet.subcategories.addIds(set.subCategories);\n }\n if (set.elements && set.elements.length) {\n this._imodelAccess.hiliteSet.elements.addIds(set.elements);\n this._imodelAccess.selectionSet.add(set.elements);\n }\n });\n }\n\n private removeHiliteSet(set: HiliteSet) {\n using(this.suspendIModelToolSelectionSync(), (_) => {\n if (set.models.length) {\n this._imodelAccess.hiliteSet.models.deleteIds(set.models);\n }\n if (set.subCategories.length) {\n this._imodelAccess.hiliteSet.subcategories.deleteIds(set.subCategories);\n }\n if (set.elements.length) {\n this._imodelAccess.hiliteSet.elements.deleteIds(set.elements);\n this._imodelAccess.selectionSet.remove(set.elements);\n }\n });\n }\n\n private onIModelSelectionChanged = async (event?: CoreSelectionSetEventUnsafe): Promise<void> => {\n if (this._isSuspended) {\n return;\n }\n\n if (CoreSelectionSetEventType.Clear === event!.type) {\n this._selectionStorage.clearSelection({ imodelKey: this._imodelAccess.key, source: this._selectionSourceName });\n return;\n }\n\n const elementIds = this.getSelectionSetChangeIds(event!);\n const scopedSelection = computeSelection({ queryExecutor: this._imodelAccess, elementIds, scope: this._activeScopeProvider() });\n await this.handleIModelSelectionChange(event!.type, scopedSelection);\n };\n\n private async handleIModelSelectionChange(type: CoreSelectionSetEventType, iterator: AsyncIterableIterator<SelectableInstanceKey>) {\n if (type === CoreSelectionSetEventType.Remove) {\n for await (const selectable of iterator) {\n this._selectionStorage.removeFromSelection({ imodelKey: this._imodelAccess.key, source: this._selectionSourceName, selectables: [selectable] });\n }\n return;\n }\n\n if (type === CoreSelectionSetEventType.Replace) {\n this._selectionStorage.clearSelection({ imodelKey: this._imodelAccess.key, source: this._selectionSourceName });\n }\n\n for await (const selectable of iterator) {\n this._selectionStorage.addToSelection({ imodelKey: this._imodelAccess.key, source: this._selectionSourceName, selectables: [selectable] });\n }\n }\n\n private getSelectionSetChangeIds(event: CoreSelectionSetEventUnsafe): string[] {\n switch (event.type) {\n case CoreSelectionSetEventType.Add:\n case CoreSelectionSetEventType.Replace:\n assert(!!event.added);\n return this.idArgToIds(event.added);\n default:\n assert(!!event.removed);\n return this.idArgToIds(event.removed);\n }\n }\n\n private idArgToIds(ids: Id64Arg): string[] {\n if (typeof ids === \"string\") {\n return [ids];\n }\n if (ids instanceof Set) {\n return [...ids];\n }\n return ids;\n }\n}\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ECSchemaProvider, ECSqlQueryExecutor } from "@itwin/presentation-shared";
|
|
2
|
+
import { Selectables } from "./Selectable";
|
|
3
|
+
/**
|
|
4
|
+
* A set of model, subcategory and element ids that can be used for specifying hilite.
|
|
5
|
+
* @see https://www.itwinjs.org/reference/core-frontend/selectionset/hiliteset/
|
|
6
|
+
* @beta
|
|
7
|
+
*/
|
|
8
|
+
export interface HiliteSet {
|
|
9
|
+
models: string[];
|
|
10
|
+
subCategories: string[];
|
|
11
|
+
elements: string[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Props for creating a `HiliteSetProvider` instance.
|
|
15
|
+
* @internal Not exported through barrel, but used in public API as an argument. May be supplemented with optional attributes any time.
|
|
16
|
+
*/
|
|
17
|
+
export interface HiliteSetProviderProps {
|
|
18
|
+
imodelAccess: ECSchemaProvider & ECSqlQueryExecutor;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Defines return value of `createHiliteSetProvider`.
|
|
22
|
+
*
|
|
23
|
+
* @beta Used in public API as a return value. Not expected to be created / extended by package
|
|
24
|
+
* consumers, may be supplemented with required attributes any time.
|
|
25
|
+
*/
|
|
26
|
+
export interface HiliteSetProvider {
|
|
27
|
+
/** Get the current hilite set iterator for the specified imodel */
|
|
28
|
+
getHiliteSet(props: {
|
|
29
|
+
selectables: Selectables;
|
|
30
|
+
}): AsyncIterableIterator<HiliteSet>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Creates a hilite set provider that returns a `HiliteSet` for given selectables.
|
|
34
|
+
* @beta
|
|
35
|
+
*/
|
|
36
|
+
export declare function createHiliteSetProvider(props: HiliteSetProviderProps): HiliteSetProvider;
|
|
37
|
+
//# sourceMappingURL=HiliteSetProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HiliteSetProvider.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/HiliteSetProvider.ts"],"names":[],"mappings":"AAOA,OAAO,EAAM,gBAAgB,EAAgB,kBAAkB,EAAsB,MAAM,4BAA4B,CAAC;AACxH,OAAO,EAAyB,WAAW,EAAE,MAAM,cAAc,CAAC;AAKlE;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,gBAAgB,GAAG,kBAAkB,CAAC;CACrD;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,mEAAmE;IACnE,YAAY,CAAC,KAAK,EAAE;QAAE,WAAW,EAAE,WAAW,CAAA;KAAE,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC;CACrF;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,sBAAsB,GAAG,iBAAiB,CAExF"}
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.createHiliteSetProvider = void 0;
|
|
8
|
+
const rxjs_1 = require("rxjs");
|
|
9
|
+
const rxjs_for_await_1 = require("rxjs-for-await");
|
|
10
|
+
const presentation_shared_1 = require("@itwin/presentation-shared");
|
|
11
|
+
const Utils_1 = require("./Utils");
|
|
12
|
+
const HILITE_SET_EMIT_FREQUENCY = 20;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a hilite set provider that returns a `HiliteSet` for given selectables.
|
|
15
|
+
* @beta
|
|
16
|
+
*/
|
|
17
|
+
function createHiliteSetProvider(props) {
|
|
18
|
+
return new HiliteSetProviderImpl(props);
|
|
19
|
+
}
|
|
20
|
+
exports.createHiliteSetProvider = createHiliteSetProvider;
|
|
21
|
+
class HiliteSetProviderImpl {
|
|
22
|
+
_imodelAccess;
|
|
23
|
+
// Map between a class name and its type
|
|
24
|
+
_classRelationCache;
|
|
25
|
+
constructor(props) {
|
|
26
|
+
this._imodelAccess = props.imodelAccess;
|
|
27
|
+
this._classRelationCache = new Map();
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get hilite set iterator for supplied `Selectables`.
|
|
31
|
+
*/
|
|
32
|
+
getHiliteSet(props) {
|
|
33
|
+
const obs = this.getHiliteSetObservable(props);
|
|
34
|
+
return (0, rxjs_for_await_1.eachValueFrom)(obs);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Returns a "hot" observable of hilite sets.
|
|
38
|
+
*/
|
|
39
|
+
getHiliteSetObservable({ selectables }) {
|
|
40
|
+
const instancesByType = this.getInstancesByType(selectables);
|
|
41
|
+
const observables = {
|
|
42
|
+
models: this.getHilitedModels(instancesByType),
|
|
43
|
+
subCategories: this.getHilitedSubCategories(instancesByType),
|
|
44
|
+
elements: this.getHilitedElements(instancesByType),
|
|
45
|
+
};
|
|
46
|
+
let hiliteSet = { models: [], subCategories: [], elements: [] };
|
|
47
|
+
let lastEmitTime = performance.now();
|
|
48
|
+
const subject = new rxjs_1.Subject();
|
|
49
|
+
const subscriptions = ["models", "subCategories", "elements"].map((key) => observables[key].subscribe({
|
|
50
|
+
next(val) {
|
|
51
|
+
hiliteSet[key].push(val);
|
|
52
|
+
if (performance.now() - lastEmitTime < HILITE_SET_EMIT_FREQUENCY) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
subject.next(hiliteSet);
|
|
56
|
+
hiliteSet = { models: [], subCategories: [], elements: [] };
|
|
57
|
+
lastEmitTime = performance.now();
|
|
58
|
+
},
|
|
59
|
+
complete() {
|
|
60
|
+
observables[key] = undefined;
|
|
61
|
+
if (observables.models || observables.subCategories || observables.elements) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
// Emit last batch before completing the observable.
|
|
65
|
+
if (hiliteSet.elements.length || hiliteSet.models.length || hiliteSet.subCategories.length) {
|
|
66
|
+
subject.next(hiliteSet);
|
|
67
|
+
}
|
|
68
|
+
subject.complete();
|
|
69
|
+
},
|
|
70
|
+
error(err) {
|
|
71
|
+
subscriptions.forEach((x) => x.unsubscribe());
|
|
72
|
+
subscriptions.length = 0;
|
|
73
|
+
subject.error(err);
|
|
74
|
+
},
|
|
75
|
+
}));
|
|
76
|
+
return subject;
|
|
77
|
+
}
|
|
78
|
+
async getType(key) {
|
|
79
|
+
const cachedType = this._classRelationCache.get(key.className.replace(".", ":"));
|
|
80
|
+
if (cachedType) {
|
|
81
|
+
return cachedType;
|
|
82
|
+
}
|
|
83
|
+
const promise = this.getTypeImpl(key).then((res) => {
|
|
84
|
+
// Update the cache with the result of the promise.
|
|
85
|
+
this._classRelationCache.set(key.className, res);
|
|
86
|
+
return res;
|
|
87
|
+
});
|
|
88
|
+
// Add the promise to cache to prevent `getTypeImpl` being called multiple times.
|
|
89
|
+
this._classRelationCache.set(key.className, promise);
|
|
90
|
+
return promise;
|
|
91
|
+
}
|
|
92
|
+
async getTypeImpl(key) {
|
|
93
|
+
const keyClass = await this.getClass(key.className);
|
|
94
|
+
return ((keyClass &&
|
|
95
|
+
((await this.checkType(keyClass, "BisCore", "Subject", "subject")) ??
|
|
96
|
+
(await this.checkType(keyClass, "BisCore", "Model", "model")) ??
|
|
97
|
+
(await this.checkType(keyClass, "BisCore", "Category", "category")) ??
|
|
98
|
+
(await this.checkType(keyClass, "BisCore", "SubCategory", "subCategory")) ??
|
|
99
|
+
(await this.checkType(keyClass, "Functional", "FunctionalElement", "functionalElement")) ??
|
|
100
|
+
(await this.checkType(keyClass, "BisCore", "GroupInformationElement", "groupInformationElement")) ??
|
|
101
|
+
(await this.checkType(keyClass, "BisCore", "GeometricElement", "geometricElement")) ??
|
|
102
|
+
(await this.checkType(keyClass, "BisCore", "Element", "element")))) ??
|
|
103
|
+
"unknown");
|
|
104
|
+
}
|
|
105
|
+
async checkType(keyClass, schemaName, className, type) {
|
|
106
|
+
return (await keyClass.is(className, schemaName)) ? type : undefined;
|
|
107
|
+
}
|
|
108
|
+
getInstancesByType(selectables) {
|
|
109
|
+
const keyTypeObs = (0, rxjs_1.merge)((0, rxjs_1.from)(selectables.custom.values()).pipe((0, rxjs_1.mergeMap)((selectable) => selectable.loadInstanceKeys())), (0, rxjs_1.from)(selectables.instanceKeys).pipe((0, rxjs_1.mergeMap)(([className, idSet]) => (0, rxjs_1.from)(idSet).pipe((0, rxjs_1.map)((id) => ({ className, id })))))).pipe(
|
|
110
|
+
// Get types for each instance key
|
|
111
|
+
(0, rxjs_1.mergeMap)((instanceKey) => (0, rxjs_1.from)(this.getType(instanceKey)).pipe((0, rxjs_1.map)((instanceIdType) => ({ instanceId: instanceKey.id, instanceIdType })))),
|
|
112
|
+
// Cache the results
|
|
113
|
+
(0, rxjs_1.shareReplay)());
|
|
114
|
+
return Object.fromEntries(INSTANCE_TYPES.map((type) => [
|
|
115
|
+
type,
|
|
116
|
+
keyTypeObs.pipe((0, rxjs_1.filter)(({ instanceIdType }) => instanceIdType === type), (0, rxjs_1.map)(({ instanceId }) => instanceId), unique()),
|
|
117
|
+
]));
|
|
118
|
+
}
|
|
119
|
+
getHilitedModels(instancesByType) {
|
|
120
|
+
return (0, rxjs_1.forkJoin)({
|
|
121
|
+
modelKeys: instancesByType.model.pipe((0, rxjs_1.toArray)()),
|
|
122
|
+
subjectKeys: instancesByType.subject.pipe((0, rxjs_1.toArray)()),
|
|
123
|
+
}).pipe((0, rxjs_1.mergeMap)(({ modelKeys, subjectKeys }) => {
|
|
124
|
+
if (!modelKeys.length && !subjectKeys.length) {
|
|
125
|
+
return rxjs_1.EMPTY;
|
|
126
|
+
}
|
|
127
|
+
const bindings = [];
|
|
128
|
+
const ctes = [
|
|
129
|
+
`
|
|
130
|
+
ChildSubjects(ECInstanceId, JsonProperties) AS (
|
|
131
|
+
SELECT ECInstanceId, JsonProperties
|
|
132
|
+
FROM BisCore.Subject
|
|
133
|
+
WHERE ${(0, Utils_1.formIdBindings)("ECInstanceId", subjectKeys, bindings)}
|
|
134
|
+
UNION ALL
|
|
135
|
+
SELECT r.ECInstanceId, r.JsonProperties
|
|
136
|
+
FROM ChildSubjects s
|
|
137
|
+
JOIN BisCore.Subject r ON r.Parent.Id = s.ECInstanceId
|
|
138
|
+
)
|
|
139
|
+
`,
|
|
140
|
+
`
|
|
141
|
+
Models(ECInstanceId) AS (
|
|
142
|
+
SELECT s.ECInstanceId AS ECInstanceId
|
|
143
|
+
FROM BisCore.Model s
|
|
144
|
+
WHERE ${(0, Utils_1.formIdBindings)("ECInstanceId", modelKeys, bindings)}
|
|
145
|
+
)
|
|
146
|
+
`,
|
|
147
|
+
];
|
|
148
|
+
const ecsql = [
|
|
149
|
+
`
|
|
150
|
+
SELECT r.ECInstanceId AS ECInstanceId
|
|
151
|
+
FROM ChildSubjects s
|
|
152
|
+
JOIN BisCore.PhysicalPartition r ON r.Parent.Id = s.ECInstanceId OR json_extract(s.JsonProperties,'$.Subject.Model.TargetPartition') = printf('0x%x', r.ECInstanceId)
|
|
153
|
+
`,
|
|
154
|
+
`
|
|
155
|
+
SELECT ECInstanceId FROM Models
|
|
156
|
+
`,
|
|
157
|
+
].join(" UNION ");
|
|
158
|
+
return (0, rxjs_1.from)(this._imodelAccess.createQueryReader({ ctes, ecsql, bindings }));
|
|
159
|
+
}), (0, rxjs_1.map)((row) => row.ECInstanceId));
|
|
160
|
+
}
|
|
161
|
+
getHilitedSubCategories(instancesByType) {
|
|
162
|
+
return (0, rxjs_1.forkJoin)({
|
|
163
|
+
subCategoryKeys: instancesByType.subCategory.pipe((0, rxjs_1.toArray)()),
|
|
164
|
+
categoryKeys: instancesByType.category.pipe((0, rxjs_1.toArray)()),
|
|
165
|
+
}).pipe((0, rxjs_1.mergeMap)(({ subCategoryKeys, categoryKeys }) => {
|
|
166
|
+
if (!subCategoryKeys.length && !categoryKeys.length) {
|
|
167
|
+
return rxjs_1.EMPTY;
|
|
168
|
+
}
|
|
169
|
+
const bindings = [];
|
|
170
|
+
const ctes = [
|
|
171
|
+
`
|
|
172
|
+
CategorySubCategories(ECInstanceId) AS (
|
|
173
|
+
SELECT r.ECInstanceId AS ECInstanceId
|
|
174
|
+
FROM BisCore.Category s
|
|
175
|
+
JOIN BisCore.SubCategory r ON r.Parent.Id = s.ECInstanceId
|
|
176
|
+
WHERE ${(0, Utils_1.formIdBindings)("s.ECInstanceId", categoryKeys, bindings)}
|
|
177
|
+
)
|
|
178
|
+
`,
|
|
179
|
+
`
|
|
180
|
+
SubCategories(ECInstanceId) AS (
|
|
181
|
+
SELECT s.ECInstanceId AS ECInstanceId
|
|
182
|
+
FROM BisCore.SubCategory s
|
|
183
|
+
WHERE ${(0, Utils_1.formIdBindings)("s.ECInstanceId", subCategoryKeys, bindings)}
|
|
184
|
+
)
|
|
185
|
+
`,
|
|
186
|
+
];
|
|
187
|
+
const ecsql = [`SELECT ECInstanceId FROM CategorySubCategories`, `SELECT ECInstanceId FROM SubCategories`].join(" UNION ");
|
|
188
|
+
return (0, rxjs_1.from)(this._imodelAccess.createQueryReader({ ctes, ecsql, bindings }));
|
|
189
|
+
}), (0, rxjs_1.map)((row) => row.ECInstanceId));
|
|
190
|
+
}
|
|
191
|
+
getHilitedElements(instancesByType) {
|
|
192
|
+
return (0, rxjs_1.forkJoin)({
|
|
193
|
+
groupInformationElementKeys: instancesByType.groupInformationElement.pipe((0, rxjs_1.toArray)()),
|
|
194
|
+
geometricElementKeys: instancesByType.geometricElement.pipe((0, rxjs_1.toArray)()),
|
|
195
|
+
functionalElements: instancesByType.functionalElement.pipe((0, rxjs_1.toArray)()),
|
|
196
|
+
elementKeys: instancesByType.element.pipe((0, rxjs_1.toArray)()),
|
|
197
|
+
}).pipe((0, rxjs_1.mergeMap)(({ groupInformationElementKeys, geometricElementKeys, functionalElements, elementKeys }) => {
|
|
198
|
+
const hasFunctionalElements = !!functionalElements.length;
|
|
199
|
+
if (!groupInformationElementKeys.length && !geometricElementKeys.length && !elementKeys.length && !hasFunctionalElements) {
|
|
200
|
+
return rxjs_1.EMPTY;
|
|
201
|
+
}
|
|
202
|
+
const bindings = [];
|
|
203
|
+
const ctes = [
|
|
204
|
+
...(hasFunctionalElements ? this.getHilitedFunctionalElementsQueryCTEs(functionalElements, bindings) : []),
|
|
205
|
+
`
|
|
206
|
+
GroupMembers(ECInstanceId, ECClassId) AS (
|
|
207
|
+
SELECT TargetECInstanceId, TargetECClassId
|
|
208
|
+
FROM BisCore.ElementGroupsMembers
|
|
209
|
+
WHERE ${(0, Utils_1.formIdBindings)("SourceECInstanceId", groupInformationElementKeys, bindings)}
|
|
210
|
+
)
|
|
211
|
+
`,
|
|
212
|
+
`
|
|
213
|
+
GroupGeometricElements(ECInstanceId, ECClassId) AS (
|
|
214
|
+
SELECT ECInstanceId, ECClassId FROM GroupMembers
|
|
215
|
+
UNION ALL
|
|
216
|
+
SELECT r.ECInstanceId, r.ECClassId
|
|
217
|
+
FROM GroupGeometricElements s
|
|
218
|
+
JOIN BisCore.Element r ON r.Parent.Id = s.ECInstanceId
|
|
219
|
+
)
|
|
220
|
+
`,
|
|
221
|
+
`
|
|
222
|
+
ElementGeometricElements(ECInstanceId, ECClassId) AS (
|
|
223
|
+
SELECT ECInstanceId, ECClassId
|
|
224
|
+
FROM BisCore.Element
|
|
225
|
+
WHERE ${(0, Utils_1.formIdBindings)("ECInstanceId", elementKeys, bindings)}
|
|
226
|
+
UNION ALL
|
|
227
|
+
SELECT r.ECInstanceId, r.ECClassId
|
|
228
|
+
FROM ElementGeometricElements s
|
|
229
|
+
JOIN BisCore.Element r ON r.Parent.Id = s.ECInstanceId
|
|
230
|
+
)
|
|
231
|
+
`,
|
|
232
|
+
`
|
|
233
|
+
GeometricElementGeometricElements(ECInstanceId, ECClassId) AS (
|
|
234
|
+
SELECT ECInstanceId, ECClassId
|
|
235
|
+
FROM BisCore.GeometricElement
|
|
236
|
+
WHERE ${(0, Utils_1.formIdBindings)("ECInstanceId", geometricElementKeys, bindings)}
|
|
237
|
+
UNION ALL
|
|
238
|
+
SELECT r.ECInstanceId, r.ECClassId
|
|
239
|
+
FROM GeometricElementGeometricElements s
|
|
240
|
+
JOIN BisCore.Element r ON r.Parent.Id = s.ECInstanceId
|
|
241
|
+
)
|
|
242
|
+
`,
|
|
243
|
+
];
|
|
244
|
+
const ecsql = [
|
|
245
|
+
...(hasFunctionalElements ? ["SELECT ECInstanceId FROM FunctionalElementChildGeometricElements WHERE ECClassId IS (BisCore.GeometricElement)"] : []),
|
|
246
|
+
"SELECT ECInstanceId FROM GeometricElementGeometricElements WHERE ECClassId IS (BisCore.GeometricElement)",
|
|
247
|
+
"SELECT ECInstanceId FROM GroupGeometricElements WHERE ECClassId IS (BisCore.GeometricElement)",
|
|
248
|
+
"SELECT ECInstanceId FROM ElementGeometricElements WHERE ECClassId IS (BisCore.GeometricElement)",
|
|
249
|
+
].join(" UNION ");
|
|
250
|
+
return (0, rxjs_1.from)(this._imodelAccess.createQueryReader({ ctes, ecsql, bindings }));
|
|
251
|
+
}), (0, rxjs_1.map)((row) => row.ECInstanceId));
|
|
252
|
+
}
|
|
253
|
+
getHilitedFunctionalElementsQueryCTEs(functionalElements, bindings) {
|
|
254
|
+
return [
|
|
255
|
+
`
|
|
256
|
+
ChildFunctionalElements(ECInstanceId, ECClassId) AS (
|
|
257
|
+
SELECT ECInstanceId, ECClassId
|
|
258
|
+
FROM Functional.FunctionalElement
|
|
259
|
+
WHERE ${(0, Utils_1.formIdBindings)("ECInstanceId", functionalElements, bindings)}
|
|
260
|
+
UNION ALL
|
|
261
|
+
SELECT r.ECInstanceId, r.ECClassId
|
|
262
|
+
FROM ChildFunctionalElements s
|
|
263
|
+
JOIN Functional.FunctionalElement r ON r.Parent.Id = s.ECInstanceId
|
|
264
|
+
)
|
|
265
|
+
`,
|
|
266
|
+
`
|
|
267
|
+
PhysicalElements(ECInstanceId, ECClassId) AS (
|
|
268
|
+
SELECT r.SourceECInstanceId, r.SourceECClassId
|
|
269
|
+
FROM ChildFunctionalElements s
|
|
270
|
+
JOIN Functional.PhysicalElementFulfillsFunction r ON r.TargetECInstanceId = s.ECInstanceId
|
|
271
|
+
)
|
|
272
|
+
`,
|
|
273
|
+
`
|
|
274
|
+
DrawingGraphicElements(ECInstanceId, ECClassId) AS (
|
|
275
|
+
SELECT r.SourceECInstanceId, r.SourceECClassId
|
|
276
|
+
FROM ChildFunctionalElements s
|
|
277
|
+
JOIN Functional.DrawingGraphicRepresentsFunctionalElement r ON r.TargetECInstanceId = s.ECInstanceId
|
|
278
|
+
)
|
|
279
|
+
`,
|
|
280
|
+
`
|
|
281
|
+
PhysicalElementGeometricElements(ECInstanceId, ECClassId) AS (
|
|
282
|
+
SELECT ECInstanceId, ECClassId FROM PhysicalElements
|
|
283
|
+
UNION ALL
|
|
284
|
+
SELECT r.ECInstanceId, r.ECClassId
|
|
285
|
+
FROM PhysicalElementGeometricElements s
|
|
286
|
+
JOIN BisCore.Element r ON r.Parent.Id = s.ECInstanceId
|
|
287
|
+
)
|
|
288
|
+
`,
|
|
289
|
+
`
|
|
290
|
+
DrawingGraphicElementGeometricElements(ECInstanceId, ECClassId) AS (
|
|
291
|
+
SELECT ECInstanceId, ECClassId FROM DrawingGraphicElements
|
|
292
|
+
UNION ALL
|
|
293
|
+
SELECT r.ECInstanceId, r.ECClassId
|
|
294
|
+
FROM DrawingGraphicElementGeometricElements s
|
|
295
|
+
JOIN BisCore.Element r ON r.Parent.Id = s.ECInstanceId
|
|
296
|
+
)
|
|
297
|
+
`,
|
|
298
|
+
`
|
|
299
|
+
FunctionalElementChildGeometricElements(ECInstanceId, ECClassId) AS (
|
|
300
|
+
SELECT ECInstanceId, ECClassId FROM PhysicalElementGeometricElements
|
|
301
|
+
UNION
|
|
302
|
+
SELECT ECInstanceId, ECClassId FROM DrawingGraphicElementGeometricElements
|
|
303
|
+
)
|
|
304
|
+
`,
|
|
305
|
+
];
|
|
306
|
+
}
|
|
307
|
+
async getClass(fullClassName) {
|
|
308
|
+
const { schemaName, className } = (0, presentation_shared_1.parseFullClassName)(fullClassName);
|
|
309
|
+
const schema = await this._imodelAccess.getSchema(schemaName);
|
|
310
|
+
if (!schema) {
|
|
311
|
+
return undefined;
|
|
312
|
+
}
|
|
313
|
+
const schemaClass = await schema.getClass(className);
|
|
314
|
+
if (!schemaClass) {
|
|
315
|
+
return undefined;
|
|
316
|
+
}
|
|
317
|
+
return schemaClass;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
const INSTANCE_TYPES = [
|
|
321
|
+
"subject",
|
|
322
|
+
"model",
|
|
323
|
+
"category",
|
|
324
|
+
"subCategory",
|
|
325
|
+
"functionalElement",
|
|
326
|
+
"groupInformationElement",
|
|
327
|
+
"geometricElement",
|
|
328
|
+
"element",
|
|
329
|
+
"unknown",
|
|
330
|
+
];
|
|
331
|
+
function unique() {
|
|
332
|
+
return function (obs) {
|
|
333
|
+
return obs.pipe((0, rxjs_1.scan)((acc, val) => {
|
|
334
|
+
if (acc.set.has(val)) {
|
|
335
|
+
delete acc.val;
|
|
336
|
+
return acc;
|
|
337
|
+
}
|
|
338
|
+
acc.set.add(val);
|
|
339
|
+
acc.val = val;
|
|
340
|
+
return acc;
|
|
341
|
+
}, { set: new Set() }), (0, rxjs_1.map)(({ val }) => val), (0, rxjs_1.filter)((x) => !!x));
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
//# sourceMappingURL=HiliteSetProvider.js.map
|