@vitrosoftware/common-ui-ts 1.1.79 → 1.1.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitrosoftware/common-ui-ts",
3
- "version": "1.1.79",
3
+ "version": "1.1.81",
4
4
  "description": "vitro software common ui ts",
5
5
  "author": "",
6
6
  "license": "MIT",
@@ -3,11 +3,11 @@ import { BIMModel, BIMCommon, BIMAnnotation } from '/resource/bimViewer/js/bim-v
3
3
  import {
4
4
  Viewer, XKTLoaderPlugin, NavCubePlugin, SectionPlanesPlugin, math, BCFViewpointsPlugin, AnnotationsPlugin,
5
5
  ContextMenu, TreeViewPlugin, StoreyViewsPlugin, AngleMeasurementsPlugin, CameraMemento, DistanceMeasurementsPlugin,
6
- GLTFLoaderPlugin, utils
6
+ GLTFLoaderPlugin, utils, FastNavPlugin
7
7
  }
8
8
  from '/resource/bimViewer/js/xeokit/xeokit-sdk.es.js';
9
9
  import { VitroTreeViewPlugin } from "/resource/bimViewer/js/xeokit/VitroTreeViewPlugin.js";
10
- import { VitroFastNavPlugin } from "/resource/bimViewer/js/xeokit/VitroFastNavPlugin.js";window.initBimViewer = function(context) {var angleMeasurementsData = [
10
+ window.initBimViewer = function(context) {var angleMeasurementsData = [
11
11
 
12
12
  ];
13
13
  var bcfData = {};
@@ -98,6 +98,10 @@ const canvasContextMenu = new ContextMenu({
98
98
  },
99
99
  doAction: function (context) {
100
100
  context.viewer.scene.setObjectsVisible(context.viewer.scene.visibleObjectIds, false);
101
+
102
+ if (context.treeViewPlugin) {
103
+ context.treeViewPlugin.setCheckedAll(false);
104
+ }
101
105
  }
102
106
  },
103
107
  {
@@ -111,6 +115,10 @@ const canvasContextMenu = new ContextMenu({
111
115
  scene.setObjectsVisible(scene.objectIds, true);
112
116
  scene.setObjectsXRayed(scene.xrayedObjectIds, false);
113
117
  scene.setObjectsSelected(scene.selectedObjectIds, false);
118
+
119
+ if (context.treeViewPlugin) {
120
+ context.treeViewPlugin.setCheckedAll(true);
121
+ }
114
122
  }
115
123
  }
116
124
  ],
@@ -133,7 +141,7 @@ const objectContextMenu = new ContextMenu({
133
141
  {
134
142
  getTitle: function (context) { return document.webL10n.get('inspect_properties') },
135
143
  doAction: function (context) {
136
- if(context.entity && context.entity.id) {
144
+ if (context.entity && context.entity.id) {
137
145
  showPropertyInspector(context);
138
146
  }
139
147
  }
@@ -167,7 +175,11 @@ const objectContextMenu = new ContextMenu({
167
175
  doAction: function (context) {
168
176
  const objectId = context.entity.id;
169
177
 
170
- context.treeViewPlugin.showInTree(objectId);
178
+ if (!$('#btnToggleSidebarTreeView').hasClass('toggled')) {
179
+ $('#btnToggleSidebarTreeView').toggleClass('toggled');
180
+ openSidebarTreeView();
181
+ }
182
+ context.treeViewPlugin.showInTree(objectId);
171
183
  }
172
184
  }
173
185
  ],
@@ -327,7 +339,8 @@ viewer.cameraControl.on("rightClick", function (e) {
327
339
  } else {
328
340
 
329
341
  canvasContextMenu.context = { // Must set context before showing menu
330
- viewer: viewer
342
+ viewer: viewer,
343
+ treeViewPlugin: treeView,
331
344
  };
332
345
 
333
346
  canvasContextMenu.show(e.event.pageX, e.event.pageY);
@@ -359,11 +372,10 @@ const sectionPlanes = new SectionPlanesPlugin(viewer, {
359
372
  });
360
373
 
361
374
  //------------------------------------------------------------------------------------------------------------------
362
- // Add a GLTFModelsPlugin - we'll use this to load the model geometry and IFC metadata
375
+ // Add a XKTLoaderPlugin - we'll use this to load the model geometry and IFC metadata
363
376
  //------------------------------------------------------------------------------------------------------------------
364
377
 
365
378
  const xktLoader = new XKTLoaderPlugin(viewer);
366
- const gltfLoader = new GLTFLoaderPlugin(viewer);
367
379
 
368
380
 
369
381
  xktLoader.globalizeObjectIds = false; // For multiple models in TreeView
@@ -436,7 +448,7 @@ function addModelToTreeView() {
436
448
  viewer.scene.canvas.spinner.processes--;
437
449
  };
438
450
 
439
- BIMModel.GetChildList(-1, false, null, callback, error);
451
+ BIMModel.GetChildList("-1", false, null, callback, error);
440
452
  }
441
453
 
442
454
  //------------------------------------------------------------------------------------------------------------------
@@ -499,7 +511,7 @@ function doLoadModel() {
499
511
 
500
512
 
501
513
 
502
- const vitroFastNavPlugin = new VitroFastNavPlugin(viewer, {
514
+ const fastNavPlugin = new FastNavPlugin(viewer, {
503
515
  hideEdges: true, // Don't show edges while we interact (default is true)
504
516
  hideSAO: true, // Don't show ambient shadows while we interact (default is true)
505
517
  hideColorTexture: true, // No color textures while we interact (default is true)
@@ -1645,43 +1657,22 @@ function compareModels(isSideBySide) {
1645
1657
  var modelUrl = compareModelUrl + disableCacheStr;
1646
1658
  var metaModelDataUrl = fileItem.MetaModelDataPath + disableCacheStr;
1647
1659
 
1648
- getJSON(compareModelUrl, metaModelDataUrl, function(data) {
1649
-
1650
- window.model2DataUrl = metaModelDataUrl;
1651
-
1652
- var settings = {
1653
- id: Date.now(),
1654
- src: modelUrl,
1655
- metaModelJSON: data,
1656
- edges: true,
1657
- performance: true,
1658
- position: [0, 0, 0]
1659
- };
1660
-
1661
- if (isSideBySide) {
1662
- settings.position = [-55, 0, 0];
1663
- }
1664
-
1665
- var model2 = undefined;
1666
- if (srcModel.endsWith('.xkt')) {
1667
- model2 = xktLoader.load(settings);
1668
- } else {
1669
- model2 = gltfLoader.load(settings);
1670
- }
1660
+ var settings = {
1661
+ id: Date.now(),
1662
+ src: modelUrl,
1663
+ edges: true,
1664
+ performance: true,
1665
+ position: [0, 0, 0]
1666
+ };
1671
1667
 
1672
- var metaObj = data.metaObjects;
1673
- var result = [];
1674
- for (var id in metaObj) {
1675
- if (!metaObj.hasOwnProperty(id)) continue;
1676
- result[metaObj[id].id] = metaObj[id];
1677
- }
1678
- window.model2 = model2;
1679
- window.model2.customMeta = result;
1668
+ if (isSideBySide) {
1669
+ settings.position = [-55, 0, 0];
1670
+ }
1680
1671
 
1681
- model2.on('loaded', () => {
1682
- viewer.scene.canvas.spinner.processes++;
1683
- doCompareModels(isSideBySide);
1684
- });
1672
+ window.model2 = xktLoader.load(settings);
1673
+ window.model2.on('loaded', () => {
1674
+ viewer.scene.canvas.spinner.processes++;
1675
+ doCompareModels(isSideBySide);
1685
1676
  });
1686
1677
  }
1687
1678
 
@@ -2075,18 +2066,63 @@ function getPickResultModelId(pickResult) {
2075
2066
  }
2076
2067
  }
2077
2068
 
2069
+ function getPropertyValue(property) {
2070
+ if (property.value_bool != null && property.value_bool != undefined) {
2071
+ return property.value_bool;
2072
+ }
2073
+ else if (property.value_int != null && property.value_int != undefined) {
2074
+ return property.value_int;
2075
+ }
2076
+ else if (property.value_text != null && property.value_text != undefined) {
2077
+ return property.value_text;
2078
+ }
2079
+ else if (property.value_real != null && property.value_real != undefined) {
2080
+ return property.value_real;
2081
+ }
2082
+ }
2083
+
2084
+ function convertProperty(data) {
2085
+ let groups = [];
2086
+
2087
+ for (let property of data) {
2088
+ let existingGroups = groups.filter(group => group.name == property.group_name);
2089
+ if (existingGroups.length > 0) {
2090
+ existingGroups[0].properties.push({ name: property.name, value: getPropertyValue(property) });
2091
+ }
2092
+ else {
2093
+ let newGroup = {
2094
+ name: property.group_name,
2095
+ properties: [],
2096
+ };
2097
+ newGroup.properties.push({ name: property.name, value: getPropertyValue(property) });
2098
+
2099
+
2100
+ groups.push(newGroup);
2101
+ }
2102
+ }
2103
+
2104
+ return groups;
2105
+ }
2106
+
2078
2107
  function setPropertyBDSets(id, version) {
2079
2108
  const html = [];
2080
-
2109
+
2081
2110
  html.push('<div class="element-attributes">');
2082
2111
  html.push('</div>');
2083
2112
 
2084
- BIMModel.GetPropertyList(id,
2085
- (propertySets) => {
2086
- addPropertySet(propertySets, html);
2087
- });
2088
-
2113
+ viewer.scene.canvas.spinner.processes++;
2089
2114
 
2115
+ BIMModel.GetPropertyList(id,
2116
+ (data) => {
2117
+ const propertySets = convertProperty(data);
2118
+ addPropertySet(propertySets, html);
2119
+ viewer.scene.canvas.spinner.processes--;
2120
+ },
2121
+ (error) => {
2122
+ viewer.scene.canvas.spinner.processes--;
2123
+ }
2124
+ );
2125
+
2090
2126
  $('#propInspector .prop-inspector-content')[0].innerHTML = html.join("");
2091
2127
  $('.xeokit-accordion-container').accordion({
2092
2128
  collapsible: true,
@@ -2177,104 +2213,10 @@ function initPropertySetsResizable() {
2177
2213
  //
2178
2214
  //------------------------------------------------------------------------------------------------------------------
2179
2215
 
2180
- BIMCommon.GetFileItem = (callback) => {
2181
-
2182
- const item = {
2183
- ModelPath: context.filePath,
2184
- SiteId: context.file.siteId,
2185
- ListId: context.file.listId,
2186
- UniqueId: context.file.id,
2187
- FileVersionList: [],
2188
- Path: context.filePath,
2189
- ...context.file
2190
- };
2191
-
2192
- if (callback) {
2193
- callback(item);
2194
- }
2195
- }
2196
-
2197
- BIMCommon.CreateWebServerUrl = () => {
2198
- return 'http://79.143.70.197/Design';
2199
- };
2200
-
2201
2216
  BIMAnnotation.GetNote = (callback) => {
2202
2217
  callback([]);
2203
2218
  }
2204
2219
 
2205
- BIMModel.GetParentIdList = (elementId, recurse, isGeometry, callback) => {
2206
- context.getParentIdList(elementId).then(res => {
2207
- if (callback) {
2208
- callback(res);
2209
- }
2210
- })
2211
- }
2212
-
2213
- BIMModel.GetPropertyList = (elementId, callback) => {
2214
-
2215
- const getValue = (property) => {
2216
- if (property.ValueBool != null && property.ValueBool != undefined) {
2217
- return property.ValueBool;
2218
- }
2219
- else if (property.ValueInt != null && property.ValueInt != undefined) {
2220
- return property.ValueInt;
2221
- }
2222
- else if (property.ValueText != null && property.ValueText != undefined) {
2223
- return property.ValueText;
2224
- }
2225
- else if (property.ValueReal != null && property.ValueReal != undefined) {
2226
- return property.ValueReal;
2227
- }
2228
- }
2229
-
2230
- context.getPropertyList(elementId).then(res => {
2231
- let groups = [];
2232
-
2233
- for (let property of res) {
2234
- let existingGroups = groups.filter(group => group.name == property.GroupName);
2235
- if (existingGroups.length > 0) {
2236
- existingGroups[0].properties.push({ name: property.Name, value: getValue(property) });
2237
- }
2238
- else {
2239
- let newGroup = {
2240
- name: property.GroupName,
2241
- properties: [],
2242
- };
2243
- newGroup.properties.push({ name: property.Name, value: getValue(property) });
2244
-
2245
-
2246
- groups.push(newGroup);
2247
- }
2248
- }
2249
-
2250
- callback(groups);
2251
- })
2252
- }
2253
-
2254
- BIMModel.GetChildList = (elementId, recurse, isGeometry, callback) => {
2255
- let data = {
2256
- recurse: recurse,
2257
- isGeometry: isGeometry
2258
- }
2259
- context.getChildList(elementId, data).then(res => {
2260
- if (callback) {
2261
- callback(res);
2262
- }
2263
- });
2264
- }
2265
-
2266
- BIMModel.GetChildIdList = (elementId, recurse, isGeometry, callback) => {
2267
- let data = {
2268
- recurse: recurse,
2269
- isGeometry: isGeometry
2270
- };
2271
- context.getChildIdList(elementId, data).then(res => {
2272
- if (callback) {
2273
- callback(res);
2274
- }
2275
- });
2276
- }
2277
-
2278
2220
  function saveNote(pickResult) {
2279
2221
 
2280
2222
  }
@@ -2576,6 +2518,33 @@ function createSidebarNotesItemHeader(noteData) {
2576
2518
  function hidePropInspector() {
2577
2519
  $('#propInspector').hide();
2578
2520
  }
2521
+
2522
+ function compareModels(isSideBySide) {
2523
+
2524
+ var version = context.fileVersionList[0];
2525
+
2526
+ var disableCacheStr = getDisableCacheStr();
2527
+ var compareModelUrl = context.getFilePath(context.file.id, version.name);
2528
+ var modelUrl = compareModelUrl + disableCacheStr;
2529
+
2530
+ var settings = {
2531
+ id: Date.now(),
2532
+ src: modelUrl,
2533
+ edges: true,
2534
+ performance: true,
2535
+ position: [0, 0, 0]
2536
+ };
2537
+
2538
+ if (isSideBySide) {
2539
+ settings.position = [-55, 0, 0];
2540
+ }
2541
+
2542
+ window.model2 = xktLoader.load(settings);
2543
+ window.model2.on('loaded', () => {
2544
+ viewer.scene.canvas.spinner.processes++;
2545
+ doCompareModels(isSideBySide);
2546
+ });
2547
+ }
2579
2548
 
2580
2549
  //------------------------------------------------------------------------------------------------------------------
2581
2550
  // Do action wherever we click on an object
@@ -2618,33 +2587,30 @@ viewer.cameraControl.on("picked", (pickResult) => {
2618
2587
 
2619
2588
  window.viewer = viewer;
2620
2589
 
2621
- BIMCommon.GetFileItem(function (res) {
2622
- BIMCommon.FileItem = res;
2590
+ let version = context.fileVersionList.find(x => x.id === context.versionId);
2591
+ let versionStr = version ? version.name : null;
2623
2592
 
2624
- var fileItem = BIMCommon.FileItem;
2593
+ BIMCommon.GetFileItem(context.file.id, versionStr, function (modelId) {
2625
2594
 
2626
- var versionList = BIMCommon.FileItem.FileVersionList;
2627
- if (versionList.length == 0) {
2628
- $('#btnToggleCompare').hide();
2629
- } else {
2630
- $('#btnToggleCompare').show();
2631
- }
2595
+ context.getItem(modelId).then(item => {
2596
+ var filePath = context.getFilePath(item.id);
2597
+ var fileName = context.file.fieldValueMap?.name;
2598
+
2599
+ document.title += " - " + fileName;
2600
+ srcModel = filePath;
2601
+ srcMetaModelData = '';
2602
+ fileVersion = '';
2603
+ fileVersionPath = filePath;
2604
+ hideXeokitSpinner();
2605
+ doLoadModel();
2632
2606
 
2633
- var filePath = fileItem.Path;
2634
- var fileName = context.file.fieldValueMap?.name;
2635
2607
 
2636
- document.title += " - " + fileName;
2608
+ BIMCommon.FileVersion = versionStr;
2609
+ BIMCommon.FileItemId = context.file.id;
2610
+ })
2637
2611
 
2638
- if (fileItem.FileVersion)
2639
- {
2640
- $('#fileVersion').text("[v" + fileItem.FileVersion + "]");
2641
- }
2642
- srcModel = fileItem.ModelPath;
2643
- srcMetaModelData = fileItem.MetaModelDataPath;
2644
- fileVersion = fileItem.FileVersion;
2645
- fileVersionPath = filePath;
2646
- hideXeokitSpinner();
2647
- doLoadModel();
2612
+ }, function () {
2613
+ alert("The file is being processed");
2648
2614
  });
2649
2615
 
2650
2616
  function init() {