From 123657431dbbf00e523304e91b323af4ca3d0a61 Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Tue, 29 Jul 2025 14:55:23 +0900 Subject: [PATCH] =?UTF-8?q?=EC=A2=8C=EC=9A=B0=EB=A1=9C=20=EB=84=93?= =?UTF-8?q?=EC=96=B4=EC=A7=84=20=ED=98=95=EC=83=81=EC=9D=80=20=EC=8A=A4?= =?UTF-8?q?=EC=BC=80=EC=9D=BC=20=EC=A1=B0=EC=A0=95=20x?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/api/image/canvas/route.js | 11 ++---- .../circuitTrestle/CircuitTrestleSetting.jsx | 38 ++++++++++++++++++- src/hooks/module/useModuleBasicSetting.js | 3 ++ 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/src/app/api/image/canvas/route.js b/src/app/api/image/canvas/route.js index 347c88df..9f4e3f52 100644 --- a/src/app/api/image/canvas/route.js +++ b/src/app/api/image/canvas/route.js @@ -100,14 +100,11 @@ const resizeImage = async (image) => { let finalWidth = Math.round(image.bitmap.width * scale) let finalHeight = Math.round(image.bitmap.height * scale) - - if (scale < 0.6) { - finalWidth = targetImageWidth - finalHeight = targetImageHeight - } - // 실제 리사이즈 실행 - image.resize({ w: finalWidth, h: finalHeight }) + if (scale >= 0.6) { + // 실제 리사이즈 실행 + image.resize({ w: finalWidth, h: finalHeight }) + } //배경 이미지를 생성 const mixedImage = new Jimp({ width: convertStandardWidth, height: convertStandardHeight, color: 0xffffffff }) diff --git a/src/components/floor-plan/modal/circuitTrestle/CircuitTrestleSetting.jsx b/src/components/floor-plan/modal/circuitTrestle/CircuitTrestleSetting.jsx index 50e35342..f6908913 100644 --- a/src/components/floor-plan/modal/circuitTrestle/CircuitTrestleSetting.jsx +++ b/src/components/floor-plan/modal/circuitTrestle/CircuitTrestleSetting.jsx @@ -122,12 +122,46 @@ export default function CircuitTrestleSetting({ id }) { canvas.set({ zoom: 1 }) canvas.viewportTransform = [1, 0, 0, 1, 0, 0] - let x, y + canvas.renderAll() + // roof polygon들의 중간점 계산 + const roofPolygons = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.ROOF) + let x, y x = canvas.width / 2 y = canvas.height / 2 - canvas.zoomToPoint(new fabric.Point(x, y), 0.5) + /*if (roofPolygons.length > 0) { + let minX = Infinity, + minY = Infinity, + maxX = -Infinity, + maxY = -Infinity + + roofPolygons.forEach((obj) => { + const boundingRect = obj.getBoundingRect() + minX = Math.min(minX, boundingRect.left) + minY = Math.min(minY, boundingRect.top) + maxX = Math.max(maxX, boundingRect.left + boundingRect.width) + maxY = Math.max(maxY, boundingRect.top + boundingRect.height) + }) + + x = (minX + maxX) / 2 + y = (minY + maxY) / 2 + } else { + // roof polygon이 없으면 기본 중앙점 사용 + x = canvas.width / 2 + y = canvas.height / 2 + } + + if (x > 1600) { + x = 0 + y = 0 + } + if (y > 1600) { + x = 0 + y = 0 + }*/ + + canvas.zoomToPoint(new fabric.Point(x, y), 0.4) changeFontSize('lengthText', '28') changeFontSize('circuitNumber', '28') changeFontSize('flowText', '28') diff --git a/src/hooks/module/useModuleBasicSetting.js b/src/hooks/module/useModuleBasicSetting.js index fd8f3a12..57d402bb 100644 --- a/src/hooks/module/useModuleBasicSetting.js +++ b/src/hooks/module/useModuleBasicSetting.js @@ -232,6 +232,9 @@ export function useModuleBasicSetting(tabNum) { //가대 상세 데이터 기준으로 모듈 설치 배치면 생성 const makeModuleInstArea = (roof, trestleDetail) => { //지붕 객체 반환 + if (!roof.pitch) { + return + } if (tabNum == 3) { if (!roof) { -- 2.47.2