@xeokit/xeokit-sdk 2.5.2-beta-4 → 2.5.2-beta-5

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.
@@ -114018,6 +114018,7 @@ function CubeTextureCanvas(viewer, navCubeScene, cfg = {}) {
114018
114018
 
114019
114019
  const cubeColor = "lightgrey";
114020
114020
  const cubeHighlightColor = cfg.hoverColor || "rgba(0,0,0,0.4)";
114021
+ const textColor = cfg.textColor || "black";
114021
114022
 
114022
114023
  const height = 500;
114023
114024
  const width = height + (height / 3);
@@ -114167,7 +114168,7 @@ function CubeTextureCanvas(viewer, navCubeScene, cfg = {}) {
114167
114168
  }
114168
114169
  }
114169
114170
  if (area.label) {
114170
- context.fillStyle = "black";
114171
+ context.fillStyle = textColor;
114171
114172
  context.font = '60px sans-serif';
114172
114173
  context.textAlign = "center";
114173
114174
  var xcenter = xmin + (width * 0.5);
@@ -114371,7 +114372,7 @@ class NavCubePlugin extends Plugin {
114371
114372
  * @param {String} [cfg.cameraFly=true] Whether the {@link Camera} flies or jumps to each selected axis or diagonal.
114372
114373
  * @param {String} [cfg.cameraFitFOV=45] How much of the field-of-view, in degrees, that the 3D scene should fill the {@link Canvas} when the {@link Camera} moves to an axis or diagonal.
114373
114374
  * @param {String} [cfg.cameraFlyDuration=0.5] When flying the {@link Camera} to each new axis or diagonal, how long, in seconds, that the Camera takes to get there.
114374
- * @param {String} [cfg.color="lightgrey] Custom uniform color for the faces of the NavCube.
114375
+ * @param {String} [cfg.color="lightgrey"] Custom uniform color for the faces of the NavCube.
114375
114376
  * @param {String} [cfg.frontColor="#55FF55"] Custom color for the front face of the NavCube. Overrides ````color````.
114376
114377
  * @param {String} [cfg.backColor="#55FF55"] Custom color for the back face of the NavCube. Overrides ````color````.
114377
114378
  * @param {String} [cfg.leftColor="#FF5555"] Custom color for the left face of the NavCube. Overrides ````color````.
@@ -114379,6 +114380,7 @@ class NavCubePlugin extends Plugin {
114379
114380
  * @param {String} [cfg.topColor="#5555FF"] Custom color for the top face of the NavCube. Overrides ````color````.
114380
114381
  * @param {String} [cfg.bottomColor="#5555FF"] Custom color for the bottom face of the NavCube. Overrides ````color````.
114381
114382
  * @param {String} [cfg.hoverColor="rgba(0,0,0,0.4)"] Custom color for highlighting regions on the NavCube as we hover the pointer over them.
114383
+ * @param {String} [cfg.textColor="black"] Custom text color for labels of the NavCube.
114382
114384
  * @param {Boolean} [cfg.fitVisible=false] Sets whether the axis, corner and edge-aligned views will fit the
114383
114385
  * view to the entire {@link Scene} or just to visible object-{@link Entity}s. Entitys are visible objects when {@link Entity#isObject} and {@link Entity#visible} are both ````true````.
114384
114386
  * @param {Boolean} [cfg.synchProjection=false] Sets whether the NavCube switches between perspective and orthographic projections in synchrony with the {@link Camera}. When ````false````, the NavCube will always be rendered with perspective projection.
@@ -121081,6 +121083,176 @@ class STLLoaderPlugin extends Plugin {
121081
121083
  }
121082
121084
  }
121083
121085
 
121086
+ /**
121087
+ * @desc A {@link TreeViewPlugin} render class.
121088
+ *
121089
+ */
121090
+ class RenderService {
121091
+
121092
+ /*
121093
+ * Creates the root node of the tree.
121094
+ * @return {HTMLElement} The root node of the tree.
121095
+ */
121096
+ createRootNode() {
121097
+ return document.createElement('ul')
121098
+ }
121099
+
121100
+ /*
121101
+ * Creates node of the tree.
121102
+ * @param {Object} node The node to create.
121103
+
121104
+ * @return {HTMLElement} The html element for the node.
121105
+ */
121106
+ createNodeElement(node, expandHandler, checkHandler, contextmenuHandler, titleClickHandler) {
121107
+ const nodeElement = document.createElement('li');
121108
+ nodeElement.id = node.nodeId;
121109
+
121110
+ if (node.xrayed) {
121111
+ nodeElement.classList.add('xrayed-node');
121112
+ }
121113
+
121114
+ if (node.children.length > 0) {
121115
+ const switchElement = document.createElement('a');
121116
+ switchElement.href = '#';
121117
+ switchElement.id = `switch-${node.nodeId}`;
121118
+ switchElement.textContent = '+';
121119
+ switchElement.classList.add('plus');
121120
+ if (expandHandler) switchElement.addEventListener('click', expandHandler);
121121
+ nodeElement.appendChild(switchElement);
121122
+ }
121123
+
121124
+ const checkbox = document.createElement('input');
121125
+ checkbox.id = `checkbox-${node.nodeId}`;
121126
+ checkbox.type = "checkbox";
121127
+ checkbox.checked = node.checked;
121128
+ checkbox.style["pointer-events"] = "all";
121129
+ if (checkHandler) checkbox.addEventListener("change", checkHandler);
121130
+ nodeElement.appendChild(checkbox);
121131
+
121132
+ const span = document.createElement('span');
121133
+ span.textContent = node.title;
121134
+ nodeElement.appendChild(span);
121135
+
121136
+ if (contextmenuHandler) {
121137
+ span.oncontextmenu = contextmenuHandler;
121138
+ }
121139
+
121140
+ if (titleClickHandler) {
121141
+ span.onclick = titleClickHandler;
121142
+ }
121143
+
121144
+ return nodeElement;
121145
+ }
121146
+
121147
+ createDisabledNodeElement(rootName) {
121148
+ const li = document.createElement('li');
121149
+
121150
+ const switchElement = document.createElement('a');
121151
+ switchElement.href = '#';
121152
+ switchElement.textContent = '!';
121153
+ switchElement.classList.add('warn');
121154
+ switchElement.classList.add('warning');
121155
+ li.appendChild(switchElement);
121156
+
121157
+ const span = document.createElement('span');
121158
+ span.textContent = rootName;
121159
+ li.appendChild(span);
121160
+
121161
+ return li;
121162
+ }
121163
+
121164
+ addChildren(element, nodes) {
121165
+ const ul = document.createElement('ul');
121166
+ nodes.forEach((nodeElement) => {
121167
+ ul.appendChild(nodeElement);
121168
+ });
121169
+
121170
+ element.parentElement.appendChild(ul);
121171
+ }
121172
+
121173
+ expand(element, expandHandler, collapseHandler) {
121174
+ element.classList.remove('plus');
121175
+ element.classList.add('minus');
121176
+ element.textContent = '-';
121177
+ element.removeEventListener('click', expandHandler);
121178
+ element.addEventListener('click', collapseHandler);
121179
+ }
121180
+
121181
+ collapse(element, expandHandler, collapseHandler) {
121182
+ if (!element) {
121183
+ return;
121184
+ }
121185
+ const parent = element.parentElement;
121186
+ if (!parent) {
121187
+ return;
121188
+ }
121189
+ const ul = parent.querySelector('ul');
121190
+ if (!ul) {
121191
+ return;
121192
+ }
121193
+ parent.removeChild(ul);
121194
+ element.classList.remove('minus');
121195
+ element.classList.add('plus');
121196
+ element.textContent = '+';
121197
+ element.removeEventListener('click', collapseHandler);
121198
+ element.addEventListener('click', expandHandler);
121199
+ }
121200
+
121201
+ isExpanded(element) {
121202
+ const parentElement = element.parentElement;
121203
+ return parentElement.getElementsByTagName('li')[0] !== undefined;
121204
+ }
121205
+
121206
+ getId(element) {
121207
+ const parentElement = element.parentElement;
121208
+ return parentElement.id;
121209
+ }
121210
+
121211
+ getIdFromCheckbox(element) {
121212
+ return element.id.replace('checkbox-', '');
121213
+ }
121214
+
121215
+ getSwitchElement(nodeId) {
121216
+ return document.getElementById(`switch-${nodeId}`);
121217
+ }
121218
+
121219
+ isChecked(element) {
121220
+ return element.checked;
121221
+ }
121222
+
121223
+ setCheckbox(nodeId, checked) {
121224
+ const checkbox = document.getElementById(`checkbox-${nodeId}`);
121225
+ if (checkbox) {
121226
+ if (checked !== checkbox.checked) {
121227
+ checkbox.checked = checked;
121228
+ }
121229
+ }
121230
+ }
121231
+
121232
+ setXRayed(nodeId, xrayed) {
121233
+ const treeNode = document.getElementById(nodeId);
121234
+ if (treeNode) {
121235
+ if (xrayed) {
121236
+ treeNode.classList.add('xrayed-node');
121237
+ } else {
121238
+ treeNode.classList.remove('xrayed-node');
121239
+ }
121240
+ }
121241
+ }
121242
+
121243
+ setHighlighted(nodeId, highlighted) {
121244
+ const treeNode = document.getElementById(nodeId);
121245
+ if (treeNode) {
121246
+ if (highlighted) {
121247
+ treeNode.scrollIntoView({block: "center"});
121248
+ treeNode.classList.add('highlighted-node');
121249
+ } else {
121250
+ treeNode.classList.remove('highlighted-node');
121251
+ }
121252
+ }
121253
+ }
121254
+ }
121255
+
121084
121256
  const treeViews = [];
121085
121257
 
121086
121258
  /**
@@ -121440,6 +121612,7 @@ class TreeViewPlugin extends Plugin {
121440
121612
  * ````IfcBuildingStorey```` nodes will be ordered spatially, from the highest storey down to the lowest, on the
121441
121613
  * vertical World axis. For all hierarchy types, other node types will be ordered in the ascending alphanumeric order of their titles.
121442
121614
  * @param {Boolean} [cfg.pruneEmptyNodes=true] When true, will not contain nodes that don't have content in the {@link Scene}. These are nodes whose {@link MetaObject}s don't have {@link Entity}s.
121615
+ * @param {RenderService} [cfg.renderService] Optional {@link RenderService} to use. Defaults to the {@link TreeViewPlugin}'s default {@link RenderService}.
121443
121616
  */
121444
121617
  constructor(viewer, cfg = {}) {
121445
121618
 
@@ -121479,7 +121652,6 @@ class TreeViewPlugin extends Plugin {
121479
121652
  this._autoAddModels = (cfg.autoAddModels !== false);
121480
121653
  this._autoExpandDepth = (cfg.autoExpandDepth || 0);
121481
121654
  this._sortNodes = (cfg.sortNodes !== false);
121482
- this._pruneEmptyNodes = (cfg.pruneEmptyNodes !== false);
121483
121655
  this._viewer = viewer;
121484
121656
  this._rootElement = null;
121485
121657
  this._muteSceneEvents = false;
@@ -121487,10 +121659,15 @@ class TreeViewPlugin extends Plugin {
121487
121659
  this._rootNodes = [];
121488
121660
  this._objectNodes = {}; // Object ID -> Node
121489
121661
  this._nodeNodes = {}; // Node ID -> Node
121490
- this._rootName = cfg.rootName;
121662
+ this._rootNames = {}; // Node ID -> Root name
121491
121663
  this._sortNodes = cfg.sortNodes;
121492
121664
  this._pruneEmptyNodes = cfg.pruneEmptyNodes;
121493
121665
  this._showListItemElementId = null;
121666
+ this._renderService = cfg.renderService || new RenderService();
121667
+
121668
+ if (!this._renderService) {
121669
+ throw new Error('TreeViewPlugin: no render service set');
121670
+ }
121494
121671
 
121495
121672
  this._containerElement.oncontextmenu = (e) => {
121496
121673
  e.preventDefault();
@@ -121517,10 +121694,9 @@ class TreeViewPlugin extends Plugin {
121517
121694
  } else {
121518
121695
  node.numVisibleEntities--;
121519
121696
  }
121520
- const checkbox = document.getElementById(`checkbox-${node.nodeId}`);
121521
- if (checkbox) {
121522
- checkbox.checked = visible;
121523
- }
121697
+
121698
+ this._renderService.setCheckbox(node.nodeId, visible);
121699
+
121524
121700
  let parent = node.parent;
121525
121701
  while (parent) {
121526
121702
  parent.checked = visible;
@@ -121529,15 +121705,12 @@ class TreeViewPlugin extends Plugin {
121529
121705
  } else {
121530
121706
  parent.numVisibleEntities--;
121531
121707
  }
121532
- const parentCheckbox = document.getElementById(`checkbox-${parent.nodeId}`);
121533
- if (parentCheckbox) {
121534
- const newChecked = (parent.numVisibleEntities > 0);
121535
- if (newChecked !== parentCheckbox.checked) {
121536
- parentCheckbox.checked = newChecked;
121537
- }
121538
- }
121708
+
121709
+ this._renderService.setCheckbox(parent.nodeId, (parent.numVisibleEntities > 0));
121710
+
121539
121711
  parent = parent.parent;
121540
121712
  }
121713
+
121541
121714
  this._muteTreeEvents = false;
121542
121715
  });
121543
121716
 
@@ -121557,15 +121730,8 @@ class TreeViewPlugin extends Plugin {
121557
121730
  return;
121558
121731
  }
121559
121732
  node.xrayed = xrayed;
121560
- const listItemElementId = node.nodeId;
121561
- const listItemElement = document.getElementById(listItemElementId);
121562
- if (listItemElement !== null) {
121563
- if (xrayed) {
121564
- listItemElement.classList.add('xrayed-node');
121565
- } else {
121566
- listItemElement.classList.remove('xrayed-node');
121567
- }
121568
- }
121733
+
121734
+ this._renderService.setXRayed(node.nodeId, xrayed);
121569
121735
  this._muteTreeEvents = false;
121570
121736
  });
121571
121737
 
@@ -121589,14 +121755,15 @@ class TreeViewPlugin extends Plugin {
121589
121755
  }
121590
121756
  this._muteSceneEvents = true;
121591
121757
  const checkbox = event.target;
121592
- const visible = checkbox.checked;
121593
- const nodeId = checkbox.id.replace('checkbox-', '');
121758
+ const visible = this._renderService.isChecked(checkbox);
121759
+ const nodeId = this._renderService.getIdFromCheckbox(checkbox);
121760
+
121594
121761
  const checkedNode = this._nodeNodes[nodeId];
121595
121762
  const objects = this._viewer.scene.objects;
121596
121763
  let numUpdated = 0;
121764
+
121597
121765
  this._withNodeTree(checkedNode, (node) => {
121598
121766
  const objectId = node.objectId;
121599
- const checkBoxId = `checkbox-${node.nodeId}`;
121600
121767
  const entity = objects[objectId];
121601
121768
  const isLeaf = (node.children.length === 0);
121602
121769
  node.numVisibleEntities = visible ? node.numEntities : 0;
@@ -121604,27 +121771,26 @@ class TreeViewPlugin extends Plugin {
121604
121771
  numUpdated++;
121605
121772
  }
121606
121773
  node.checked = visible;
121607
- const checkbox2 = document.getElementById(checkBoxId);
121608
- if (checkbox2) {
121609
- checkbox2.checked = visible;
121610
- }
121774
+
121775
+ this._renderService.setCheckbox(node.nodeId, visible);
121776
+
121611
121777
  if (entity) {
121612
121778
  entity.visible = visible;
121613
121779
  }
121614
121780
  });
121781
+
121615
121782
  let parent = checkedNode.parent;
121616
121783
  while (parent) {
121617
121784
  parent.checked = visible;
121618
- const checkbox2 = document.getElementById(`checkbox-${parent.nodeId}`); // Parent checkboxes are always in DOM
121785
+
121619
121786
  if (visible) {
121620
121787
  parent.numVisibleEntities += numUpdated;
121621
121788
  } else {
121622
121789
  parent.numVisibleEntities -= numUpdated;
121623
121790
  }
121624
- const newChecked = (parent.numVisibleEntities > 0);
121625
- if (newChecked !== checkbox2.checked) {
121626
- checkbox2.checked = newChecked;
121627
- }
121791
+
121792
+ this._renderService.setCheckbox(parent.nodeId, (parent.numVisibleEntities > 0));
121793
+
121628
121794
  parent = parent.parent;
121629
121795
  }
121630
121796
  this._muteSceneEvents = false;
@@ -121722,6 +121888,11 @@ class TreeViewPlugin extends Plugin {
121722
121888
  return;
121723
121889
  }
121724
121890
  this._metaModels[modelId] = metaModel;
121891
+
121892
+ if (options && options.rootName) {
121893
+ this._rootNames[modelId] = options.rootName;
121894
+ }
121895
+
121725
121896
  model.on("destroyed", () => {
121726
121897
  this.removeModel(model.id);
121727
121898
  });
@@ -121743,6 +121914,11 @@ class TreeViewPlugin extends Plugin {
121743
121914
  if (!metaModel) {
121744
121915
  return;
121745
121916
  }
121917
+
121918
+ if (this._rootNames[modelId]) {
121919
+ delete this._rootNames[modelId];
121920
+ }
121921
+
121746
121922
  delete this._metaModels[modelId];
121747
121923
  this._createNodes();
121748
121924
  }
@@ -121764,21 +121940,22 @@ class TreeViewPlugin extends Plugin {
121764
121940
  * @param {String} objectId ID of the {@link Entity}.
121765
121941
  */
121766
121942
  showNode(objectId) {
121767
- if (this._showListItemElementId) {
121768
- this.unShowNode();
121769
- }
121943
+ this.unShowNode();
121944
+
121770
121945
  const node = this._objectNodes[objectId];
121771
121946
  if (!node) {
121772
121947
  return; // Node may not exist for the given object if (this._pruneEmptyNodes == true)
121773
121948
  }
121949
+
121774
121950
  const nodeId = node.nodeId;
121775
- const switchElementId = "switch-" + nodeId;
121776
- const switchElement = document.getElementById(switchElementId);
121951
+
121952
+ const switchElement = this._renderService.getSwitchElement(nodeId);
121777
121953
  if (switchElement) {
121778
121954
  this._expandSwitchElement(switchElement);
121779
121955
  switchElement.scrollIntoView();
121780
- return;
121956
+ return true;
121781
121957
  }
121958
+
121782
121959
  const path = [];
121783
121960
  path.unshift(node);
121784
121961
  let parent = node.parent;
@@ -121786,20 +121963,17 @@ class TreeViewPlugin extends Plugin {
121786
121963
  path.unshift(parent);
121787
121964
  parent = parent.parent;
121788
121965
  }
121966
+
121789
121967
  for (let i = 0, len = path.length; i < len; i++) {
121790
- const node = path[i];
121791
- const nodeId = node.nodeId;
121792
- const switchElementId = "switch-" + nodeId;
121793
- const switchElement = document.getElementById(switchElementId);
121968
+ const switchElement = this._renderService.getSwitchElement(path[i].nodeId);
121794
121969
  if (switchElement) {
121795
121970
  this._expandSwitchElement(switchElement);
121796
121971
  }
121797
121972
  }
121798
- const listItemElementId = nodeId;
121799
- const listItemElement = document.getElementById(listItemElementId);
121800
- listItemElement.scrollIntoView({block: "center"});
121801
- listItemElement.classList.add("highlighted-node");
121802
- this._showListItemElementId = listItemElementId;
121973
+
121974
+ this._renderService.setHighlighted(nodeId, true);
121975
+
121976
+ this._showListItemElementId = nodeId;
121803
121977
  }
121804
121978
 
121805
121979
  /**
@@ -121813,12 +121987,9 @@ class TreeViewPlugin extends Plugin {
121813
121987
  if (!this._showListItemElementId) {
121814
121988
  return;
121815
121989
  }
121816
- const listItemElement = document.getElementById(this._showListItemElementId);
121817
- if (!listItemElement) {
121818
- this._showListItemElementId = null;
121819
- return;
121820
- }
121821
- listItemElement.classList.remove("highlighted-node");
121990
+
121991
+ this._renderService.setHighlighted(this._showListItemElementId, false);
121992
+
121822
121993
  this._showListItemElementId = null;
121823
121994
  }
121824
121995
 
@@ -121835,9 +122006,8 @@ class TreeViewPlugin extends Plugin {
121835
122006
  if (countDepth === depth) {
121836
122007
  return;
121837
122008
  }
121838
- const nodeId = node.nodeId;
121839
- const switchElementId = "switch-" + nodeId;
121840
- const switchElement = document.getElementById(switchElementId);
122009
+
122010
+ const switchElement = this._renderService.getSwitchElement(node.nodeId);
121841
122011
  if (switchElement) {
121842
122012
  this._expandSwitchElement(switchElement);
121843
122013
  const childNodes = node.children;
@@ -121992,11 +122162,12 @@ class TreeViewPlugin extends Plugin {
121992
122162
 
121993
122163
  _createDisabledNodes() {
121994
122164
 
121995
- const ul = document.createElement('ul');
121996
- this._rootElement = ul;
121997
- this._containerElement.appendChild(ul);
122165
+ const rootNode = this._renderService.createRootNode();
122166
+ this._rootElement = rootNode;
122167
+ this._containerElement.appendChild(rootNode);
121998
122168
 
121999
122169
  const rootMetaObjects = this._viewer.metaScene.rootMetaObjects;
122170
+
122000
122171
  for (let objectId in rootMetaObjects) {
122001
122172
  const rootMetaObject = rootMetaObjects[objectId];
122002
122173
  const metaObjectType = rootMetaObject.type;
@@ -122004,17 +122175,9 @@ class TreeViewPlugin extends Plugin {
122004
122175
  const rootName = ((metaObjectName && metaObjectName !== ""
122005
122176
  && metaObjectName !== "Undefined"
122006
122177
  && metaObjectName !== "Default") ? metaObjectName : metaObjectType);
122007
- const li = document.createElement('li');
122008
- ul.appendChild(li);
122009
- const switchElement = document.createElement('a');
122010
- switchElement.href = '#';
122011
- switchElement.textContent = '!';
122012
- switchElement.classList.add('warn');
122013
- switchElement.classList.add('warning');
122014
- li.appendChild(switchElement);
122015
- const span = document.createElement('span');
122016
- span.textContent = rootName;
122017
- li.appendChild(span);
122178
+
122179
+ const childNode = this._renderService.createDisabledNodeElement(rootName);
122180
+ rootNode.appendChild(childNode);
122018
122181
  }
122019
122182
  }
122020
122183
 
@@ -122065,7 +122228,7 @@ class TreeViewPlugin extends Plugin {
122065
122228
  buildingNode = {
122066
122229
  nodeId: `${this._id}-${objectId}`,
122067
122230
  objectId: objectId,
122068
- title: this._rootName || ((metaObjectName && metaObjectName !== "" && metaObjectName !== "Undefined" && metaObjectName !== "Default") ? metaObjectName : metaObjectType),
122231
+ title: this._rootNames[metaObject.metaModels[0].id] || ((metaObjectName && metaObjectName !== "" && metaObjectName !== "Undefined" && metaObjectName !== "Default") ? metaObjectName : metaObjectType),
122069
122232
  type: metaObjectType,
122070
122233
  parent: null,
122071
122234
  numEntities: 0,
@@ -122168,7 +122331,7 @@ class TreeViewPlugin extends Plugin {
122168
122331
  rootNode = {
122169
122332
  nodeId: `${this._id}-${objectId}`,
122170
122333
  objectId: objectId,
122171
- title: this._rootName || ((metaObjectName && metaObjectName !== "" && metaObjectName !== "Undefined" && metaObjectName !== "Default") ? metaObjectName : metaObjectType),
122334
+ title: this._rootNames[metaObject.metaModels[0].id] || ((metaObjectName && metaObjectName !== "" && metaObjectName !== "Undefined" && metaObjectName !== "Default") ? metaObjectName : metaObjectType),
122172
122335
  type: metaObjectType,
122173
122336
  parent: null,
122174
122337
  numEntities: 0,
@@ -122249,7 +122412,7 @@ class TreeViewPlugin extends Plugin {
122249
122412
  const node = {
122250
122413
  nodeId: `${this._id}-${objectId}`,
122251
122414
  objectId: objectId,
122252
- title: (!parent) ? (this._rootName || metaObjectName) : (metaObjectName && metaObjectName !== "" && metaObjectName !== "Undefined" && metaObjectName !== "Default") ? metaObjectName : metaObjectType,
122415
+ title: (!parent) ? (this._rootNames[metaObject.metaModels[0].id] || metaObjectName) : (metaObjectName && metaObjectName !== "" && metaObjectName !== "Undefined" && metaObjectName !== "Default") ? metaObjectName : metaObjectType,
122253
122416
  type: metaObjectType,
122254
122417
  parent: parent,
122255
122418
  numEntities: 0,
@@ -122397,112 +122560,63 @@ class TreeViewPlugin extends Plugin {
122397
122560
  const rootNodeElements = this._rootNodes.map((rootNode) => {
122398
122561
  return this._createNodeElement(rootNode);
122399
122562
  });
122400
- const ul = document.createElement('ul');
122563
+
122564
+ const rootNode = this._renderService.createRootNode();
122401
122565
  rootNodeElements.forEach((nodeElement) => {
122402
- ul.appendChild(nodeElement);
122566
+ rootNode.appendChild(nodeElement);
122403
122567
  });
122404
- this._containerElement.appendChild(ul);
122405
- this._rootElement = ul;
122568
+
122569
+ this._containerElement.appendChild(rootNode);
122570
+ this._rootElement = rootNode;
122406
122571
  }
122407
122572
 
122408
122573
  _createNodeElement(node) {
122409
- const nodeElement = document.createElement('li');
122410
- //const nodeId = this._objectToNodeID(node.objectId);
122411
- const nodeId = node.nodeId;
122412
- if (node.xrayed) {
122413
- nodeElement.classList.add('xrayed-node');
122414
- }
122415
- nodeElement.id = nodeId;
122416
- if (node.children.length > 0) {
122417
- const switchElementId = "switch-" + nodeId;
122418
- const switchElement = document.createElement('a');
122419
- switchElement.href = '#';
122420
- switchElement.id = switchElementId;
122421
- switchElement.textContent = '+';
122422
- switchElement.classList.add('plus');
122423
- switchElement.addEventListener('click', this._switchExpandHandler);
122424
- nodeElement.appendChild(switchElement);
122425
- }
122426
- const checkbox = document.createElement('input');
122427
- checkbox.id = `checkbox-${nodeId}`;
122428
- checkbox.type = "checkbox";
122429
- checkbox.checked = node.checked;
122430
- checkbox.style["pointer-events"] = "all";
122431
- checkbox.addEventListener("change", this._checkboxChangeHandler);
122432
- nodeElement.appendChild(checkbox);
122433
- const span = document.createElement('span');
122434
- span.textContent = node.title;
122435
- nodeElement.appendChild(span);
122436
- span.oncontextmenu = (e) => {
122437
- this.fire("contextmenu", {
122438
- event: e,
122574
+ const contextmenuHandler = (event) =>{
122575
+ this.fire("contextmenu", {
122576
+ event: event,
122439
122577
  viewer: this._viewer,
122440
122578
  treeViewPlugin: this,
122441
122579
  treeViewNode: node
122442
122580
  });
122443
- e.preventDefault();
122581
+ event.preventDefault();
122444
122582
  };
122445
- span.onclick = (e) => {
122583
+ const onclickHandler = (event) => {
122446
122584
  this.fire("nodeTitleClicked", {
122447
- event: e,
122585
+ event: event,
122448
122586
  viewer: this._viewer,
122449
122587
  treeViewPlugin: this,
122450
122588
  treeViewNode: node
122451
122589
  });
122452
- e.preventDefault();
122590
+ event.preventDefault();
122453
122591
  };
122454
- return nodeElement;
122592
+
122593
+ return this._renderService.createNodeElement(node, this._switchExpandHandler, this._checkboxChangeHandler, contextmenuHandler, onclickHandler);
122455
122594
  }
122456
122595
 
122457
122596
  _expandSwitchElement(switchElement) {
122458
- const parentElement = switchElement.parentElement;
122459
- const expanded = parentElement.getElementsByTagName('li')[0];
122597
+ const expanded = this._renderService.isExpanded(switchElement);
122460
122598
  if (expanded) {
122461
122599
  return;
122462
122600
  }
122463
- const nodeId = parentElement.id;
122464
- const switchNode = this._nodeNodes[nodeId];
122465
- const childNodes = switchNode.children;
122466
- const nodeElements = childNodes.map((node) => {
122601
+
122602
+ const nodeId = this._renderService.getId(switchElement);
122603
+
122604
+ const nodeElements = this._nodeNodes[nodeId].children.map((node) => {
122467
122605
  return this._createNodeElement(node);
122468
122606
  });
122469
- const ul = document.createElement('ul');
122470
- nodeElements.forEach((nodeElement) => {
122471
- ul.appendChild(nodeElement);
122472
- });
122473
- parentElement.appendChild(ul);
122474
- switchElement.classList.remove('plus');
122475
- switchElement.classList.add('minus');
122476
- switchElement.textContent = '-';
122477
- switchElement.removeEventListener('click', this._switchExpandHandler);
122478
- switchElement.addEventListener('click', this._switchCollapseHandler);
122479
- }
122480
-
122481
- _collapseNode(objectId) {
122482
- const nodeId = objectId;
122483
- const switchElementId = "switch-" + nodeId;
122484
- const switchElement = document.getElementById(switchElementId);
122607
+
122608
+ this._renderService.addChildren(switchElement, nodeElements);
122609
+
122610
+ this._renderService.expand(switchElement, this._switchExpandHandler, this._switchCollapseHandler);
122611
+ }
122612
+
122613
+ _collapseNode(nodeId) {
122614
+ const switchElement = this._renderService.getSwitchElement(nodeId);
122485
122615
  this._collapseSwitchElement(switchElement);
122486
122616
  }
122487
122617
 
122488
122618
  _collapseSwitchElement(switchElement) {
122489
- if (!switchElement) {
122490
- return;
122491
- }
122492
- const parent = switchElement.parentElement;
122493
- if (!parent) {
122494
- return;
122495
- }
122496
- const ul = parent.querySelector('ul');
122497
- if (!ul) {
122498
- return;
122499
- }
122500
- parent.removeChild(ul);
122501
- switchElement.classList.remove('minus');
122502
- switchElement.classList.add('plus');
122503
- switchElement.textContent = '+';
122504
- switchElement.removeEventListener('click', this._switchCollapseHandler);
122505
- switchElement.addEventListener('click', this._switchExpandHandler);
122619
+ this._renderService.collapse(switchElement, this._switchExpandHandler, this._switchCollapseHandler);
122506
122620
  }
122507
122621
  }
122508
122622
 
@@ -126987,9 +127101,9 @@ parsers[ParserV10.version] = ParserV10;
126987
127101
  * }
126988
127102
  *
126989
127103
  * // Gets the contents of the given .XKT file in an arraybuffer
126990
- * getXKT(src, ok, error) {
127104
+ * getXKT(xKTSrc, ok, error) {
126991
127105
  * console.log("MyDataSource#getXKT(" + xKTSrc + ", ... )");
126992
- * utils.loadArraybuffer(src,
127106
+ * utils.loadArraybuffer(xKTSrc,
126993
127107
  * (arraybuffer) => {
126994
127108
  * ok(arraybuffer);
126995
127109
  * },