|
@@ -10,7 +10,6 @@ import {
|
|
|
HatchPolylineBoundary,
|
|
|
vertex,
|
|
|
} from "@tarikjabiri/dxf";
|
|
|
-import { defaultStyle as iconDefStyle } from '../components/icon'
|
|
|
import { useStore } from "../store";
|
|
|
import Zip from "jszip";
|
|
|
import { LineData } from "../components/line";
|
|
@@ -33,6 +32,7 @@ import {
|
|
|
} from "./use-viewer";
|
|
|
import { nextTick } from "vue";
|
|
|
import { SLineData } from "../components/sequent-line";
|
|
|
+import { IRect } from "konva/lib/types";
|
|
|
|
|
|
export const useGetDXF = () => {
|
|
|
const store = useStore();
|
|
@@ -131,7 +131,6 @@ export const useGetDXF = () => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- console.log(textArr);
|
|
|
textArr.forEach((item) => {
|
|
|
const lineWidth = charWidth * item.charCount;
|
|
|
let p = { x: pad, y: pad + lineNum * fontSize * 1.2 };
|
|
@@ -161,18 +160,21 @@ export const useGetDXF = () => {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
- const writeImage = async (imgGroup: Group, scaleCallback?: (scale: Size) => () => void) => {
|
|
|
+ const writeImage = async (imgGroup: Group, scaleCallback?: (scale: Size, box: IRect) => () => void) => {
|
|
|
let curRect = imgGroup.getClientRect();
|
|
|
const oldViewMat = viewer.viewMat;
|
|
|
setViewport(curRect);
|
|
|
await nextTick();
|
|
|
const imgRect = imgGroup.getClientRect();
|
|
|
- const back = scaleCallback && scaleCallback({ width: imgRect.width / curRect.width, height: imgRect.height / curRect.height })
|
|
|
+ const back = scaleCallback && scaleCallback({ width: imgRect.width / curRect.width, height: imgRect.height / curRect.height }, imgRect)
|
|
|
await nextTick()
|
|
|
const img = (await imgGroup!.toImage({
|
|
|
pixelRatio: 1,
|
|
|
quality: 1,
|
|
|
mimeType: "image/png",
|
|
|
+ }).catch((e) => {
|
|
|
+ console.error(e)
|
|
|
+ throw e
|
|
|
})) as HTMLImageElement;
|
|
|
back && back()
|
|
|
await nextTick()
|
|
@@ -195,6 +197,9 @@ export const useGetDXF = () => {
|
|
|
fetch(img.src)
|
|
|
.then((res) => res.blob())
|
|
|
.then((blob) => zip.file(path, blob, {}))
|
|
|
+ .catch(e => {
|
|
|
+ console.error(e)
|
|
|
+ })
|
|
|
);
|
|
|
viewer.setViewMat(oldViewMat);
|
|
|
};
|
|
@@ -362,11 +367,11 @@ export const useGetDXF = () => {
|
|
|
const pathGroup = $stage
|
|
|
.findOne<Group>(`#${iconItem.id}`)!
|
|
|
.findOne<Group>(".rep-position")!;
|
|
|
- await writeImage(pathGroup, (scale) => {
|
|
|
- const sw = iconItem.strokeWidth || (iconDefStyle as any).strokeWidth || undefined
|
|
|
- iconItem.strokeWidth = sw && (sw * Math.max(scale.width, scale.height))
|
|
|
+
|
|
|
+ await writeImage(pathGroup, () => {
|
|
|
+ iconItem.strokeScaleEnabled = true
|
|
|
return () => {
|
|
|
- iconItem.strokeWidth = sw
|
|
|
+ iconItem.strokeScaleEnabled = false
|
|
|
}
|
|
|
});
|
|
|
break;
|