@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.
@@ -114014,6 +114014,7 @@ function CubeTextureCanvas(viewer, navCubeScene, cfg = {}) {
114014
114014
 
114015
114015
  const cubeColor = "lightgrey";
114016
114016
  const cubeHighlightColor = cfg.hoverColor || "rgba(0,0,0,0.4)";
114017
+ const textColor = cfg.textColor || "black";
114017
114018
 
114018
114019
  const height = 500;
114019
114020
  const width = height + (height / 3);
@@ -114163,7 +114164,7 @@ function CubeTextureCanvas(viewer, navCubeScene, cfg = {}) {
114163
114164
  }
114164
114165
  }
114165
114166
  if (area.label) {
114166
- context.fillStyle = "black";
114167
+ context.fillStyle = textColor;
114167
114168
  context.font = '60px sans-serif';
114168
114169
  context.textAlign = "center";
114169
114170
  var xcenter = xmin + (width * 0.5);
@@ -114367,7 +114368,7 @@ class NavCubePlugin extends Plugin {
114367
114368
  * @param {String} [cfg.cameraFly=true] Whether the {@link Camera} flies or jumps to each selected axis or diagonal.
114368
114369
  * @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.
114369
114370
  * @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.
114370
- * @param {String} [cfg.color="lightgrey] Custom uniform color for the faces of the NavCube.
114371
+ * @param {String} [cfg.color="lightgrey"] Custom uniform color for the faces of the NavCube.
114371
114372
  * @param {String} [cfg.frontColor="#55FF55"] Custom color for the front face of the NavCube. Overrides ````color````.
114372
114373
  * @param {String} [cfg.backColor="#55FF55"] Custom color for the back face of the NavCube. Overrides ````color````.
114373
114374
  * @param {String} [cfg.leftColor="#FF5555"] Custom color for the left face of the NavCube. Overrides ````color````.
@@ -114375,6 +114376,7 @@ class NavCubePlugin extends Plugin {
114375
114376
  * @param {String} [cfg.topColor="#5555FF"] Custom color for the top face of the NavCube. Overrides ````color````.
114376
114377
  * @param {String} [cfg.bottomColor="#5555FF"] Custom color for the bottom face of the NavCube. Overrides ````color````.
114377
114378
  * @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.
114379
+ * @param {String} [cfg.textColor="black"] Custom text color for labels of the NavCube.
114378
114380
  * @param {Boolean} [cfg.fitVisible=false] Sets whether the axis, corner and edge-aligned views will fit the
114379
114381
  * 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````.
114380
114382
  * @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.
@@ -121077,6 +121079,176 @@ class STLLoaderPlugin extends Plugin {
121077
121079
  }
121078
121080
  }
121079
121081
 
121082
+ /**
121083
+ * @desc A {@link TreeViewPlugin} render class.
121084
+ *
121085
+ */
121086
+ class RenderService {
121087
+
121088
+ /*
121089
+ * Creates the root node of the tree.
121090
+ * @return {HTMLElement} The root node of the tree.
121091
+ */
121092
+ createRootNode() {
121093
+ return document.createElement('ul')
121094
+ }
121095
+
121096
+ /*
121097
+ * Creates node of the tree.
121098
+ * @param {Object} node The node to create.
121099
+
121100
+ * @return {HTMLElement} The html element for the node.
121101
+ */
121102
+ createNodeElement(node, expandHandler, checkHandler, contextmenuHandler, titleClickHandler) {
121103
+ const nodeElement = document.createElement('li');
121104
+ nodeElement.id = node.nodeId;
121105
+
121106
+ if (node.xrayed) {
121107
+ nodeElement.classList.add('xrayed-node');
121108
+ }
121109
+
121110
+ if (node.children.length > 0) {
121111
+ const switchElement = document.createElement('a');
121112
+ switchElement.href = '#';
121113
+ switchElement.id = `switch-${node.nodeId}`;
121114
+ switchElement.textContent = '+';
121115
+ switchElement.classList.add('plus');
121116
+ if (expandHandler) switchElement.addEventListener('click', expandHandler);
121117
+ nodeElement.appendChild(switchElement);
121118
+ }
121119
+
121120
+ const checkbox = document.createElement('input');
121121
+ checkbox.id = `checkbox-${node.nodeId}`;
121122
+ checkbox.type = "checkbox";
121123
+ checkbox.checked = node.checked;
121124
+ checkbox.style["pointer-events"] = "all";
121125
+ if (checkHandler) checkbox.addEventListener("change", checkHandler);
121126
+ nodeElement.appendChild(checkbox);
121127
+
121128
+ const span = document.createElement('span');
121129
+ span.textContent = node.title;
121130
+ nodeElement.appendChild(span);
121131
+
121132
+ if (contextmenuHandler) {
121133
+ span.oncontextmenu = contextmenuHandler;
121134
+ }
121135
+
121136
+ if (titleClickHandler) {
121137
+ span.onclick = titleClickHandler;
121138
+ }
121139
+
121140
+ return nodeElement;
121141
+ }
121142
+
121143
+ createDisabledNodeElement(rootName) {
121144
+ const li = document.createElement('li');
121145
+
121146
+ const switchElement = document.createElement('a');
121147
+ switchElement.href = '#';
121148
+ switchElement.textContent = '!';
121149
+ switchElement.classList.add('warn');
121150
+ switchElement.classList.add('warning');
121151
+ li.appendChild(switchElement);
121152
+
121153
+ const span = document.createElement('span');
121154
+ span.textContent = rootName;
121155
+ li.appendChild(span);
121156
+
121157
+ return li;
121158
+ }
121159
+
121160
+ addChildren(element, nodes) {
121161
+ const ul = document.createElement('ul');
121162
+ nodes.forEach((nodeElement) => {
121163
+ ul.appendChild(nodeElement);
121164
+ });
121165
+
121166
+ element.parentElement.appendChild(ul);
121167
+ }
121168
+
121169
+ expand(element, expandHandler, collapseHandler) {
121170
+ element.classList.remove('plus');
121171
+ element.classList.add('minus');
121172
+ element.textContent = '-';
121173
+ element.removeEventListener('click', expandHandler);
121174
+ element.addEventListener('click', collapseHandler);
121175
+ }
121176
+
121177
+ collapse(element, expandHandler, collapseHandler) {
121178
+ if (!element) {
121179
+ return;
121180
+ }
121181
+ const parent = element.parentElement;
121182
+ if (!parent) {
121183
+ return;
121184
+ }
121185
+ const ul = parent.querySelector('ul');
121186
+ if (!ul) {
121187
+ return;
121188
+ }
121189
+ parent.removeChild(ul);
121190
+ element.classList.remove('minus');
121191
+ element.classList.add('plus');
121192
+ element.textContent = '+';
121193
+ element.removeEventListener('click', collapseHandler);
121194
+ element.addEventListener('click', expandHandler);
121195
+ }
121196
+
121197
+ isExpanded(element) {
121198
+ const parentElement = element.parentElement;
121199
+ return parentElement.getElementsByTagName('li')[0] !== undefined;
121200
+ }
121201
+
121202
+ getId(element) {
121203
+ const parentElement = element.parentElement;
121204
+ return parentElement.id;
121205
+ }
121206
+
121207
+ getIdFromCheckbox(element) {
121208
+ return element.id.replace('checkbox-', '');
121209
+ }
121210
+
121211
+ getSwitchElement(nodeId) {
121212
+ return document.getElementById(`switch-${nodeId}`);
121213
+ }
121214
+
121215
+ isChecked(element) {
121216
+ return element.checked;
121217
+ }
121218
+
121219
+ setCheckbox(nodeId, checked) {
121220
+ const checkbox = document.getElementById(`checkbox-${nodeId}`);
121221
+ if (checkbox) {
121222
+ if (checked !== checkbox.checked) {
121223
+ checkbox.checked = checked;
121224
+ }
121225
+ }
121226
+ }
121227
+
121228
+ setXRayed(nodeId, xrayed) {
121229
+ const treeNode = document.getElementById(nodeId);
121230
+ if (treeNode) {
121231
+ if (xrayed) {
121232
+ treeNode.classList.add('xrayed-node');
121233
+ } else {
121234
+ treeNode.classList.remove('xrayed-node');
121235
+ }
121236
+ }
121237
+ }
121238
+
121239
+ setHighlighted(nodeId, highlighted) {
121240
+ const treeNode = document.getElementById(nodeId);
121241
+ if (treeNode) {
121242
+ if (highlighted) {
121243
+ treeNode.scrollIntoView({block: "center"});
121244
+ treeNode.classList.add('highlighted-node');
121245
+ } else {
121246
+ treeNode.classList.remove('highlighted-node');
121247
+ }
121248
+ }
121249
+ }
121250
+ }
121251
+
121080
121252
  const treeViews = [];
121081
121253
 
121082
121254
  /**
@@ -121436,6 +121608,7 @@ class TreeViewPlugin extends Plugin {
121436
121608
  * ````IfcBuildingStorey```` nodes will be ordered spatially, from the highest storey down to the lowest, on the
121437
121609
  * vertical World axis. For all hierarchy types, other node types will be ordered in the ascending alphanumeric order of their titles.
121438
121610
  * @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.
121611
+ * @param {RenderService} [cfg.renderService] Optional {@link RenderService} to use. Defaults to the {@link TreeViewPlugin}'s default {@link RenderService}.
121439
121612
  */
121440
121613
  constructor(viewer, cfg = {}) {
121441
121614
 
@@ -121475,7 +121648,6 @@ class TreeViewPlugin extends Plugin {
121475
121648
  this._autoAddModels = (cfg.autoAddModels !== false);
121476
121649
  this._autoExpandDepth = (cfg.autoExpandDepth || 0);
121477
121650
  this._sortNodes = (cfg.sortNodes !== false);
121478
- this._pruneEmptyNodes = (cfg.pruneEmptyNodes !== false);
121479
121651
  this._viewer = viewer;
121480
121652
  this._rootElement = null;
121481
121653
  this._muteSceneEvents = false;
@@ -121483,10 +121655,15 @@ class TreeViewPlugin extends Plugin {
121483
121655
  this._rootNodes = [];
121484
121656
  this._objectNodes = {}; // Object ID -> Node
121485
121657
  this._nodeNodes = {}; // Node ID -> Node
121486
- this._rootName = cfg.rootName;
121658
+ this._rootNames = {}; // Node ID -> Root name
121487
121659
  this._sortNodes = cfg.sortNodes;
121488
121660
  this._pruneEmptyNodes = cfg.pruneEmptyNodes;
121489
121661
  this._showListItemElementId = null;
121662
+ this._renderService = cfg.renderService || new RenderService();
121663
+
121664
+ if (!this._renderService) {
121665
+ throw new Error('TreeViewPlugin: no render service set');
121666
+ }
121490
121667
 
121491
121668
  this._containerElement.oncontextmenu = (e) => {
121492
121669
  e.preventDefault();
@@ -121513,10 +121690,9 @@ class TreeViewPlugin extends Plugin {
121513
121690
  } else {
121514
121691
  node.numVisibleEntities--;
121515
121692
  }
121516
- const checkbox = document.getElementById(`checkbox-${node.nodeId}`);
121517
- if (checkbox) {
121518
- checkbox.checked = visible;
121519
- }
121693
+
121694
+ this._renderService.setCheckbox(node.nodeId, visible);
121695
+
121520
121696
  let parent = node.parent;
121521
121697
  while (parent) {
121522
121698
  parent.checked = visible;
@@ -121525,15 +121701,12 @@ class TreeViewPlugin extends Plugin {
121525
121701
  } else {
121526
121702
  parent.numVisibleEntities--;
121527
121703
  }
121528
- const parentCheckbox = document.getElementById(`checkbox-${parent.nodeId}`);
121529
- if (parentCheckbox) {
121530
- const newChecked = (parent.numVisibleEntities > 0);
121531
- if (newChecked !== parentCheckbox.checked) {
121532
- parentCheckbox.checked = newChecked;
121533
- }
121534
- }
121704
+
121705
+ this._renderService.setCheckbox(parent.nodeId, (parent.numVisibleEntities > 0));
121706
+
121535
121707
  parent = parent.parent;
121536
121708
  }
121709
+
121537
121710
  this._muteTreeEvents = false;
121538
121711
  });
121539
121712
 
@@ -121553,15 +121726,8 @@ class TreeViewPlugin extends Plugin {
121553
121726
  return;
121554
121727
  }
121555
121728
  node.xrayed = xrayed;
121556
- const listItemElementId = node.nodeId;
121557
- const listItemElement = document.getElementById(listItemElementId);
121558
- if (listItemElement !== null) {
121559
- if (xrayed) {
121560
- listItemElement.classList.add('xrayed-node');
121561
- } else {
121562
- listItemElement.classList.remove('xrayed-node');
121563
- }
121564
- }
121729
+
121730
+ this._renderService.setXRayed(node.nodeId, xrayed);
121565
121731
  this._muteTreeEvents = false;
121566
121732
  });
121567
121733
 
@@ -121585,14 +121751,15 @@ class TreeViewPlugin extends Plugin {
121585
121751
  }
121586
121752
  this._muteSceneEvents = true;
121587
121753
  const checkbox = event.target;
121588
- const visible = checkbox.checked;
121589
- const nodeId = checkbox.id.replace('checkbox-', '');
121754
+ const visible = this._renderService.isChecked(checkbox);
121755
+ const nodeId = this._renderService.getIdFromCheckbox(checkbox);
121756
+
121590
121757
  const checkedNode = this._nodeNodes[nodeId];
121591
121758
  const objects = this._viewer.scene.objects;
121592
121759
  let numUpdated = 0;
121760
+
121593
121761
  this._withNodeTree(checkedNode, (node) => {
121594
121762
  const objectId = node.objectId;
121595
- const checkBoxId = `checkbox-${node.nodeId}`;
121596
121763
  const entity = objects[objectId];
121597
121764
  const isLeaf = (node.children.length === 0);
121598
121765
  node.numVisibleEntities = visible ? node.numEntities : 0;
@@ -121600,27 +121767,26 @@ class TreeViewPlugin extends Plugin {
121600
121767
  numUpdated++;
121601
121768
  }
121602
121769
  node.checked = visible;
121603
- const checkbox2 = document.getElementById(checkBoxId);
121604
- if (checkbox2) {
121605
- checkbox2.checked = visible;
121606
- }
121770
+
121771
+ this._renderService.setCheckbox(node.nodeId, visible);
121772
+
121607
121773
  if (entity) {
121608
121774
  entity.visible = visible;
121609
121775
  }
121610
121776
  });
121777
+
121611
121778
  let parent = checkedNode.parent;
121612
121779
  while (parent) {
121613
121780
  parent.checked = visible;
121614
- const checkbox2 = document.getElementById(`checkbox-${parent.nodeId}`); // Parent checkboxes are always in DOM
121781
+
121615
121782
  if (visible) {
121616
121783
  parent.numVisibleEntities += numUpdated;
121617
121784
  } else {
121618
121785
  parent.numVisibleEntities -= numUpdated;
121619
121786
  }
121620
- const newChecked = (parent.numVisibleEntities > 0);
121621
- if (newChecked !== checkbox2.checked) {
121622
- checkbox2.checked = newChecked;
121623
- }
121787
+
121788
+ this._renderService.setCheckbox(parent.nodeId, (parent.numVisibleEntities > 0));
121789
+
121624
121790
  parent = parent.parent;
121625
121791
  }
121626
121792
  this._muteSceneEvents = false;
@@ -121718,6 +121884,11 @@ class TreeViewPlugin extends Plugin {
121718
121884
  return;
121719
121885
  }
121720
121886
  this._metaModels[modelId] = metaModel;
121887
+
121888
+ if (options && options.rootName) {
121889
+ this._rootNames[modelId] = options.rootName;
121890
+ }
121891
+
121721
121892
  model.on("destroyed", () => {
121722
121893
  this.removeModel(model.id);
121723
121894
  });
@@ -121739,6 +121910,11 @@ class TreeViewPlugin extends Plugin {
121739
121910
  if (!metaModel) {
121740
121911
  return;
121741
121912
  }
121913
+
121914
+ if (this._rootNames[modelId]) {
121915
+ delete this._rootNames[modelId];
121916
+ }
121917
+
121742
121918
  delete this._metaModels[modelId];
121743
121919
  this._createNodes();
121744
121920
  }
@@ -121760,21 +121936,22 @@ class TreeViewPlugin extends Plugin {
121760
121936
  * @param {String} objectId ID of the {@link Entity}.
121761
121937
  */
121762
121938
  showNode(objectId) {
121763
- if (this._showListItemElementId) {
121764
- this.unShowNode();
121765
- }
121939
+ this.unShowNode();
121940
+
121766
121941
  const node = this._objectNodes[objectId];
121767
121942
  if (!node) {
121768
121943
  return; // Node may not exist for the given object if (this._pruneEmptyNodes == true)
121769
121944
  }
121945
+
121770
121946
  const nodeId = node.nodeId;
121771
- const switchElementId = "switch-" + nodeId;
121772
- const switchElement = document.getElementById(switchElementId);
121947
+
121948
+ const switchElement = this._renderService.getSwitchElement(nodeId);
121773
121949
  if (switchElement) {
121774
121950
  this._expandSwitchElement(switchElement);
121775
121951
  switchElement.scrollIntoView();
121776
- return;
121952
+ return true;
121777
121953
  }
121954
+
121778
121955
  const path = [];
121779
121956
  path.unshift(node);
121780
121957
  let parent = node.parent;
@@ -121782,20 +121959,17 @@ class TreeViewPlugin extends Plugin {
121782
121959
  path.unshift(parent);
121783
121960
  parent = parent.parent;
121784
121961
  }
121962
+
121785
121963
  for (let i = 0, len = path.length; i < len; i++) {
121786
- const node = path[i];
121787
- const nodeId = node.nodeId;
121788
- const switchElementId = "switch-" + nodeId;
121789
- const switchElement = document.getElementById(switchElementId);
121964
+ const switchElement = this._renderService.getSwitchElement(path[i].nodeId);
121790
121965
  if (switchElement) {
121791
121966
  this._expandSwitchElement(switchElement);
121792
121967
  }
121793
121968
  }
121794
- const listItemElementId = nodeId;
121795
- const listItemElement = document.getElementById(listItemElementId);
121796
- listItemElement.scrollIntoView({block: "center"});
121797
- listItemElement.classList.add("highlighted-node");
121798
- this._showListItemElementId = listItemElementId;
121969
+
121970
+ this._renderService.setHighlighted(nodeId, true);
121971
+
121972
+ this._showListItemElementId = nodeId;
121799
121973
  }
121800
121974
 
121801
121975
  /**
@@ -121809,12 +121983,9 @@ class TreeViewPlugin extends Plugin {
121809
121983
  if (!this._showListItemElementId) {
121810
121984
  return;
121811
121985
  }
121812
- const listItemElement = document.getElementById(this._showListItemElementId);
121813
- if (!listItemElement) {
121814
- this._showListItemElementId = null;
121815
- return;
121816
- }
121817
- listItemElement.classList.remove("highlighted-node");
121986
+
121987
+ this._renderService.setHighlighted(this._showListItemElementId, false);
121988
+
121818
121989
  this._showListItemElementId = null;
121819
121990
  }
121820
121991
 
@@ -121831,9 +122002,8 @@ class TreeViewPlugin extends Plugin {
121831
122002
  if (countDepth === depth) {
121832
122003
  return;
121833
122004
  }
121834
- const nodeId = node.nodeId;
121835
- const switchElementId = "switch-" + nodeId;
121836
- const switchElement = document.getElementById(switchElementId);
122005
+
122006
+ const switchElement = this._renderService.getSwitchElement(node.nodeId);
121837
122007
  if (switchElement) {
121838
122008
  this._expandSwitchElement(switchElement);
121839
122009
  const childNodes = node.children;
@@ -121988,11 +122158,12 @@ class TreeViewPlugin extends Plugin {
121988
122158
 
121989
122159
  _createDisabledNodes() {
121990
122160
 
121991
- const ul = document.createElement('ul');
121992
- this._rootElement = ul;
121993
- this._containerElement.appendChild(ul);
122161
+ const rootNode = this._renderService.createRootNode();
122162
+ this._rootElement = rootNode;
122163
+ this._containerElement.appendChild(rootNode);
121994
122164
 
121995
122165
  const rootMetaObjects = this._viewer.metaScene.rootMetaObjects;
122166
+
121996
122167
  for (let objectId in rootMetaObjects) {
121997
122168
  const rootMetaObject = rootMetaObjects[objectId];
121998
122169
  const metaObjectType = rootMetaObject.type;
@@ -122000,17 +122171,9 @@ class TreeViewPlugin extends Plugin {
122000
122171
  const rootName = ((metaObjectName && metaObjectName !== ""
122001
122172
  && metaObjectName !== "Undefined"
122002
122173
  && metaObjectName !== "Default") ? metaObjectName : metaObjectType);
122003
- const li = document.createElement('li');
122004
- ul.appendChild(li);
122005
- const switchElement = document.createElement('a');
122006
- switchElement.href = '#';
122007
- switchElement.textContent = '!';
122008
- switchElement.classList.add('warn');
122009
- switchElement.classList.add('warning');
122010
- li.appendChild(switchElement);
122011
- const span = document.createElement('span');
122012
- span.textContent = rootName;
122013
- li.appendChild(span);
122174
+
122175
+ const childNode = this._renderService.createDisabledNodeElement(rootName);
122176
+ rootNode.appendChild(childNode);
122014
122177
  }
122015
122178
  }
122016
122179
 
@@ -122061,7 +122224,7 @@ class TreeViewPlugin extends Plugin {
122061
122224
  buildingNode = {
122062
122225
  nodeId: `${this._id}-${objectId}`,
122063
122226
  objectId: objectId,
122064
- title: this._rootName || ((metaObjectName && metaObjectName !== "" && metaObjectName !== "Undefined" && metaObjectName !== "Default") ? metaObjectName : metaObjectType),
122227
+ title: this._rootNames[metaObject.metaModels[0].id] || ((metaObjectName && metaObjectName !== "" && metaObjectName !== "Undefined" && metaObjectName !== "Default") ? metaObjectName : metaObjectType),
122065
122228
  type: metaObjectType,
122066
122229
  parent: null,
122067
122230
  numEntities: 0,
@@ -122164,7 +122327,7 @@ class TreeViewPlugin extends Plugin {
122164
122327
  rootNode = {
122165
122328
  nodeId: `${this._id}-${objectId}`,
122166
122329
  objectId: objectId,
122167
- title: this._rootName || ((metaObjectName && metaObjectName !== "" && metaObjectName !== "Undefined" && metaObjectName !== "Default") ? metaObjectName : metaObjectType),
122330
+ title: this._rootNames[metaObject.metaModels[0].id] || ((metaObjectName && metaObjectName !== "" && metaObjectName !== "Undefined" && metaObjectName !== "Default") ? metaObjectName : metaObjectType),
122168
122331
  type: metaObjectType,
122169
122332
  parent: null,
122170
122333
  numEntities: 0,
@@ -122245,7 +122408,7 @@ class TreeViewPlugin extends Plugin {
122245
122408
  const node = {
122246
122409
  nodeId: `${this._id}-${objectId}`,
122247
122410
  objectId: objectId,
122248
- title: (!parent) ? (this._rootName || metaObjectName) : (metaObjectName && metaObjectName !== "" && metaObjectName !== "Undefined" && metaObjectName !== "Default") ? metaObjectName : metaObjectType,
122411
+ title: (!parent) ? (this._rootNames[metaObject.metaModels[0].id] || metaObjectName) : (metaObjectName && metaObjectName !== "" && metaObjectName !== "Undefined" && metaObjectName !== "Default") ? metaObjectName : metaObjectType,
122249
122412
  type: metaObjectType,
122250
122413
  parent: parent,
122251
122414
  numEntities: 0,
@@ -122393,112 +122556,63 @@ class TreeViewPlugin extends Plugin {
122393
122556
  const rootNodeElements = this._rootNodes.map((rootNode) => {
122394
122557
  return this._createNodeElement(rootNode);
122395
122558
  });
122396
- const ul = document.createElement('ul');
122559
+
122560
+ const rootNode = this._renderService.createRootNode();
122397
122561
  rootNodeElements.forEach((nodeElement) => {
122398
- ul.appendChild(nodeElement);
122562
+ rootNode.appendChild(nodeElement);
122399
122563
  });
122400
- this._containerElement.appendChild(ul);
122401
- this._rootElement = ul;
122564
+
122565
+ this._containerElement.appendChild(rootNode);
122566
+ this._rootElement = rootNode;
122402
122567
  }
122403
122568
 
122404
122569
  _createNodeElement(node) {
122405
- const nodeElement = document.createElement('li');
122406
- //const nodeId = this._objectToNodeID(node.objectId);
122407
- const nodeId = node.nodeId;
122408
- if (node.xrayed) {
122409
- nodeElement.classList.add('xrayed-node');
122410
- }
122411
- nodeElement.id = nodeId;
122412
- if (node.children.length > 0) {
122413
- const switchElementId = "switch-" + nodeId;
122414
- const switchElement = document.createElement('a');
122415
- switchElement.href = '#';
122416
- switchElement.id = switchElementId;
122417
- switchElement.textContent = '+';
122418
- switchElement.classList.add('plus');
122419
- switchElement.addEventListener('click', this._switchExpandHandler);
122420
- nodeElement.appendChild(switchElement);
122421
- }
122422
- const checkbox = document.createElement('input');
122423
- checkbox.id = `checkbox-${nodeId}`;
122424
- checkbox.type = "checkbox";
122425
- checkbox.checked = node.checked;
122426
- checkbox.style["pointer-events"] = "all";
122427
- checkbox.addEventListener("change", this._checkboxChangeHandler);
122428
- nodeElement.appendChild(checkbox);
122429
- const span = document.createElement('span');
122430
- span.textContent = node.title;
122431
- nodeElement.appendChild(span);
122432
- span.oncontextmenu = (e) => {
122433
- this.fire("contextmenu", {
122434
- event: e,
122570
+ const contextmenuHandler = (event) =>{
122571
+ this.fire("contextmenu", {
122572
+ event: event,
122435
122573
  viewer: this._viewer,
122436
122574
  treeViewPlugin: this,
122437
122575
  treeViewNode: node
122438
122576
  });
122439
- e.preventDefault();
122577
+ event.preventDefault();
122440
122578
  };
122441
- span.onclick = (e) => {
122579
+ const onclickHandler = (event) => {
122442
122580
  this.fire("nodeTitleClicked", {
122443
- event: e,
122581
+ event: event,
122444
122582
  viewer: this._viewer,
122445
122583
  treeViewPlugin: this,
122446
122584
  treeViewNode: node
122447
122585
  });
122448
- e.preventDefault();
122586
+ event.preventDefault();
122449
122587
  };
122450
- return nodeElement;
122588
+
122589
+ return this._renderService.createNodeElement(node, this._switchExpandHandler, this._checkboxChangeHandler, contextmenuHandler, onclickHandler);
122451
122590
  }
122452
122591
 
122453
122592
  _expandSwitchElement(switchElement) {
122454
- const parentElement = switchElement.parentElement;
122455
- const expanded = parentElement.getElementsByTagName('li')[0];
122593
+ const expanded = this._renderService.isExpanded(switchElement);
122456
122594
  if (expanded) {
122457
122595
  return;
122458
122596
  }
122459
- const nodeId = parentElement.id;
122460
- const switchNode = this._nodeNodes[nodeId];
122461
- const childNodes = switchNode.children;
122462
- const nodeElements = childNodes.map((node) => {
122597
+
122598
+ const nodeId = this._renderService.getId(switchElement);
122599
+
122600
+ const nodeElements = this._nodeNodes[nodeId].children.map((node) => {
122463
122601
  return this._createNodeElement(node);
122464
122602
  });
122465
- const ul = document.createElement('ul');
122466
- nodeElements.forEach((nodeElement) => {
122467
- ul.appendChild(nodeElement);
122468
- });
122469
- parentElement.appendChild(ul);
122470
- switchElement.classList.remove('plus');
122471
- switchElement.classList.add('minus');
122472
- switchElement.textContent = '-';
122473
- switchElement.removeEventListener('click', this._switchExpandHandler);
122474
- switchElement.addEventListener('click', this._switchCollapseHandler);
122475
- }
122476
-
122477
- _collapseNode(objectId) {
122478
- const nodeId = objectId;
122479
- const switchElementId = "switch-" + nodeId;
122480
- const switchElement = document.getElementById(switchElementId);
122603
+
122604
+ this._renderService.addChildren(switchElement, nodeElements);
122605
+
122606
+ this._renderService.expand(switchElement, this._switchExpandHandler, this._switchCollapseHandler);
122607
+ }
122608
+
122609
+ _collapseNode(nodeId) {
122610
+ const switchElement = this._renderService.getSwitchElement(nodeId);
122481
122611
  this._collapseSwitchElement(switchElement);
122482
122612
  }
122483
122613
 
122484
122614
  _collapseSwitchElement(switchElement) {
122485
- if (!switchElement) {
122486
- return;
122487
- }
122488
- const parent = switchElement.parentElement;
122489
- if (!parent) {
122490
- return;
122491
- }
122492
- const ul = parent.querySelector('ul');
122493
- if (!ul) {
122494
- return;
122495
- }
122496
- parent.removeChild(ul);
122497
- switchElement.classList.remove('minus');
122498
- switchElement.classList.add('plus');
122499
- switchElement.textContent = '+';
122500
- switchElement.removeEventListener('click', this._switchCollapseHandler);
122501
- switchElement.addEventListener('click', this._switchExpandHandler);
122615
+ this._renderService.collapse(switchElement, this._switchExpandHandler, this._switchCollapseHandler);
122502
122616
  }
122503
122617
  }
122504
122618
 
@@ -126983,9 +127097,9 @@ parsers[ParserV10.version] = ParserV10;
126983
127097
  * }
126984
127098
  *
126985
127099
  * // Gets the contents of the given .XKT file in an arraybuffer
126986
- * getXKT(src, ok, error) {
127100
+ * getXKT(xKTSrc, ok, error) {
126987
127101
  * console.log("MyDataSource#getXKT(" + xKTSrc + ", ... )");
126988
- * utils.loadArraybuffer(src,
127102
+ * utils.loadArraybuffer(xKTSrc,
126989
127103
  * (arraybuffer) => {
126990
127104
  * ok(arraybuffer);
126991
127105
  * },