From bac1f6e0f66e3cbf5efde56c89461d8cd51d9375 Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Sat, 8 Feb 2025 18:39:49 +0900 Subject: [PATCH] =?UTF-8?q?=ED=95=9C=EC=AA=BD=ED=9D=90=EB=A6=84=20?= =?UTF-8?q?=EC=A7=80=EB=B6=95=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/common.js | 1 + src/hooks/common/useCanvasConfigInitialize.js | 12 ++++++-- src/hooks/roofcover/useRoofShapeSetting.js | 28 +++++++++---------- src/hooks/useLine.js | 10 ++++--- 4 files changed, 31 insertions(+), 20 deletions(-) diff --git a/src/common/common.js b/src/common/common.js index cf6d37bf..f53210ab 100644 --- a/src/common/common.js +++ b/src/common/common.js @@ -185,6 +185,7 @@ export const SAVE_KEY = [ 'moduleInfo', 'circuitNumber', 'circuit', + 'onlyOffset', ] export const OBJECT_PROTOTYPE = [fabric.Line.prototype, fabric.Polygon.prototype, fabric.Triangle.prototype] diff --git a/src/hooks/common/useCanvasConfigInitialize.js b/src/hooks/common/useCanvasConfigInitialize.js index 99e99c36..089aeea9 100644 --- a/src/hooks/common/useCanvasConfigInitialize.js +++ b/src/hooks/common/useCanvasConfigInitialize.js @@ -31,7 +31,11 @@ export function useCanvasConfigInitialize() { const flowTexts = canvas.getObjects().filter((obj) => obj.name === 'flowText') if (basicSetting.roofAngleSet === 'slope') { offsetTexts.forEach((obj) => { - obj.set({ text: `${!obj.originText ? '' : obj.originText + '-'}∠${obj.pitch}${angleUnit}` }) + let text = `${!obj.originText ? '' : obj.originText}` + if (!obj.onlyOffset) { + text = text + `-∠${obj.pitch}${angleUnit}` + } + obj.set({ text: text }) }) flowTexts.forEach((obj) => { obj.set({ text: `${!obj.originText ? '' : obj.originText + '-'}∠${obj.pitch}${pitchText}` }) @@ -40,7 +44,11 @@ export function useCanvasConfigInitialize() { if (basicSetting.roofAngleSet === 'flat') { offsetTexts.forEach((obj) => { - obj.set({ text: `${!obj.originText ? '' : obj.originText + '-'}∠${getDegreeByChon(obj.pitch)}${angleUnit}` }) + let text = `${!obj.originText ? '' : obj.originText}` + if (!obj.onlyOffset) { + text = text + `-∠${getDegreeByChon(obj.pitch)}${angleUnit}` + } + obj.set({ text: text }) }) flowTexts.forEach((obj) => { obj.set({ text: `${!obj.originText ? '' : obj.originText + '-'}∠${getDegreeByChon(obj.pitch)}${pitchText}` }) diff --git a/src/hooks/roofcover/useRoofShapeSetting.js b/src/hooks/roofcover/useRoofShapeSetting.js index 61acfd61..407c19a0 100644 --- a/src/hooks/roofcover/useRoofShapeSetting.js +++ b/src/hooks/roofcover/useRoofShapeSetting.js @@ -197,10 +197,10 @@ export function useRoofShapeSetting(id) { // 변별로 설정중 한쪽흐름일 경우 한쪽흐름의 pitch로 설정 if (pitch) { outerLines.forEach((line) => { - if (line.attributes.type === LINE_TYPE.WALLLINE.EAVES) { + if (line.attributes.type === LINE_TYPE.WALLLINE.SHED) { line.attributes = { ...line.attributes, - pitch: pitch, + pitch: pitchRef.current, onlyOffset: true, } } @@ -228,15 +228,15 @@ export function useRoofShapeSetting(id) { offset: eavesOffset / 10, pitch: pitchRef.current, type: LINE_TYPE.WALLLINE.EAVES, - onlyOffset: true, } } if (line.direction === 'top') { line.attributes = { offset: shedWidth / 10, - pitch: pitch, + pitch: pitchRef.current, type: LINE_TYPE.WALLLINE.SHED, + onlyOffset: true, } } } else { @@ -245,7 +245,6 @@ export function useRoofShapeSetting(id) { offset: eavesOffset / 10, pitch: pitchRef.current, type: LINE_TYPE.WALLLINE.EAVES, - onlyOffset: true, } } @@ -254,6 +253,7 @@ export function useRoofShapeSetting(id) { offset: shedWidth / 10, pitch: pitchRef.current, type: LINE_TYPE.WALLLINE.SHED, + onlyOffset: true, } } } @@ -276,7 +276,6 @@ export function useRoofShapeSetting(id) { offset: eavesOffset / 10, pitch: pitchRef.current, type: LINE_TYPE.WALLLINE.EAVES, - onlyOffset: true, } } @@ -285,6 +284,7 @@ export function useRoofShapeSetting(id) { offset: shedWidth / 10, pitch: pitchRef.current, type: LINE_TYPE.WALLLINE.SHED, + onlyOffset: true, } } } else { @@ -293,7 +293,6 @@ export function useRoofShapeSetting(id) { offset: eavesOffset / 10, pitch: pitchRef.current, type: LINE_TYPE.WALLLINE.EAVES, - onlyOffset: true, } } @@ -302,6 +301,7 @@ export function useRoofShapeSetting(id) { offset: shedWidth / 10, pitch: pitchRef.current, type: LINE_TYPE.WALLLINE.SHED, + onlyOffset: true, } } } @@ -323,7 +323,6 @@ export function useRoofShapeSetting(id) { offset: eavesOffset / 10, pitch: pitchRef.current, type: LINE_TYPE.WALLLINE.EAVES, - onlyOffset: true, } } @@ -332,6 +331,7 @@ export function useRoofShapeSetting(id) { offset: shedWidth / 10, pitch: pitchRef.current, type: LINE_TYPE.WALLLINE.SHED, + onlyOffset: true, } } } else { @@ -340,7 +340,6 @@ export function useRoofShapeSetting(id) { offset: eavesOffset / 10, pitch: pitchRef.current, type: LINE_TYPE.WALLLINE.EAVES, - onlyOffset: true, } } @@ -349,6 +348,7 @@ export function useRoofShapeSetting(id) { offset: shedWidth / 10, pitch: pitchRef.current, type: LINE_TYPE.WALLLINE.SHED, + onlyOffset: true, } } } @@ -371,7 +371,6 @@ export function useRoofShapeSetting(id) { offset: eavesOffset / 10, pitch: pitchRef.current, type: LINE_TYPE.WALLLINE.EAVES, - onlyOffset: true, } } @@ -380,6 +379,7 @@ export function useRoofShapeSetting(id) { offset: shedWidth / 10, pitch: pitchRef.current, type: LINE_TYPE.WALLLINE.SHED, + onlyOffset: true, } } } else { @@ -388,7 +388,6 @@ export function useRoofShapeSetting(id) { offset: eavesOffset / 10, pitch: pitchRef.current, type: LINE_TYPE.WALLLINE.EAVES, - onlyOffset: true, } } @@ -397,6 +396,7 @@ export function useRoofShapeSetting(id) { offset: shedWidth / 10, pitch: pitchRef.current, type: LINE_TYPE.WALLLINE.SHED, + onlyOffset: true, } } } @@ -503,7 +503,7 @@ export function useRoofShapeSetting(id) { outerLines.forEach((line) => { line.attributes = { offset: eavesOffset / 10, - pitch: pitchRef.current, + pitch: currentAngleType === ANGLE_TYPE.SLOPE ? pitch : getChonByDegree(pitch), type: LINE_TYPE.WALLLINE.EAVES, onlyOffset: false, } @@ -526,7 +526,7 @@ export function useRoofShapeSetting(id) { } else if (line.direction === 'top' || line.direction === 'bottom') { line.attributes = { offset: eavesOffset / 10, - pitch: pitchRef.current, + pitch: currentAngleType === ANGLE_TYPE.SLOPE ? pitch : getChonByDegree(pitch), type: LINE_TYPE.WALLLINE.EAVES, } } @@ -549,7 +549,7 @@ export function useRoofShapeSetting(id) { } else if (line.direction === 'left' || line.direction === 'right') { line.attributes = { offset: eavesOffset / 10, - pitch: pitchRef.current, + pitch: currentAngleType === ANGLE_TYPE.SLOPE ? pitch : getChonByDegree(pitch), type: LINE_TYPE.WALLLINE.EAVES, } } diff --git a/src/hooks/useLine.js b/src/hooks/useLine.js index dd251463..e2667e80 100644 --- a/src/hooks/useLine.js +++ b/src/hooks/useLine.js @@ -93,10 +93,11 @@ export const useLine = () => { let left, top - const textStr = - currentAngleType === ANGLE_TYPE.SLOPE - ? `${attributes.offset ? attributes.offset * 10 : attributes.width * 10}${!onlyOffset && attributes.pitch ? '-∠' + attributes.pitch + angleUnit : ''}` - : `${attributes.offset ? attributes.offset * 10 : attributes.width * 10}${!onlyOffset && attributes.pitch ? '-∠' + getDegreeByChon(attributes.pitch) + angleUnit : ''}` + const textStr = `${attributes.offset ? attributes.offset * 10 : attributes.width * 10}` + + // currentAngleType === ANGLE_TYPE.SLOPE + // ? `${attributes.offset ? attributes.offset * 10 : attributes.width * 10}${!onlyOffset && attributes.pitch ? '-∠' + attributes.pitch + angleUnit : ''}` + // : `${attributes.offset ? attributes.offset * 10 : attributes.width * 10}${!onlyOffset && attributes.pitch ? '-∠' + getDegreeByChon(attributes.pitch) + angleUnit : ''}` if (direction === 'top') { left = (startPoint.x + endPoint.x) / 2 @@ -125,6 +126,7 @@ export const useLine = () => { name: 'pitchText', parentId: line.id, pitch: attributes.pitch, + onlyOffset, }) canvas.add(text)