From bc3a19d041cd19ad157bec191c491d7a76ade7f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AF=BC=EC=8B=9D?= <43837214+Minsiki@users.noreply.github.com> Date: Thu, 27 Feb 2025 18:13:58 +0900 Subject: [PATCH] =?UTF-8?q?=EC=B9=98=EC=88=98=EC=84=A0=20property=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dimensionLine/DimensionLineSetting.jsx | 33 +++++++++++-------- src/hooks/common/useCommonUtils.js | 4 +++ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/components/floor-plan/modal/dimensionLine/DimensionLineSetting.jsx b/src/components/floor-plan/modal/dimensionLine/DimensionLineSetting.jsx index a49c9ad6..e08bc839 100644 --- a/src/components/floor-plan/modal/dimensionLine/DimensionLineSetting.jsx +++ b/src/components/floor-plan/modal/dimensionLine/DimensionLineSetting.jsx @@ -31,6 +31,7 @@ export default function DimensionLineSetting(props) { useEffect(() => { if (canvas) { const dimensionObject = canvas.getActiveObject() + console.log(dimensionObject) const id = dimensionObject.groupId const textObj = dimensionObject._objects.filter((obj) => obj.name === 'dimensionLineText' && obj.group.groupId === id)[0] if (!textObj) return @@ -38,6 +39,7 @@ export default function DimensionLineSetting(props) { setBasicLength(+dimensionObject.length) setSelectedSlope1(dimensionObject.angle1) setSelectedSlope2(dimensionObject.angle2) + setSlopeAble(dimensionObject.slopeAble) } if (basicSetting.roofAngleSet === 'slope') { @@ -65,13 +67,13 @@ export default function DimensionLineSetting(props) { }, []) useEffect(() => { - if (!slopeAble) { - const dimensionObject = canvas.getActiveObject() - dimensionObject.set({ - angle1: null, - angle2: null, - }) - } + // if (!slopeAble) { + // const dimensionObject = canvas.getActiveObject() + // dimensionObject.set({ + // angle1: null, + // angle2: null, + // }) + // } }, [slopeAble]) const handleChangeLength = () => { @@ -79,19 +81,24 @@ export default function DimensionLineSetting(props) { const dimensionObject = canvas.getActiveObject() const id = dimensionObject.groupId const textObj = dimensionObject._objects.filter((obj) => obj.name === 'dimensionLineText' && obj.group.groupId === id)[0] - let resultText = +changeLength > 0 ? +changeLength : '0' - console.log(changeLength) + let resultText = +changeLength > 0 ? +changeLength : dimensionObject.length + if (slopeAble) { resultText = !selectedSlope2 - ? calculateLength(basicLength, selectedSlope1.value).toFixed(0) - : calculateLength(basicLength, selectedSlope1.value, selectedSlope2.value).toFixed(0) + ? calculateLength(resultText, selectedSlope1.value).toFixed(0) + : calculateLength(resultText, selectedSlope1.value, selectedSlope2.value).toFixed(0) } textObj.set({ text: String(resultText), }) - dimensionObject.set({ length: +resultText }) + dimensionObject.set({ + length: +changeLength > 0 ? +changeLength : dimensionObject.length, + slopeAble: slopeAble, + angle1: selectedSlope1, + angle2: selectedSlope2, + }) setBasicLength(resultText) setChangeLength('') canvas.renderAll() @@ -153,7 +160,7 @@ export default function DimensionLineSetting(props) {