bill 2 月之前
父節點
當前提交
ec0b76b0f3

文件差異過大導致無法顯示
+ 1 - 0
public/styles/shitifuhao_o.svg


+ 1 - 1
public/styles/style-12.svg

@@ -1,5 +1,5 @@
 <svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
-<circle cx="7" cy="16" r="6" stroke="white" stroke-linecap="round"/>
+<path d="M7 22C10.3137 22 13 19.3137 13 16C13 12.6863 10.3137 10 7 10C3.68629 10 1 12.6863 1 16C1 19.3137 3.68629 22 7 22Z" stroke="white" stroke-linecap="round"/>
 <path d="M13 16H22" stroke="white" stroke-linecap="round"/>
 <path d="M15 16L19.5 9" stroke="white" stroke-linecap="round"/>
 <path d="M22 16L30 10" stroke="white" stroke-linecap="round"/>

+ 13 - 0
src/core/components/circle/temp-circle.vue

@@ -6,6 +6,7 @@
         ...data,
         ...matConfig,
         zIndex: undefined,
+        hitStrokeWidth: data.strokeWidth,
         opacity: addMode ? 0.3 : data.opacity,
       }"
     />
@@ -16,6 +17,16 @@
       @update-text="(val) => emit('updateContent', val)"
       @update:is-edit="(val) => emit('update:isEdit', val)"
     />
+    <v-circle
+      v-if="data.radiusX < 0.5 && data.radiusY < 0.5"
+      :config="{
+        x: matConfig.x,
+        y: matConfig.y,
+        radius: data.strokeWidth,
+        opacity: 0,
+        fill: 'red',
+      }"
+    />
 
     <SizeLine
       :config="matConfig"
@@ -41,12 +52,14 @@ import { DC } from "@/deconstruction.js";
 import { Circle } from "konva/lib/shapes/Circle";
 import { Transform } from "konva/lib/Util";
 import { useConfig } from "@/core/hook/use-config.ts";
+import { zeroEq } from "@/utils/math.ts";
 
 const props = defineProps<{ data: CircleData; addMode?: boolean; editer?: boolean }>();
 const emit = defineEmits<{
   (e: "updateContent", data: string): void;
   (e: "update:isEdit", data: boolean): void;
 }>();
+console.log(props.data.radiusX, props.data.radiusY);
 
 const config = useConfig();
 const data = computed(() => ({ ...defaultStyle, ...props.data }));

+ 8 - 1
src/core/components/icon/icon.vue

@@ -21,12 +21,13 @@ import {
 } from "../../html-mount/propertys/index.ts";
 import { Transform } from "konva/lib/Util";
 import originDescribes from "../../html-mount/propertys/describes.json";
-import { ref } from "vue";
+import { ref, watchEffect } from "vue";
 import { MathUtils } from "three";
 import { useCustomTransformer } from "@/core/hook/use-transformer.ts";
 import { Group } from "konva/lib/Group";
 import { Rect } from "konva/lib/shapes/Rect";
 import { setShapeTransform } from "@/utils/shape.ts";
+import { useMouseShapeStatus } from "@/core/hook/use-mouse-status.ts";
 
 const props = defineProps<{ data: IconData }>();
 const emit = defineEmits<{
@@ -91,6 +92,12 @@ const { shape, tData, data, operateMenus, describes } = useComponentStatus({
   ],
 });
 
+const status = useMouseShapeStatus(shape);
+watchEffect(() => {
+  if (status.value.active) {
+    console.error(props.data);
+  }
+});
 if (props.data.fixScreen) {
   const other = ref({ rotate: 0 });
   mergeDescribes(other, {}, ["rotate"], describes);

+ 87 - 65
src/core/hook/use-dxf.ts

@@ -25,16 +25,20 @@ import { ImageData } from "../components/image";
 import { onlyId } from "@/utils/shared";
 import { ArrowData, PointerPosition } from "../components/arrow";
 import { IconData } from "../components/icon";
-import { useSetViewport, useViewer, useViewerInvertTransform } from "./use-viewer";
+import {
+  useSetViewport,
+  useViewer,
+  useViewerInvertTransform,
+} from "./use-viewer";
 import { nextTick } from "vue";
 import { SLineData } from "../components/sequent-line";
 
 export const useGetDXF = () => {
   const store = useStore();
   const stage = useStage();
-  const invMat = useViewerInvertTransform()
-  const { setViewport } = useSetViewport()
-  const {viewer} = useViewer()
+  const invMat = useViewerInvertTransform();
+  const { setViewport } = useSetViewport();
+  const { viewer } = useViewer();
 
   return async () => {
     const writer = new DxfWriter();
@@ -42,8 +46,8 @@ export const useGetDXF = () => {
     const zip = new Zip();
     const genPromises: Promise<any>[] = [];
 
-    const fontStyle = writer.tables.styleTable.records[0]
-    fontStyle.fontFileName = 'SimSun'
+    const fontStyle = writer.tables.styleTable.records[0];
+    fontStyle.fontFileName = "SimSun";
 
     type PL = {
       id?: string;
@@ -86,46 +90,48 @@ export const useGetDXF = () => {
       const mat = $text.getTransform();
       const fontSize = $text.fontSize() * 0.8;
       let text = $text.text();
-      text = text.replace(/(\n|\r|\t)/ig, '')
+      text = text.replace(/(\n|\r|\t)/gi, "");
       const pad = $text.padding();
       const align = $text.align();
-      const textArr: {content: string, charCount: number}[] = [];
+      const textArr: { content: string; charCount: number }[] = [];
       let lineNum = 1;
       const width = $text.width();
       const charWidth = fontSize * 0.9;
 
-      console.log(text)
-      const lineCharCount = sp ? Math.max(Math.floor(width / charWidth), 2) : Number.MAX_VALUE;
+      console.log(text);
+      const lineCharCount = sp
+        ? Math.max(Math.floor(width / charWidth), 2)
+        : Number.MAX_VALUE;
       let ndx = 0;
       let prevNdx = 0;
-      let charCount = 0
+      let charCount = 0;
 
       while (ndx < text.length) {
-        ndx++
-        const c = /[\u4e00-\u9fff]/.test(text.charAt(ndx)) ? 2.4 : 1
-        
+        ndx++;
+        const c = /[\u4e00-\u9fff]/.test(text.charAt(ndx)) ? 2.4 : 1;
+
         if (charCount === lineCharCount || ndx >= text.length) {
-          charCount += c
+          charCount += c;
           textArr.push({
             content: text.substring(prevNdx, ndx + 1),
-            charCount
+            charCount,
           });
-          charCount = 0
-          prevNdx = ndx
+          charCount = 0;
+          prevNdx = ndx;
         } else if (charCount > lineCharCount) {
           textArr.push({
             content: text.substring(prevNdx, ndx),
-            charCount
+            charCount,
           });
-          charCount = 0
-          ndx--
-          prevNdx = ndx
+          charCount = 0;
+          ndx--;
+          prevNdx = ndx;
         } else {
-          charCount += c
+          charCount += c;
         }
       }
 
-      console.log(textArr)
+      console.log(textArr);
       textArr.forEach((item) => {
         const lineWidth = charWidth * item.charCount;
         let p = { x: pad, y: pad + lineNum * fontSize * 1.2 };
@@ -143,37 +149,42 @@ export const useGetDXF = () => {
           //     : align === "right"
           //     ? TextHorizontalAlignment.Right
           //     : TextHorizontalAlignment.Left,
-        })
-        const text = writer.addText(point3d(start.x, -start.y), fontSize, item.content, {
-          rotation: $text.rotation(),
-          // horizontalAlignment:
-          //   align === "center"
-          //     ? TextHorizontalAlignment.Center
-          //     : align === "right"
-          //     ? TextHorizontalAlignment.Right
-          //     : TextHorizontalAlignment.Left,
         });
-        text.trueColor = TrueColor.fromHex($text.fill() as string).toString()
-        text.height = fontSize
+        const text = writer.addText(
+          point3d(start.x, -start.y),
+          fontSize,
+          item.content,
+          {
+            rotation: $text.rotation(),
+            // horizontalAlignment:
+            //   align === "center"
+            //     ? TextHorizontalAlignment.Center
+            //     : align === "right"
+            //     ? TextHorizontalAlignment.Right
+            //     : TextHorizontalAlignment.Left,
+          }
+        );
+        text.trueColor = TrueColor.fromHex($text.fill() as string).toString();
+        text.height = fontSize;
         lineNum++;
       });
     };
 
     const writeImage = async (imgGroup: Group, minSize: Size) => {
-      let rect = imgGroup.getClientRect()
+      let rect = imgGroup.getClientRect();
       const oldViewMat = viewer.viewMat;
-      setViewport(rect)
-      await nextTick()
-      rect = imgGroup.getClientRect()
-      const img = await imgGroup!.toImage({
+      setViewport(rect);
+      await nextTick();
+      rect = imgGroup.getClientRect();
+      const img = (await imgGroup!.toImage({
         pixelRatio: 1,
         quality: 1,
-        mimeType: 'image/png'
-      }) as HTMLImageElement
-      const start = invMat.value.point({x: rect.x, y: rect.y + rect.height})
-      const end = invMat.value.point({x: rect.x + rect.width, y: rect.y})
-      const name = onlyId().replace(/\-/g, '')
-      const path = name + '.png'
+        mimeType: "image/png",
+      })) as HTMLImageElement;
+      const start = invMat.value.point({ x: rect.x, y: rect.y + rect.height });
+      const end = invMat.value.point({ x: rect.x + rect.width, y: rect.y });
+      const name = onlyId().replace(/\-/g, "");
+      const path = name + ".png";
 
       const image = writer.addImage(
         path,
@@ -184,23 +195,23 @@ export const useGetDXF = () => {
         1,
         0
       );
-      image.ratio = Math.abs(end.x - start.x) / img.width
+      image.ratio = Math.abs(end.x - start.x) / img.width;
       genPromises.push(
         fetch(img.src)
           .then((res) => res.blob())
-          .then((blob) => zip.file(path, blob, {  }))
+          .then((blob) => zip.file(path, blob, {}))
       );
       viewer.setViewMat(oldViewMat);
     };
 
     for (const _item of store.sortItems) {
       if (_item.hide) continue;
-      
+
       const type = store.getType(_item.id);
       let item;
       let mat;
       switch (type) {
-        case 'sequentLine':
+        case "sequentLine":
           item = _item as SLineData;
           writer.addLWPolyline(
             item.points.map((p) => ({ point: point2d(p.x, -p.y) })),
@@ -211,11 +222,11 @@ export const useGetDXF = () => {
             }
           );
           break;
-        case 'line':
+        case "line":
           const litem = _item as LineData;
-          litem.lines.forEach(line => {
-            const a = litem.points.find(p => p.id === line.a)!
-            const b = litem.points.find(p => p.id === line.b)!
+          litem.lines.forEach((line) => {
+            const a = litem.points.find((p) => p.id === line.a)!;
+            const b = litem.points.find((p) => p.id === line.b)!;
             // writer.addLine(
             //   point3d(a.x, a.y, 0),
             //   point3d(b.x, b.y, 0),
@@ -237,7 +248,7 @@ export const useGetDXF = () => {
                 ).toString(),
               }
             );
-          })
+          });
 
           break;
 
@@ -269,14 +280,14 @@ export const useGetDXF = () => {
 
         case "arrow":
           item = _item as ArrowData;
-          writer.addLWPolyline(
-            item.points.map((p) => ({ point: point2d(p.x, -p.y) })),
-            {
-              flags: LWPolylineFlags.None,
-              constantWidth: item.strokeWidth,
-              trueColor: TrueColor.fromHex(item.fill || "#FFFFFF").toString(),
-            }
-          );
+          // writer.addLWPolyline(
+          //   item.points.map((p) => ({ point: point2d(p.x, -p.y) })),
+          //   {
+          //     flags: LWPolylineFlags.None,
+          //     constantWidth: item.strokeWidth,
+          //     trueColor: TrueColor.fromHex(item.fill || "#FFFFFF").toString(),
+          //   }
+          // );
           const isEnd = [PointerPosition.end, PointerPosition.all].includes(
             item.pointerPosition || PointerPosition.start
           );
@@ -286,6 +297,7 @@ export const useGetDXF = () => {
 
           for (let i = 0; i < item.points.length - 1; i++) {
             const line = [item.points[i], item.points[i + 1]];
+            const nline = [...line];
             const vector = lineVector(line);
 
             if (isStart) {
@@ -293,6 +305,7 @@ export const useGetDXF = () => {
                 .clone()
                 .multiplyScalar(item.pointerLength!)
                 .add(line[0]);
+              nline[0] = start;
               const l1 = verticalVectorLine(
                 vector,
                 start,
@@ -314,6 +327,7 @@ export const useGetDXF = () => {
                 .clone()
                 .multiplyScalar(-item.pointerLength!)
                 .add(line[1]);
+              nline[1] = start;
               const l1 = verticalVectorLine(
                 vector,
                 start,
@@ -330,9 +344,17 @@ export const useGetDXF = () => {
                 stroke: item.fill,
               });
             }
+            writer.addLWPolyline(
+              nline.map((p) => ({ point: point2d(p.x, -p.y) })),
+              {
+                flags: LWPolylineFlags.None,
+                constantWidth: item.strokeWidth,
+                trueColor: TrueColor.fromHex(item.fill || "#FFFFFF").toString(),
+              }
+            );
           }
           break;
-          
+
         case "image":
           item = _item as ImageData;
           await writeImage($stage.findOne<Group>(`#${item.id}`)!, item);
@@ -349,7 +371,7 @@ export const useGetDXF = () => {
     }
 
     let dxfString = writer.stringify();
-    zip.file( onlyId() + ".dxf", dxfString);
+    zip.file(onlyId() + ".dxf", dxfString);
     return Promise.all(genPromises).then(() =>
       zip.generateAsync({ type: "blob" })
     );

+ 6 - 0
src/example/platform/platform-draw.ts

@@ -80,7 +80,9 @@ const getResourceLayers = (data: AIExposeData) => {
   return data.floors
     .map((floor) => {
       let box: SceneFloor["box"];
+      // if (true) {
       if (!floor.box || !floor.box.bound.x_max || !floor.box.bound.z_max) {
+      console.log(floor.geos)
         const xs = floor.geos.flatMap((item) => item.map((p) => p.x));
         const ys = floor.geos.flatMap((item) => item.map((p) => p.y));
         const zs = floor.geos.flatMap((item) => item.map((p) => p.z));
@@ -111,6 +113,9 @@ const getResourceLayers = (data: AIExposeData) => {
         box,
         taggings: data.taggings
           .filter((item) => {
+            console.log(item.position.z === undefined ||
+              (item.position.z >= box.bound.z_min &&
+                item.position.z <= box.bound.z_max), item, box)
             return (
               item.position.z === undefined ||
               (item.position.z >= box.bound.z_min &&
@@ -213,6 +218,7 @@ const drawLayerResource = (
         ...iconDefaultStyle,
         name: item.name,
         stroke: item.url.includes(".svg") ? "#000000" : undefined,
+        fill: null,
         createTime: createTime + layerResource.geos.length + ndx,
         url: item.url,
         lock: import.meta.env.DEV ? false : true,