@inweb/viewer-visualize 25.11.0 → 25.11.1

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.
@@ -829,7 +829,7 @@
829
829
  function resetView(viewer) {
830
830
  if (!viewer.visualizeJs)
831
831
  return;
832
- viewer.executeCommand("setActiveDragger", "");
832
+ viewer.executeCommand("setActiveDragger");
833
833
  viewer.executeCommand("clearSlices");
834
834
  viewer.executeCommand("clearOverlay");
835
835
  viewer.executeCommand("setMarkupColor");
@@ -13874,8 +13874,8 @@
13874
13874
  this.addImage(screenPoint, image.src, image.width, image.height, image.id);
13875
13875
  }));
13876
13876
  }
13877
- getViewpoint() {
13878
- const viewpoint = {};
13877
+ getViewpoint(viewpoint) {
13878
+ if (!viewpoint) viewpoint = {};
13879
13879
  viewpoint.lines = this.getMarkupLines();
13880
13880
  viewpoint.texts = this.getMarkupTexts();
13881
13881
  viewpoint.arrows = this.getMarkupArrows();
@@ -13889,7 +13889,6 @@
13889
13889
  viewpoint.snapshot = {
13890
13890
  data: this.combineMarkupWithDrawing()
13891
13891
  };
13892
- viewpoint.description = (new Date).toDateString();
13893
13892
  return viewpoint;
13894
13893
  }
13895
13894
  enableEditMode(mode) {
@@ -16837,6 +16836,7 @@
16837
16836
  this.viewer.update(true);
16838
16837
  this.viewer.syncOpenCloudVisualStyle(false);
16839
16838
  this.viewer.syncOptions();
16839
+ this.viewer.syncOverlay();
16840
16840
  this.viewer.resize();
16841
16841
  this.viewer.emitEvent({ type: "databasechunk", data, model: this.model });
16842
16842
  }
@@ -16899,6 +16899,7 @@
16899
16899
  visViewer.parseVsfx(data);
16900
16900
  this.viewer.syncOpenCloudVisualStyle(false);
16901
16901
  this.viewer.syncOptions();
16902
+ this.viewer.syncOverlay();
16902
16903
  this.viewer.resize();
16903
16904
  }
16904
16905
  console.timeEnd("File load time");
@@ -16989,6 +16990,7 @@
16989
16990
  updaterController.update(UpdateType.kForce);
16990
16991
  this.viewer.syncOpenCloudVisualStyle(false);
16991
16992
  this.viewer.syncOptions();
16993
+ this.viewer.syncOverlay();
16992
16994
  this.viewer.resize();
16993
16995
  this.viewer.emitEvent({ type: "databasechunk", data: chunk, model: this.model });
16994
16996
  }
@@ -17064,6 +17066,7 @@
17064
17066
  updaterController.update(UpdateType.kForce);
17065
17067
  this.viewer.syncOpenCloudVisualStyle(false);
17066
17068
  this.viewer.syncOptions();
17069
+ this.viewer.syncOverlay();
17067
17070
  this.viewer.resize();
17068
17071
  this.viewer.emitEvent({ type: "databasechunk", data: chunk, model: this.model });
17069
17072
  }
@@ -17444,18 +17447,18 @@
17444
17447
  }
17445
17448
  this._viewer.update();
17446
17449
  }
17447
- getViewpoint() {
17450
+ getViewpoint(viewpoint) {
17451
+ if (!this._viewer.visualizeJs)
17452
+ return {};
17448
17453
  function getLogicalPoint3dFromArray(array) {
17449
17454
  return { x: array[0], y: array[1], z: array[2] };
17450
17455
  }
17451
- if (!this._viewer.visualizeJs)
17452
- return {};
17453
17456
  const visLib = this._viewer.visLib();
17454
17457
  const visViewer = visLib.getViewer();
17455
- const viewpoint = {
17456
- lines: [],
17457
- texts: [],
17458
- };
17458
+ if (!viewpoint)
17459
+ viewpoint = {};
17460
+ viewpoint.lines = [];
17461
+ viewpoint.texts = [];
17459
17462
  const model = visViewer.getMarkupModel();
17460
17463
  const itr = model.getEntitiesIterator();
17461
17464
  for (; !itr.done(); itr.step()) {
@@ -17501,7 +17504,6 @@
17501
17504
  viewpoint.custom_fields = {
17502
17505
  markup_color: this.getMarkupColor(),
17503
17506
  };
17504
- viewpoint.description = new Date().toDateString();
17505
17507
  return viewpoint;
17506
17508
  }
17507
17509
  enableEditMode(mode) {
@@ -17719,6 +17721,7 @@
17719
17721
  this._gestureManager.initialize();
17720
17722
  this.syncOpenCloudVisualStyle(true);
17721
17723
  this.syncOptions();
17724
+ this.syncOverlay();
17722
17725
  this._renderTime = performance.now();
17723
17726
  this.render(this._renderTime);
17724
17727
  this.emitEvent({ type: "initialize" });
@@ -18020,9 +18023,9 @@
18020
18023
  return this;
18021
18024
  }
18022
18025
  /**
18023
- * List of names of registered draggers.
18026
+ * List of names of available draggers.
18024
18027
  *
18025
- * The following draggers are registered by default:
18028
+ * The following draggers are available by default:
18026
18029
  *
18027
18030
  * - `Line`
18028
18031
  * - `Text`
@@ -18082,6 +18085,7 @@
18082
18085
  .join(" ");
18083
18086
  }
18084
18087
  this.emitEvent({ type: "changeactivedragger", data: name });
18088
+ this.update();
18085
18089
  }
18086
18090
  return this._activeDragger;
18087
18091
  }
@@ -18092,9 +18096,6 @@
18092
18096
  this.setActiveDragger(dragger.name);
18093
18097
  }
18094
18098
  }
18095
- /**
18096
- * Removes all cutting planes.
18097
- */
18098
18099
  clearSlices() {
18099
18100
  if (!this.visualizeJs)
18100
18101
  return;
@@ -18104,18 +18105,12 @@
18104
18105
  activeView.delete();
18105
18106
  this.update();
18106
18107
  }
18107
- /**
18108
- * Clears the overlay view.
18109
- */
18110
18108
  clearOverlay() {
18111
18109
  if (!this.visualizeJs)
18112
18110
  return;
18113
18111
  this._markup.clearOverlay();
18114
18112
  this.update();
18115
18113
  }
18116
- /**
18117
- * Creates an overlay view. Overlay view is used to draw cutting planes and `Visualize` markups.
18118
- */
18119
18114
  syncOverlay() {
18120
18115
  if (!this.visualizeJs)
18121
18116
  return;
@@ -18342,6 +18337,7 @@
18342
18337
  visViewer.parseFile(data);
18343
18338
  this.syncOpenCloudVisualStyle(false);
18344
18339
  this.syncOptions();
18340
+ this.syncOverlay();
18345
18341
  this.resize();
18346
18342
  this.emitEvent({ type: "geometryprogress", data: 1, buffer });
18347
18343
  this.emitEvent({ type: "databasechunk", data, buffer });
@@ -18384,6 +18380,7 @@
18384
18380
  visViewer.parseVsfx(data);
18385
18381
  this.syncOpenCloudVisualStyle(false);
18386
18382
  this.syncOptions();
18383
+ this.syncOverlay();
18387
18384
  this.resize();
18388
18385
  this.emitEvent({ type: "geometryprogress", data: 1, buffer });
18389
18386
  this.emitEvent({ type: "databasechunk", data, buffer });
@@ -18412,11 +18409,13 @@
18412
18409
  const visLib = this.visLib();
18413
18410
  const visViewer = visLib.getViewer();
18414
18411
  this.setActiveDragger();
18412
+ this.clearSlices();
18415
18413
  this.clearOverlay();
18416
18414
  visViewer.clear();
18417
18415
  visViewer.createLocalDatabase();
18418
18416
  this.syncOpenCloudVisualStyle(true);
18419
18417
  this.syncOptions();
18418
+ this.syncOverlay();
18420
18419
  this.resize();
18421
18420
  this.emitEvent({ type: "clear" });
18422
18421
  return this;
@@ -18467,28 +18466,35 @@
18467
18466
  this.update();
18468
18467
  return entityId;
18469
18468
  }
18470
- /**
18471
- * Sets the viewer state to the specified viewpoint.
18472
- *
18473
- * To get a list of available viewpoints from the server for a specific file, use the
18474
- * `File.getViewpoints()`.
18475
- *
18476
- * @param viewpoint - Viewpoint data.
18477
- */
18478
18469
  drawViewpoint(viewpoint) {
18470
+ var _a;
18471
+ if (!this.visualizeJs)
18472
+ return;
18473
+ const draggerName = (_a = this._activeDragger) === null || _a === void 0 ? void 0 : _a.name;
18474
+ this.setActiveDragger();
18475
+ this.clearSlices();
18476
+ this.clearOverlay();
18477
+ this.clearSelected();
18478
+ this.showAll();
18479
+ this.explode();
18479
18480
  this.setOrthogonalCameraSettings(viewpoint.orthogonal_camera);
18480
18481
  this.setClippingPlanes(viewpoint.clipping_planes);
18482
+ this.setSelection(viewpoint.selection);
18481
18483
  this._markup.setViewpoint(viewpoint);
18484
+ this.setActiveDragger(draggerName);
18485
+ this.emitEvent({ type: "drawviewpoint", data: viewpoint });
18486
+ this.update();
18482
18487
  }
18483
- /**
18484
- * Saves the viewer state at the viewpoint.
18485
- *
18486
- * To save a viewpoint to the server for a specific file, use the `File.saveViewpoint()`.
18487
- */
18488
18488
  createViewpoint() {
18489
- const viewpoint = this._markup.getViewpoint();
18489
+ if (!this.visualizeJs)
18490
+ return {};
18491
+ const viewpoint = {};
18490
18492
  viewpoint.orthogonal_camera = this.getOrthogonalCameraSettings();
18491
18493
  viewpoint.clipping_planes = this.getClippingPlanes();
18494
+ viewpoint.selection = this.getSelection();
18495
+ viewpoint.description = new Date().toDateString();
18496
+ this._markup.getViewpoint(viewpoint);
18497
+ this.emitEvent({ type: "createviewpoint", data: viewpoint });
18492
18498
  return viewpoint;
18493
18499
  }
18494
18500
  getPoint3dFromArray(array) {
@@ -18511,13 +18517,10 @@
18511
18517
  setOrthogonalCameraSettings(settings) {
18512
18518
  const visViewer = this.visViewer();
18513
18519
  const activeView = visViewer.activeView;
18514
- this.resetActiveDragger();
18515
- this.clearSlices();
18516
- this.clearOverlay();
18517
18520
  if (settings) {
18518
18521
  activeView.setView(this.getLogicalPoint3dAsArray(settings.view_point), this.getLogicalPoint3dAsArray(settings.direction), this.getLogicalPoint3dAsArray(settings.up_vector), settings.field_width, settings.field_height, true);
18522
+ this.syncOverlay();
18519
18523
  }
18520
- this.syncOverlay();
18521
18524
  }
18522
18525
  getClippingPlanes() {
18523
18526
  const visViewer = this.visViewer();
@@ -18525,26 +18528,32 @@
18525
18528
  const clipping_planes = [];
18526
18529
  for (let i = 0; i < activeView.numCuttingPlanes(); i++) {
18527
18530
  const cuttingPlane = activeView.getCuttingPlane(i);
18528
- const plane = {
18531
+ const clipping_plane = {
18529
18532
  location: this.getPoint3dFromArray(cuttingPlane.getOrigin()),
18530
18533
  direction: this.getPoint3dFromArray(cuttingPlane.normal()),
18531
18534
  };
18532
- clipping_planes.push(plane);
18535
+ clipping_planes.push(clipping_plane);
18533
18536
  }
18534
18537
  return clipping_planes;
18535
18538
  }
18536
- setClippingPlanes(clippingPlanes) {
18537
- if (clippingPlanes) {
18539
+ setClippingPlanes(clipping_planes) {
18540
+ if (clipping_planes) {
18538
18541
  const visViewer = this.visViewer();
18539
18542
  const activeView = visViewer.activeView;
18540
- for (const plane of clippingPlanes) {
18543
+ for (const clipping_plane of clipping_planes) {
18541
18544
  const cuttingPlane = new (this.visLib().OdTvPlane)();
18542
- cuttingPlane.set(this.getLogicalPoint3dAsArray(plane.location), this.getLogicalPoint3dAsArray(plane.direction));
18545
+ cuttingPlane.set(this.getLogicalPoint3dAsArray(clipping_plane.location), this.getLogicalPoint3dAsArray(clipping_plane.direction));
18543
18546
  activeView.addCuttingPlane(cuttingPlane);
18544
18547
  activeView.setEnableCuttingPlaneFill(true, 0x66, 0x66, 0x66);
18545
18548
  }
18546
18549
  }
18547
18550
  }
18551
+ getSelection() {
18552
+ return this.getSelected().map((handle) => ({ handle }));
18553
+ }
18554
+ setSelection(selection) {
18555
+ this.setSelected(selection === null || selection === void 0 ? void 0 : selection.map((component) => component.handle));
18556
+ }
18548
18557
  /**
18549
18558
  * Executes the command denoted by the given command. If the command is not found, tries to
18550
18559
  * set active dragger with the specified name.