build-dxf 0.0.19-1 → 0.0.19-11

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/src/index3.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as THREE from "three";
2
- import { i as isString, n as noop, r as resolveUnref, t as tryOnScopeDispose, b as isClient, c as tryOnMounted, d as identity, e as buildProps, f as definePropType, _ as _export_sfc, u as useNamespace, g as isNumber, h as addUnit, w as withInstall, j as useEmptyValuesProps, k as useSizeProp, p as provideGlobalConfig, l as iconPropType, m as useGlobalComponentSettings, T as TypeComponentsMap, o as ElIcon, q as TypeComponents, s as useTimeoutFn, v as isString$1, x as isFunction, y as isBoolean, z as isElement, A as withInstallFunction, L as Lines, E as ElButton, a as ElCheckbox, S as SelectLocalFile } from "./selectLocalFile.js";
2
+ import { O as isString, P as noop, Q as resolveUnref, T as tryOnScopeDispose, U as isClient, V as tryOnMounted, W as identity, m as buildProps, q as definePropType, _ as _export_sfc, x as useNamespace, B as isNumber, X as addUnit, y as withInstall, Y as useEmptyValuesProps, w as useSizeProp, Z as provideGlobalConfig, v as iconPropType, $ as useGlobalComponentSettings, a0 as TypeComponentsMap, E as ElIcon, a1 as TypeComponents, a2 as useTimeoutFn, A as isString$1, a3 as isFunction, C as isBoolean, a4 as isElement, a5 as withInstallFunction, I as Lines, J as DomEventRegister } from "./selectLocalFile.js";
3
3
  import { C as Component, L as LineSegment, P as Point, B as Box2, E as EventDispatcher, b as PointVirtualGrid, Q as Quadtree } from "./build.js";
4
- import { watch, ref, defineComponent, computed, createElementBlock, openBlock, normalizeClass, unref, renderSlot, createVNode, Transition, withCtx, withDirectives, createElementVNode, normalizeStyle, createTextVNode, toDisplayString, vShow, shallowReactive, onMounted, createBlock, createCommentVNode, resolveDynamicComponent, Fragment, withModifiers, nextTick, isVNode, render, toRaw, createStaticVNode, createApp } from "vue";
4
+ import { watch, ref, defineComponent, computed, createElementBlock, openBlock, normalizeClass, unref, renderSlot, createVNode, Transition, withCtx, withDirectives, createElementVNode, normalizeStyle, createTextVNode, toDisplayString, vShow, shallowReactive, onMounted, createBlock, createCommentVNode, resolveDynamicComponent, Fragment, withModifiers, nextTick, isVNode, render, toRaw, watchEffect, onUnmounted, renderList, createApp } from "vue";
5
5
  import "clipper-lib";
6
6
  import "dxf-writer";
7
7
  import "three/addons/controls/OrbitControls.js";
@@ -777,7 +777,7 @@ class DrawLine extends CommandFlowComponent {
777
777
  * @param next
778
778
  */
779
779
  selectPoint(next) {
780
- let editor = this.parent?.findComponentByName("Editor"), renderer = editor.renderer, start = null, end = null, points = [], circle = new THREE.Mesh(new THREE.SphereGeometry(0.05), new THREE.MeshBasicMaterial({ color: 65280 })), dom = renderer.html2DRenderer?.domElement, line = new Lines([], 16711935), auxiliaryLine = new Lines([
780
+ let editor = this.parent?.findComponentByName("Editor"), start = null, end = null, points = [], circle = new THREE.Mesh(new THREE.SphereGeometry(0.05), new THREE.MeshBasicMaterial({ color: 65280 })), dom = editor.domContainer.domElement, line = new Lines([], 16711935), auxiliaryLine = new Lines([
781
781
  new THREE.Vector3(-1e4, 0, 0),
782
782
  new THREE.Vector3(1e4, 0, 0),
783
783
  new THREE.Vector3(0, -1e4, 0),
@@ -804,10 +804,10 @@ class DrawLine extends CommandFlowComponent {
804
804
  if (find) {
805
805
  circle.position.set(point.x, point.y, 0);
806
806
  this.container.add(circle);
807
- dom.parentElement.style.cursor = "none";
807
+ dom.style.cursor = "none";
808
808
  } else {
809
809
  circle.removeFromParent();
810
- dom.parentElement.style.cursor = "crosshair";
810
+ dom.style.cursor = "crosshair";
811
811
  }
812
812
  currentPoint.copy(point);
813
813
  if (!(start && end)) return;
@@ -1097,11 +1097,11 @@ class Default extends Component {
1097
1097
  const rectangle = line.expandToRectangle(0.02, "bothSides");
1098
1098
  object3D.geometry = editor.renderManager.createGeometry({ position: rectangle.createGeometry() }, 6);
1099
1099
  this.container.add(object3D);
1100
- dom.parentElement.style.cursor = "pointer";
1100
+ dom.style.cursor = "pointer";
1101
1101
  currentSelectLine = line;
1102
1102
  } else {
1103
1103
  object3D.removeFromParent();
1104
- dom.parentElement.style.cursor = "default";
1104
+ dom.style.cursor = "default";
1105
1105
  currentSelectLine = null;
1106
1106
  }
1107
1107
  }),
@@ -1248,10 +1248,8 @@ class CommandManager extends EventDispatcher {
1248
1248
  }
1249
1249
  }
1250
1250
  }
1251
- const _hoisted_1 = { class: "pointer-events-none absolute left-0 top-0 w-full h-fit z-[10000] flex flex-row justify-between p-[5px] box-border select-none pointer-events-[all]" };
1252
- const _hoisted_2 = { class: "pointer-events-auto" };
1253
- const _hoisted_3 = { class: "pointer-events-auto" };
1254
- const _hoisted_4 = { class: "text-[14px] bg-[rgba(255,255,255,1)] rounded-[6px] p-[0px_10px]" };
1251
+ const _hoisted_1 = { class: "mt-[5px] text-[#888] text-[10px] absolute left-[10px] bottom-[10px] rounded-[8px] min-w-[150px] bg-black/15 p-[10px]" };
1252
+ const _hoisted_2 = { class: "inline-block ml-[10px]" };
1255
1253
  const _sfc_main = /* @__PURE__ */ defineComponent({
1256
1254
  __name: "EditorTool",
1257
1255
  props: {
@@ -1259,24 +1257,32 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1259
1257
  },
1260
1258
  setup(__props) {
1261
1259
  const props = __props;
1262
- const originalLineVisible = ref(true), dxfVisible = ref(true), whiteModelVisible = ref(true), isLook = ref(false), dxfSystem = toRaw(props.dxfSystem);
1263
- function setLines(lines) {
1264
- if (lines) {
1265
- localStorage.setItem("lines", JSON.stringify(lines));
1266
- try {
1267
- dxfSystem.Dxf.set(lines);
1268
- dxfSystem.Dxf.lineOffset();
1269
- } catch (error) {
1270
- console.log(error);
1271
- }
1272
- }
1273
- }
1274
- async function selectLocalFile() {
1275
- const data = await SelectLocalFile.json();
1276
- if (Array.isArray(data)) {
1277
- localStorage.removeItem("orbitControls");
1278
- setLines(data);
1279
- }
1260
+ const originalLineVisible = ref(true), dxfVisible = ref(true), whiteModelVisible = ref(true), isLook = ref(false), elRef = ref();
1261
+ ref();
1262
+ const dxfSystem = toRaw(props.dxfSystem), domEventRegister = dxfSystem.findComponentByType(DomEventRegister), toolBarPosition = ref({ left: 10, top: 10 }), shortcutKeys = [
1263
+ { "name": "绘制连续线段", "shortcut": "Ctrl + L" },
1264
+ { "name": "绘制线段确认", "shortcut": "Enter" },
1265
+ { "name": "绘制门线", "shortcut": "Ctrl + M" },
1266
+ { "name": "绘制窗户线", "shortcut": "Ctrl + Q" },
1267
+ { "name": "移动线段点", "shortcut": "Ctrl + P" },
1268
+ { "name": "删除线段", "shortcut": "选中 + Delete" },
1269
+ { "name": "删除窗户线", "shortcut": "选中 + Q + Delete" },
1270
+ { "name": "选中", "shortcut": "鼠标左键" },
1271
+ { "name": "多选", "shortcut": "鼠标左键 + Ctrl" },
1272
+ { "name": "取消选中", "shortcut": "鼠标左键 + Alt" },
1273
+ { "name": "框选", "shortcut": "鼠标左键 + 移动" },
1274
+ { "name": "线段同方向合并", "shortcut": "Ctrl + G" },
1275
+ { "name": "线段连接", "shortcut": "选中 + Shift + L" },
1276
+ { "name": "线段交点连接", "shortcut": "选中 + Ctrl + Shift + L" },
1277
+ { "name": "取消命令", "shortcut": "Esc" }
1278
+ ];
1279
+ watchEffect(() => localStorage.setItem("EditorToolPosition", JSON.stringify(toolBarPosition.value)));
1280
+ function setEditorToolPosition(left, top) {
1281
+ const dom = elRef.value, toolBarDom = elRef.value, rect = dom.getBoundingClientRect(), toolBarRect = toolBarDom.getBoundingClientRect(), minX = 0, maxX = toolBarRect.width - rect.width, minY = 0, maxY = toolBarRect.height - rect.height;
1282
+ left = Math.max(minX, Math.min(left, maxX));
1283
+ top = Math.max(minY, Math.min(top, maxY));
1284
+ toolBarPosition.value = { left, top };
1285
+ console.log(left, top);
1280
1286
  }
1281
1287
  watch(originalLineVisible, () => dxfSystem.Variable.set("originalLineVisible", originalLineVisible.value));
1282
1288
  watch(dxfVisible, () => dxfSystem.Variable.set("dxfVisible", dxfVisible.value));
@@ -1285,43 +1291,33 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1285
1291
  dxfSystem.Variable.addEventListener("originalLineVisible", (e) => originalLineVisible.value = e.value);
1286
1292
  dxfSystem.Variable.addEventListener("dxfVisible", (e) => dxfVisible.value = e.value);
1287
1293
  dxfSystem.Variable.addEventListener("whiteModelVisible", (e) => whiteModelVisible.value = e.value);
1294
+ onMounted(() => {
1295
+ if (localStorage.getItem("EditorToolPosition")) {
1296
+ const { left, top } = JSON.parse(localStorage.getItem("EditorToolPosition") ?? "{}");
1297
+ setEditorToolPosition(left, top);
1298
+ }
1299
+ });
1300
+ onUnmounted(() => {
1301
+ domEventRegister.mouseMoveEventProxylock = false;
1302
+ });
1288
1303
  return (_ctx, _cache) => {
1289
- return openBlock(), createElementBlock("div", _hoisted_1, [
1290
- createElementVNode("div", _hoisted_2, [
1291
- createVNode(unref(ElButton), {
1292
- size: "small",
1293
- type: "success",
1294
- onClick: selectLocalFile
1295
- }, {
1296
- default: withCtx(() => _cache[2] || (_cache[2] = [
1297
- createTextVNode(" 选择文件 ", -1)
1298
- ])),
1299
- _: 1,
1300
- __: [2]
1301
- }),
1302
- createVNode(unref(ElButton), {
1303
- size: "small",
1304
- type: "primary",
1305
- onClick: _cache[0] || (_cache[0] = ($event) => unref(dxfSystem).Dxf.download("test.dxf"))
1306
- }, {
1307
- default: withCtx(() => _cache[3] || (_cache[3] = [
1308
- createTextVNode(" 下载 DXF ", -1)
1309
- ])),
1310
- _: 1,
1311
- __: [3]
1312
- })
1313
- ]),
1314
- createElementVNode("div", _hoisted_3, [
1315
- createElementVNode("div", _hoisted_4, [
1316
- createVNode(unref(ElCheckbox), {
1317
- modelValue: dxfVisible.value,
1318
- "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => dxfVisible.value = $event),
1319
- label: "dxf"
1320
- }, null, 8, ["modelValue"])
1321
- ]),
1322
- _cache[4] || (_cache[4] = createStaticVNode('<div class="mt-[5px] text-[#c9c9c9] text-[10px]"><p class="text-right"> 绘制连续线段:<span class="w-[110px] inline-block">Ctrl + L</span></p><p class="text-right"> 绘制线段确认:<span class="w-[110px] inline-block">Enter</span></p><p class="text-right"> 绘制门线:<span class="w-[110px] inline-block">Ctrl + M</span></p><p class="text-right"> 绘制窗户线:<span class="w-[110px] inline-block">Ctrl + Q</span></p><p class="text-right"> 移动线段点:<span class="w-[110px] inline-block">Ctrl + P</span></p><p class="text-right"> 删除线段:<span class="w-[110px] inline-block">选中 + Delete</span></p><p class="text-right"> 删除窗户线:<span class="w-[110px] inline-block">选中 + Q + Delete</span></p><p class="text-right"> 选中:<span class="w-[110px] inline-block">鼠标左键</span></p><p class="text-right"> 多选:<span class="w-[110px] inline-block">鼠标左键 + Ctrl</span></p><p class="text-right"> 取消选中:<span class="w-[110px] inline-block">鼠标左键 + Alt</span></p><p class="text-right"> 框选:<span class="w-[110px] inline-block">鼠标左键 + 移动</span></p><p class="text-right"> 线段同方向合并:<span class="w-[110px] inline-block">Ctrl + G</span></p><p class="text-right"> 线段连接:<span class="w-[110px] inline-block">选中 + Shift + L</span></p><p class="text-right"> 线段交点连接:<span class="w-[110px] inline-block">选中 + Ctrl + Shift + L</span></p><p class="text-right"> 取消命令:<span class="w-[110px] inline-block">Esc</span></p></div>', 1))
1304
+ return openBlock(), createElementBlock("div", {
1305
+ ref_key: "elRef",
1306
+ ref: elRef,
1307
+ class: "pointer-events-none overflow-hidden absolute left-0 top-0 w-full h-full z-[10000] flex flex-row justify-between p-[5px] box-border select-none pointer-events-[all]"
1308
+ }, [
1309
+ createElementVNode("div", _hoisted_1, [
1310
+ (openBlock(), createElementBlock(Fragment, null, renderList(shortcutKeys, (item) => {
1311
+ return createElementVNode("p", {
1312
+ class: "p-[2px_0px] flex justify-between text-right border-b-1 border-b-[rgba(255,255,255,0.1)] last-of-type:border-b-0",
1313
+ key: item.name
1314
+ }, [
1315
+ createTextVNode(toDisplayString(item.name) + ": ", 1),
1316
+ createElementVNode("span", _hoisted_2, toDisplayString(item.shortcut), 1)
1317
+ ]);
1318
+ }), 64))
1323
1319
  ])
1324
- ]);
1320
+ ], 512);
1325
1321
  };
1326
1322
  }
1327
1323
  });
@@ -1436,7 +1432,6 @@ class RenderManager extends Component {
1436
1432
  actionHistory = /* @__PURE__ */ new Set();
1437
1433
  onAddFromParent() {
1438
1434
  const dxfLineModel = this.dxfLineModel;
1439
- this.reset();
1440
1435
  this.editor.container.add(this.container);
1441
1436
  this.editor.container.add(dxfLineModel.dxfModelGroup);
1442
1437
  dxfLineModel.dxfLineModel.material = new THREE.LineBasicMaterial({
@@ -1450,6 +1445,7 @@ class RenderManager extends Component {
1450
1445
  });
1451
1446
  this.variable.addEventListener("dxfVisible", (e) => dxfLineModel.dxfModelGroup.visible = e.value);
1452
1447
  this.dxf.addEventListener("createGroup", () => this.reset());
1448
+ this.reset();
1453
1449
  }
1454
1450
  updatedMode = null;
1455
1451
  /** 重新设置数据
@@ -1463,6 +1459,7 @@ class RenderManager extends Component {
1463
1459
  }
1464
1460
  this.pointVirtualGrid = new PointVirtualGrid();
1465
1461
  const box = this.dxf.box.clone().expansion(Math.max(this.dxf.box.width, this.dxf.box.height) * 2);
1462
+ if (box.width === 0 || box.height === 0) box.set(-200, -200, 200, 200);
1466
1463
  this.quadtree = new Quadtree(box);
1467
1464
  this.lines.length = 0;
1468
1465
  this.dxf.lineSegments.forEach((line) => {