@itwin/presentation-backend 4.0.0-dev.52 → 4.0.0-dev.54
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/lib/cjs/presentation-backend/BackendLoggerCategory.d.ts +41 -41
- package/lib/cjs/presentation-backend/BackendLoggerCategory.js +50 -50
- package/lib/cjs/presentation-backend/Constants.d.ts +8 -8
- package/lib/cjs/presentation-backend/Constants.js +40 -36
- package/lib/cjs/presentation-backend/Constants.js.map +1 -1
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts +11 -11
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.js +260 -260
- package/lib/cjs/presentation-backend/NativePlatform.d.ts +87 -87
- package/lib/cjs/presentation-backend/NativePlatform.js +140 -140
- package/lib/cjs/presentation-backend/NativePlatform.js.map +1 -1
- package/lib/cjs/presentation-backend/Presentation.d.ts +106 -106
- package/lib/cjs/presentation-backend/Presentation.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/Presentation.js +148 -148
- package/lib/cjs/presentation-backend/Presentation.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts +12 -12
- package/lib/cjs/presentation-backend/PresentationIpcHandler.js +41 -41
- package/lib/cjs/presentation-backend/PresentationManager.d.ts +456 -456
- package/lib/cjs/presentation-backend/PresentationManager.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManager.js +309 -309
- package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts +61 -61
- package/lib/cjs/presentation-backend/PresentationManagerDetail.js +430 -426
- package/lib/cjs/presentation-backend/PresentationManagerDetail.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts +62 -62
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js +388 -388
- package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts +102 -102
- package/lib/cjs/presentation-backend/RulesetEmbedder.js +283 -279
- package/lib/cjs/presentation-backend/RulesetEmbedder.js.map +1 -1
- package/lib/cjs/presentation-backend/RulesetManager.d.ts +53 -53
- package/lib/cjs/presentation-backend/RulesetManager.js +73 -73
- package/lib/cjs/presentation-backend/RulesetVariablesManager.d.ts +140 -140
- package/lib/cjs/presentation-backend/RulesetVariablesManager.js +129 -129
- package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts +28 -28
- package/lib/cjs/presentation-backend/SelectionScopesHelper.js +210 -210
- package/lib/cjs/presentation-backend/TemporaryStorage.d.ts +123 -123
- package/lib/cjs/presentation-backend/TemporaryStorage.js +151 -151
- package/lib/cjs/presentation-backend/UpdatesTracker.d.ts +27 -27
- package/lib/cjs/presentation-backend/UpdatesTracker.js +54 -54
- package/lib/cjs/presentation-backend/Utils.d.ts +49 -49
- package/lib/cjs/presentation-backend/Utils.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/Utils.js +107 -107
- package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.d.ts +16 -16
- package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js +55 -51
- package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js.map +1 -1
- package/lib/cjs/presentation-backend/domain/RulesetElements.d.ts +21 -21
- package/lib/cjs/presentation-backend/domain/RulesetElements.js +38 -38
- package/lib/cjs/presentation-backend.d.ts +19 -19
- package/lib/cjs/presentation-backend.js +39 -35
- package/lib/cjs/presentation-backend.js.map +1 -1
- package/package.json +14 -14
|
@@ -1,82 +1,82 @@
|
|
|
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
|
-
/** @packageDocumentation
|
|
7
|
-
* @module Core
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.SelectionScopesHelper = void 0;
|
|
11
|
-
const core_backend_1 = require("@itwin/core-backend");
|
|
12
|
-
const core_bentley_1 = require("@itwin/core-bentley");
|
|
13
|
-
const presentation_common_1 = require("@itwin/presentation-common");
|
|
14
|
-
const Utils_1 = require("./Utils");
|
|
15
|
-
/**
|
|
16
|
-
* Contains helper methods for computing selection scopes. Will get removed
|
|
17
|
-
* once rules-driven scopes are implemented.
|
|
18
|
-
*
|
|
19
|
-
* @internal
|
|
20
|
-
*/
|
|
21
|
-
class SelectionScopesHelper {
|
|
22
|
-
// istanbul ignore next
|
|
23
|
-
constructor() { }
|
|
24
|
-
static getSelectionScopes() {
|
|
25
|
-
const createSelectionScope = (scopeId, label, description) => ({
|
|
26
|
-
id: scopeId,
|
|
27
|
-
label,
|
|
28
|
-
description,
|
|
29
|
-
});
|
|
30
|
-
return [
|
|
31
|
-
createSelectionScope("element", "Element", "Select the picked element"),
|
|
32
|
-
createSelectionScope("assembly", "Assembly", "Select parent of the picked element"),
|
|
33
|
-
createSelectionScope("top-assembly", "Top Assembly", "Select the topmost parent of the picked element"),
|
|
34
|
-
// WIP: temporarily comment-out "category" and "model" scopes since we can't hilite contents of them fast enough
|
|
35
|
-
// createSelectionScope("category", "Category", "Select all elements in the picked element's category"),
|
|
36
|
-
// createSelectionScope("model", "Model", "Select all elements in the picked element's model"),
|
|
37
|
-
];
|
|
38
|
-
}
|
|
39
|
-
static getElementKey(iModel, elementId, ancestorLevel) {
|
|
40
|
-
let currId = elementId;
|
|
41
|
-
let parentId = iModel.elements.tryGetElementProps(currId)?.parent?.id;
|
|
42
|
-
while (parentId && ancestorLevel !== 0) {
|
|
43
|
-
currId = parentId;
|
|
44
|
-
parentId = iModel.elements.tryGetElementProps(currId)?.parent?.id;
|
|
45
|
-
--ancestorLevel;
|
|
46
|
-
}
|
|
47
|
-
return (0, Utils_1.getElementKey)(iModel, currId);
|
|
48
|
-
}
|
|
49
|
-
static computeElementSelection(iModel, elementIds, ancestorLevel) {
|
|
50
|
-
const parentKeys = new presentation_common_1.KeySet();
|
|
51
|
-
elementIds.forEach(skipTransients((id) => {
|
|
52
|
-
const key = this.getElementKey(iModel, id, ancestorLevel);
|
|
53
|
-
key && parentKeys.add(key);
|
|
54
|
-
}));
|
|
55
|
-
return parentKeys;
|
|
56
|
-
}
|
|
57
|
-
static computeCategorySelection(iModel, ids) {
|
|
58
|
-
const categoryKeys = new presentation_common_1.KeySet();
|
|
59
|
-
ids.forEach(skipTransients((id) => {
|
|
60
|
-
const el = iModel.elements.tryGetElement(id);
|
|
61
|
-
if (el instanceof core_backend_1.GeometricElement) {
|
|
62
|
-
const category = iModel.elements.tryGetElementProps(el.category);
|
|
63
|
-
if (category)
|
|
64
|
-
categoryKeys.add({ className: category.classFullName, id: category.id });
|
|
65
|
-
}
|
|
66
|
-
}));
|
|
67
|
-
return categoryKeys;
|
|
68
|
-
}
|
|
69
|
-
static computeModelSelection(iModel, ids) {
|
|
70
|
-
const modelKeys = new presentation_common_1.KeySet();
|
|
71
|
-
ids.forEach(skipTransients((id) => {
|
|
72
|
-
const el = iModel.elements.tryGetElementProps(id);
|
|
73
|
-
const model = el ? iModel.models.tryGetModelProps(el.model) : undefined;
|
|
74
|
-
if (model)
|
|
75
|
-
modelKeys.add({ className: model.classFullName, id: model.id });
|
|
76
|
-
}));
|
|
77
|
-
return modelKeys;
|
|
78
|
-
}
|
|
79
|
-
static getRelatedFunctionalElementKey(imodel, graphicalElementId) {
|
|
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
|
+
/** @packageDocumentation
|
|
7
|
+
* @module Core
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.SelectionScopesHelper = void 0;
|
|
11
|
+
const core_backend_1 = require("@itwin/core-backend");
|
|
12
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
13
|
+
const presentation_common_1 = require("@itwin/presentation-common");
|
|
14
|
+
const Utils_1 = require("./Utils");
|
|
15
|
+
/**
|
|
16
|
+
* Contains helper methods for computing selection scopes. Will get removed
|
|
17
|
+
* once rules-driven scopes are implemented.
|
|
18
|
+
*
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
class SelectionScopesHelper {
|
|
22
|
+
// istanbul ignore next
|
|
23
|
+
constructor() { }
|
|
24
|
+
static getSelectionScopes() {
|
|
25
|
+
const createSelectionScope = (scopeId, label, description) => ({
|
|
26
|
+
id: scopeId,
|
|
27
|
+
label,
|
|
28
|
+
description,
|
|
29
|
+
});
|
|
30
|
+
return [
|
|
31
|
+
createSelectionScope("element", "Element", "Select the picked element"),
|
|
32
|
+
createSelectionScope("assembly", "Assembly", "Select parent of the picked element"),
|
|
33
|
+
createSelectionScope("top-assembly", "Top Assembly", "Select the topmost parent of the picked element"),
|
|
34
|
+
// WIP: temporarily comment-out "category" and "model" scopes since we can't hilite contents of them fast enough
|
|
35
|
+
// createSelectionScope("category", "Category", "Select all elements in the picked element's category"),
|
|
36
|
+
// createSelectionScope("model", "Model", "Select all elements in the picked element's model"),
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
static getElementKey(iModel, elementId, ancestorLevel) {
|
|
40
|
+
let currId = elementId;
|
|
41
|
+
let parentId = iModel.elements.tryGetElementProps(currId)?.parent?.id;
|
|
42
|
+
while (parentId && ancestorLevel !== 0) {
|
|
43
|
+
currId = parentId;
|
|
44
|
+
parentId = iModel.elements.tryGetElementProps(currId)?.parent?.id;
|
|
45
|
+
--ancestorLevel;
|
|
46
|
+
}
|
|
47
|
+
return (0, Utils_1.getElementKey)(iModel, currId);
|
|
48
|
+
}
|
|
49
|
+
static computeElementSelection(iModel, elementIds, ancestorLevel) {
|
|
50
|
+
const parentKeys = new presentation_common_1.KeySet();
|
|
51
|
+
elementIds.forEach(skipTransients((id) => {
|
|
52
|
+
const key = this.getElementKey(iModel, id, ancestorLevel);
|
|
53
|
+
key && parentKeys.add(key);
|
|
54
|
+
}));
|
|
55
|
+
return parentKeys;
|
|
56
|
+
}
|
|
57
|
+
static computeCategorySelection(iModel, ids) {
|
|
58
|
+
const categoryKeys = new presentation_common_1.KeySet();
|
|
59
|
+
ids.forEach(skipTransients((id) => {
|
|
60
|
+
const el = iModel.elements.tryGetElement(id);
|
|
61
|
+
if (el instanceof core_backend_1.GeometricElement) {
|
|
62
|
+
const category = iModel.elements.tryGetElementProps(el.category);
|
|
63
|
+
if (category)
|
|
64
|
+
categoryKeys.add({ className: category.classFullName, id: category.id });
|
|
65
|
+
}
|
|
66
|
+
}));
|
|
67
|
+
return categoryKeys;
|
|
68
|
+
}
|
|
69
|
+
static computeModelSelection(iModel, ids) {
|
|
70
|
+
const modelKeys = new presentation_common_1.KeySet();
|
|
71
|
+
ids.forEach(skipTransients((id) => {
|
|
72
|
+
const el = iModel.elements.tryGetElementProps(id);
|
|
73
|
+
const model = el ? iModel.models.tryGetModelProps(el.model) : undefined;
|
|
74
|
+
if (model)
|
|
75
|
+
modelKeys.add({ className: model.classFullName, id: model.id });
|
|
76
|
+
}));
|
|
77
|
+
return modelKeys;
|
|
78
|
+
}
|
|
79
|
+
static getRelatedFunctionalElementKey(imodel, graphicalElementId) {
|
|
80
80
|
const query = `
|
|
81
81
|
SELECT funcSchemaDef.Name || '.' || funcClassDef.Name funcElClassName, fe.ECInstanceId funcElId
|
|
82
82
|
FROM bis.Element e
|
|
@@ -86,29 +86,29 @@ class SelectionScopesHelper {
|
|
|
86
86
|
INNER JOIN meta.ECClassDef funcClassDef ON funcClassDef.ECInstanceId = fe.ECClassId
|
|
87
87
|
INNER JOIN meta.ECSchemaDef funcSchemaDef ON funcSchemaDef.ECInstanceId = funcClassDef.Schema.Id
|
|
88
88
|
WHERE e.ECInstanceId = ?
|
|
89
|
-
`;
|
|
90
|
-
return imodel.withPreparedStatement(query, (stmt) => {
|
|
91
|
-
stmt.bindId(1, graphicalElementId);
|
|
92
|
-
// istanbul ignore else
|
|
93
|
-
if (core_bentley_1.DbResult.BE_SQLITE_ROW === stmt.step()) {
|
|
94
|
-
const row = stmt.getRow();
|
|
95
|
-
if (row.funcElClassName && row.funcElId)
|
|
96
|
-
return { className: row.funcElClassName.replace(".", ":"), id: row.funcElId };
|
|
97
|
-
}
|
|
98
|
-
return undefined;
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
static findFirstRelatedFunctionalElementKey(imodel, graphicalElementId) {
|
|
102
|
-
let currId = graphicalElementId;
|
|
103
|
-
while (currId) {
|
|
104
|
-
const relatedFunctionalKey = this.getRelatedFunctionalElementKey(imodel, currId);
|
|
105
|
-
if (relatedFunctionalKey)
|
|
106
|
-
return relatedFunctionalKey;
|
|
107
|
-
currId = imodel.elements.tryGetElementProps(currId)?.parent?.id;
|
|
108
|
-
}
|
|
109
|
-
return undefined;
|
|
110
|
-
}
|
|
111
|
-
static elementClassDerivesFrom(imodel, elementId, baseClassFullName) {
|
|
89
|
+
`;
|
|
90
|
+
return imodel.withPreparedStatement(query, (stmt) => {
|
|
91
|
+
stmt.bindId(1, graphicalElementId);
|
|
92
|
+
// istanbul ignore else
|
|
93
|
+
if (core_bentley_1.DbResult.BE_SQLITE_ROW === stmt.step()) {
|
|
94
|
+
const row = stmt.getRow();
|
|
95
|
+
if (row.funcElClassName && row.funcElId)
|
|
96
|
+
return { className: row.funcElClassName.replace(".", ":"), id: row.funcElId };
|
|
97
|
+
}
|
|
98
|
+
return undefined;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
static findFirstRelatedFunctionalElementKey(imodel, graphicalElementId) {
|
|
102
|
+
let currId = graphicalElementId;
|
|
103
|
+
while (currId) {
|
|
104
|
+
const relatedFunctionalKey = this.getRelatedFunctionalElementKey(imodel, currId);
|
|
105
|
+
if (relatedFunctionalKey)
|
|
106
|
+
return relatedFunctionalKey;
|
|
107
|
+
currId = imodel.elements.tryGetElementProps(currId)?.parent?.id;
|
|
108
|
+
}
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
static elementClassDerivesFrom(imodel, elementId, baseClassFullName) {
|
|
112
112
|
const query = `
|
|
113
113
|
SELECT 1
|
|
114
114
|
FROM bis.Element e
|
|
@@ -116,112 +116,112 @@ class SelectionScopesHelper {
|
|
|
116
116
|
INNER JOIN meta.ECClassDef baseClass ON baseClass.ECInstanceId = baseClassRels.TargetECInstanceId
|
|
117
117
|
INNER JOIN meta.ECSchemaDef baseSchema ON baseSchema.ECInstanceId = baseClass.Schema.Id
|
|
118
118
|
WHERE e.ECInstanceId = ? AND (baseSchema.Name || ':' || baseClass.Name) = ?
|
|
119
|
-
`;
|
|
120
|
-
return imodel.withPreparedStatement(query, (stmt) => {
|
|
121
|
-
stmt.bindId(1, elementId);
|
|
122
|
-
stmt.bindString(2, baseClassFullName);
|
|
123
|
-
return (core_bentley_1.DbResult.BE_SQLITE_ROW === stmt.step());
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
static computeFunctionalElementSelection(iModel, ids) {
|
|
127
|
-
const keys = new presentation_common_1.KeySet();
|
|
128
|
-
ids.forEach(skipTransients((id) => {
|
|
129
|
-
const is3d = this.elementClassDerivesFrom(iModel, id, core_backend_1.GeometricElement3d.classFullName);
|
|
130
|
-
if (!is3d) {
|
|
131
|
-
// if the input is not a 3d element, we try to find the first related functional element
|
|
132
|
-
const firstFunctionalKey = this.findFirstRelatedFunctionalElementKey(iModel, id);
|
|
133
|
-
if (firstFunctionalKey) {
|
|
134
|
-
keys.add(firstFunctionalKey);
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
let keyToAdd;
|
|
139
|
-
if (is3d) {
|
|
140
|
-
// if we're computing scope for a 3d element, try to switch to its related functional element
|
|
141
|
-
keyToAdd = this.getRelatedFunctionalElementKey(iModel, id);
|
|
142
|
-
}
|
|
143
|
-
if (!keyToAdd)
|
|
144
|
-
keyToAdd = (0, Utils_1.getElementKey)(iModel, id);
|
|
145
|
-
keyToAdd && keys.add(keyToAdd);
|
|
146
|
-
}));
|
|
147
|
-
return keys;
|
|
148
|
-
}
|
|
149
|
-
static computeFunctionalAssemblySelection(iModel, ids) {
|
|
150
|
-
const keys = new presentation_common_1.KeySet();
|
|
151
|
-
ids.forEach(skipTransients((id) => {
|
|
152
|
-
let idToGetAssemblyFor = id;
|
|
153
|
-
const is3d = this.elementClassDerivesFrom(iModel, id, core_backend_1.GeometricElement3d.classFullName);
|
|
154
|
-
if (!is3d) {
|
|
155
|
-
// if the input is not a 3d element, we try to find the first related functional element
|
|
156
|
-
const firstFunctionalKey = this.findFirstRelatedFunctionalElementKey(iModel, id);
|
|
157
|
-
if (firstFunctionalKey)
|
|
158
|
-
idToGetAssemblyFor = firstFunctionalKey.id;
|
|
159
|
-
}
|
|
160
|
-
// find the assembly of either the given element or the functional element
|
|
161
|
-
const assemblyKey = this.getElementKey(iModel, idToGetAssemblyFor, 1);
|
|
162
|
-
let keyToAdd = assemblyKey;
|
|
163
|
-
if (is3d && keyToAdd) {
|
|
164
|
-
// if we're computing scope for a 3d element, try to switch to its related functional element
|
|
165
|
-
const relatedFunctionalKey = this.getRelatedFunctionalElementKey(iModel, keyToAdd.id);
|
|
166
|
-
if (relatedFunctionalKey)
|
|
167
|
-
keyToAdd = relatedFunctionalKey;
|
|
168
|
-
}
|
|
169
|
-
keyToAdd && keys.add(keyToAdd);
|
|
170
|
-
}));
|
|
171
|
-
return keys;
|
|
172
|
-
}
|
|
173
|
-
static computeFunctionalTopAssemblySelection(iModel, ids) {
|
|
174
|
-
const keys = new presentation_common_1.KeySet();
|
|
175
|
-
ids.forEach(skipTransients((id) => {
|
|
176
|
-
let idToGetAssemblyFor = id;
|
|
177
|
-
const is3d = this.elementClassDerivesFrom(iModel, id, core_backend_1.GeometricElement3d.classFullName);
|
|
178
|
-
if (!is3d) {
|
|
179
|
-
// if the input is not a 3d element, we try to find the first related functional element
|
|
180
|
-
const firstFunctionalKey = this.findFirstRelatedFunctionalElementKey(iModel, id);
|
|
181
|
-
if (firstFunctionalKey)
|
|
182
|
-
idToGetAssemblyFor = firstFunctionalKey.id;
|
|
183
|
-
}
|
|
184
|
-
// find the top assembly of either the given element or the functional element
|
|
185
|
-
const topAssemblyKey = this.getElementKey(iModel, idToGetAssemblyFor, Number.MAX_SAFE_INTEGER);
|
|
186
|
-
let keyToAdd = topAssemblyKey;
|
|
187
|
-
if (is3d && keyToAdd) {
|
|
188
|
-
// if we're computing scope for a 3d element, try to switch to its related functional element
|
|
189
|
-
const relatedFunctionalKey = this.getRelatedFunctionalElementKey(iModel, keyToAdd.id);
|
|
190
|
-
if (relatedFunctionalKey)
|
|
191
|
-
keyToAdd = relatedFunctionalKey;
|
|
192
|
-
}
|
|
193
|
-
keyToAdd && keys.add(keyToAdd);
|
|
194
|
-
}));
|
|
195
|
-
return keys;
|
|
196
|
-
}
|
|
197
|
-
static async computeSelection(requestOptions, elementIds, scopeId) {
|
|
198
|
-
if (!(0, presentation_common_1.isComputeSelectionRequestOptions)(requestOptions)) {
|
|
199
|
-
return this.computeSelection({
|
|
200
|
-
...requestOptions,
|
|
201
|
-
elementIds: elementIds,
|
|
202
|
-
scope: { id: scopeId },
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
switch (requestOptions.scope.id) {
|
|
206
|
-
case "element": return this.computeElementSelection(requestOptions.imodel, requestOptions.elementIds, requestOptions.scope.ancestorLevel ?? 0);
|
|
207
|
-
case "assembly": return this.computeElementSelection(requestOptions.imodel, requestOptions.elementIds, 1);
|
|
208
|
-
case "top-assembly": return this.computeElementSelection(requestOptions.imodel, requestOptions.elementIds, Number.MAX_SAFE_INTEGER);
|
|
209
|
-
case "category": return this.computeCategorySelection(requestOptions.imodel, requestOptions.elementIds);
|
|
210
|
-
case "model": return this.computeModelSelection(requestOptions.imodel, requestOptions.elementIds);
|
|
211
|
-
case "functional":
|
|
212
|
-
case "functional-element":
|
|
213
|
-
return this.computeFunctionalElementSelection(requestOptions.imodel, requestOptions.elementIds);
|
|
214
|
-
case "functional-assembly": return this.computeFunctionalAssemblySelection(requestOptions.imodel, requestOptions.elementIds);
|
|
215
|
-
case "functional-top-assembly": return this.computeFunctionalTopAssemblySelection(requestOptions.imodel, requestOptions.elementIds);
|
|
216
|
-
}
|
|
217
|
-
throw new presentation_common_1.PresentationError(presentation_common_1.PresentationStatus.InvalidArgument, "scopeId");
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
exports.SelectionScopesHelper = SelectionScopesHelper;
|
|
221
|
-
const skipTransients = (callback) => {
|
|
222
|
-
return (id) => {
|
|
223
|
-
if (!core_bentley_1.Id64.isTransient(id))
|
|
224
|
-
callback(id);
|
|
225
|
-
};
|
|
226
|
-
};
|
|
119
|
+
`;
|
|
120
|
+
return imodel.withPreparedStatement(query, (stmt) => {
|
|
121
|
+
stmt.bindId(1, elementId);
|
|
122
|
+
stmt.bindString(2, baseClassFullName);
|
|
123
|
+
return (core_bentley_1.DbResult.BE_SQLITE_ROW === stmt.step());
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
static computeFunctionalElementSelection(iModel, ids) {
|
|
127
|
+
const keys = new presentation_common_1.KeySet();
|
|
128
|
+
ids.forEach(skipTransients((id) => {
|
|
129
|
+
const is3d = this.elementClassDerivesFrom(iModel, id, core_backend_1.GeometricElement3d.classFullName);
|
|
130
|
+
if (!is3d) {
|
|
131
|
+
// if the input is not a 3d element, we try to find the first related functional element
|
|
132
|
+
const firstFunctionalKey = this.findFirstRelatedFunctionalElementKey(iModel, id);
|
|
133
|
+
if (firstFunctionalKey) {
|
|
134
|
+
keys.add(firstFunctionalKey);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
let keyToAdd;
|
|
139
|
+
if (is3d) {
|
|
140
|
+
// if we're computing scope for a 3d element, try to switch to its related functional element
|
|
141
|
+
keyToAdd = this.getRelatedFunctionalElementKey(iModel, id);
|
|
142
|
+
}
|
|
143
|
+
if (!keyToAdd)
|
|
144
|
+
keyToAdd = (0, Utils_1.getElementKey)(iModel, id);
|
|
145
|
+
keyToAdd && keys.add(keyToAdd);
|
|
146
|
+
}));
|
|
147
|
+
return keys;
|
|
148
|
+
}
|
|
149
|
+
static computeFunctionalAssemblySelection(iModel, ids) {
|
|
150
|
+
const keys = new presentation_common_1.KeySet();
|
|
151
|
+
ids.forEach(skipTransients((id) => {
|
|
152
|
+
let idToGetAssemblyFor = id;
|
|
153
|
+
const is3d = this.elementClassDerivesFrom(iModel, id, core_backend_1.GeometricElement3d.classFullName);
|
|
154
|
+
if (!is3d) {
|
|
155
|
+
// if the input is not a 3d element, we try to find the first related functional element
|
|
156
|
+
const firstFunctionalKey = this.findFirstRelatedFunctionalElementKey(iModel, id);
|
|
157
|
+
if (firstFunctionalKey)
|
|
158
|
+
idToGetAssemblyFor = firstFunctionalKey.id;
|
|
159
|
+
}
|
|
160
|
+
// find the assembly of either the given element or the functional element
|
|
161
|
+
const assemblyKey = this.getElementKey(iModel, idToGetAssemblyFor, 1);
|
|
162
|
+
let keyToAdd = assemblyKey;
|
|
163
|
+
if (is3d && keyToAdd) {
|
|
164
|
+
// if we're computing scope for a 3d element, try to switch to its related functional element
|
|
165
|
+
const relatedFunctionalKey = this.getRelatedFunctionalElementKey(iModel, keyToAdd.id);
|
|
166
|
+
if (relatedFunctionalKey)
|
|
167
|
+
keyToAdd = relatedFunctionalKey;
|
|
168
|
+
}
|
|
169
|
+
keyToAdd && keys.add(keyToAdd);
|
|
170
|
+
}));
|
|
171
|
+
return keys;
|
|
172
|
+
}
|
|
173
|
+
static computeFunctionalTopAssemblySelection(iModel, ids) {
|
|
174
|
+
const keys = new presentation_common_1.KeySet();
|
|
175
|
+
ids.forEach(skipTransients((id) => {
|
|
176
|
+
let idToGetAssemblyFor = id;
|
|
177
|
+
const is3d = this.elementClassDerivesFrom(iModel, id, core_backend_1.GeometricElement3d.classFullName);
|
|
178
|
+
if (!is3d) {
|
|
179
|
+
// if the input is not a 3d element, we try to find the first related functional element
|
|
180
|
+
const firstFunctionalKey = this.findFirstRelatedFunctionalElementKey(iModel, id);
|
|
181
|
+
if (firstFunctionalKey)
|
|
182
|
+
idToGetAssemblyFor = firstFunctionalKey.id;
|
|
183
|
+
}
|
|
184
|
+
// find the top assembly of either the given element or the functional element
|
|
185
|
+
const topAssemblyKey = this.getElementKey(iModel, idToGetAssemblyFor, Number.MAX_SAFE_INTEGER);
|
|
186
|
+
let keyToAdd = topAssemblyKey;
|
|
187
|
+
if (is3d && keyToAdd) {
|
|
188
|
+
// if we're computing scope for a 3d element, try to switch to its related functional element
|
|
189
|
+
const relatedFunctionalKey = this.getRelatedFunctionalElementKey(iModel, keyToAdd.id);
|
|
190
|
+
if (relatedFunctionalKey)
|
|
191
|
+
keyToAdd = relatedFunctionalKey;
|
|
192
|
+
}
|
|
193
|
+
keyToAdd && keys.add(keyToAdd);
|
|
194
|
+
}));
|
|
195
|
+
return keys;
|
|
196
|
+
}
|
|
197
|
+
static async computeSelection(requestOptions, elementIds, scopeId) {
|
|
198
|
+
if (!(0, presentation_common_1.isComputeSelectionRequestOptions)(requestOptions)) {
|
|
199
|
+
return this.computeSelection({
|
|
200
|
+
...requestOptions,
|
|
201
|
+
elementIds: elementIds,
|
|
202
|
+
scope: { id: scopeId },
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
switch (requestOptions.scope.id) {
|
|
206
|
+
case "element": return this.computeElementSelection(requestOptions.imodel, requestOptions.elementIds, requestOptions.scope.ancestorLevel ?? 0);
|
|
207
|
+
case "assembly": return this.computeElementSelection(requestOptions.imodel, requestOptions.elementIds, 1);
|
|
208
|
+
case "top-assembly": return this.computeElementSelection(requestOptions.imodel, requestOptions.elementIds, Number.MAX_SAFE_INTEGER);
|
|
209
|
+
case "category": return this.computeCategorySelection(requestOptions.imodel, requestOptions.elementIds);
|
|
210
|
+
case "model": return this.computeModelSelection(requestOptions.imodel, requestOptions.elementIds);
|
|
211
|
+
case "functional":
|
|
212
|
+
case "functional-element":
|
|
213
|
+
return this.computeFunctionalElementSelection(requestOptions.imodel, requestOptions.elementIds);
|
|
214
|
+
case "functional-assembly": return this.computeFunctionalAssemblySelection(requestOptions.imodel, requestOptions.elementIds);
|
|
215
|
+
case "functional-top-assembly": return this.computeFunctionalTopAssemblySelection(requestOptions.imodel, requestOptions.elementIds);
|
|
216
|
+
}
|
|
217
|
+
throw new presentation_common_1.PresentationError(presentation_common_1.PresentationStatus.InvalidArgument, "scopeId");
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
exports.SelectionScopesHelper = SelectionScopesHelper;
|
|
221
|
+
const skipTransients = (callback) => {
|
|
222
|
+
return (id) => {
|
|
223
|
+
if (!core_bentley_1.Id64.isTransient(id))
|
|
224
|
+
callback(id);
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
227
|
//# sourceMappingURL=SelectionScopesHelper.js.map
|