@itwin/grouping-mapping-widget 0.3.3 → 0.4.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/lib/cjs/formula/FormulaTokensValidator.d.ts +1 -1
- package/lib/cjs/formula/FormulaTokensValidator.js +3 -1
- package/lib/cjs/formula/FormulaTokensValidator.js.map +1 -1
- package/lib/cjs/formula/FormulaValidator.d.ts +1 -1
- package/lib/cjs/formula/FormulaValidator.js +2 -2
- package/lib/cjs/formula/FormulaValidator.js.map +1 -1
- package/lib/cjs/grouping-mapping-widget.d.ts +4 -0
- package/lib/cjs/grouping-mapping-widget.js +6 -1
- package/lib/cjs/grouping-mapping-widget.js.map +1 -1
- package/lib/cjs/widget/GroupingMappingWidget.d.ts +3 -1
- package/lib/cjs/widget/GroupingMappingWidget.js +3 -2
- package/lib/cjs/widget/GroupingMappingWidget.js.map +1 -1
- package/lib/cjs/widget/IMappingClient.d.ts +327 -0
- package/lib/cjs/widget/IMappingClient.js +7 -0
- package/lib/cjs/widget/IMappingClient.js.map +1 -0
- package/lib/cjs/widget/components/BlockingOverlay.d.ts +7 -0
- package/lib/cjs/widget/components/BlockingOverlay.js +21 -0
- package/lib/cjs/widget/components/BlockingOverlay.js.map +1 -0
- package/lib/cjs/widget/components/BlockingOverlay.scss +26 -0
- package/lib/cjs/widget/components/CalculatedPropertyAction.js +3 -4
- package/lib/cjs/widget/components/CalculatedPropertyAction.js.map +1 -1
- package/lib/cjs/widget/components/CalculatedPropertyTable.js +2 -3
- package/lib/cjs/widget/components/CalculatedPropertyTable.js.map +1 -1
- package/lib/cjs/widget/components/ConfirmMappingsImport.js +2 -3
- package/lib/cjs/widget/components/ConfirmMappingsImport.js.map +1 -1
- package/lib/cjs/widget/components/CustomCalculationAction.js +4 -5
- package/lib/cjs/widget/components/CustomCalculationAction.js.map +1 -1
- package/lib/cjs/widget/components/CustomCalculationTable.js +2 -3
- package/lib/cjs/widget/components/CustomCalculationTable.js.map +1 -1
- package/lib/cjs/widget/components/GroupAction.d.ts +2 -1
- package/lib/cjs/widget/components/GroupAction.js +15 -10
- package/lib/cjs/widget/components/GroupAction.js.map +1 -1
- package/lib/cjs/widget/components/GroupPropertyAction.js +5 -7
- package/lib/cjs/widget/components/GroupPropertyAction.js.map +1 -1
- package/lib/cjs/widget/components/GroupPropertyTable.js +2 -3
- package/lib/cjs/widget/components/GroupPropertyTable.js.map +1 -1
- package/lib/cjs/widget/components/GroupQueryBuilderContainer.js +1 -0
- package/lib/cjs/widget/components/GroupQueryBuilderContainer.js.map +1 -1
- package/lib/cjs/widget/components/GroupQueryBuilderContext.d.ts +1 -0
- package/lib/cjs/widget/components/GroupQueryBuilderContext.js +1 -0
- package/lib/cjs/widget/components/GroupQueryBuilderContext.js.map +1 -1
- package/lib/cjs/widget/components/GroupTile.d.ts +13 -0
- package/lib/cjs/widget/components/GroupTile.js +18 -0
- package/lib/cjs/widget/components/GroupTile.js.map +1 -0
- package/lib/cjs/widget/components/GroupTile.scss +32 -0
- package/lib/cjs/widget/components/Grouping.js +224 -164
- package/lib/cjs/widget/components/Grouping.js.map +1 -1
- package/lib/cjs/widget/components/Grouping.scss +39 -4
- package/lib/cjs/widget/components/GroupingMapping.d.ts +15 -3
- package/lib/cjs/widget/components/GroupingMapping.js +29 -5
- package/lib/cjs/widget/components/GroupingMapping.js.map +1 -1
- package/lib/cjs/widget/components/Mapping.js +33 -12
- package/lib/cjs/widget/components/Mapping.js.map +1 -1
- package/lib/cjs/widget/components/MappingAction.js +10 -5
- package/lib/cjs/widget/components/MappingAction.js.map +1 -1
- package/lib/cjs/widget/components/PropertyMenu.js +26 -19
- package/lib/cjs/widget/components/PropertyMenu.js.map +1 -1
- package/lib/cjs/widget/components/QueryBuilder.d.ts +11 -5
- package/lib/cjs/widget/components/QueryBuilder.js +229 -141
- package/lib/cjs/widget/components/QueryBuilder.js.map +1 -1
- package/lib/cjs/widget/components/SelectMappings.js +5 -6
- package/lib/cjs/widget/components/SelectMappings.js.map +1 -1
- package/lib/cjs/widget/components/property-grid/PropertyView.js +5 -0
- package/lib/cjs/widget/components/property-grid/PropertyView.js.map +1 -1
- package/lib/cjs/widget/components/utils.d.ts +6 -0
- package/lib/cjs/widget/components/utils.js +9 -1
- package/lib/cjs/widget/components/utils.js.map +1 -1
- package/lib/cjs/widget/components/utils.scss +12 -3
- package/lib/cjs/widget/components/viewerUtils.d.ts +19 -0
- package/lib/cjs/widget/components/viewerUtils.js +224 -3
- package/lib/cjs/widget/components/viewerUtils.js.map +1 -1
- package/lib/cjs/widget/hooks/useFormulaValidation.d.ts +1 -1
- package/lib/cjs/widget/hooks/useFormulaValidation.js +5 -5
- package/lib/cjs/widget/hooks/useFormulaValidation.js.map +1 -1
- package/lib/esm/formula/FormulaTokensValidator.d.ts +1 -1
- package/lib/esm/formula/FormulaTokensValidator.js +3 -1
- package/lib/esm/formula/FormulaTokensValidator.js.map +1 -1
- package/lib/esm/formula/FormulaValidator.d.ts +1 -1
- package/lib/esm/formula/FormulaValidator.js +2 -2
- package/lib/esm/formula/FormulaValidator.js.map +1 -1
- package/lib/esm/grouping-mapping-widget.d.ts +4 -0
- package/lib/esm/grouping-mapping-widget.js +4 -0
- package/lib/esm/grouping-mapping-widget.js.map +1 -1
- package/lib/esm/widget/GroupingMappingWidget.d.ts +3 -1
- package/lib/esm/widget/GroupingMappingWidget.js +3 -2
- package/lib/esm/widget/GroupingMappingWidget.js.map +1 -1
- package/lib/esm/widget/IMappingClient.d.ts +327 -0
- package/lib/esm/widget/IMappingClient.js +6 -0
- package/lib/esm/widget/IMappingClient.js.map +1 -0
- package/lib/esm/widget/components/BlockingOverlay.d.ts +7 -0
- package/lib/esm/widget/components/BlockingOverlay.js +14 -0
- package/lib/esm/widget/components/BlockingOverlay.js.map +1 -0
- package/lib/esm/widget/components/BlockingOverlay.scss +26 -0
- package/lib/esm/widget/components/CalculatedPropertyAction.js +4 -5
- package/lib/esm/widget/components/CalculatedPropertyAction.js.map +1 -1
- package/lib/esm/widget/components/CalculatedPropertyTable.js +3 -4
- package/lib/esm/widget/components/CalculatedPropertyTable.js.map +1 -1
- package/lib/esm/widget/components/ConfirmMappingsImport.js +3 -4
- package/lib/esm/widget/components/ConfirmMappingsImport.js.map +1 -1
- package/lib/esm/widget/components/CustomCalculationAction.js +5 -6
- package/lib/esm/widget/components/CustomCalculationAction.js.map +1 -1
- package/lib/esm/widget/components/CustomCalculationTable.js +3 -4
- package/lib/esm/widget/components/CustomCalculationTable.js.map +1 -1
- package/lib/esm/widget/components/GroupAction.d.ts +2 -1
- package/lib/esm/widget/components/GroupAction.js +17 -12
- package/lib/esm/widget/components/GroupAction.js.map +1 -1
- package/lib/esm/widget/components/GroupPropertyAction.js +6 -8
- package/lib/esm/widget/components/GroupPropertyAction.js.map +1 -1
- package/lib/esm/widget/components/GroupPropertyTable.js +3 -4
- package/lib/esm/widget/components/GroupPropertyTable.js.map +1 -1
- package/lib/esm/widget/components/GroupQueryBuilderContainer.js +1 -0
- package/lib/esm/widget/components/GroupQueryBuilderContainer.js.map +1 -1
- package/lib/esm/widget/components/GroupQueryBuilderContext.d.ts +1 -0
- package/lib/esm/widget/components/GroupQueryBuilderContext.js +1 -0
- package/lib/esm/widget/components/GroupQueryBuilderContext.js.map +1 -1
- package/lib/esm/widget/components/GroupTile.d.ts +13 -0
- package/lib/esm/widget/components/GroupTile.js +11 -0
- package/lib/esm/widget/components/GroupTile.js.map +1 -0
- package/lib/esm/widget/components/GroupTile.scss +32 -0
- package/lib/esm/widget/components/Grouping.js +230 -170
- package/lib/esm/widget/components/Grouping.js.map +1 -1
- package/lib/esm/widget/components/Grouping.scss +39 -4
- package/lib/esm/widget/components/GroupingMapping.d.ts +15 -3
- package/lib/esm/widget/components/GroupingMapping.js +27 -4
- package/lib/esm/widget/components/GroupingMapping.js.map +1 -1
- package/lib/esm/widget/components/Mapping.js +35 -14
- package/lib/esm/widget/components/Mapping.js.map +1 -1
- package/lib/esm/widget/components/MappingAction.js +12 -7
- package/lib/esm/widget/components/MappingAction.js.map +1 -1
- package/lib/esm/widget/components/PropertyMenu.js +28 -21
- package/lib/esm/widget/components/PropertyMenu.js.map +1 -1
- package/lib/esm/widget/components/QueryBuilder.d.ts +11 -5
- package/lib/esm/widget/components/QueryBuilder.js +230 -142
- package/lib/esm/widget/components/QueryBuilder.js.map +1 -1
- package/lib/esm/widget/components/SelectMappings.js +6 -7
- package/lib/esm/widget/components/SelectMappings.js.map +1 -1
- package/lib/esm/widget/components/property-grid/PropertyView.js +5 -0
- package/lib/esm/widget/components/property-grid/PropertyView.js.map +1 -1
- package/lib/esm/widget/components/utils.d.ts +6 -0
- package/lib/esm/widget/components/utils.js +6 -0
- package/lib/esm/widget/components/utils.js.map +1 -1
- package/lib/esm/widget/components/utils.scss +12 -3
- package/lib/esm/widget/components/viewerUtils.d.ts +19 -0
- package/lib/esm/widget/components/viewerUtils.js +207 -3
- package/lib/esm/widget/components/viewerUtils.js.map +1 -1
- package/lib/esm/widget/hooks/useFormulaValidation.d.ts +1 -1
- package/lib/esm/widget/hooks/useFormulaValidation.js +5 -5
- package/lib/esm/widget/hooks/useFormulaValidation.js.map +1 -1
- package/package.json +30 -30
|
@@ -1,10 +1,180 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.clearEmphasizedElements = exports.manufactureKeys = exports.zoomToElements = exports.visualizeElements = exports.visualizeElementsByKeys = exports.visualizeElementsById = void 0;
|
|
3
|
+
exports.clearAll = exports.clearEmphasizedOverriddenElements = exports.clearEmphasizedElements = exports.manufactureKeys = exports.getHiliteIds = exports.zoomToElements = exports.transparentOverriddenElements = exports.visualizeElements = exports.visualizeElementsByKeys = exports.visualizeElementsById = exports.emphasizeElementsByKeys = exports.emphasisElementsById = exports.emphasizeElements = exports.clearOverriddenElements = exports.overrideElements = exports.overrideElementsById = exports.clearHiddenElements = exports.hideElements = exports.hideElementsById = exports.clearIsolatedElements = exports.isolateElements = exports.isolateElementsById = exports.isolateElementsByKeys = void 0;
|
|
4
4
|
const core_frontend_1 = require("@itwin/core-frontend");
|
|
5
5
|
const core_common_1 = require("@itwin/core-common");
|
|
6
6
|
const presentation_common_1 = require("@itwin/presentation-common");
|
|
7
7
|
const presentation_frontend_1 = require("@itwin/presentation-frontend");
|
|
8
|
+
const isolateElementsByKeys = async (keySet, replace = false) => {
|
|
9
|
+
if (!core_frontend_1.IModelApp.viewManager.selectedView) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
const vp = core_frontend_1.IModelApp.viewManager.selectedView;
|
|
13
|
+
const hiliteProvider = presentation_frontend_1.HiliteSetProvider.create({
|
|
14
|
+
imodel: vp.iModel,
|
|
15
|
+
});
|
|
16
|
+
const set = await hiliteProvider.getHiliteSet(keySet);
|
|
17
|
+
if (set.elements) {
|
|
18
|
+
const ids = [...set.elements];
|
|
19
|
+
exports.isolateElements(ids, replace);
|
|
20
|
+
return ids;
|
|
21
|
+
}
|
|
22
|
+
return [];
|
|
23
|
+
};
|
|
24
|
+
exports.isolateElementsByKeys = isolateElementsByKeys;
|
|
25
|
+
const isolateElementsById = async (elementIds, iModelConnection, replace = false) => {
|
|
26
|
+
if (!core_frontend_1.IModelApp.viewManager.selectedView) {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
const vp = core_frontend_1.IModelApp.viewManager.selectedView;
|
|
30
|
+
const keySet = await exports.manufactureKeys(elementIds, iModelConnection);
|
|
31
|
+
const hiliteProvider = presentation_frontend_1.HiliteSetProvider.create({
|
|
32
|
+
imodel: vp.iModel,
|
|
33
|
+
});
|
|
34
|
+
const set = await hiliteProvider.getHiliteSet(keySet);
|
|
35
|
+
if (set.elements) {
|
|
36
|
+
const ids = [...set.elements];
|
|
37
|
+
exports.isolateElements(ids, replace);
|
|
38
|
+
return ids;
|
|
39
|
+
}
|
|
40
|
+
return [];
|
|
41
|
+
};
|
|
42
|
+
exports.isolateElementsById = isolateElementsById;
|
|
43
|
+
const isolateElements = (hilitedIds, replace = false) => {
|
|
44
|
+
if (!core_frontend_1.IModelApp.viewManager.selectedView) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const vp = core_frontend_1.IModelApp.viewManager.selectedView;
|
|
48
|
+
const emph = core_frontend_1.EmphasizeElements.getOrCreate(vp);
|
|
49
|
+
emph.isolateElements(hilitedIds, vp, replace);
|
|
50
|
+
};
|
|
51
|
+
exports.isolateElements = isolateElements;
|
|
52
|
+
const clearIsolatedElements = () => {
|
|
53
|
+
if (!core_frontend_1.IModelApp.viewManager.selectedView) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const vp = core_frontend_1.IModelApp.viewManager.selectedView;
|
|
57
|
+
const emph = core_frontend_1.EmphasizeElements.getOrCreate(vp);
|
|
58
|
+
emph.clearIsolatedElements(vp);
|
|
59
|
+
};
|
|
60
|
+
exports.clearIsolatedElements = clearIsolatedElements;
|
|
61
|
+
const hideElementsById = async (elementIds, iModelConnection, replace = false) => {
|
|
62
|
+
if (!core_frontend_1.IModelApp.viewManager.selectedView) {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
const vp = core_frontend_1.IModelApp.viewManager.selectedView;
|
|
66
|
+
const keySet = await exports.manufactureKeys(elementIds, iModelConnection);
|
|
67
|
+
const hiliteProvider = presentation_frontend_1.HiliteSetProvider.create({
|
|
68
|
+
imodel: vp.iModel,
|
|
69
|
+
});
|
|
70
|
+
const set = await hiliteProvider.getHiliteSet(keySet);
|
|
71
|
+
if (set.elements) {
|
|
72
|
+
const ids = [...set.elements];
|
|
73
|
+
exports.hideElements(ids, replace);
|
|
74
|
+
return ids;
|
|
75
|
+
}
|
|
76
|
+
return [];
|
|
77
|
+
};
|
|
78
|
+
exports.hideElementsById = hideElementsById;
|
|
79
|
+
const hideElements = (hilitedIds, replace = false) => {
|
|
80
|
+
if (!core_frontend_1.IModelApp.viewManager.selectedView) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const vp = core_frontend_1.IModelApp.viewManager.selectedView;
|
|
84
|
+
const emph = core_frontend_1.EmphasizeElements.getOrCreate(vp);
|
|
85
|
+
emph.hideElements(hilitedIds, vp, replace);
|
|
86
|
+
};
|
|
87
|
+
exports.hideElements = hideElements;
|
|
88
|
+
const clearHiddenElements = () => {
|
|
89
|
+
if (!core_frontend_1.IModelApp.viewManager.selectedView) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const vp = core_frontend_1.IModelApp.viewManager.selectedView;
|
|
93
|
+
const emph = core_frontend_1.EmphasizeElements.getOrCreate(vp);
|
|
94
|
+
emph.clearHiddenElements(vp);
|
|
95
|
+
};
|
|
96
|
+
exports.clearHiddenElements = clearHiddenElements;
|
|
97
|
+
const overrideElementsById = async (iModelConnection, elementIds, color, overrideType = core_common_1.FeatureOverrideType.ColorOnly) => {
|
|
98
|
+
if (!core_frontend_1.IModelApp.viewManager.selectedView) {
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
101
|
+
const vp = core_frontend_1.IModelApp.viewManager.selectedView;
|
|
102
|
+
const keySet = await exports.manufactureKeys(elementIds, iModelConnection);
|
|
103
|
+
const hiliteProvider = presentation_frontend_1.HiliteSetProvider.create({
|
|
104
|
+
imodel: vp.iModel,
|
|
105
|
+
});
|
|
106
|
+
const set = await hiliteProvider.getHiliteSet(keySet);
|
|
107
|
+
if (set.elements) {
|
|
108
|
+
const ids = [...set.elements];
|
|
109
|
+
exports.overrideElements(ids, color, overrideType);
|
|
110
|
+
return ids;
|
|
111
|
+
}
|
|
112
|
+
return [];
|
|
113
|
+
};
|
|
114
|
+
exports.overrideElementsById = overrideElementsById;
|
|
115
|
+
const overrideElements = (hilitedIds, color, overrideType = core_common_1.FeatureOverrideType.ColorOnly) => {
|
|
116
|
+
if (!core_frontend_1.IModelApp.viewManager.selectedView) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const vp = core_frontend_1.IModelApp.viewManager.selectedView;
|
|
120
|
+
const emph = core_frontend_1.EmphasizeElements.getOrCreate(vp);
|
|
121
|
+
emph.overrideElements(hilitedIds, vp, core_common_1.ColorDef.fromString(color), overrideType, true);
|
|
122
|
+
};
|
|
123
|
+
exports.overrideElements = overrideElements;
|
|
124
|
+
const clearOverriddenElements = () => {
|
|
125
|
+
if (!core_frontend_1.IModelApp.viewManager.selectedView) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const vp = core_frontend_1.IModelApp.viewManager.selectedView;
|
|
129
|
+
const emph = core_frontend_1.EmphasizeElements.getOrCreate(vp);
|
|
130
|
+
emph.clearOverriddenElements(vp);
|
|
131
|
+
};
|
|
132
|
+
exports.clearOverriddenElements = clearOverriddenElements;
|
|
133
|
+
const emphasizeElements = (hilitedIds, defaultAppearance = undefined, replace = false) => {
|
|
134
|
+
if (!core_frontend_1.IModelApp.viewManager.selectedView) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const vp = core_frontend_1.IModelApp.viewManager.selectedView;
|
|
138
|
+
const emph = core_frontend_1.EmphasizeElements.getOrCreate(vp);
|
|
139
|
+
emph.wantEmphasis = true;
|
|
140
|
+
emph.emphasizeElements(hilitedIds, vp, defaultAppearance, replace);
|
|
141
|
+
};
|
|
142
|
+
exports.emphasizeElements = emphasizeElements;
|
|
143
|
+
const emphasisElementsById = async (iModelConnection, elementIds, defaultAppearance = undefined, replace = false) => {
|
|
144
|
+
if (!core_frontend_1.IModelApp.viewManager.selectedView) {
|
|
145
|
+
return [];
|
|
146
|
+
}
|
|
147
|
+
const vp = core_frontend_1.IModelApp.viewManager.selectedView;
|
|
148
|
+
const keySet = await exports.manufactureKeys(elementIds, iModelConnection);
|
|
149
|
+
const hiliteProvider = presentation_frontend_1.HiliteSetProvider.create({
|
|
150
|
+
imodel: vp.iModel,
|
|
151
|
+
});
|
|
152
|
+
const set = await hiliteProvider.getHiliteSet(keySet);
|
|
153
|
+
if (set.elements) {
|
|
154
|
+
const ids = [...set.elements];
|
|
155
|
+
exports.emphasizeElements(ids, defaultAppearance, replace);
|
|
156
|
+
return ids;
|
|
157
|
+
}
|
|
158
|
+
return [];
|
|
159
|
+
};
|
|
160
|
+
exports.emphasisElementsById = emphasisElementsById;
|
|
161
|
+
const emphasizeElementsByKeys = async (keySet, defaultAppearance = undefined, replace = false) => {
|
|
162
|
+
if (!core_frontend_1.IModelApp.viewManager.selectedView) {
|
|
163
|
+
return [];
|
|
164
|
+
}
|
|
165
|
+
const vp = core_frontend_1.IModelApp.viewManager.selectedView;
|
|
166
|
+
const hiliteProvider = presentation_frontend_1.HiliteSetProvider.create({
|
|
167
|
+
imodel: vp.iModel,
|
|
168
|
+
});
|
|
169
|
+
const set = await hiliteProvider.getHiliteSet(keySet);
|
|
170
|
+
if (set.elements) {
|
|
171
|
+
const ids = [...set.elements];
|
|
172
|
+
exports.emphasizeElements(ids, defaultAppearance, replace);
|
|
173
|
+
return ids;
|
|
174
|
+
}
|
|
175
|
+
return [];
|
|
176
|
+
};
|
|
177
|
+
exports.emphasizeElementsByKeys = emphasizeElementsByKeys;
|
|
8
178
|
const visualizeElementsById = async (elementIds, color, iModelConnection, replace = false, wantEmphasis = true) => {
|
|
9
179
|
if (!core_frontend_1.IModelApp.viewManager.selectedView) {
|
|
10
180
|
return [];
|
|
@@ -46,7 +216,7 @@ const visualizeElements = (elementIds, color, replace = false, wantEmphasis = tr
|
|
|
46
216
|
}
|
|
47
217
|
const vp = core_frontend_1.IModelApp.viewManager.selectedView;
|
|
48
218
|
const emph = core_frontend_1.EmphasizeElements.getOrCreate(vp);
|
|
49
|
-
emph.overrideElements(elementIds, vp, core_common_1.ColorDef.fromString(color), core_common_1.FeatureOverrideType.
|
|
219
|
+
emph.overrideElements(elementIds, vp, core_common_1.ColorDef.fromString(color), core_common_1.FeatureOverrideType.ColorAndAlpha, true);
|
|
50
220
|
if (!wantEmphasis) {
|
|
51
221
|
return;
|
|
52
222
|
}
|
|
@@ -54,6 +224,21 @@ const visualizeElements = (elementIds, color, replace = false, wantEmphasis = tr
|
|
|
54
224
|
emph.emphasizeElements(elementIds, vp, undefined, replace);
|
|
55
225
|
};
|
|
56
226
|
exports.visualizeElements = visualizeElements;
|
|
227
|
+
const transparentOverriddenElements = () => {
|
|
228
|
+
var _a;
|
|
229
|
+
if (!core_frontend_1.IModelApp.viewManager.selectedView) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
const vp = core_frontend_1.IModelApp.viewManager.selectedView;
|
|
233
|
+
const emph = core_frontend_1.EmphasizeElements.getOrCreate(vp);
|
|
234
|
+
const ids = (_a = emph.getOverriddenElements()) === null || _a === void 0 ? void 0 : _a.values();
|
|
235
|
+
if (ids) {
|
|
236
|
+
const toOverride = new Set();
|
|
237
|
+
Array.from(ids).forEach((a) => a.forEach((id) => toOverride.add(id)));
|
|
238
|
+
emph.overrideElements(toOverride, vp, core_common_1.ColorDef.red.withAlpha(50), core_common_1.FeatureOverrideType.AlphaOnly, true);
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
exports.transparentOverriddenElements = transparentOverriddenElements;
|
|
57
242
|
const zoomToElements = async (elementIds) => {
|
|
58
243
|
if (!core_frontend_1.IModelApp.viewManager.selectedView || elementIds.length === 0) {
|
|
59
244
|
return;
|
|
@@ -66,6 +251,22 @@ const zoomToElements = async (elementIds) => {
|
|
|
66
251
|
await vp.zoomToElements(elementIds, { ...viewChangeOpts });
|
|
67
252
|
};
|
|
68
253
|
exports.zoomToElements = zoomToElements;
|
|
254
|
+
const getHiliteIds = async (elementIds, iModelConnection) => {
|
|
255
|
+
if (!core_frontend_1.IModelApp.viewManager.selectedView) {
|
|
256
|
+
return [];
|
|
257
|
+
}
|
|
258
|
+
const vp = core_frontend_1.IModelApp.viewManager.selectedView;
|
|
259
|
+
const keySet = await exports.manufactureKeys(elementIds, iModelConnection);
|
|
260
|
+
const hiliteProvider = presentation_frontend_1.HiliteSetProvider.create({
|
|
261
|
+
imodel: vp.iModel,
|
|
262
|
+
});
|
|
263
|
+
const set = await hiliteProvider.getHiliteSet(keySet);
|
|
264
|
+
if (set.elements) {
|
|
265
|
+
return [...set.elements];
|
|
266
|
+
}
|
|
267
|
+
return [];
|
|
268
|
+
};
|
|
269
|
+
exports.getHiliteIds = getHiliteIds;
|
|
69
270
|
const manufactureKeys = async (elementIds, iModelConnection) => {
|
|
70
271
|
// segment ids into batches
|
|
71
272
|
const batches = [];
|
|
@@ -109,7 +310,27 @@ const clearEmphasizedElements = () => {
|
|
|
109
310
|
const vp = core_frontend_1.IModelApp.viewManager.selectedView;
|
|
110
311
|
const emph = core_frontend_1.EmphasizeElements.getOrCreate(vp);
|
|
111
312
|
emph.clearEmphasizedElements(vp);
|
|
112
|
-
emph.clearOverriddenElements(vp);
|
|
113
313
|
};
|
|
114
314
|
exports.clearEmphasizedElements = clearEmphasizedElements;
|
|
315
|
+
const clearEmphasizedOverriddenElements = () => {
|
|
316
|
+
if (!core_frontend_1.IModelApp.viewManager.selectedView) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
const vp = core_frontend_1.IModelApp.viewManager.selectedView;
|
|
320
|
+
const emph = core_frontend_1.EmphasizeElements.getOrCreate(vp);
|
|
321
|
+
emph.clearEmphasizedElements(vp);
|
|
322
|
+
emph.clearOverriddenElements(vp);
|
|
323
|
+
};
|
|
324
|
+
exports.clearEmphasizedOverriddenElements = clearEmphasizedOverriddenElements;
|
|
325
|
+
const clearAll = () => {
|
|
326
|
+
if (!core_frontend_1.IModelApp.viewManager.selectedView) {
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
const vp = core_frontend_1.IModelApp.viewManager.selectedView;
|
|
330
|
+
const emph = core_frontend_1.EmphasizeElements.getOrCreate(vp);
|
|
331
|
+
emph.clearEmphasizedElements(vp);
|
|
332
|
+
emph.clearOverriddenElements(vp);
|
|
333
|
+
emph.clearHiddenElements(vp);
|
|
334
|
+
};
|
|
335
|
+
exports.clearAll = clearAll;
|
|
115
336
|
//# sourceMappingURL=viewerUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewerUtils.js","sourceRoot":"","sources":["../../../../src/widget/components/viewerUtils.tsx"],"names":[],"mappings":";;;AAQA,wDAG8B;AAI9B,oDAG4B;AAC5B,oEAAoD;AACpD,wEAAiE;AAE1D,MAAM,qBAAqB,GAAG,KAAK,EACxC,UAAoB,EACpB,KAAa,EACb,gBAAkC,EAClC,OAAO,GAAG,KAAK,EACf,YAAY,GAAG,IAAI,EACnB,EAAE;IACF,IAAI,CAAC,yBAAS,CAAC,WAAW,CAAC,YAAY,EAAE;QACvC,OAAO,EAAE,CAAC;KACX;IAED,MAAM,EAAE,GAAG,yBAAS,CAAC,WAAW,CAAC,YAAY,CAAC;IAE9C,MAAM,MAAM,GAAG,MAAM,uBAAe,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;IACnE,MAAM,cAAc,GAAsB,yCAAiB,CAAC,MAAM,CAAC;QACjE,MAAM,EAAE,EAAE,CAAC,MAAM;KAClB,CAAC,CAAC;IACH,MAAM,GAAG,GAAG,MAAM,cAAc,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACtD,IAAI,GAAG,CAAC,QAAQ,EAAE;QAChB,MAAM,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC9B,yBAAiB,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;QACrD,OAAO,GAAG,CAAC;KACZ;IACD,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAxBW,QAAA,qBAAqB,yBAwBhC;AAEK,MAAM,uBAAuB,GAAG,KAAK,EAC1C,MAAc,EACd,KAAa,EACb,OAAO,GAAG,KAAK,EACf,YAAY,GAAG,IAAI,EACnB,EAAE;IACF,IAAI,CAAC,yBAAS,CAAC,WAAW,CAAC,YAAY,EAAE;QACvC,OAAO,EAAE,CAAC;KACX;IAED,MAAM,EAAE,GAA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AK,CAAC,CAAC;KACrC;IAED,MAAM,WAAW,GAAG,CAAC,IAGpB,EAGC,EAAE;QACF,OAAO,IAAI,CAAC,EAAE,KAAK,SAAS,CAAC;IAC/B,CAAC,CAAC;IAEF,4CAA4C;IAC5C,MAAM,IAAI,GAAG,SAAS;SACnB,GAAG,CAAC,CAAC,IAAkB,EAAE,EAAE,CAAC,CAAC;QAC5B,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,SAAS,EAAE,IAAI,CAAC,aAAa;KAC9B,CAAC,CAAC;SACF,MAAM,CAAC,WAAW,CAAC,CAAC;IACvB,OAAO,IAAI,4BAAM,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC,CAAC;AA7CW,QAAA,eAAe,mBA6C1B;AAEK,MAAM,uBAAuB,GAAG,GAAG,EAAE;IAC1C,IAAI,CAAC,yBAAS,CAAC,WAAW,CAAC,YAAY,EAAE;QACvC,OAAO;KACR;IACD,MAAM,EAAE,GAAG,yBAAS,CAAC,WAAW,CAAC,YAAY,CAAC;IAC9C,MAAM,IAAI,GAAG,iCAAiB,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAC/C,IAAI,CAAC,uBAAuB,CAAC,EAAE,CAAC,CAAC;IACjC,IAAI,CAAC,uBAAuB,CAAC,EAAE,CAAC,CAAC;AACnC,CAAC,CAAC;AARW,QAAA,uBAAuB,2BAQlC","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*--------------------------------------------------------------------------------------------*/\nimport type {\n IModelConnection,\n ViewChangeOptions,\n} from \"@itwin/core-frontend\";\nimport {\n EmphasizeElements,\n IModelApp,\n} from \"@itwin/core-frontend\";\nimport type {\n ElementProps,\n} from \"@itwin/core-common\";\nimport {\n ColorDef,\n FeatureOverrideType,\n} from \"@itwin/core-common\";\nimport { KeySet } from \"@itwin/presentation-common\";\nimport { HiliteSetProvider } from \"@itwin/presentation-frontend\";\n\nexport const visualizeElementsById = async (\n elementIds: string[],\n color: string,\n iModelConnection: IModelConnection,\n replace = false,\n wantEmphasis = true,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return [];\n }\n\n const vp = IModelApp.viewManager.selectedView;\n\n const keySet = await manufactureKeys(elementIds, iModelConnection);\n const hiliteProvider: HiliteSetProvider = HiliteSetProvider.create({\n imodel: vp.iModel,\n });\n const set = await hiliteProvider.getHiliteSet(keySet);\n if (set.elements) {\n const ids = [...set.elements];\n visualizeElements(ids, color, replace, wantEmphasis);\n return ids;\n }\n return [];\n};\n\nexport const visualizeElementsByKeys = async (\n keySet: KeySet,\n color: string,\n replace = false,\n wantEmphasis = true,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return [];\n }\n\n const vp = IModelApp.viewManager.selectedView;\n\n const hiliteProvider: HiliteSetProvider = HiliteSetProvider.create({\n imodel: vp.iModel,\n });\n const set = await hiliteProvider.getHiliteSet(keySet);\n if (set.elements) {\n const ids = [...set.elements];\n visualizeElements(ids, color, replace, wantEmphasis);\n return ids;\n }\n return [];\n};\n\nexport const visualizeElements = (\n elementIds: string[],\n color: string,\n replace = false,\n wantEmphasis = true,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n\n emph.overrideElements(\n elementIds,\n vp,\n ColorDef.fromString(color),\n FeatureOverrideType.ColorOnly,\n true,\n );\n if (!wantEmphasis) {\n return;\n }\n emph.wantEmphasis = true;\n emph.emphasizeElements(elementIds, vp, undefined, replace);\n};\n\nexport const zoomToElements = async (elementIds: string[]) => {\n if (!IModelApp.viewManager.selectedView || elementIds.length === 0) {\n return;\n }\n\n const vp = IModelApp.viewManager.selectedView;\n const viewChangeOpts: ViewChangeOptions = {};\n viewChangeOpts.animateFrustumChange = true;\n // It was removed. Should be a prop to be passed to lookAtViewAlignedVolume within the implementation.\n // viewChangeOpts.marginPercent = new MarginPercent(0.1, 0.1, 0.1, 0.1);\n await vp.zoomToElements(elementIds, { ...viewChangeOpts });\n};\n\nexport const manufactureKeys = async (\n elementIds: string[],\n iModelConnection: IModelConnection,\n): Promise<KeySet> => {\n // segment ids into batches\n const batches: string[][] = [];\n let currBatch: string[] = [];\n const batchSize = 100000;\n for (const id of elementIds) {\n if (currBatch.length < batchSize) {\n currBatch.push(id);\n } else {\n batches.push(currBatch);\n currBatch = [id];\n }\n }\n if (currBatch.length > 0 && currBatch.length <= batchSize) {\n batches.push(currBatch);\n }\n\n // retrieve element properties in batches\n let elemProps: ElementProps[] = [];\n for (const batch of batches) {\n const props = await iModelConnection.elements.getProps(batch);\n elemProps = elemProps.concat(props);\n }\n\n const isElementId = (elem: {\n id: string | undefined;\n className: string;\n }): elem is {\n id: string;\n className: string;\n } => {\n return elem.id !== undefined;\n };\n\n // create keyset from the element properties\n const keys = elemProps\n .map((elem: ElementProps) => ({\n id: elem.id,\n className: elem.classFullName,\n }))\n .filter(isElementId);\n return new KeySet(keys);\n};\n\nexport const clearEmphasizedElements = () => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n emph.clearEmphasizedElements(vp);\n emph.clearOverriddenElements(vp);\n};\n"]}
|
|
1
|
+
{"version":3,"file":"viewerUtils.js","sourceRoot":"","sources":["../../../../src/widget/components/viewerUtils.tsx"],"names":[],"mappings":";;;AAMA,wDAAoE;AAEpE,oDAAmE;AACnE,oEAAoD;AACpD,wEAAiE;AAE1D,MAAM,qBAAqB,GAAG,KAAK,EACxC,MAAc,EACd,OAAO,GAAG,KAAK,EACf,EAAE;IACF,IAAI,CAAC,yBAAS,CAAC,WAAW,CAAC,YAAY,EAAE;QACvC,OAAO,EAAE,CAAC;KACX;IAED,MAAM,EAAE,GAAG,yBAAS,CAAC,WAAW,CAAC,YAAY,CAAC;IAE9C,MAAM,cAAc,GAAsB,yCAAiB,CAAC,MAAM,CA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AEK,MAAM,uBAAuB,GAAG,GAAG,EAAE;IAC1C,IAAI,CAAC,yBAAS,CAAC,WAAW,CAAC,YAAY,EAAE;QACvC,OAAO;KACR;IACD,MAAM,EAAE,GAAG,yBAAS,CAAC,WAAW,CAAC,YAAY,CAAC;IAC9C,MAAM,IAAI,GAAG,iCAAiB,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAC/C,IAAI,CAAC,uBAAuB,CAAC,EAAE,CAAC,CAAC;AACnC,CAAC,CAAC;AAPW,QAAA,uBAAuB,2BAOlC;AAEK,MAAM,iCAAiC,GAAG,GAAG,EAAE;IACpD,IAAI,CAAC,yBAAS,CAAC,WAAW,CAAC,YAAY,EAAE;QACvC,OAAO;KACR;IACD,MAAM,EAAE,GAAG,yBAAS,CAAC,WAAW,CAAC,YAAY,CAAC;IAC9C,MAAM,IAAI,GAAG,iCAAiB,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAC/C,IAAI,CAAC,uBAAuB,CAAC,EAAE,CAAC,CAAC;IACjC,IAAI,CAAC,uBAAuB,CAAC,EAAE,CAAC,CAAC;AACnC,CAAC,CAAC;AARW,QAAA,iCAAiC,qCAQ5C;AAEK,MAAM,QAAQ,GAAG,GAAG,EAAE;IAC3B,IAAI,CAAC,yBAAS,CAAC,WAAW,CAAC,YAAY,EAAE;QACvC,OAAO;KACR;IACD,MAAM,EAAE,GAAG,yBAAS,CAAC,WAAW,CAAC,YAAY,CAAC;IAC9C,MAAM,IAAI,GAAG,iCAAiB,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAC/C,IAAI,CAAC,uBAAuB,CAAC,EAAE,CAAC,CAAC;IACjC,IAAI,CAAC,uBAAuB,CAAC,EAAE,CAAC,CAAC;IACjC,IAAI,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAC;AAC/B,CAAC,CAAC;AATW,QAAA,QAAQ,YASnB","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*--------------------------------------------------------------------------------------------*/\nimport type { ViewChangeOptions } from \"@itwin/core-frontend\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport { EmphasizeElements, IModelApp } from \"@itwin/core-frontend\";\nimport type { ElementProps, FeatureAppearance } from \"@itwin/core-common\";\nimport { ColorDef, FeatureOverrideType } from \"@itwin/core-common\";\nimport { KeySet } from \"@itwin/presentation-common\";\nimport { HiliteSetProvider } from \"@itwin/presentation-frontend\";\n\nexport const isolateElementsByKeys = async (\n keySet: KeySet,\n replace = false,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return [];\n }\n\n const vp = IModelApp.viewManager.selectedView;\n\n const hiliteProvider: HiliteSetProvider = HiliteSetProvider.create({\n imodel: vp.iModel,\n });\n const set = await hiliteProvider.getHiliteSet(keySet);\n if (set.elements) {\n const ids = [...set.elements];\n isolateElements(ids, replace);\n return ids;\n }\n return [];\n};\n\nexport const isolateElementsById = async (\n elementIds: string[],\n iModelConnection: IModelConnection,\n replace = false,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return [];\n }\n\n const vp = IModelApp.viewManager.selectedView;\n\n const keySet = await manufactureKeys(elementIds, iModelConnection);\n const hiliteProvider: HiliteSetProvider = HiliteSetProvider.create({\n imodel: vp.iModel,\n });\n const set = await hiliteProvider.getHiliteSet(keySet);\n if (set.elements) {\n const ids = [...set.elements];\n isolateElements(ids, replace);\n return ids;\n }\n return [];\n};\n\nexport const isolateElements = (hilitedIds: string[], replace = false) => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n\n emph.isolateElements(hilitedIds, vp, replace);\n};\n\nexport const clearIsolatedElements = () => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n emph.clearIsolatedElements(vp);\n};\n\nexport const hideElementsById = async (\n elementIds: string[],\n iModelConnection: IModelConnection,\n replace = false,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return [];\n }\n\n const vp = IModelApp.viewManager.selectedView;\n\n const keySet = await manufactureKeys(elementIds, iModelConnection);\n const hiliteProvider: HiliteSetProvider = HiliteSetProvider.create({\n imodel: vp.iModel,\n });\n const set = await hiliteProvider.getHiliteSet(keySet);\n if (set.elements) {\n const ids = [...set.elements];\n hideElements(ids, replace);\n return ids;\n }\n return [];\n};\n\nexport const hideElements = (hilitedIds: string[], replace = false) => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n\n emph.hideElements(hilitedIds, vp, replace);\n};\n\nexport const clearHiddenElements = () => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n emph.clearHiddenElements(vp);\n};\n\nexport const overrideElementsById = async (\n iModelConnection: IModelConnection,\n elementIds: string[],\n color: string,\n overrideType = FeatureOverrideType.ColorOnly,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return [];\n }\n\n const vp = IModelApp.viewManager.selectedView;\n\n const keySet = await manufactureKeys(elementIds, iModelConnection);\n const hiliteProvider: HiliteSetProvider = HiliteSetProvider.create({\n imodel: vp.iModel,\n });\n const set = await hiliteProvider.getHiliteSet(keySet);\n if (set.elements) {\n const ids = [...set.elements];\n overrideElements(ids, color, overrideType);\n return ids;\n }\n return [];\n};\n\nexport const overrideElements = (\n hilitedIds: string[],\n color: string,\n overrideType = FeatureOverrideType.ColorOnly,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n\n emph.overrideElements(\n hilitedIds,\n vp,\n ColorDef.fromString(color),\n overrideType,\n true,\n );\n};\n\nexport const clearOverriddenElements = () => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n emph.clearOverriddenElements(vp);\n};\n\nexport const emphasizeElements = (\n hilitedIds: string[],\n defaultAppearance: FeatureAppearance | undefined = undefined,\n replace = false,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n\n emph.wantEmphasis = true;\n emph.emphasizeElements(hilitedIds, vp, defaultAppearance, replace);\n};\n\nexport const emphasisElementsById = async (\n iModelConnection: IModelConnection,\n elementIds: string[],\n defaultAppearance: FeatureAppearance | undefined = undefined,\n replace = false,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return [];\n }\n\n const vp = IModelApp.viewManager.selectedView;\n\n const keySet = await manufactureKeys(elementIds, iModelConnection);\n const hiliteProvider: HiliteSetProvider = HiliteSetProvider.create({\n imodel: vp.iModel,\n });\n const set = await hiliteProvider.getHiliteSet(keySet);\n if (set.elements) {\n const ids = [...set.elements];\n emphasizeElements(ids, defaultAppearance, replace);\n return ids;\n }\n return [];\n};\n\nexport const emphasizeElementsByKeys = async (\n keySet: KeySet,\n defaultAppearance: FeatureAppearance | undefined = undefined,\n replace = false,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return [];\n }\n\n const vp = IModelApp.viewManager.selectedView;\n\n const hiliteProvider: HiliteSetProvider = HiliteSetProvider.create({\n imodel: vp.iModel,\n });\n const set = await hiliteProvider.getHiliteSet(keySet);\n if (set.elements) {\n const ids = [...set.elements];\n emphasizeElements(ids, defaultAppearance, replace);\n return ids;\n }\n return [];\n};\n\nexport const visualizeElementsById = async (\n elementIds: string[],\n color: string,\n iModelConnection: IModelConnection,\n replace = false,\n wantEmphasis = true,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return [];\n }\n\n const vp = IModelApp.viewManager.selectedView;\n\n const keySet = await manufactureKeys(elementIds, iModelConnection);\n const hiliteProvider: HiliteSetProvider = HiliteSetProvider.create({\n imodel: vp.iModel,\n });\n const set = await hiliteProvider.getHiliteSet(keySet);\n if (set.elements) {\n const ids = [...set.elements];\n visualizeElements(ids, color, replace, wantEmphasis);\n return ids;\n }\n return [];\n};\n\nexport const visualizeElementsByKeys = async (\n keySet: KeySet,\n color: string,\n replace = false,\n wantEmphasis = true,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return [];\n }\n\n const vp = IModelApp.viewManager.selectedView;\n\n const hiliteProvider: HiliteSetProvider = HiliteSetProvider.create({\n imodel: vp.iModel,\n });\n const set = await hiliteProvider.getHiliteSet(keySet);\n if (set.elements) {\n const ids = [...set.elements];\n visualizeElements(ids, color, replace, wantEmphasis);\n return ids;\n }\n return [];\n};\n\nexport const visualizeElements = (\n elementIds: string[],\n color: string,\n replace = false,\n wantEmphasis = true,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n\n emph.overrideElements(\n elementIds,\n vp,\n ColorDef.fromString(color),\n FeatureOverrideType.ColorAndAlpha,\n true,\n );\n if (!wantEmphasis) {\n return;\n }\n emph.wantEmphasis = true;\n emph.emphasizeElements(elementIds, vp, undefined, replace);\n};\n\nexport const transparentOverriddenElements = () => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n const ids = emph.getOverriddenElements()?.values();\n if (ids) {\n const toOverride = new Set<string>();\n Array.from(ids).forEach((a) => a.forEach((id) => toOverride.add(id)));\n emph.overrideElements(\n toOverride,\n vp,\n ColorDef.red.withAlpha(50),\n FeatureOverrideType.AlphaOnly,\n true,\n );\n }\n};\n\nexport const zoomToElements = async (elementIds: string[]) => {\n if (!IModelApp.viewManager.selectedView || elementIds.length === 0) {\n return;\n }\n\n const vp = IModelApp.viewManager.selectedView;\n const viewChangeOpts: ViewChangeOptions = {};\n viewChangeOpts.animateFrustumChange = true;\n // It was removed. Should be a prop to be passed to lookAtViewAlignedVolume within the implementation.\n // viewChangeOpts.marginPercent = new MarginPercent(0.1, 0.1, 0.1, 0.1);\n await vp.zoomToElements(elementIds, { ...viewChangeOpts });\n};\n\nexport const getHiliteIds = async (\n elementIds: string[],\n iModelConnection: IModelConnection,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return [];\n }\n\n const vp = IModelApp.viewManager.selectedView;\n\n const keySet = await manufactureKeys(elementIds, iModelConnection);\n const hiliteProvider: HiliteSetProvider = HiliteSetProvider.create({\n imodel: vp.iModel,\n });\n const set = await hiliteProvider.getHiliteSet(keySet);\n if (set.elements) {\n return [...set.elements];\n }\n return [];\n};\n\nexport const manufactureKeys = async (\n elementIds: string[],\n iModelConnection: IModelConnection,\n): Promise<KeySet> => {\n // segment ids into batches\n const batches: string[][] = [];\n let currBatch: string[] = [];\n const batchSize = 100000;\n for (const id of elementIds) {\n if (currBatch.length < batchSize) {\n currBatch.push(id);\n } else {\n batches.push(currBatch);\n currBatch = [id];\n }\n }\n if (currBatch.length > 0 && currBatch.length <= batchSize) {\n batches.push(currBatch);\n }\n\n // retrieve element properties in batches\n let elemProps: ElementProps[] = [];\n for (const batch of batches) {\n const props = await iModelConnection.elements.getProps(batch);\n elemProps = elemProps.concat(props);\n }\n\n const isElementId = (elem: {\n id: string | undefined;\n className: string;\n }): elem is {\n id: string;\n className: string;\n } => {\n return elem.id !== undefined;\n };\n\n // create keyset from the element properties\n const keys = elemProps\n .map((elem: ElementProps) => ({\n id: elem.id,\n className: elem.classFullName,\n }))\n .filter(isElementId);\n return new KeySet(keys);\n};\n\nexport const clearEmphasizedElements = () => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n emph.clearEmphasizedElements(vp);\n};\n\nexport const clearEmphasizedOverriddenElements = () => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n emph.clearEmphasizedElements(vp);\n emph.clearOverriddenElements(vp);\n};\n\nexport const clearAll = () => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n emph.clearEmphasizedElements(vp);\n emph.clearOverriddenElements(vp);\n emph.clearHiddenElements(vp);\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PropertyMap } from "../../formula/Types";
|
|
2
|
-
export declare function useFormulaValidation(formula: string, properties: PropertyMap, setFormulaErrorMessage: (s: string) => void): {
|
|
2
|
+
export declare function useFormulaValidation(formulaName: string, formula: string, properties: PropertyMap, setFormulaErrorMessage: (s: string) => void): {
|
|
3
3
|
isValid: boolean;
|
|
4
4
|
forceValidation: () => boolean;
|
|
5
5
|
};
|
|
@@ -8,22 +8,22 @@ exports.useFormulaValidation = void 0;
|
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
const FormulaValidator_1 = require("../../formula/FormulaValidator");
|
|
10
10
|
const utils_1 = require("../utils");
|
|
11
|
-
function validate(formula, properties, setFormulaErrorMessage, setIsValid) {
|
|
11
|
+
function validate(formulaName, formula, properties, setFormulaErrorMessage, setIsValid) {
|
|
12
12
|
if (!formula) {
|
|
13
13
|
setFormulaErrorMessage("");
|
|
14
14
|
setIsValid(false);
|
|
15
15
|
return false;
|
|
16
16
|
}
|
|
17
|
-
const error = FormulaValidator_1.validateFormula(formula, properties);
|
|
17
|
+
const error = FormulaValidator_1.validateFormula(formulaName, formula, properties);
|
|
18
18
|
setFormulaErrorMessage(error);
|
|
19
19
|
setIsValid(!error);
|
|
20
20
|
return !error;
|
|
21
21
|
}
|
|
22
22
|
const debouncedValidationFunc = utils_1.debounce(validate, 1000);
|
|
23
|
-
function useFormulaValidation(formula, properties, setFormulaErrorMessage) {
|
|
23
|
+
function useFormulaValidation(formulaName, formula, properties, setFormulaErrorMessage) {
|
|
24
24
|
const [isValid, setIsValid] = react_1.useState(false);
|
|
25
|
-
react_1.useEffect(() => debouncedValidationFunc(formula, properties, setFormulaErrorMessage, setIsValid), [formula, properties, setFormulaErrorMessage]);
|
|
26
|
-
return { isValid, forceValidation: () => validate(formula, properties, setFormulaErrorMessage, setIsValid) };
|
|
25
|
+
react_1.useEffect(() => debouncedValidationFunc(formulaName, formula, properties, setFormulaErrorMessage, setIsValid), [formulaName, formula, properties, setFormulaErrorMessage]);
|
|
26
|
+
return { isValid, forceValidation: () => validate(formulaName, formula, properties, setFormulaErrorMessage, setIsValid) };
|
|
27
27
|
}
|
|
28
28
|
exports.useFormulaValidation = useFormulaValidation;
|
|
29
29
|
//# sourceMappingURL=useFormulaValidation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormulaValidation.js","sourceRoot":"","sources":["../../../../src/widget/hooks/useFormulaValidation.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,iCAA4C;AAC5C,qEAAiE;AAEjE,oCAAoC;AAEpC,SAAS,QAAQ,CAAC,OAAe,EAAE,UAAuB,EAAE,sBAA2C,EAAE,UAAgC;
|
|
1
|
+
{"version":3,"file":"useFormulaValidation.js","sourceRoot":"","sources":["../../../../src/widget/hooks/useFormulaValidation.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,iCAA4C;AAC5C,qEAAiE;AAEjE,oCAAoC;AAEpC,SAAS,QAAQ,CAAC,WAAmB,EAAE,OAAe,EAAE,UAAuB,EAAE,sBAA2C,EAAE,UAAgC;IAC5J,IAAI,CAAC,OAAO,EAAE;QACZ,sBAAsB,CAAC,EAAE,CAAC,CAAC;QAC3B,UAAU,CAAC,KAAK,CAAC,CAAC;QAClB,OAAO,KAAK,CAAC;KACd;IAED,MAAM,KAAK,GAAG,kCAAe,CAAC,WAAW,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;IAChE,sBAAsB,CAAC,KAAK,CAAC,CAAC;IAC9B,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC;IACnB,OAAO,CAAC,KAAK,CAAC;AAChB,CAAC;AAED,MAAM,uBAAuB,GAAG,gBAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AAEzD,SAAgB,oBAAoB,CAAC,WAAmB,EAAE,OAAe,EAAE,UAAuB,EAAE,sBAA2C;IAC7I,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,gBAAQ,CAAC,KAAK,CAAC,CAAC;IAC9C,iBAAS,CAAC,GAAG,EAAE,CAAC,uBAAuB,CAAC,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,UAAU,CAAC,EAAE,CAAC,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,sBAAsB,CAAC,CAAC,CAAC;IAC3K,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,UAAU,CAAC,EAAE,CAAC;AAC5H,CAAC;AAJD,oDAIC","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*--------------------------------------------------------------------------------------------*/\nimport { useEffect, useState } from \"react\";\nimport { validateFormula } from \"../../formula/FormulaValidator\";\nimport type { PropertyMap } from \"../../formula/Types\";\nimport { debounce } from \"../utils\";\n\nfunction validate(formulaName: string, formula: string, properties: PropertyMap, setFormulaErrorMessage: (s: string) => void, setIsValid: (b: boolean) => void): boolean {\n if (!formula) {\n setFormulaErrorMessage(\"\");\n setIsValid(false);\n return false;\n }\n\n const error = validateFormula(formulaName, formula, properties);\n setFormulaErrorMessage(error);\n setIsValid(!error);\n return !error;\n}\n\nconst debouncedValidationFunc = debounce(validate, 1000);\n\nexport function useFormulaValidation(formulaName: string, formula: string, properties: PropertyMap, setFormulaErrorMessage: (s: string) => void) {\n const [isValid, setIsValid] = useState(false);\n useEffect(() => debouncedValidationFunc(formulaName, formula, properties, setFormulaErrorMessage, setIsValid), [formulaName, formula, properties, setFormulaErrorMessage]);\n return { isValid, forceValidation: () => validate(formulaName, formula, properties, setFormulaErrorMessage, setIsValid) };\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Token } from "./InfixToPostfixConverter";
|
|
2
2
|
import type { Queue } from "./Queue";
|
|
3
3
|
import type { PropertyMap } from "./Types";
|
|
4
|
-
export declare function validateTokens(tokens: Queue<Token>, properties: PropertyMap): string;
|
|
4
|
+
export declare function validateTokens(formulaName: string, tokens: Queue<Token>, properties: PropertyMap): string;
|
|
5
5
|
//# sourceMappingURL=FormulaTokensValidator.d.ts.map
|
|
@@ -18,7 +18,7 @@ function isNumericalConstant(name) {
|
|
|
18
18
|
"sqrt2",
|
|
19
19
|
].includes(name.toLowerCase());
|
|
20
20
|
}
|
|
21
|
-
export function validateTokens(tokens, properties) {
|
|
21
|
+
export function validateTokens(formulaName, tokens, properties) {
|
|
22
22
|
if (tokens.length === 0)
|
|
23
23
|
return "Formula cannot be empty.";
|
|
24
24
|
const argStack = new Stack();
|
|
@@ -43,6 +43,8 @@ export function validateTokens(tokens, properties) {
|
|
|
43
43
|
argStack.push("number");
|
|
44
44
|
}
|
|
45
45
|
else {
|
|
46
|
+
if (token.value === formulaName)
|
|
47
|
+
return "Formula cannot reference itself.";
|
|
46
48
|
const prop = properties[token.value];
|
|
47
49
|
if (!prop)
|
|
48
50
|
return `Variable "${token.value}" is not available.`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormulaTokensValidator.js","sourceRoot":"","sources":["../../../src/formula/FormulaTokensValidator.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,4BAA4B,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACtF,OAAO,EAAE,8BAA8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7C,OAAO,oCAAoC,CAAC;KAC7C;IAED,OAAO,EAAE,CAAC;AACZ,CAAC","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*--------------------------------------------------------------------------------------------*/\nimport { getFormulaFunctionReturnType, getFunction } from \"./FormulaFunctionProvider\";\nimport { getOperatorArgumentCountBounds, getOperatorReturnType, isOperator } from \"./FormulaOperatorsProvider\";\nimport type { Token } from \"./InfixToPostfixConverter\";\nimport { TokenType } from \"./InfixToPostfixConverter\";\nimport type { Queue } from \"./Queue\";\nimport { Stack } from \"./Stack\";\nimport type { PossibleDataType, PropertyMap } from \"./Types\";\n\nfunction isNumericalConstant(name: string): boolean {\n return [\n \"e\",\n \"ln2\",\n \"ln10\",\n \"log2e\",\n \"log10e\",\n \"pi\",\n \"sqrt1_2\",\n \"sqrt2\",\n ].includes(name.toLowerCase());\n}\n\nexport function validateTokens(tokens: Queue<Token>, properties: PropertyMap): string {\n if (tokens.length === 0)\n return \"Formula cannot be empty.\";\n\n const argStack = new Stack<PossibleDataType>();\n\n while (tokens.length > 0) {\n const token = tokens.dequeue()!;\n\n switch (token.type) {\n case TokenType.Number:\n argStack.push(\"number\");\n break;\n case TokenType.String:\n argStack.push(\"string\");\n break;\n case TokenType.Boolean:\n argStack.push(\"boolean\");\n break;\n case TokenType.Null:\n argStack.push(\"undefined\");\n break;\n case TokenType.Variable:\n const isConstant = isNumericalConstant(token.value);\n if (isConstant) {\n argStack.push(\"number\");\n } else {\n const prop = properties[token.value];\n if (!prop)\n return `Variable \"${token.value}\" is not available.`;\n argStack.push(prop);\n }\n break;\n case TokenType.Operator:\n if (!isOperator(token.value))\n return `Operator \"${token.value}\" is not supported.`;\n\n const operatorBounds = getOperatorArgumentCountBounds(token.value);\n if (!operatorBounds)\n return `Operator \"${token.value}\" is not supported.`;\n\n if (operatorBounds[0] === 2 && token.argCount === 1)\n return `Unary operator \"${token.value}\" is not supported.`;\n\n if (argStack.length < token.argCount) {\n return `Too few arguments given for ${token.argCount === 1 ? \"unary\" : \"binary\"} operator \"${token.value}\".`;\n }\n const opArgs = argStack.popN(token.argCount).reverse();\n let operationResult;\n if (opArgs.length === 1)\n operationResult = getOperatorReturnType(token.value, opArgs[0]);\n else if (opArgs.length === 2)\n operationResult = getOperatorReturnType(token.value, opArgs[0], opArgs[1]);\n else\n return `Operator \"${token.value}\" does not support ${token.argCount} operands.`;\n\n if (operationResult.errorMessage)\n return operationResult.errorMessage;\n else\n argStack.push(operationResult.value!);\n\n break;\n case TokenType.Function:\n const fnArg = getFunction(token.value);\n if (!fnArg)\n return `Function \"${token.value}\" is not supported.`;\n\n const fnArgBounds = fnArg.argumentCountBounds;\n if (fnArgBounds[0] === 0 && fnArgBounds[1] === 0 && token.argCount > 0) {\n return `Function \"${token.value}\" does not accept any arguments.`;\n } else if (fnArgBounds[1] === -1 && token.argCount < fnArgBounds[0]) {\n if (fnArgBounds[0] === 1) {\n return `Function \"${token.value}\" requires at least 1 argument.`;\n } else {\n if (token.argCount === 1) {\n return `Function \"${token.value}\" requires at least ${fnArgBounds[0]} arguments, but only 1 argument was given.`;\n } else {\n return `Function \"${token.value}\" requires at least ${fnArgBounds[0]} arguments, but only ${token.argCount} arguments were given.`;\n }\n }\n } else if (fnArgBounds[0] === fnArgBounds[1] && token.argCount !== fnArgBounds[0]) {\n if (fnArgBounds[0] === 1) {\n return `Function \"${token.value}\" requires exactly 1 argument, but ${token.argCount} arguments were given.`;\n } else {\n if (token.argCount === 1) {\n return `Function \"${token.value}\" requires exactly ${fnArgBounds[0]} arguments, but 1 argument was given.`;\n } else {\n return `Function \"${token.value}\" requires exactly ${fnArgBounds[0]} arguments, but ${token.argCount} arguments were given.`;\n }\n }\n }\n\n const fArgs = argStack.popN(token.argCount).reverse();\n if (fArgs.length < token.argCount) {\n return `Too few arguments given for function \"${token.value}\".`;\n }\n\n const functionResult = getFormulaFunctionReturnType(fnArg, fArgs);\n if (functionResult.errorMessage)\n return `Function \"${token.value}\" is invalid. ${functionResult.errorMessage}`;\n else\n argStack.push(functionResult.value!);\n\n break;\n }\n }\n\n if (argStack.length !== 1) {\n return \"Formula is invalid.\";\n }\n\n const resultType = argStack.pop();\n if (!resultType || resultType === \"undefined\") {\n return \"Formula cannot always return null.\";\n }\n\n return \"\";\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"FormulaTokensValidator.js","sourceRoot":"","sources":["../../../src/formula/FormulaTokensValidator.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,4BAA4B,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACtF,OAAO,EAAE,8BAA8B,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAE/G,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC,SAAS,mBAAmB,CAAC,IAAY;IACvC,OAAO;QACL,GAAG;QACH,KAAK;QACL,MAAM;QACN,OAAO;QACP,QAAQ;QACR,IAAI;QACJ,SAAS;QACT,OAAO;KACR,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,WAAmB,EAAE,MAAoB,EAAE,UAAuB;IAC/F,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QACrB,OAAO,0BAA0B,CAAC;IAEpC,MAAM,QAAQ,GAAG,IAAI,KAAK,EAAoB,CAAC;IAE/C,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;QACxB,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,EAAG,CAAC;QAEhC,QAAQ,KAAK,CAAC,IAAI,EAAE;YAClB,KAAK,SAAS,CAAC,MAAM;gBACnB,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACxB,MAAM;YACR,K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AQ,EAAE;oBACjC,OAAO,yCAAyC,KAAK,CAAC,KAAK,IAAI,CAAC;iBACjE;gBAED,MAAM,cAAc,GAAG,4BAA4B,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;gBAClE,IAAI,cAAc,CAAC,YAAY;oBAC7B,OAAO,aAAa,KAAK,CAAC,KAAK,iBAAiB,cAAc,CAAC,YAAY,EAAE,CAAC;;oBAE9E,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,KAAM,CAAC,CAAC;gBAEvC,MAAM;SACT;KACF;IAED,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;QACzB,OAAO,qBAAqB,CAAC;KAC9B;IAED,MAAM,UAAU,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC;IAClC,IAAI,CAAC,UAAU,IAAI,UAAU,KAAK,WAAW,EAAE;QAC7C,OAAO,oCAAoC,CAAC;KAC7C;IAED,OAAO,EAAE,CAAC;AACZ,CAAC","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*--------------------------------------------------------------------------------------------*/\nimport { getFormulaFunctionReturnType, getFunction } from \"./FormulaFunctionProvider\";\nimport { getOperatorArgumentCountBounds, getOperatorReturnType, isOperator } from \"./FormulaOperatorsProvider\";\nimport type { Token } from \"./InfixToPostfixConverter\";\nimport { TokenType } from \"./InfixToPostfixConverter\";\nimport type { Queue } from \"./Queue\";\nimport { Stack } from \"./Stack\";\nimport type { PossibleDataType, PropertyMap } from \"./Types\";\n\nfunction isNumericalConstant(name: string): boolean {\n return [\n \"e\",\n \"ln2\",\n \"ln10\",\n \"log2e\",\n \"log10e\",\n \"pi\",\n \"sqrt1_2\",\n \"sqrt2\",\n ].includes(name.toLowerCase());\n}\n\nexport function validateTokens(formulaName: string, tokens: Queue<Token>, properties: PropertyMap): string {\n if (tokens.length === 0)\n return \"Formula cannot be empty.\";\n\n const argStack = new Stack<PossibleDataType>();\n\n while (tokens.length > 0) {\n const token = tokens.dequeue()!;\n\n switch (token.type) {\n case TokenType.Number:\n argStack.push(\"number\");\n break;\n case TokenType.String:\n argStack.push(\"string\");\n break;\n case TokenType.Boolean:\n argStack.push(\"boolean\");\n break;\n case TokenType.Null:\n argStack.push(\"undefined\");\n break;\n case TokenType.Variable:\n const isConstant = isNumericalConstant(token.value);\n if (isConstant) {\n argStack.push(\"number\");\n } else {\n if (token.value === formulaName)\n return \"Formula cannot reference itself.\";\n\n const prop = properties[token.value];\n if (!prop)\n return `Variable \"${token.value}\" is not available.`;\n\n argStack.push(prop);\n }\n break;\n case TokenType.Operator:\n if (!isOperator(token.value))\n return `Operator \"${token.value}\" is not supported.`;\n\n const operatorBounds = getOperatorArgumentCountBounds(token.value);\n if (!operatorBounds)\n return `Operator \"${token.value}\" is not supported.`;\n\n if (operatorBounds[0] === 2 && token.argCount === 1)\n return `Unary operator \"${token.value}\" is not supported.`;\n\n if (argStack.length < token.argCount) {\n return `Too few arguments given for ${token.argCount === 1 ? \"unary\" : \"binary\"} operator \"${token.value}\".`;\n }\n const opArgs = argStack.popN(token.argCount).reverse();\n let operationResult;\n if (opArgs.length === 1)\n operationResult = getOperatorReturnType(token.value, opArgs[0]);\n else if (opArgs.length === 2)\n operationResult = getOperatorReturnType(token.value, opArgs[0], opArgs[1]);\n else\n return `Operator \"${token.value}\" does not support ${token.argCount} operands.`;\n\n if (operationResult.errorMessage)\n return operationResult.errorMessage;\n else\n argStack.push(operationResult.value!);\n\n break;\n case TokenType.Function:\n const fnArg = getFunction(token.value);\n if (!fnArg)\n return `Function \"${token.value}\" is not supported.`;\n\n const fnArgBounds = fnArg.argumentCountBounds;\n if (fnArgBounds[0] === 0 && fnArgBounds[1] === 0 && token.argCount > 0) {\n return `Function \"${token.value}\" does not accept any arguments.`;\n } else if (fnArgBounds[1] === -1 && token.argCount < fnArgBounds[0]) {\n if (fnArgBounds[0] === 1) {\n return `Function \"${token.value}\" requires at least 1 argument.`;\n } else {\n if (token.argCount === 1) {\n return `Function \"${token.value}\" requires at least ${fnArgBounds[0]} arguments, but only 1 argument was given.`;\n } else {\n return `Function \"${token.value}\" requires at least ${fnArgBounds[0]} arguments, but only ${token.argCount} arguments were given.`;\n }\n }\n } else if (fnArgBounds[0] === fnArgBounds[1] && token.argCount !== fnArgBounds[0]) {\n if (fnArgBounds[0] === 1) {\n return `Function \"${token.value}\" requires exactly 1 argument, but ${token.argCount} arguments were given.`;\n } else {\n if (token.argCount === 1) {\n return `Function \"${token.value}\" requires exactly ${fnArgBounds[0]} arguments, but 1 argument was given.`;\n } else {\n return `Function \"${token.value}\" requires exactly ${fnArgBounds[0]} arguments, but ${token.argCount} arguments were given.`;\n }\n }\n }\n\n const fArgs = argStack.popN(token.argCount).reverse();\n if (fArgs.length < token.argCount) {\n return `Too few arguments given for function \"${token.value}\".`;\n }\n\n const functionResult = getFormulaFunctionReturnType(fnArg, fArgs);\n if (functionResult.errorMessage)\n return `Function \"${token.value}\" is invalid. ${functionResult.errorMessage}`;\n else\n argStack.push(functionResult.value!);\n\n break;\n }\n }\n\n if (argStack.length !== 1) {\n return \"Formula is invalid.\";\n }\n\n const resultType = argStack.pop();\n if (!resultType || resultType === \"undefined\") {\n return \"Formula cannot always return null.\";\n }\n\n return \"\";\n}\n\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { PropertyMap } from "./Types";
|
|
2
|
-
export declare function validateFormula(formula: string, properties: PropertyMap): string;
|
|
2
|
+
export declare function validateFormula(formulaName: string, formula: string, properties: PropertyMap): string;
|
|
3
3
|
//# sourceMappingURL=FormulaValidator.d.ts.map
|
|
@@ -6,7 +6,7 @@ import { splitFormula } from "./FormulaSplitter";
|
|
|
6
6
|
import { validateTokens } from "./FormulaTokensValidator";
|
|
7
7
|
import { convertInfixToPostfix } from "./InfixToPostfixConverter";
|
|
8
8
|
import { ParenthesisState, validateParenthesis } from "./ParenthesisValidator";
|
|
9
|
-
export function validateFormula(formula, properties) {
|
|
9
|
+
export function validateFormula(formulaName, formula, properties) {
|
|
10
10
|
var _a;
|
|
11
11
|
const parenthesisState = validateParenthesis(formula);
|
|
12
12
|
if (ParenthesisState.NotClosed === parenthesisState) {
|
|
@@ -26,6 +26,6 @@ export function validateFormula(formula, properties) {
|
|
|
26
26
|
if (undefined === postfixFormulaTokens.value) {
|
|
27
27
|
return (_a = postfixFormulaTokens.errorMessage) !== null && _a !== void 0 ? _a : "Unknown error";
|
|
28
28
|
}
|
|
29
|
-
return validateTokens(postfixFormulaTokens.value, properties);
|
|
29
|
+
return validateTokens(formulaName, postfixFormulaTokens.value, properties);
|
|
30
30
|
}
|
|
31
31
|
//# sourceMappingURL=FormulaValidator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormulaValidator.js","sourceRoot":"","sources":["../../../src/formula/FormulaValidator.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG/E,MAAM,UAAU,eAAe,CAAC,OAAe,EAAE,UAAuB;;
|
|
1
|
+
{"version":3,"file":"FormulaValidator.js","sourceRoot":"","sources":["../../../src/formula/FormulaValidator.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG/E,MAAM,UAAU,eAAe,CAAC,WAAmB,EAAE,OAAe,EAAE,UAAuB;;IAC3F,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACtD,IAAI,gBAAgB,CAAC,SAAS,KAAK,gBAAgB,EAAE;QACnD,OAAO,0CAA0C,CAAC;KACnD;SAAM,IAAI,gBAAgB,CAAC,SAAS,KAAK,gBAAgB,EAAE;QAC1D,OAAO,0CAA0C,CAAC;KACnD;IAED,IAAI,kBAAkB,CAAC;IACvB,IAAI;QACF,kBAAkB,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;KAC5C;IAAC,OAAO,EAAE,EAAE;QACX,OAAQ,EAAY,CAAC,OAAO,CAAC;KAC9B;IAED,MAAM,oBAAoB,GAAG,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;IAEvE,IAAI,SAAS,KAAK,oBAAoB,CAAC,KAAK,EAAE;QAC5C,OAAO,MAAA,oBAAoB,CAAC,YAAY,mCAAI,eAAe,CAAC;KAC7D;IAED,OAAO,cAAc,CAAC,WAAW,EAAE,oBAAoB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;AAC7E,CAAC","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*--------------------------------------------------------------------------------------------*/\nimport { splitFormula } from \"./FormulaSplitter\";\nimport { validateTokens } from \"./FormulaTokensValidator\";\nimport { convertInfixToPostfix } from \"./InfixToPostfixConverter\";\nimport { ParenthesisState, validateParenthesis } from \"./ParenthesisValidator\";\nimport type { PropertyMap } from \"./Types\";\n\nexport function validateFormula(formulaName: string, formula: string, properties: PropertyMap): string {\n const parenthesisState = validateParenthesis(formula);\n if (ParenthesisState.NotClosed === parenthesisState) {\n return \"Opened but not closed parenthesis found.\";\n } else if (ParenthesisState.NotOpened === parenthesisState) {\n return \"Closed but not opened parenthesis found.\";\n }\n\n let infixFormulaTokens;\n try {\n infixFormulaTokens = splitFormula(formula);\n } catch (ex) {\n return (ex as Error).message;\n }\n\n const postfixFormulaTokens = convertInfixToPostfix(infixFormulaTokens);\n\n if (undefined === postfixFormulaTokens.value) {\n return postfixFormulaTokens.errorMessage ?? \"Unknown error\";\n }\n\n return validateTokens(formulaName, postfixFormulaTokens.value, properties);\n}\n"]}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/** UI Provider for iTwin Viewer Applications */
|
|
2
2
|
export * from "./widget/GroupingMappingWidget";
|
|
3
|
+
/** Interfaces for providing custom MappingClient */
|
|
4
|
+
export { createDefaultMappingClient, ClientPrefix } from "./widget/components/GroupingMapping";
|
|
5
|
+
export * from "@itwin/insights-client";
|
|
6
|
+
export * from "./widget/IMappingClient";
|
|
3
7
|
/** Internal components for custom UIs */
|
|
4
8
|
export { Mappings } from "./widget/components/Mapping";
|
|
5
9
|
export { Groupings } from "./widget/components/Grouping";
|
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
/** UI Provider for iTwin Viewer Applications */
|
|
6
6
|
export * from "./widget/GroupingMappingWidget";
|
|
7
|
+
/** Interfaces for providing custom MappingClient */
|
|
8
|
+
export { createDefaultMappingClient } from "./widget/components/GroupingMapping";
|
|
9
|
+
export * from "@itwin/insights-client";
|
|
10
|
+
export * from "./widget/IMappingClient";
|
|
7
11
|
/** Internal components for custom UIs */
|
|
8
12
|
export { Mappings } from "./widget/components/Mapping";
|
|
9
13
|
export { Groupings } from "./widget/components/Grouping";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grouping-mapping-widget.js","sourceRoot":"","sources":["../../src/grouping-mapping-widget.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,gDAAgD;AAChD,cAAc,gCAAgC,CAAC;AAE/C,yCAAyC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC","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/** UI Provider for iTwin Viewer Applications */\nexport * from \"./widget/GroupingMappingWidget\";\n\n/** Internal components for custom UIs */\nexport { Mappings } from \"./widget/components/Mapping\";\nexport { Groupings } from \"./widget/components/Grouping\";\nexport { PropertyMenu } from \"./widget/components/PropertyMenu\";\n"]}
|
|
1
|
+
{"version":3,"file":"grouping-mapping-widget.js","sourceRoot":"","sources":["../../src/grouping-mapping-widget.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,gDAAgD;AAChD,cAAc,gCAAgC,CAAC;AAE/C,oDAAoD;AACpD,OAAO,EAAE,0BAA0B,EAAgB,MAAM,qCAAqC,CAAC;AAC/F,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AAExC,yCAAyC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC","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/** UI Provider for iTwin Viewer Applications */\nexport * from \"./widget/GroupingMappingWidget\";\n\n/** Interfaces for providing custom MappingClient */\nexport { createDefaultMappingClient, ClientPrefix } from \"./widget/components/GroupingMapping\";\nexport * from \"@itwin/insights-client\";\nexport * from \"./widget/IMappingClient\";\n\n/** Internal components for custom UIs */\nexport { Mappings } from \"./widget/components/Mapping\";\nexport { Groupings } from \"./widget/components/Grouping\";\nexport { PropertyMenu } from \"./widget/components/PropertyMenu\";\n"]}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { AbstractWidgetProps, UiItemsProvider } from "@itwin/appui-abstract";
|
|
2
2
|
import { AbstractZoneLocation, StagePanelLocation, StagePanelSection } from "@itwin/appui-abstract";
|
|
3
3
|
import type { AccessToken } from "@itwin/core-bentley";
|
|
4
|
+
import type { IMappingClient } from "./IMappingClient";
|
|
4
5
|
export declare class GroupingMappingProvider implements UiItemsProvider {
|
|
5
6
|
readonly id = "GroupingMappingProvider";
|
|
6
7
|
private readonly _accessToken?;
|
|
7
8
|
private readonly _prefix?;
|
|
8
|
-
|
|
9
|
+
private readonly _client?;
|
|
10
|
+
constructor(accessToken?: AccessToken, prefix?: "" | "dev" | "qa", client?: IMappingClient);
|
|
9
11
|
provideWidgets(_stageId: string, stageUsage: string, location: StagePanelLocation, section?: StagePanelSection, zonelocation?: AbstractZoneLocation): ReadonlyArray<AbstractWidgetProps>;
|
|
10
12
|
}
|
|
11
13
|
//# sourceMappingURL=GroupingMappingWidget.d.ts.map
|
|
@@ -2,10 +2,11 @@ import { AbstractZoneLocation, StagePanelLocation, StagePanelSection, StageUsage
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import GroupingMapping from "./components/GroupingMapping";
|
|
4
4
|
export class GroupingMappingProvider {
|
|
5
|
-
constructor(accessToken, prefix) {
|
|
5
|
+
constructor(accessToken, prefix, client) {
|
|
6
6
|
this.id = "GroupingMappingProvider";
|
|
7
7
|
this._accessToken = accessToken;
|
|
8
8
|
this._prefix = prefix;
|
|
9
|
+
this._client = client;
|
|
9
10
|
}
|
|
10
11
|
provideWidgets(_stageId, stageUsage, location, section, zonelocation) {
|
|
11
12
|
const widgets = [];
|
|
@@ -17,7 +18,7 @@ export class GroupingMappingProvider {
|
|
|
17
18
|
id: "GroupingMappingWidget",
|
|
18
19
|
label: "Grouping & Mapping",
|
|
19
20
|
getWidgetContent: () => {
|
|
20
|
-
return React.createElement(GroupingMapping, { accessToken: this._accessToken, prefix: this._prefix });
|
|
21
|
+
return React.createElement(GroupingMapping, { accessToken: this._accessToken, prefix: this._prefix, client: this._client });
|
|
21
22
|
},
|
|
22
23
|
};
|
|
23
24
|
widgets.push(GroupingMappingWidget);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupingMappingWidget.js","sourceRoot":"","sources":["../../../src/widget/GroupingMappingWidget.tsx"],"names":[],"mappings":"AAQA,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,GACX,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,eAAe,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"GroupingMappingWidget.js","sourceRoot":"","sources":["../../../src/widget/GroupingMappingWidget.tsx"],"names":[],"mappings":"AAQA,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,GACX,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAI3D,MAAM,OAAO,uBAAuB;IAOlC,YAAY,WAAyB,EAAE,MAA0B,EAAE,MAAuB;QAN1E,OAAE,GAAG,yBAAyB,CAAC;QAO7C,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAEM,cAAc,CACnB,QAAgB,EAChB,UAAkB,EAClB,QAA4B,EAC5B,OAA2B,EAC3B,YAAmC;QAEnC,MAAM,OAAO,GAA0B,EAAE,CAAC;QAC1C,IACE,CAAC,QAAQ,KAAK,kBAAkB,CAAC,IAAI;YACnC,OAAO,KAAK,iBAAiB,CAAC,KAAK;YACnC,UAAU,KAAK,UAAU,CAAC,OAAO,CAAC;YACpC,YAAY,KAAK,oBAAoB,CAAC,UAAU,EAChD;YACA,MAAM,qBAAqB,GAAwB;gBACjD,EAAE,EAAE,uBAAuB;gBAC3B,KAAK,EAAE,oBAAoB;gBAC3B,gBAAgB,EAAE,GAAG,EAAE;oBACrB,OAAO,oBAAC,eAAe,IAAC,WAAW,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,OAAO,GAAI,CAAC;gBACzG,CAAC;aACF,CAAC;YAEF,OAAO,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;SACrC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","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*--------------------------------------------------------------------------------------------*/\nimport type {\n AbstractWidgetProps,\n UiItemsProvider,\n} from \"@itwin/appui-abstract\";\nimport {\n AbstractZoneLocation,\n StagePanelLocation,\n StagePanelSection,\n StageUsage,\n} from \"@itwin/appui-abstract\";\nimport type { AccessToken } from \"@itwin/core-bentley\";\nimport React from \"react\";\nimport GroupingMapping from \"./components/GroupingMapping\";\nimport type { ClientPrefix } from \"./components/GroupingMapping\";\nimport type { IMappingClient } from \"./IMappingClient\";\n\nexport class GroupingMappingProvider implements UiItemsProvider {\n public readonly id = \"GroupingMappingProvider\";\n\n private readonly _accessToken?: AccessToken;\n private readonly _prefix?: ClientPrefix;\n private readonly _client?: IMappingClient;\n\n constructor(accessToken?: AccessToken, prefix?: \"\" | \"dev\" | \"qa\", client?: IMappingClient) {\n this._accessToken = accessToken;\n this._prefix = prefix;\n this._client = client;\n }\n\n public provideWidgets(\n _stageId: string,\n stageUsage: string,\n location: StagePanelLocation,\n section?: StagePanelSection,\n zonelocation?: AbstractZoneLocation\n ): ReadonlyArray<AbstractWidgetProps> {\n const widgets: AbstractWidgetProps[] = [];\n if (\n (location === StagePanelLocation.Left &&\n section === StagePanelSection.Start &&\n stageUsage === StageUsage.General) ||\n zonelocation === AbstractZoneLocation.CenterLeft\n ) {\n const GroupingMappingWidget: AbstractWidgetProps = {\n id: \"GroupingMappingWidget\",\n label: \"Grouping & Mapping\",\n getWidgetContent: () => {\n return <GroupingMapping accessToken={this._accessToken} prefix={this._prefix} client={this._client} />;\n },\n };\n\n widgets.push(GroupingMappingWidget);\n }\n\n return widgets;\n }\n}\n"]}
|