diff --git a/src/components/webtopo-svgedit/components/center-panel/index.vue b/src/components/webtopo-svgedit/components/center-panel/index.vue index 35ca468..ac661cb 100644 --- a/src/components/webtopo-svgedit/components/center-panel/index.vue +++ b/src/components/webtopo-svgedit/components/center-panel/index.vue @@ -153,6 +153,40 @@ width: 0, height: 0 }, + point_coordinate: { + tl: { + x: 0, + y: 0 + }, + tc: { + x: 0, + y: 0 + }, + tr: { + x: 0, + y: 0 + }, + l: { + x: 0, + y: 0 + }, + r: { + x: 0, + y: 0 + }, + bl: { + x: 0, + y: 0 + }, + bc: { + x: 0, + y: 0 + }, + br: { + x: 0, + y: 0 + } + }, ...globalStore.create_svg_info }; globalStore.setHandleSvgInfo(done_item_json, globalStore.done_json.length); diff --git a/src/components/webtopo-svgedit/composables/index.ts b/src/components/webtopo-svgedit/composables/index.ts new file mode 100644 index 0000000..cc7a37e --- /dev/null +++ b/src/components/webtopo-svgedit/composables/index.ts @@ -0,0 +1,51 @@ +import { useGlobalStore } from '../store/global'; +import { calculateRotatedPointCoordinate } from '../utils'; + +export const useSetPointCoordinate = () => { + const globalStore = useGlobalStore(); + if (globalStore.handle_svg_info) { + const item_point = globalStore.handle_svg_info.info; + globalStore.handle_svg_info.info.point_coordinate = { + tl: calculateRotatedPointCoordinate( + item_point.point_coordinate.tl, + item_point.client, + -item_point.rotate + ), + tc: calculateRotatedPointCoordinate( + item_point.point_coordinate.tc, + item_point.client, + -item_point.rotate + ), + tr: calculateRotatedPointCoordinate( + item_point.point_coordinate.tr, + item_point.client, + -item_point.rotate + ), + l: calculateRotatedPointCoordinate( + item_point.point_coordinate.l, + item_point.client, + -item_point.rotate + ), + r: calculateRotatedPointCoordinate( + item_point.point_coordinate.r, + item_point.client, + -item_point.rotate + ), + bl: calculateRotatedPointCoordinate( + item_point.point_coordinate.bl, + item_point.client, + -item_point.rotate + ), + bc: calculateRotatedPointCoordinate( + item_point.point_coordinate.bc, + item_point.client, + -item_point.rotate + ), + br: calculateRotatedPointCoordinate( + item_point.point_coordinate.br, + item_point.client, + -item_point.rotate + ) + }; + } +}; diff --git a/src/store/global/index.ts b/src/store/global/index.ts index 94b5c71..5fccdb2 100644 --- a/src/store/global/index.ts +++ b/src/store/global/index.ts @@ -98,3 +98,6 @@ export const useGlobalStore = defineStore('global-store', { } } }); +useGlobalStore().$subscribe((mutation, state) => { + console.log(mutation, state, 102); +}); diff --git a/src/store/global/types.ts b/src/store/global/types.ts index f17e113..75874c8 100644 --- a/src/store/global/types.ts +++ b/src/store/global/types.ts @@ -14,10 +14,7 @@ export interface IDoneJson extends IConfigItem { id: string; x: number; y: number; - client: { - x: number; - y: number; - }; + client: ICoordinate; scale_x: number; scale_y: number; rotate: number; @@ -27,6 +24,16 @@ export interface IDoneJson extends IConfigItem { width: number; height: number; }; + point_coordinate: { + tl: ICoordinate; + tc: ICoordinate; + tr: ICoordinate; + l: ICoordinate; + r: ICoordinate; + bl: ICoordinate; + bc: ICoordinate; + br: ICoordinate; + }; } export enum EGlobalStoreIntention { None = 'None', @@ -91,3 +98,7 @@ export enum EScaleInfoType { BottomCenter = 'BottomCenter', BottomRight = 'BottomRight' } +export interface ICoordinate { + x: number; + y: number; +}