@itwin/presentation-backend 4.0.0-dev.8 → 4.0.0-dev.81
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 +47 -1
- package/lib/cjs/assets/primary-presentation-rules/ElementProperties.PresentationRuleSet.json +14 -14
- package/lib/cjs/assets/supplemental-presentation-rules/BisCore.PresentationRuleSet.json +726 -762
- package/lib/cjs/assets/supplemental-presentation-rules/Functional.PresentationRuleSet.json +139 -139
- package/lib/cjs/presentation-backend/BackendLoggerCategory.d.ts +41 -41
- package/lib/cjs/presentation-backend/BackendLoggerCategory.js +50 -50
- package/lib/cjs/presentation-backend/BackendLoggerCategory.js.map +1 -1
- 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 +272 -274
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.js.map +1 -1
- package/lib/cjs/presentation-backend/NativePlatform.d.ts +87 -87
- package/lib/cjs/presentation-backend/NativePlatform.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/NativePlatform.js +147 -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 -150
- package/lib/cjs/presentation-backend/Presentation.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts +11 -12
- package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationIpcHandler.js +30 -41
- package/lib/cjs/presentation-backend/PresentationIpcHandler.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManager.d.ts +463 -445
- package/lib/cjs/presentation-backend/PresentationManager.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManager.js +317 -311
- package/lib/cjs/presentation-backend/PresentationManager.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts +61 -61
- package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManagerDetail.js +442 -430
- 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.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js +388 -388
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js.map +1 -1
- package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts +102 -102
- package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/RulesetEmbedder.js +287 -282
- 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/RulesetManager.js.map +1 -1
- package/lib/cjs/presentation-backend/RulesetVariablesManager.d.ts +140 -140
- package/lib/cjs/presentation-backend/RulesetVariablesManager.js +129 -129
- package/lib/cjs/presentation-backend/RulesetVariablesManager.js.map +1 -1
- package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts +28 -28
- package/lib/cjs/presentation-backend/SelectionScopesHelper.js +226 -229
- package/lib/cjs/presentation-backend/SelectionScopesHelper.js.map +1 -1
- package/lib/cjs/presentation-backend/TemporaryStorage.d.ts +123 -123
- package/lib/cjs/presentation-backend/TemporaryStorage.js +151 -151
- package/lib/cjs/presentation-backend/TemporaryStorage.js.map +1 -1
- package/lib/cjs/presentation-backend/UpdatesTracker.d.ts +27 -27
- package/lib/cjs/presentation-backend/UpdatesTracker.js +54 -54
- package/lib/cjs/presentation-backend/UpdatesTracker.js.map +1 -1
- 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 -106
- package/lib/cjs/presentation-backend/Utils.js.map +1 -1
- 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/domain/RulesetElements.js.map +1 -1
- 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 +20 -18
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
/** @packageDocumentation
|
|
2
|
-
* @module Core
|
|
3
|
-
*/
|
|
4
|
-
import { IModelDb } from "@itwin/core-backend";
|
|
5
|
-
import { Id64String } from "@itwin/core-bentley";
|
|
6
|
-
import { ComputeSelectionRequestOptions, KeySet, SelectionScope, SelectionScopeRequestOptions } from "@itwin/presentation-common";
|
|
7
|
-
/**
|
|
8
|
-
* Contains helper methods for computing selection scopes. Will get removed
|
|
9
|
-
* once rules-driven scopes are implemented.
|
|
10
|
-
*
|
|
11
|
-
* @internal
|
|
12
|
-
*/
|
|
13
|
-
export declare class SelectionScopesHelper {
|
|
14
|
-
private constructor();
|
|
15
|
-
static getSelectionScopes(): SelectionScope[];
|
|
16
|
-
private static getElementKey;
|
|
17
|
-
private static computeElementSelection;
|
|
18
|
-
private static computeCategorySelection;
|
|
19
|
-
private static computeModelSelection;
|
|
20
|
-
private static getRelatedFunctionalElementKey;
|
|
21
|
-
private static findFirstRelatedFunctionalElementKey;
|
|
22
|
-
private static elementClassDerivesFrom;
|
|
23
|
-
private static computeFunctionalElementSelection;
|
|
24
|
-
private static computeFunctionalAssemblySelection;
|
|
25
|
-
private static computeFunctionalTopAssemblySelection;
|
|
26
|
-
static computeSelection(requestOptions: SelectionScopeRequestOptions<IModelDb>, ids: Id64String[], scopeId: string): Promise<KeySet>;
|
|
27
|
-
static computeSelection(requestOptions: ComputeSelectionRequestOptions<IModelDb>): Promise<KeySet>;
|
|
28
|
-
}
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Core
|
|
3
|
+
*/
|
|
4
|
+
import { IModelDb } from "@itwin/core-backend";
|
|
5
|
+
import { Id64String } from "@itwin/core-bentley";
|
|
6
|
+
import { ComputeSelectionRequestOptions, KeySet, SelectionScope, SelectionScopeRequestOptions } from "@itwin/presentation-common";
|
|
7
|
+
/**
|
|
8
|
+
* Contains helper methods for computing selection scopes. Will get removed
|
|
9
|
+
* once rules-driven scopes are implemented.
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare class SelectionScopesHelper {
|
|
14
|
+
private constructor();
|
|
15
|
+
static getSelectionScopes(): SelectionScope[];
|
|
16
|
+
private static getElementKey;
|
|
17
|
+
private static computeElementSelection;
|
|
18
|
+
private static computeCategorySelection;
|
|
19
|
+
private static computeModelSelection;
|
|
20
|
+
private static getRelatedFunctionalElementKey;
|
|
21
|
+
private static findFirstRelatedFunctionalElementKey;
|
|
22
|
+
private static elementClassDerivesFrom;
|
|
23
|
+
private static computeFunctionalElementSelection;
|
|
24
|
+
private static computeFunctionalAssemblySelection;
|
|
25
|
+
private static computeFunctionalTopAssemblySelection;
|
|
26
|
+
static computeSelection(requestOptions: SelectionScopeRequestOptions<IModelDb>, ids: Id64String[], scopeId: string): Promise<KeySet>;
|
|
27
|
+
static computeSelection(requestOptions: ComputeSelectionRequestOptions<IModelDb>): Promise<KeySet>;
|
|
28
|
+
}
|
|
29
29
|
//# sourceMappingURL=SelectionScopesHelper.d.ts.map
|
|
@@ -1,230 +1,227 @@
|
|
|
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
|
-
|
|
41
|
-
let
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
LEFT JOIN func.
|
|
85
|
-
LEFT JOIN func.
|
|
86
|
-
|
|
87
|
-
INNER JOIN meta.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
INNER JOIN meta.
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
stmt.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
case "
|
|
210
|
-
case "
|
|
211
|
-
case "
|
|
212
|
-
case "
|
|
213
|
-
|
|
214
|
-
case "functional":
|
|
215
|
-
case "functional-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
callback(id);
|
|
228
|
-
};
|
|
229
|
-
};
|
|
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
|
+
const query = `
|
|
81
|
+
SELECT funcSchemaDef.Name || '.' || funcClassDef.Name funcElClassName, fe.ECInstanceId funcElId
|
|
82
|
+
FROM bis.Element e
|
|
83
|
+
LEFT JOIN func.PhysicalElementFulfillsFunction rel1 ON rel1.SourceECInstanceId = e.ECInstanceId
|
|
84
|
+
LEFT JOIN func.DrawingGraphicRepresentsFunctionalElement rel2 ON rel2.SourceECInstanceId = e.ECInstanceId
|
|
85
|
+
LEFT JOIN func.FunctionalElement fe ON fe.ECInstanceId IN (rel1.TargetECInstanceId, rel2.TargetECInstanceId)
|
|
86
|
+
INNER JOIN meta.ECClassDef funcClassDef ON funcClassDef.ECInstanceId = fe.ECClassId
|
|
87
|
+
INNER JOIN meta.ECSchemaDef funcSchemaDef ON funcSchemaDef.ECInstanceId = funcClassDef.Schema.Id
|
|
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) {
|
|
112
|
+
const query = `
|
|
113
|
+
SELECT 1
|
|
114
|
+
FROM bis.Element e
|
|
115
|
+
INNER JOIN meta.ClassHasAllBaseClasses baseClassRels ON baseClassRels.SourceECInstanceId = e.ECClassId
|
|
116
|
+
INNER JOIN meta.ECClassDef baseClass ON baseClass.ECInstanceId = baseClassRels.TargetECInstanceId
|
|
117
|
+
INNER JOIN meta.ECSchemaDef baseSchema ON baseSchema.ECInstanceId = baseClass.Schema.Id
|
|
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
|
+
};
|
|
230
227
|
//# sourceMappingURL=SelectionScopesHelper.js.map
|