@inweb/viewer-visualize 27.2.1 → 27.2.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.
@@ -2092,9 +2092,10 @@
2092
2092
  const ext = this.getViewer().getActiveExtents();
2093
2093
  const min = ext.min();
2094
2094
  const max = ext.max();
2095
- this.m_size_x = Math.abs(max[0] - min[0]) / 2;
2096
- this.m_size_y = Math.abs(max[1] - min[1]) / 2;
2097
- this.m_size_z = Math.abs(max[2] - min[2]) / 2;
2095
+ const sizeX = Math.abs(max[0] - min[0]);
2096
+ const sizeY = Math.abs(max[1] - min[1]);
2097
+ const sizeZ = Math.abs(max[2] - min[2]);
2098
+ this.m_size = Math.sqrt(sizeX * sizeX + sizeY * sizeY + sizeZ * sizeZ) || 1;
2098
2099
  this.m_center = this.toPoint(ext.center());
2099
2100
  this.m_normal = this.createNormal();
2100
2101
  const avp = this.getViewer().activeView;
@@ -2104,7 +2105,7 @@
2104
2105
  this.index = avp.numCuttingPlanes() - 1;
2105
2106
  const { red, green, blue } = this.subject.options.cuttingPlaneFillColor;
2106
2107
  avp.setEnableCuttingPlaneFill(true, red, green, blue);
2107
- avp.setCuttingPlaneFillPatternEnabled(true, this.m_module.CuttingPlaneFillStyle.kHorizontalBars, 0x0, 0x0, 0x0);
2108
+ avp.setCuttingPlaneFillPatternEnabled(true, this.m_module.CuttingPlaneFillStyle.kSlantRight, 0x0, 0x0, 0x0);
2108
2109
  this.m_model = this.getModel();
2109
2110
  this.createPreview();
2110
2111
  this.deleteAll([ext, avp, plane]);
@@ -2113,9 +2114,9 @@
2113
2114
  super.dispose();
2114
2115
  if (this.m_entity) {
2115
2116
  this.m_model.removeEntity(this.m_entity);
2116
- this.deleteAll([this.m_model, this.m_entity, this.planePreview, this.m_center]);
2117
+ this.deleteAll([this.m_model, this.m_entity, this.m_planePreview, this.m_center]);
2117
2118
  this.m_entity = null;
2118
- this.planePreview = null;
2119
+ this.m_planePreview = null;
2119
2120
  this.subject.update();
2120
2121
  }
2121
2122
  }
@@ -2131,7 +2132,6 @@
2131
2132
  start(x, y) {
2132
2133
  this.press = true;
2133
2134
  this.m_last = this.screenToWorld(x, y);
2134
- this.m_click = { x, y };
2135
2135
  }
2136
2136
  drag(x, y) {
2137
2137
  if (this.press) {
@@ -2143,52 +2143,47 @@
2143
2143
  this.m_last = point;
2144
2144
  const avp = this.getViewer().activeView;
2145
2145
  const plane = this.createPlane();
2146
- const newPlane = plane.set(this.toGePoint(this.m_center), this.m_normal);
2147
- const newCutting = avp.updateCuttingPlane(this.index, plane);
2146
+ plane.set(this.toGePoint(this.m_center), this.m_normal);
2147
+ avp.updateCuttingPlane(this.index, plane);
2148
2148
  this.drawPreview();
2149
- this.deleteAll([avp, plane, oldCenter, delta, oldLast, newPlane, newCutting]);
2149
+ this.deleteAll([avp, plane, oldCenter, delta, oldLast]);
2150
2150
  const device = this.getViewer().getActiveDevice();
2151
2151
  device.invalidate(device.getSize());
2152
2152
  }
2153
2153
  }
2154
2154
  end(x, y) {
2155
2155
  this.press = false;
2156
- if (x === this.m_click.x && y === this.m_click.y) {
2157
- this.m_normal = [this.m_normal[0] * -1, this.m_normal[1] * -1, this.m_normal[2] * -1];
2158
- const avp = this.getViewer().activeView;
2159
- const plane = this.createPlane();
2160
- plane.set(this.toGePoint(this.m_center), this.m_normal);
2161
- avp.updateCuttingPlane(this.index, plane);
2162
- this.deleteAll([avp, plane, this.m_last]);
2163
- const device = this.getViewer().getActiveDevice();
2164
- device.invalidate(device.getSize());
2165
- }
2156
+ }
2157
+ dblclick(ev) {
2158
+ this.m_normal = [this.m_normal[0] * -1, this.m_normal[1] * -1, this.m_normal[2] * -1];
2159
+ const avp = this.getViewer().activeView;
2160
+ const plane = this.createPlane();
2161
+ plane.set(this.toGePoint(this.m_center), this.m_normal);
2162
+ avp.updateCuttingPlane(this.index, plane);
2163
+ this.deleteAll([avp, plane, this.m_last]);
2164
+ const device = this.getViewer().getActiveDevice();
2165
+ device.invalidate(device.getSize());
2166
2166
  }
2167
2167
  createPreview() {
2168
2168
  this.m_entity = this.m_model.appendEntity("&CuttingPlanePreview");
2169
2169
  const GeometryTypes = this.m_module.GeometryTypes;
2170
- const transparencyDef = new this.m_module.OdTvTransparencyDef();
2171
- const colorDef = new this.m_module.OdTvColorDef(112, 112, 112);
2172
- transparencyDef.setValue(0.9);
2170
+ const facesColorDef = new this.m_module.OdTvColorDef(0xf0, 0xf0, 0xf0);
2171
+ const facesTransparencyDef = new this.m_module.OdTvTransparencyDef(0.7);
2172
+ const edgesColorDef = new this.m_module.OdTvColorDef(0xd0, 0xd0, 0xd0);
2173
2173
  const entityPtr = this.m_entity.openObject();
2174
- entityPtr.setColor(colorDef, GeometryTypes.kFaces.value);
2175
- colorDef.setColor(112, 112, 112);
2176
- entityPtr.setColor(colorDef, GeometryTypes.kEdges.value);
2177
- entityPtr.setLineWeight(5);
2178
- entityPtr.setTransparency(transparencyDef, GeometryTypes.kFaces);
2179
- transparencyDef.setValue(1.0);
2180
- entityPtr.setTransparency(transparencyDef, GeometryTypes.kEdges);
2181
- this.planePreview = entityPtr.appendPolygon(this.getPlanePreviewCoordinate());
2182
- const polygonPtr = this.planePreview.openAsPolygon();
2174
+ entityPtr.setColor(facesColorDef, GeometryTypes.kFaces);
2175
+ entityPtr.setTransparency(facesTransparencyDef, GeometryTypes.kFaces);
2176
+ entityPtr.setColor(edgesColorDef, GeometryTypes.kEdges);
2177
+ entityPtr.setLineWeight(2);
2178
+ this.m_planePreview = entityPtr.appendPolygon(this.getPlanePreviewCoordinate());
2179
+ const polygonPtr = this.m_planePreview.openAsPolygon();
2183
2180
  polygonPtr.setFilled(true);
2184
- this.deleteAll([transparencyDef, colorDef, entityPtr, polygonPtr, GeometryTypes]);
2185
- this.subject.syncOverlay();
2181
+ this.deleteAll([facesColorDef, facesTransparencyDef, edgesColorDef, entityPtr, polygonPtr, GeometryTypes]);
2186
2182
  }
2187
2183
  drawPreview() {
2188
- const polygonPtr = this.planePreview.openAsPolygon();
2184
+ const polygonPtr = this.m_planePreview.openAsPolygon();
2189
2185
  polygonPtr.setPoints(this.getPlanePreviewCoordinate());
2190
2186
  this.deleteAll([polygonPtr]);
2191
- this.subject.syncOverlay();
2192
2187
  }
2193
2188
  }
2194
2189
 
@@ -2202,19 +2197,20 @@
2202
2197
  return delta;
2203
2198
  }
2204
2199
  getPlanePreviewCoordinate() {
2200
+ const halfSize = this.m_size / 2;
2205
2201
  return [
2206
2202
  this.m_center.x,
2207
- this.m_center.y - this.m_size_y,
2208
- this.m_center.z - this.m_size_z,
2203
+ this.m_center.y - halfSize,
2204
+ this.m_center.z - halfSize,
2209
2205
  this.m_center.x,
2210
- this.m_center.y + this.m_size_y,
2211
- this.m_center.z - this.m_size_z,
2206
+ this.m_center.y + halfSize,
2207
+ this.m_center.z - halfSize,
2212
2208
  this.m_center.x,
2213
- this.m_center.y + this.m_size_y,
2214
- this.m_center.z + this.m_size_z,
2209
+ this.m_center.y + halfSize,
2210
+ this.m_center.z + halfSize,
2215
2211
  this.m_center.x,
2216
- this.m_center.y - this.m_size_y,
2217
- this.m_center.z + this.m_size_z,
2212
+ this.m_center.y - halfSize,
2213
+ this.m_center.z + halfSize,
2218
2214
  ];
2219
2215
  }
2220
2216
  }
@@ -2229,19 +2225,20 @@
2229
2225
  return delta;
2230
2226
  }
2231
2227
  getPlanePreviewCoordinate() {
2228
+ const halfSize = this.m_size / 2;
2232
2229
  return [
2233
- this.m_center.x - this.m_size_x,
2230
+ this.m_center.x - halfSize,
2234
2231
  this.m_center.y,
2235
- this.m_center.z - this.m_size_z,
2236
- this.m_center.x + this.m_size_x,
2232
+ this.m_center.z - halfSize,
2233
+ this.m_center.x + halfSize,
2237
2234
  this.m_center.y,
2238
- this.m_center.z - this.m_size_z,
2239
- this.m_center.x + this.m_size_x,
2235
+ this.m_center.z - halfSize,
2236
+ this.m_center.x + halfSize,
2240
2237
  this.m_center.y,
2241
- this.m_center.z + this.m_size_z,
2242
- this.m_center.x - this.m_size_x,
2238
+ this.m_center.z + halfSize,
2239
+ this.m_center.x - halfSize,
2243
2240
  this.m_center.y,
2244
- this.m_center.z + this.m_size_z,
2241
+ this.m_center.z + halfSize,
2245
2242
  ];
2246
2243
  }
2247
2244
  }
@@ -2256,18 +2253,19 @@
2256
2253
  return delta;
2257
2254
  }
2258
2255
  getPlanePreviewCoordinate() {
2256
+ const halfSize = this.m_size / 2;
2259
2257
  return [
2260
- this.m_center.x - this.m_size_x,
2261
- this.m_center.y - this.m_size_y,
2258
+ this.m_center.x - halfSize,
2259
+ this.m_center.y - halfSize,
2262
2260
  this.m_center.z,
2263
- this.m_center.x + this.m_size_x,
2264
- this.m_center.y - this.m_size_y,
2261
+ this.m_center.x + halfSize,
2262
+ this.m_center.y - halfSize,
2265
2263
  this.m_center.z,
2266
- this.m_center.x + this.m_size_x,
2267
- this.m_center.y + this.m_size_y,
2264
+ this.m_center.x + halfSize,
2265
+ this.m_center.y + halfSize,
2268
2266
  this.m_center.z,
2269
- this.m_center.x - this.m_size_x,
2270
- this.m_center.y + this.m_size_y,
2267
+ this.m_center.x - halfSize,
2268
+ this.m_center.y + halfSize,
2271
2269
  this.m_center.z,
2272
2270
  ];
2273
2271
  }
@@ -18649,6 +18647,7 @@ js: import "konva/skia-backend";
18649
18647
  if (!this.visualizeJs)
18650
18648
  return;
18651
18649
  this._markup.clearOverlay();
18650
+ this.emitEvent({ type: "clearoverlay" });
18652
18651
  this.update();
18653
18652
  }
18654
18653
  clearSlices() {
@@ -18658,6 +18657,7 @@ js: import "konva/skia-backend";
18658
18657
  const activeView = visViewer.activeView;
18659
18658
  activeView.removeCuttingPlanes();
18660
18659
  activeView.delete();
18660
+ this.emitEvent({ type: "clearslices" });
18661
18661
  this.update();
18662
18662
  }
18663
18663
  getSelected() {