bruce-cesium 2.9.2 → 2.9.3

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.
@@ -9826,6 +9826,41 @@
9826
9826
  relations: this.item.relations
9827
9827
  });
9828
9828
  };
9829
+ /**
9830
+ * Constructs the rendered state of the menu item from the visuals register.
9831
+ * This will let us see the difference between what the menu item should render vs has rendered.
9832
+ */
9833
+ Manager.prototype.getRenderedState = function () {
9834
+ var items = [];
9835
+ var regos = this.register.GetRegos({
9836
+ menuItemId: this.item.id
9837
+ });
9838
+ var _loop_1 = function (i) {
9839
+ var rego = regos[i];
9840
+ if (!(rego === null || rego === void 0 ? void 0 : rego.relation)) {
9841
+ return "continue";
9842
+ }
9843
+ var relationTypeId = rego.relation["Relation.Type.ID"];
9844
+ if (!relationTypeId) {
9845
+ return "continue";
9846
+ }
9847
+ var group = items.find(function (x) { return x.relationTypeId == relationTypeId; });
9848
+ var entityId = rego.relation["Principal.Entity.ID"];
9849
+ if (!group) {
9850
+ items.push({
9851
+ relationTypeId: relationTypeId,
9852
+ entityIds: [entityId]
9853
+ });
9854
+ }
9855
+ else if (!group.entityIds.includes(entityId)) {
9856
+ group.entityIds.push(entityId);
9857
+ }
9858
+ };
9859
+ for (var i = 0; i < regos.length; i++) {
9860
+ _loop_1(i);
9861
+ }
9862
+ return items;
9863
+ };
9829
9864
  Manager.prototype.Dispose = function () {
9830
9865
  if (this.disposed) {
9831
9866
  return;
@@ -9840,22 +9875,162 @@
9840
9875
  * @param params
9841
9876
  */
9842
9877
  Manager.prototype.ReRender = function (params) {
9878
+ var _a;
9843
9879
  return __awaiter(this, void 0, void 0, function () {
9844
- var entityIds, force;
9845
- return __generator(this, function (_a) {
9846
- entityIds = params.entityIds, force = params.force;
9847
- return [2 /*return*/];
9880
+ var entityIds, force, toReRender, toReRenderDataIds, regos, groups, _loop_2, i;
9881
+ return __generator(this, function (_b) {
9882
+ switch (_b.label) {
9883
+ case 0:
9884
+ entityIds = params.entityIds, force = params.force;
9885
+ toReRenderDataIds = [];
9886
+ if (entityIds == null) {
9887
+ toReRender = this.item.relations;
9888
+ }
9889
+ else {
9890
+ toReRender = [];
9891
+ regos = this.register.GetRegos({
9892
+ menuItemId: this.item.id
9893
+ });
9894
+ groups = this.item.relations;
9895
+ _loop_2 = function (i) {
9896
+ var group = groups[i];
9897
+ var toRenderEntityIds = [];
9898
+ if ((_a = group.entityIds) === null || _a === void 0 ? void 0 : _a.length) {
9899
+ for (var i_1 = 0; i_1 < group.entityIds.length; i_1++) {
9900
+ var groupEntityId = group.entityIds[i_1];
9901
+ // Primary ID matches a re-render entity ID.
9902
+ if (entityIds.includes(groupEntityId)) {
9903
+ toRenderEntityIds.push(groupEntityId);
9904
+ }
9905
+ }
9906
+ }
9907
+ var groupRegos = regos.filter(function (x) { var _a; return ((_a = x.relation) === null || _a === void 0 ? void 0 : _a["Relation.Type.ID"]) == group.relationTypeId; });
9908
+ if (groupRegos.length) {
9909
+ for (var i_2 = 0; i_2 < groupRegos.length; i_2++) {
9910
+ var rego = groupRegos[i_2];
9911
+ var dataEntityId = rego.entityId;
9912
+ // Data ID matches a re-render entity ID.
9913
+ if (dataEntityId && entityIds.includes(dataEntityId) && rego.relation) {
9914
+ // toRenderEntityIds.push(rego.relation["Principal.Entity.ID"]);
9915
+ toReRenderDataIds.push(dataEntityId);
9916
+ }
9917
+ }
9918
+ }
9919
+ if (toRenderEntityIds.length) {
9920
+ toReRender.push({
9921
+ relationTypeId: group.relationTypeId,
9922
+ entityIds: toRenderEntityIds
9923
+ });
9924
+ }
9925
+ };
9926
+ for (i = 0; i < groups.length; i++) {
9927
+ _loop_2(i);
9928
+ }
9929
+ }
9930
+ if (!toReRenderDataIds.length) return [3 /*break*/, 2];
9931
+ return [4 /*yield*/, this.queueRenderDataIds({
9932
+ dataEntityIds: toReRenderDataIds
9933
+ })];
9934
+ case 1:
9935
+ _b.sent();
9936
+ _b.label = 2;
9937
+ case 2:
9938
+ if (!toReRender.length) return [3 /*break*/, 4];
9939
+ return [4 /*yield*/, this.queueRenderRelations({
9940
+ relations: toReRender,
9941
+ force: true
9942
+ })];
9943
+ case 3:
9944
+ _b.sent();
9945
+ _b.label = 4;
9946
+ case 4: return [2 /*return*/];
9947
+ }
9848
9948
  });
9849
9949
  });
9850
9950
  };
9851
- Manager.prototype.queueRenderRelations = function (params) {
9951
+ Manager.prototype.queueRenderDataIds = function (params) {
9852
9952
  return __awaiter(this, void 0, void 0, function () {
9853
- var relations, allIds_1, _i, relations_1, relation, entityIds, toRender, i, entityId, data, j, relation, e_1;
9953
+ var dataEntityIds, i, data, e_1;
9854
9954
  return __generator(this, function (_a) {
9855
9955
  switch (_a.label) {
9856
9956
  case 0:
9857
- _a.trys.push([0, 5, , 6]);
9858
- relations = params.relations;
9957
+ dataEntityIds = params.dataEntityIds;
9958
+ i = 0;
9959
+ _a.label = 1;
9960
+ case 1:
9961
+ if (!(i < dataEntityIds.length)) return [3 /*break*/, 6];
9962
+ _a.label = 2;
9963
+ case 2:
9964
+ _a.trys.push([2, 4, , 5]);
9965
+ return [4 /*yield*/, bruceModels.EntityRelation.GetByDataEntityId({
9966
+ entityId: dataEntityIds[i],
9967
+ api: this.apiGetter.getApi()
9968
+ })];
9969
+ case 3:
9970
+ data = _a.sent();
9971
+ if (data.relation) {
9972
+ if (this.shouldRenderRelation(data.relation)) {
9973
+ this.onGetterUpdate([data.relation]);
9974
+ }
9975
+ }
9976
+ return [3 /*break*/, 5];
9977
+ case 4:
9978
+ e_1 = _a.sent();
9979
+ console.error(e_1);
9980
+ return [3 /*break*/, 5];
9981
+ case 5:
9982
+ i++;
9983
+ return [3 /*break*/, 1];
9984
+ case 6: return [2 /*return*/];
9985
+ }
9986
+ });
9987
+ });
9988
+ };
9989
+ Manager.prototype.queueRenderRelations = function (params) {
9990
+ var _a;
9991
+ return __awaiter(this, void 0, void 0, function () {
9992
+ var relations, force, renderedState, toRender, _loop_3, i, allIds_1, _i, relations_1, relation, entityIds, i, entityId, data, toRender, j, relation, rego, e_2;
9993
+ return __generator(this, function (_b) {
9994
+ switch (_b.label) {
9995
+ case 0:
9996
+ _b.trys.push([0, 5, , 6]);
9997
+ relations = params.relations, force = params.force;
9998
+ if (force != true) {
9999
+ renderedState = this.getRenderedState();
10000
+ toRender = [];
10001
+ _loop_3 = function (i) {
10002
+ var typeId = relations[i].relationTypeId;
10003
+ var group = renderedState.find(function (x) { return x.relationTypeId == typeId; });
10004
+ if (!group || !((_a = group.entityIds) === null || _a === void 0 ? void 0 : _a.length)) {
10005
+ toRender.push(relations[i]);
10006
+ return "continue";
10007
+ }
10008
+ var entityIds = relations[i].entityIds;
10009
+ if (!(entityIds === null || entityIds === void 0 ? void 0 : entityIds.length)) {
10010
+ return "continue";
10011
+ }
10012
+ var toRenderEntityIds = [];
10013
+ for (var j = 0; j < entityIds.length; j++) {
10014
+ var entityId = entityIds[j];
10015
+ if (!group.entityIds.includes(entityId) && !toRenderEntityIds.includes(entityId)) {
10016
+ toRenderEntityIds.push(entityId);
10017
+ }
10018
+ }
10019
+ if (toRenderEntityIds.length) {
10020
+ toRender.push({
10021
+ relationTypeId: typeId,
10022
+ entityIds: toRenderEntityIds
10023
+ });
10024
+ }
10025
+ };
10026
+ for (i = 0; i < relations.length; i++) {
10027
+ _loop_3(i);
10028
+ }
10029
+ if (!toRender.length) {
10030
+ return [2 /*return*/];
10031
+ }
10032
+ relations = toRender;
10033
+ }
9859
10034
  allIds_1 = [];
9860
10035
  for (_i = 0, relations_1 = relations; _i < relations_1.length; _i++) {
9861
10036
  relation = relations_1[_i];
@@ -9865,9 +10040,8 @@
9865
10040
  allIds_1 = allIds_1.filter(function (id, index) {
9866
10041
  return allIds_1.indexOf(id) === index;
9867
10042
  });
9868
- toRender = [];
9869
10043
  i = 0;
9870
- _a.label = 1;
10044
+ _b.label = 1;
9871
10045
  case 1:
9872
10046
  if (!(i < allIds_1.length)) return [3 /*break*/, 4];
9873
10047
  entityId = allIds_1[i];
@@ -9880,50 +10054,37 @@
9880
10054
  api: this.apiGetter.getApi()
9881
10055
  })];
9882
10056
  case 2:
9883
- data = _a.sent();
9884
- console.log("get relations", data);
10057
+ data = _b.sent();
10058
+ if (this.disposed || this.viewer.isDestroyed()) {
10059
+ return [2 /*return*/];
10060
+ }
10061
+ toRender = [];
9885
10062
  for (j = 0; j < data.relations.length; j++) {
9886
10063
  relation = data.relations[j];
9887
10064
  if (this.shouldRenderRelation(relation)) {
10065
+ if (force != true) {
10066
+ rego = this.register.GetRego({
10067
+ relation: relation,
10068
+ menuItemId: this.item.id
10069
+ });
10070
+ if (rego === null || rego === void 0 ? void 0 : rego.visual) {
10071
+ continue;
10072
+ }
10073
+ }
9888
10074
  toRender.push(relation);
9889
10075
  }
9890
10076
  }
9891
- _a.label = 3;
9892
- case 3:
9893
- i++;
9894
- return [3 /*break*/, 1];
9895
- case 4:
9896
- console.log("all render", toRender);
9897
- // Relations are not being returned??
9898
- // const data = await Entity.GetListByIds({
9899
- // entityIds: allIds,
9900
- // expandRelations: true,
9901
- // api: this.apiGetter.getApi()
9902
- // });
9903
- // for (let i = 0; i < data.entities.length; i++) {
9904
- // const entity = data.entities[i];
9905
- // if (entity?.Bruce?.relations?.length) {
9906
- // const eRelations = entity.Bruce.relations;
9907
- // for (let j = 0; j < eRelations.length; j++) {
9908
- // const eRelation = eRelations[j];
9909
- // const relation: EntityRelation.IRelation = {
9910
- // "Principal.Entity.ID": entity.Bruce.ID,
9911
- // "Related.Entity.ID": eRelation["Other.Entity.ID"],
9912
- // "Relation.Type.ID": eRelation["Relation.Type.ID"]
9913
- // };
9914
- // if (this.shouldRenderRelation(relation)) {
9915
- // toRender.push(relation);
9916
- // }
9917
- // }
9918
- // }
9919
- // }
9920
10077
  if (toRender.length) {
9921
10078
  this.onGetterUpdate(toRender);
9922
10079
  }
9923
- return [3 /*break*/, 6];
10080
+ _b.label = 3;
10081
+ case 3:
10082
+ i++;
10083
+ return [3 /*break*/, 1];
10084
+ case 4: return [3 /*break*/, 6];
9924
10085
  case 5:
9925
- e_1 = _a.sent();
9926
- console.error(e_1);
10086
+ e_2 = _b.sent();
10087
+ console.error(e_2);
9927
10088
  return [3 /*break*/, 6];
9928
10089
  case 6: return [2 /*return*/];
9929
10090
  }
@@ -9951,7 +10112,7 @@
9951
10112
  Manager.prototype.onGetterUpdate = function (relations) {
9952
10113
  var _a, _b;
9953
10114
  return __awaiter(this, void 0, void 0, function () {
9954
- var killCEntity, cEntities, key, i, relation, key, cEntity, visual, e_2;
10115
+ var killCEntity, cEntities, key, i, relation, rego, key, cEntity, visual, e_3;
9955
10116
  var _this = this;
9956
10117
  return __generator(this, function (_c) {
9957
10118
  switch (_c.label) {
@@ -9986,6 +10147,19 @@
9986
10147
  }
9987
10148
  for (i = 0; i < relations.length; i++) {
9988
10149
  relation = relations[i];
10150
+ rego = this.register.GetRego({
10151
+ menuItemId: this.item.id,
10152
+ relation: relation
10153
+ });
10154
+ if (rego) {
10155
+ this.register.RemoveRegos({
10156
+ entityId: rego.entityId,
10157
+ menuItemId: this.item.id,
10158
+ relation: relation,
10159
+ requestRender: false,
10160
+ doUpdate: true
10161
+ });
10162
+ }
9989
10163
  key = RelationRenderEngine.GetRenderGroupId(relation);
9990
10164
  cEntity = cEntities[key];
9991
10165
  if (cEntity && this.shouldRenderRelation(relation)) {
@@ -10020,8 +10194,8 @@
10020
10194
  this.viewer.scene.requestRender();
10021
10195
  return [3 /*break*/, 3];
10022
10196
  case 2:
10023
- e_2 = _c.sent();
10024
- console.error(e_2);
10197
+ e_3 = _c.sent();
10198
+ console.error(e_3);
10025
10199
  return [3 /*break*/, 3];
10026
10200
  case 3: return [2 /*return*/];
10027
10201
  }
@@ -13188,7 +13362,7 @@
13188
13362
  function renderNavigator(iteration, params, bookmark, view) {
13189
13363
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6;
13190
13364
  return __awaiter(this, void 0, void 0, function () {
13191
- var viewer, scene, vSettings, bSettings, defaults, camera, newLens, shouldBe2d, curIs2d, transition, pos, terrain, hillShades, baseColor, globeHidden, terrainWireframe, globeAlpha, shadows, size, ambientOcclusion, AO, lighting, light, quality, fxaa, dateTime, clock, selectedIds, hiddenIds, isolatedIds, labelledIds, curLabelledIds, toUnLabel, entityOpacityMap, entityId, opacity, imagery, legacyRelationIds, relations, curEnabled, newItemIds, _i, curEnabled_1, id, menuItem, gOcclusion;
13365
+ var viewer, scene, vSettings, bSettings, defaults, camera, newLens, shouldBe2d, curIs2d, transition, pos, terrain, hillShades, baseColor, globeHidden, terrainWireframe, globeAlpha, shadows, size, ambientOcclusion, AO, lighting, light, quality, fxaa, dateTime, clock, selectedIds, hiddenIds, isolatedIds, labelledIds, curLabelledIds, toUnLabel, entityOpacityMap, entityId, opacity, imagery, legacyRelationIds, relations, curEnabled, newItemIds, _i, curEnabled_1, id, shouldRemove, rendered, menuItem, menuItem, gOcclusion;
13192
13366
  return __generator(this, function (_7) {
13193
13367
  switch (_7.label) {
13194
13368
  case 0:
@@ -13486,8 +13660,26 @@
13486
13660
  newItemIds = (_5 = bSettings === null || bSettings === void 0 ? void 0 : bSettings.menuItemIds) !== null && _5 !== void 0 ? _5 : [];
13487
13661
  for (_i = 0, curEnabled_1 = curEnabled; _i < curEnabled_1.length; _i++) {
13488
13662
  id = curEnabled_1[_i];
13489
- if ((newItemIds.indexOf(id) === -1 && id != RELATION_MENU_ITEM_ID) ||
13490
- (id == RELATION_MENU_ITEM_ID && !legacyRelationIds.length && !relations.length)) {
13663
+ shouldRemove = void 0;
13664
+ if (id == RELATION_MENU_ITEM_ID) {
13665
+ rendered = params.manager.GetEnabledItem(id);
13666
+ shouldRemove = false;
13667
+ if (!legacyRelationIds.length && !relations.length) {
13668
+ shouldRemove = true;
13669
+ }
13670
+ // If we're about to render legacy relationships but a non-legacy item is currently enabled then we remove it.
13671
+ else if (legacyRelationIds.length && (rendered === null || rendered === void 0 ? void 0 : rendered.type) != bruceModels.MenuItem.EType.Relations) {
13672
+ shouldRemove = true;
13673
+ }
13674
+ // If we're about to render non-legacy relationships but a legacy item is currently enabled then we remove it.
13675
+ else if (relations.length && (rendered === null || rendered === void 0 ? void 0 : rendered.type) != bruceModels.MenuItem.EType.Relationships) {
13676
+ shouldRemove = true;
13677
+ }
13678
+ }
13679
+ else {
13680
+ shouldRemove = newItemIds.indexOf(id) === -1;
13681
+ }
13682
+ if (shouldRemove) {
13491
13683
  params.manager.RemoveItemById({
13492
13684
  menuItemId: id
13493
13685
  });
@@ -13508,19 +13700,32 @@
13508
13700
  _7.label = 4;
13509
13701
  case 4:
13510
13702
  if (legacyRelationIds.length || relations.length) {
13511
- menuItem = {
13512
- id: RELATION_MENU_ITEM_ID,
13513
- Caption: "Entity relations",
13514
- BruceEntity: {
13515
- EntityIds: legacyRelationIds
13516
- },
13517
- relations: relations,
13518
- Type: bruceModels.MenuItem.EType.Relations
13519
- };
13520
- params.manager.RenderItem({
13521
- getters: params.getters,
13522
- item: menuItem
13523
- });
13703
+ if (relations.length) {
13704
+ menuItem = {
13705
+ id: RELATION_MENU_ITEM_ID,
13706
+ Caption: "Entity relations",
13707
+ relations: relations,
13708
+ Type: bruceModels.MenuItem.EType.Relationships
13709
+ };
13710
+ params.manager.RenderItem({
13711
+ getters: params.getters,
13712
+ item: menuItem
13713
+ });
13714
+ }
13715
+ else if (legacyRelationIds.length) {
13716
+ menuItem = {
13717
+ id: RELATION_MENU_ITEM_ID,
13718
+ Caption: "Entity relations",
13719
+ BruceEntity: {
13720
+ EntityIds: legacyRelationIds
13721
+ },
13722
+ Type: bruceModels.MenuItem.EType.Relations
13723
+ };
13724
+ params.manager.RenderItem({
13725
+ getters: params.getters,
13726
+ item: menuItem
13727
+ });
13728
+ }
13524
13729
  if (!assertIteration$1(params.viewer, iteration)) {
13525
13730
  return [2 /*return*/];
13526
13731
  }
@@ -16436,7 +16641,7 @@
16436
16641
  ViewerUtils.CreateWidgets = CreateWidgets;
16437
16642
  })(exports.ViewerUtils || (exports.ViewerUtils = {}));
16438
16643
 
16439
- var VERSION$1 = "2.9.2";
16644
+ var VERSION$1 = "2.9.3";
16440
16645
 
16441
16646
  exports.VERSION = VERSION$1;
16442
16647
  exports.CesiumViewMonitor = CesiumViewMonitor;